Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: gdb-patches@sourceware.org
Cc: "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Target-specific thread switching backend
Date: Wed, 05 Dec 2007 14:26:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0712051240360.26738@perivale.mips.com> (raw)

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);


             reply	other threads:[~2007-12-05 14:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-05 14:26 Maciej W. Rozycki [this message]
2007-12-05 15:22 ` Daniel Jacobowitz
2007-12-05 16:07   ` Maciej W. Rozycki
2007-12-05 18:37     ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.61.0712051240360.26738@perivale.mips.com \
    --to=macro@mips.com \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@linux-mips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox