This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] Remove usage of find_inferior in win32-i386-low.c
- From: Simon Marchi <simark at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 20 Nov 2017 03:24:51 -0000
- Subject: [binutils-gdb] Remove usage of find_inferior in win32-i386-low.c
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0b360f1926cb15edc39c661dac2f1a433fb288c0
commit 0b360f1926cb15edc39c661dac2f1a433fb288c0
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Sun Nov 19 22:23:20 2017 -0500
Remove usage of find_inferior in win32-i386-low.c
Straightforward replacement of find_inferior with the overload of
for_each_thread that filters on pid. I am able to build-test this
patch, but not run it.
gdb/gdbserver/ChangeLog:
* win32-i386-low.c (update_debug_registers_callback): Rename
to ...
(update_debug_registers): ... this, return void, remove pid_p arg.
(x86_dr_low_set_addr, x86_dr_low_set_control): Use for_each_thread.
Diff:
---
gdb/gdbserver/ChangeLog | 7 +++++++
gdb/gdbserver/win32-i386-low.c | 29 +++++++++--------------------
2 files changed, 16 insertions(+), 20 deletions(-)
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index ab59f52..e1fed94 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,10 @@
+2017-11-19 Simon Marchi <simon.marchi@ericsson.com>
+
+ * win32-i386-low.c (update_debug_registers_callback): Rename
+ to ...
+ (update_debug_registers): ... this, return void, remove pid_p arg.
+ (x86_dr_low_set_addr, x86_dr_low_set_control): Use for_each_thread.
+
2017-11-17 Simon Marchi <simon.marchi@polymtl.ca>
* inferiors.h (struct process_info): Add constructor, initialize
diff --git a/gdb/gdbserver/win32-i386-low.c b/gdb/gdbserver/win32-i386-low.c
index fd99ca9..1961a98 100644
--- a/gdb/gdbserver/win32-i386-low.c
+++ b/gdb/gdbserver/win32-i386-low.c
@@ -36,21 +36,14 @@
static struct x86_debug_reg_state debug_reg_state;
-static int
-update_debug_registers_callback (thread_info *thr, void *pid_p)
+static void
+update_debug_registers (thread_info *thread)
{
- win32_thread_info *th = (win32_thread_info *) thread_target_data (thr);
- int pid = *(int *) pid_p;
-
- /* 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. */
- th->debug_registers_changed = 1;
- }
+ win32_thread_info *th = (win32_thread_info *) thread_target_data (thread);
- return 0;
+ /* The actual update is done later just before resuming the lwp,
+ we just mark that the registers need updating. */
+ th->debug_registers_changed = 1;
}
/* Update the inferior's debug register REGNUM from STATE. */
@@ -58,12 +51,10 @@ update_debug_registers_callback (thread_info *thr, void *pid_p)
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);
-
gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
- find_inferior (&all_threads, update_debug_registers_callback, &pid);
+ /* Only update the threads of this process. */
+ for_each_thread (current_thread->id.pid (), update_debug_registers);
}
/* Update the inferior's DR7 debug control register from STATE. */
@@ -72,9 +63,7 @@ static void
x86_dr_low_set_control (unsigned long control)
{
/* Only update the threads of this process. */
- int pid = pid_of (current_thread);
-
- find_inferior (&all_threads, update_debug_registers_callback, &pid);
+ for_each_thread (current_thread->id.pid (), update_debug_registers);
}
/* Return the current value of a DR register of the current thread's