diff options
author | Gary Benson <gbenson@redhat.com> | 2015-03-24 14:05:43 +0000 |
---|---|---|
committer | Gary Benson <gbenson@redhat.com> | 2015-03-24 14:05:43 +0000 |
commit | 6d4ee8c6ad7d5b04e524b2b48ffe5639028594a5 (patch) | |
tree | 796ae04a4d944777a1aa9bcde44ec114b58f11af /gdb/gdbserver/linux-x86-low.c | |
parent | 70a0bb6b590bcfe304fe082d421feb52e0a0d4dc (diff) | |
download | gdb-6d4ee8c6ad7d5b04e524b2b48ffe5639028594a5.zip gdb-6d4ee8c6ad7d5b04e524b2b48ffe5639028594a5.tar.gz gdb-6d4ee8c6ad7d5b04e524b2b48ffe5639028594a5.tar.bz2 |
Add iterate_over_lwps to gdbserver
This commit introduces a new function, iterate_over_lwps, that
shared Linux code can use to call a function for each LWP that
matches certain criteria. This function already existed in GDB
and was in use by GDB's various low-level Linux x86 debug register
setters. An equivalent was written for gdbserver and gdbserver's
low-level Linux x86 debug register setters were modified to use
it.
gdb/ChangeLog:
* linux-nat.h: Include nat/linux-nat.h.
(iterate_over_lwps): Move declaration to nat/linux-nat.h.
* nat/linux-nat.h (struct lwp_info): New forward declaration.
(iterate_over_lwps_ftype): New typedef.
(iterate_over_lwps): New declaration.
* linux-nat.h (iterate_over_lwps): Update comment. Use
iterate_over_lwps_ftype. Update callback return value check.
gdb/gdbserver/ChangeLog:
* linux-low.h: Include nat/linux-nat.h.
* linux-low.c (iterate_over_lwps_args): New structure.
(iterate_over_lwps_filter): New function.
(iterate_over_lwps): Likewise.
* linux-x86-low.c (update_debug_registers_callback):
Update signature to what iterate_over_lwps expects.
Remove PID check that iterate_over_lwps now performs.
(x86_dr_low_set_addr): Use iterate_over_lwps.
(x86_dr_low_set_control): Likewise.
Diffstat (limited to 'gdb/gdbserver/linux-x86-low.c')
-rw-r--r-- | gdb/gdbserver/linux-x86-low.c | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c index fe4fd25..3425492 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c @@ -575,25 +575,16 @@ x86_linux_dr_set (ptid_t ptid, int regnum, unsigned long value) } static int -update_debug_registers_callback (struct inferior_list_entry *entry, - void *pid_p) +update_debug_registers_callback (struct lwp_info *lwp, void *arg) { - struct thread_info *thr = (struct thread_info *) entry; - struct lwp_info *lwp = get_thread_lwp (thr); - int pid = *(int *) pid_p; + /* The actual update is done later just before resuming the lwp, + we just mark that the registers need updating. */ + lwp->arch_private->debug_registers_changed = 1; - /* Only update the threads of this process. */ - if (pid_of (thr) == pid) - { - /* The actual update is done later just before resuming the lwp, - we just mark that the registers need updating. */ - lwp->arch_private->debug_registers_changed = 1; - - /* If the lwp isn't stopped, force it to momentarily pause, so - we can update its debug registers. */ - if (!lwp->stopped) - linux_stop_lwp (lwp); - } + /* If the lwp isn't stopped, force it to momentarily pause, so + we can update its debug registers. */ + if (!lwp->stopped) + linux_stop_lwp (lwp); return 0; } @@ -604,11 +595,11 @@ static void x86_dr_low_set_addr (int regnum, CORE_ADDR addr) { /* Only update the threads of this process. */ - int pid = pid_of (current_thread); + ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR); - find_inferior (&all_threads, update_debug_registers_callback, &pid); + iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); } /* Return the inferior's debug register REGNUM. */ @@ -627,9 +618,9 @@ static void x86_dr_low_set_control (unsigned long control) { /* Only update the threads of this process. */ - int pid = pid_of (current_thread); + ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ())); - find_inferior (&all_threads, update_debug_registers_callback, &pid); + iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL); } /* Return the inferior's DR7 debug control register. */ |