diff options
author | Pedro Alves <palves@redhat.com> | 2018-06-28 20:18:24 +0100 |
---|---|---|
committer | Pedro Alves <palves@redhat.com> | 2018-06-28 17:12:07 +0100 |
commit | f2ffa92bbce9dd5fbedc138ac2a3bc8a88327d09 (patch) | |
tree | 82502f3011afcdbad7b679a956cea3d1a4f203b2 /gdb/infcmd.c | |
parent | ecdc3a72c89e43e0e13c5478723b4f70b3964e9f (diff) | |
download | gdb-f2ffa92bbce9dd5fbedc138ac2a3bc8a88327d09.zip gdb-f2ffa92bbce9dd5fbedc138ac2a3bc8a88327d09.tar.gz gdb-f2ffa92bbce9dd5fbedc138ac2a3bc8a88327d09.tar.bz2 |
gdb: Eliminate the 'stop_pc' global
In my multi-target work, I need to add a few more
scoped_restore_current_thread and switch_to_thread calls in some
places, and in some lower-level places I was fighting against the fact
that switch_to_thread reads/refreshes the stop_pc global.
Instead of piling on workarounds, let's just finally eliminate the
stop_pc global. We already have the per-thread
thread_info->suspend.stop_pc field, so it's mainly a matter of using
that more/instead.
gdb/ChangeLog:
2018-06-28 Pedro Alves <palves@redhat.com>
* gdbthread.h (struct thread_suspend_state) <stop_pc>: Extend
comments.
(switch_to_thread_no_regs): Adjust comment.
* infcmd.c (stop_pc): Delete.
(post_create_inferior, info_program_command): Replace references
to stop_pc with references to thread_info->suspend.stop_pc.
* inferior.h (stop_pc): Delete declaration.
* infrun.c (proceed, handle_syscall_event, fill_in_stop_func)
(handle_inferior_event_1, handle_signal_stop)
(process_event_stop_test, keep_going_stepped_thread)
(handle_step_into_function, handle_step_into_function_backward)
(print_stop_location): Replace references to stop_pc with
references to thread_info->suspend.stop_pc.
(struct infcall_suspend_state) <stop_pc>: Delete field.
(save_infcall_suspend_state, restore_infcall_suspend_state):
Remove references to inf_stat->stop_pc.
* linux-fork.c (fork_load_infrun_state): Likewise.
* record-btrace.c (record_btrace_set_replay): Likewise.
* record-full.c (record_full_goto_entry): Likewise.
* remote.c (print_one_stopped_thread): Likewise.
* target.c (target_resume): Extend comment.
* thread.c (set_executing_thread): New.
(set_executing): Use it.
(switch_to_thread_no_regs, switch_to_no_thread, switch_to_thread):
Remove references to stop_pc.
Diffstat (limited to 'gdb/infcmd.c')
-rw-r--r-- | gdb/infcmd.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/gdb/infcmd.c b/gdb/infcmd.c index c6fd9ab..26d5a2a 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -94,10 +94,6 @@ static char *inferior_io_terminal_scratch; ptid_t inferior_ptid; -/* Address at which inferior stopped. */ - -CORE_ADDR stop_pc; - /* Nonzero if stopped due to completion of a stack dummy routine. */ enum stop_stack_kind stop_stack_dummy; @@ -448,10 +444,12 @@ post_create_inferior (struct target_ops *target, int from_tty) /* Now that we know the register layout, retrieve current PC. But if the PC is unavailable (e.g., we're opening a core file with missing registers info), ignore it. */ - stop_pc = 0; + thread_info *thr = inferior_thread (); + + thr->suspend.stop_pc = 0; TRY { - stop_pc = regcache_read_pc (get_current_regcache ()); + thr->suspend.stop_pc = regcache_read_pc (get_current_regcache ()); } CATCH (ex, RETURN_MASK_ERROR) { @@ -2108,7 +2106,7 @@ info_program_command (const char *args, int from_tty) target_files_info (); printf_filtered (_("Program stopped at %s.\n"), - paddress (target_gdbarch (), stop_pc)); + paddress (target_gdbarch (), tp->suspend.stop_pc)); if (tp->control.stop_step) printf_filtered (_("It stopped after being stepped.\n")); else if (stat != 0) |