From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10691 invoked by alias); 1 Oct 2008 19:19:29 -0000 Received: (qmail 10680 invoked by uid 22791); 1 Oct 2008 19:19:28 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-outbound-1.vmware.com (HELO smtp-outbound-1.vmware.com) (65.113.40.141) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 01 Oct 2008 19:18:51 +0000 Received: from mailhost4.vmware.com (mailhost4.vmware.com [10.16.67.124]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 3985367A8; Wed, 1 Oct 2008 12:18:48 -0700 (PDT) Received: from [10.20.92.59] (promb-2s-dhcp59.eng.vmware.com [10.20.92.59]) by mailhost4.vmware.com (Postfix) with ESMTP id 04EFAC9A9D; Wed, 1 Oct 2008 12:18:48 -0700 (PDT) Message-ID: <48E3CCE2.3000001@vmware.com> Date: Wed, 01 Oct 2008 19:19:00 -0000 From: Michael Snyder User-Agent: Thunderbird 1.5.0.12 (X11/20080411) MIME-Version: 1.0 To: "gdb-patches@sourceware.org" , Daniel Jacobowitz , Pedro Alves , teawater Subject: [RFA] Reverse Debugging, 2/5 Content-Type: multipart/mixed; boundary="------------060504010005050305050108" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-10/txt/msg00031.txt.bz2 This is a multi-part message in MIME format. --------------060504010005050305050108 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 0 --------------060504010005050305050108 Content-Type: text/plain; name="remote.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="remote.txt" Content-length: 3864 This patch (#2) adds a target implementation of reverse debugging (for the "remote" target), implementing the new target_ops methods and changing remote_wait and remote_resume to make use of them. Adding this patch on top of patch #1 causes no change in gdb behavior, since nothing invokes the new methods. Tested under RHEL native with no change in results. 2008-09-30 Michael Snyder Remote interface for reverse debugging. * remote.c (remote_get_execdir, remote_set_execdir): New methods. (remote_vcont_resume): Jump out if attempting reverse execution. (remote_resume): Check for reverse exec direction, and send appropriate command to target. (remote_wait): Check target response for NO_HISTORY status. Also check for empty reply (target doesn't understand "bs" or "bc). (_initialize_remote): Add new methods to remote target vector. Index: remote.c =================================================================== RCS file: /cvs/src/src/gdb/remote.c,v retrieving revision 1.310 diff -u -p -r1.310 remote.c --- remote.c 22 Sep 2008 15:21:30 -0000 1.310 +++ remote.c 30 Sep 2008 18:23:30 -0000 @@ -3385,7 +3385,15 @@ remote_resume (ptid_t ptid, int step, en set_continue_thread (ptid); buf = rs->buf; - if (siggnal != TARGET_SIGNAL_0) + if (target_get_execution_direction () == EXEC_REVERSE) + { + /* We don't pass signals to the target in reverse exec mode. */ + if (info_verbose && siggnal != TARGET_SIGNAL_0) + warning (" - Can't pass signal %d to target in reverse: ignored.\n", + siggnal); + strcpy (buf, step ? "bs" : "bc"); + } + else if (siggnal != TARGET_SIGNAL_0) { buf[0] = step ? 'S' : 'C'; buf[1] = tohex (((int) siggnal >> 4) & 0xf); @@ -3651,8 +3659,15 @@ remote_wait (ptid_t ptid, struct target_ /* We're out of sync with the target now. Did it continue or not? Not is more likely, so report a stop. */ warning (_("Remote failure reply: %s"), buf); - status->kind = TARGET_WAITKIND_STOPPED; - status->value.sig = TARGET_SIGNAL_0; + if (buf[1] == '0' && buf[2] == '6') + { + status->kind = TARGET_WAITKIND_NO_HISTORY; + } + else + { + status->kind = TARGET_WAITKIND_STOPPED; + status->value.sig = TARGET_SIGNAL_0; + } goto got_status; case 'F': /* File-I/O request. */ remote_fileio_request (buf); @@ -7545,6 +7560,35 @@ remote_command (char *args, int from_tty help_list (remote_cmdlist, "remote ", -1, gdb_stdout); } +/* Reverse execution. + TODO: set up as a capability. */ +static enum exec_direction_kind remote_execdir = EXEC_FORWARD; + +static enum exec_direction_kind remote_get_execdir (void) +{ + if (remote_debug && info_verbose) + printf_filtered ("remote execdir is %s\n", + remote_execdir == EXEC_FORWARD ? "forward" : + remote_execdir == EXEC_REVERSE ? "reverse" : + "unknown"); + return remote_execdir; +} + +static int remote_set_execdir (enum exec_direction_kind dir) +{ + if (remote_debug && info_verbose) + printf_filtered ("Set remote execdir: %s\n", + dir == EXEC_FORWARD ? "forward" : + dir == EXEC_REVERSE ? "reverse" : + "bad direction"); + + /* TODO: check target for capability. */ + if (dir == EXEC_FORWARD || dir == EXEC_REVERSE) + return (remote_execdir = dir); + else + return EXEC_ERROR; +} + static void init_remote_ops (void) { @@ -7593,6 +7637,8 @@ Specify the serial device it is connecte remote_ops.to_has_registers = 1; remote_ops.to_has_execution = 1; remote_ops.to_has_thread_control = tc_schedlock; /* can lock scheduler */ + remote_ops.to_get_execdir = remote_get_execdir; + remote_ops.to_set_execdir = remote_set_execdir; remote_ops.to_magic = OPS_MAGIC; remote_ops.to_memory_map = remote_memory_map; remote_ops.to_flash_erase = remote_flash_erase; --------------060504010005050305050108--