Fix PR remote/19840: gdb crashes on reverse-stepi
Commit Message
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 <palves@redhat.com>
PR remote/19840
* remote.c (struct remote_state) <last_resume_exec_dir>: 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(+)
Comments
Pedro Alves <palves@redhat.com> writes:
> gdb/ChangeLog:
> 2016-03-30 Pedro Alves <palves@redhat.com>
>
> PR remote/19840
> * remote.c (struct remote_state) <last_resume_exec_dir>: 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.
Patch is good to me.
On 04/04/2016 05:33 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
>> gdb/ChangeLog:
>> 2016-03-30 Pedro Alves <palves@redhat.com>
>>
>> PR remote/19840
>> * remote.c (struct remote_state) <last_resume_exec_dir>: 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.
>
> Patch is good to me.
Thanks, I've now pushed this to master and 7.11 branch.
@@ -1,3 +1,15 @@
+2016-03-30 Pedro Alves <palves@redhat.com>
+
+ PR remote/19840
+ * remote.c (struct remote_state) <last_resume_exec_dir>: 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 <dje@google.com>
* python/py-utils.c (host_string_to_python_string): New function.
@@ -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