From patchwork Wed Mar 30 12:04:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 11559 Received: (qmail 27578 invoked by alias); 30 Mar 2016 12:04:59 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 27557 invoked by uid 89); 30 Mar 2016 12:04:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=74, andi, Install X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 30 Mar 2016 12:04:56 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 5E3AF1F56D for ; Wed, 30 Mar 2016 12:04:55 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2UC4s7Q018381 for ; Wed, 30 Mar 2016 08:04:54 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH] Fix PR remote/19840: gdb crashes on reverse-stepi Date: Wed, 30 Mar 2016 13:04:54 +0100 Message-Id: <1459339494-17921-1-git-send-email-palves@redhat.com> Reverse debugging against a remote target that does reverse debugging itself (with the bs/bc packets) always trips on: (gdb) target remote localhost:... (gdb) reverse-stepi ../../gdb/target.c:602: internal-error: default_execution_direction: to_execution_direction must be implemented for reverse async I missed adding a to_execution_direction method to remote.c in commit 3223143295b5 (Adds target_execution_direction to make record targets support async mode), GDB 7.4 time. Later, GDB 7.8 switched to target-async on by default, making the regression user-visible by default too. Fix is simply to add the missing to_execution_direction implementation to target remote. Tested by Andi Kleen against Simics. gdb/ChangeLog: 2016-03-30 Pedro Alves PR remote/19840 * remote.c (struct remote_state) : New field. (new_remote_state): Default last_resume_exec_dir to EXEC_FORWARD. (remote_open_1): Reset last_resume_exec_dir to EXEC_FORWARD. (remote_resume): Store the last execution direction. (remote_execution_direction): New function. (init_remote_ops): Install it as to_execution_direction target_ops method. --- gdb/ChangeLog | 12 ++++++++++++ gdb/remote.c | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f1e99d7..ef6200f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2016-03-30 Pedro Alves + + PR remote/19840 + * remote.c (struct remote_state) : New + field. + (new_remote_state): Default last_resume_exec_dir to EXEC_FORWARD. + (remote_open_1): Reset last_resume_exec_dir to EXEC_FORWARD. + (remote_resume): Store the last execution direction. + (remote_execution_direction): New function. + (init_remote_ops): Install it as to_execution_direction target_ops + method. + 2016-03-30 Doug Evans * python/py-utils.c (host_string_to_python_string): New function. diff --git a/gdb/remote.c b/gdb/remote.c index 5c407b6..f142511 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -389,6 +389,9 @@ struct remote_state int last_sent_step; + /* The execution direction of the last resume we got. */ + enum exec_direction_kind last_resume_exec_dir; + char *finished_object; char *finished_annex; ULONGEST finished_offset; @@ -477,6 +480,7 @@ new_remote_state (void) result->buf = (char *) xmalloc (result->buf_size); result->remote_traceframe_number = -1; result->last_sent_signal = GDB_SIGNAL_0; + result->last_resume_exec_dir = EXEC_FORWARD; result->fs_pid = -1; return result; @@ -4936,6 +4940,8 @@ remote_open_1 (const char *name, int from_tty, rs->continue_thread = not_sent_ptid; rs->remote_traceframe_number = -1; + rs->last_resume_exec_dir = EXEC_FORWARD; + /* Probe for ability to use "ThreadInfo" query, as required. */ rs->use_threadinfo_query = 1; rs->use_threadextra_query = 1; @@ -5571,6 +5577,8 @@ remote_resume (struct target_ops *ops, rs->last_sent_signal = siggnal; rs->last_sent_step = step; + rs->last_resume_exec_dir = execution_direction; + /* The vCont packet doesn't need to specify threads via Hc. */ /* No reverse support (yet) for vCont. */ if (execution_direction != EXEC_REVERSE) @@ -13026,6 +13034,17 @@ remote_can_do_single_step (struct target_ops *ops) return 0; } +/* Implementation of the to_execution_direction method for the remote + target. */ + +static enum exec_direction_kind +remote_execution_direction (struct target_ops *self) +{ + struct remote_state *rs = get_remote_state (); + + return rs->last_resume_exec_dir; +} + static void init_remote_ops (void) { @@ -13171,6 +13190,7 @@ Specify the serial device it is connected to\n\ remote_ops.to_remove_vfork_catchpoint = remote_remove_vfork_catchpoint; remote_ops.to_insert_exec_catchpoint = remote_insert_exec_catchpoint; remote_ops.to_remove_exec_catchpoint = remote_remove_exec_catchpoint; + remote_ops.to_execution_direction = remote_execution_direction; } /* Set up the extended remote vector by making a copy of the standard