This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [obv] Move macro current_ptid to gdbthread.h and use it


On 11/07/2012 11:17 PM, Joel Brobecker wrote:
>> +/* Get current thread ID (Linux task ID).  */
>> >+#define current_ptid ((struct inferior_list_entry *)current_inferior)->id
>                                                         ^
>                                                         |
>       missing space there   ----------------------------+

I copied it from its original place, and don't examine it.  A space is
added.  Patch below is what I committed.

-- 
Yao

gdb/gdbserver:

2012-11-08  Yao Qi  <yao@codesourcery.com>

	* spu-low.c (current_ptid): Move it to ..
	* gdbthread.h: ... here.  New.
	* remote-utils.c (read_ptid): Use macro 'current_ptid'.
	* server.c (myresume, process_serial_event): Likewise.
	* thread-db.c (thread_db_find_new_threads): Likewise.
	* tracepoint.c (run_inferior_command): Likewise.
---
 gdb/gdbserver/gdbthread.h    |    2 ++
 gdb/gdbserver/remote-utils.c |    2 +-
 gdb/gdbserver/server.c       |    6 ++----
 gdb/gdbserver/spu-low.c      |    3 ---
 gdb/gdbserver/thread-db.c    |    2 +-
 gdb/gdbserver/tracepoint.c   |    2 +-
 6 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h
index d863ec0..adc23da 100644
--- a/gdb/gdbserver/gdbthread.h
+++ b/gdb/gdbserver/gdbthread.h
@@ -68,4 +68,6 @@ void add_thread (ptid_t ptid, void *target_data);
 struct thread_info *find_thread_ptid (ptid_t ptid);
 struct thread_info *gdb_id_to_thread (unsigned int);
 
+/* Get current thread ID (Linux task ID).  */
+#define current_ptid ((struct inferior_list_entry *) current_inferior)->id
 #endif /* GDB_THREAD_H */
diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c
index 0b3adac..63a3e80 100644
--- a/gdb/gdbserver/remote-utils.c
+++ b/gdb/gdbserver/remote-utils.c
@@ -761,7 +761,7 @@ read_ptid (char *buf, char **obuf)
 
   /* Since the stub is not sending a process id, then default to
      what's in the current inferior.  */
-  pid = ptid_get_pid (((struct inferior_list_entry *) current_inferior)->id);
+  pid = ptid_get_pid (current_ptid);
 
   if (obuf)
     *obuf = pp;
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 43fafa6..833533e 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2155,8 +2155,7 @@ myresume (char *own_buf, int step, int sig)
 
   if (step || sig || valid_cont_thread)
     {
-      resume_info[0].thread
-	= ((struct inferior_list_entry *) current_inferior)->id;
+      resume_info[0].thread = current_ptid;
       if (step)
 	resume_info[0].kind = resume_step;
       else
@@ -2888,8 +2887,7 @@ process_serial_event (void)
 	  pid = strtol (&own_buf[i], NULL, 16);
 	}
       else
-	pid =
-	  ptid_get_pid (((struct inferior_list_entry *) current_inferior)->id);
+	pid = ptid_get_pid (current_ptid);
 
       if ((tracing && disconnected_tracing) || any_persistent_commands ())
 	{
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index d7283a9..2265fad 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -51,9 +51,6 @@
 #define INSTR_SC	0x44000002
 #define NR_spu_run	0x0116
 
-/* Get current thread ID (Linux task ID).  */
-#define current_ptid ((struct inferior_list_entry *)current_inferior)->id
-
 /* These are used in remote-utils.c.  */
 int using_threads = 0;
 
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index 4a59df6..9d2041d 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -406,7 +406,7 @@ static void
 thread_db_find_new_threads (void)
 {
   td_err_e err;
-  ptid_t ptid = ((struct inferior_list_entry *) current_inferior)->id;
+  ptid_t ptid = current_ptid;
   struct thread_db *thread_db = current_process ()->private->thread_db;
   int loop, iteration;
 
diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c
index 201a25b..1526838 100644
--- a/gdb/gdbserver/tracepoint.c
+++ b/gdb/gdbserver/tracepoint.c
@@ -6692,7 +6692,7 @@ static int
 run_inferior_command (char *cmd, int len)
 {
   int err = -1;
-  int pid = ptid_get_pid (current_inferior->entry.id);
+  int pid = ptid_get_pid (current_ptid);
 
   trace_debug ("run_inferior_command: running: %s", cmd);
 
-- 
1.7.7.6


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]