diff options
author | Simon Marchi <simon.marchi@ericsson.com> | 2017-11-19 22:23:22 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2017-11-19 22:23:23 -0500 |
commit | bbf550d50e4c85666877456f014421089503e83b (patch) | |
tree | 96b50ebe3d79f3a7f52f55e41f7198632a4cb8da /gdb/gdbserver | |
parent | 00192f771796a144fe27f5f1d98d8e6f66976221 (diff) | |
download | gdb-bbf550d50e4c85666877456f014421089503e83b.zip gdb-bbf550d50e4c85666877456f014421089503e83b.tar.gz gdb-bbf550d50e4c85666877456f014421089503e83b.tar.bz2 |
Remove usage of find_inferior in reset_lwp_ptrace_options_callback
Replace with for_each_thread, and inline code from
reset_lwp_ptrace_options_callback.
gdb/gdbserver/ChangeLog:
* linux-low.c (reset_lwp_ptrace_options_callback): Remove.
(linux_handle_new_gdb_connection): Use for_each_thread, inline
code from reset_lwp_ptrace_options_callback.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 6 | ||||
-rw-r--r-- | gdb/gdbserver/linux-low.c | 50 |
2 files changed, 26 insertions, 30 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index c9f5966..3a233bb 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,11 @@ 2017-11-19 Simon Marchi <simon.marchi@ericsson.com> + * linux-low.c (reset_lwp_ptrace_options_callback): Remove. + (linux_handle_new_gdb_connection): Use for_each_thread, inline + code from reset_lwp_ptrace_options_callback. + +2017-11-19 Simon Marchi <simon.marchi@ericsson.com> + * linux-arm-low.c (struct update_registers_data): Remove. (update_registers_callback): Return void, take arguments directly, don't check thread's pid. diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c index b267c70..628135a 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c @@ -6434,33 +6434,6 @@ linux_supports_exec_events (void) return linux_supports_traceexec (); } -/* Callback for 'find_inferior'. Set the (possibly changed) ptrace - options for the specified lwp. */ - -static int -reset_lwp_ptrace_options_callback (thread_info *thread, void *args) -{ - struct lwp_info *lwp = get_thread_lwp (thread); - - if (!lwp->stopped) - { - /* Stop the lwp so we can modify its ptrace options. */ - lwp->must_set_ptrace_flags = 1; - linux_stop_lwp (lwp); - } - else - { - /* Already stopped; go ahead and set the ptrace options. */ - struct process_info *proc = find_process_pid (pid_of (thread)); - int options = linux_low_ptrace_options (proc->attached); - - linux_enable_event_reporting (lwpid_of (thread), options); - lwp->must_set_ptrace_flags = 0; - } - - return 0; -} - /* Target hook for 'handle_new_gdb_connection'. Causes a reset of the ptrace flags for all inferiors. This is in case the new GDB connection doesn't support the same set of events that the previous one did. */ @@ -6468,10 +6441,27 @@ reset_lwp_ptrace_options_callback (thread_info *thread, void *args) static void linux_handle_new_gdb_connection (void) { - pid_t pid; - /* Request that all the lwps reset their ptrace options. */ - find_inferior (&all_threads, reset_lwp_ptrace_options_callback , &pid); + for_each_thread ([] (thread_info *thread) + { + struct lwp_info *lwp = get_thread_lwp (thread); + + if (!lwp->stopped) + { + /* Stop the lwp so we can modify its ptrace options. */ + lwp->must_set_ptrace_flags = 1; + linux_stop_lwp (lwp); + } + else + { + /* Already stopped; go ahead and set the ptrace options. */ + struct process_info *proc = find_process_pid (pid_of (thread)); + int options = linux_low_ptrace_options (proc->attached); + + linux_enable_event_reporting (lwpid_of (thread), options); + lwp->must_set_ptrace_flags = 0; + } + }); } static int |