This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Target-specific thread switching backend
- From: "Maciej W. Rozycki" <macro at mips dot com>
- To: gdb-patches at sourceware dot org
- Cc: "Maciej W. Rozycki" <macro at linux-mips dot org>
- Date: Wed, 5 Dec 2007 14:13:18 +0000 (GMT)
- Subject: Target-specific thread switching backend
Hello,
In preparation for submitting support for the MDI target I propose the
following enhancement to target_switch_to_thread(). The MDI implements a
multi-threaded target which remembers the currently selected thread within
itself. All the operations that have thread-local scope, such as
accessing of the CPU registers, use that thread identifier. Therefore I
think it is reasonable to propagate the thread-switch event down to the
target, which is what the following change implements.
Tested using the mipsisa32-sde-elf target, with the mips-sim-sde32/-EB
and mips-sim-sde32/-EL boards with no regressions.
2007-12-05 Maciej W. Rozycki <macro@mips.com>
* target.c (update_current_target): Initialize
to_switch_to_thread.
* target.h (target_switch_to_thread): New macro.
* thread.c (switch_to_thread): Call target_switch_to_thread().
OK to apply?
Maciej
13327-1.diff
Index: binutils-quilt/src/gdb/target.h
===================================================================
--- binutils-quilt.orig/src/gdb/target.h 2007-12-03 14:28:21.000000000 +0000
+++ binutils-quilt/src/gdb/target.h 2007-12-03 14:28:24.000000000 +0000
@@ -393,6 +393,7 @@
void (*to_mourn_inferior) (void);
int (*to_can_run) (void);
void (*to_notice_signals) (ptid_t ptid);
+ void (*to_switch_to_thread) (void);
int (*to_thread_alive) (ptid_t ptid);
void (*to_find_new_threads) (void);
char *(*to_pid_to_str) (ptid_t);
@@ -878,6 +879,14 @@
#define target_notice_signals(ptid) \
(*current_target.to_notice_signals) (ptid)
+/* Switch to a selected thread. */
+
+#define target_switch_to_thread() \
+ do \
+ if (current_target.to_switch_to_thread) \
+ (*current_target.to_switch_to_thread) (); \
+ while (0)
+
/* Check to see if a thread is still alive. */
#define target_thread_alive(ptid) \
Index: binutils-quilt/src/gdb/thread.c
===================================================================
--- binutils-quilt.orig/src/gdb/thread.c 2007-12-03 14:20:57.000000000 +0000
+++ binutils-quilt/src/gdb/thread.c 2007-12-03 14:28:24.000000000 +0000
@@ -462,6 +462,7 @@
inferior_ptid = ptid;
reinit_frame_cache ();
registers_changed ();
+ target_switch_to_thread ();
stop_pc = read_pc ();
}
Index: binutils-quilt/src/gdb/target.c
===================================================================
--- binutils-quilt.orig/src/gdb/target.c 2007-12-03 14:20:57.000000000 +0000
+++ binutils-quilt/src/gdb/target.c 2007-12-03 14:28:24.000000000 +0000
@@ -438,6 +438,7 @@
INHERIT (to_mourn_inferior, t);
INHERIT (to_can_run, t);
INHERIT (to_notice_signals, t);
+ INHERIT (to_switch_to_thread, t);
INHERIT (to_thread_alive, t);
INHERIT (to_find_new_threads, t);
INHERIT (to_pid_to_str, t);