gdbserver: Remove gdb_id_to_thread_id
authorSimon Marchi <simon.marchi@ericsson.com>
Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 15 Sep 2017 16:02:51 +0000 (18:02 +0200)
From what I understand, this function is not doing anything useful as of
today.

Here's the result of my archeological research:

- The field thread_info::gdb_id was added in

  a06660f7  Use LWP IDs for thread IDs in gdbserver

  There was problem when using a 32-bits gdb with a 64-bits gdbserver.
  For some reason that I don't fully understand, the thread ids
  exchanged between gdb and gdbserver could overflow a 32 bits data
  type.  My guess is that they were the thread address (e.g. the
  0x7ffff7f20b40 in "Thread 0x7ffff7f20b40 (LWP 1058)" today).  This
  patch changed that so gdb/gdbserver would talk in terms of the OS
  assigned numerical id (as shown in ps).  It therefore added a way to
  convert between this gdb_id (the numerical id) and the thread id (the
  address).

95954743cb  Implement the multiprocess extensions, and add linux
              multiprocess supportNon-stop mode support.

  This patch made gdbserver deal with threads using their numerical ids
  and not the address-like id.  Starting from there, the gdb_id <->
  thread id conversion was not needed anymore, since the remote protocol
  and gdbserver were using the same kind of ids again.  The gdb_id field
  in the thread_info structure was also unused starting there.

d50171e4  Teach linux gdbserver to step-over-breakpoints.

  This patch moved the thread_info structure around, and got rid of the
  gdb_id field (which was unused).

Looking at the implementation of gdb_id_to_thread_id, it is not doing
anything useful.  It is looking up a thread by ptid using
find_thread_ptid, which basically loops over all threads looking at
their entry.id field.  If a thread with that ptid is found, it returns
its entry.id field.  So it will always return the same thing as it input
(with the exception of if no thread exist with that ptid, then it will
return null_ptid).

gdb/gdbserver/ChangeLog:

* inferiors.h (gdb_id_to_thread_id): Remove.
* inferiors.c (gdb_id_to_thread_id): Remove.
* server.c (process_serial_event): Adjust to gdb_id_to_thread_id
removal.  Move pid declaration closer to where it's used.

gdb/gdbserver/ChangeLog
gdb/gdbserver/inferiors.c
gdb/gdbserver/inferiors.h
gdb/gdbserver/server.c

index 144e09afa32e4e2efe5e9b83579d675f7dd3e3e4..eaf8e6e7748f282fbc3f0e62ed8c6e9666263699 100644 (file)
@@ -1,3 +1,10 @@
+2017-09-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+       * inferiors.h (gdb_id_to_thread_id): Remove.
+       * inferiors.c (gdb_id_to_thread_id): Remove.
+       * server.c (process_serial_event): Adjust to gdb_id_to_thread_id
+       removal.  Move pid declaration closer to where it's used.
+
 2017-09-15  Simon Marchi  <simon.marchi@ericsson.com>
 
        * server.c (handle_detach): New function.
index 22128507642915f25d2c20b8128173117e6c0aff..933dd761ac39a08fbe09d3c2932ba276c7e7aefb 100644 (file)
@@ -173,14 +173,6 @@ find_any_thread_of_pid (int pid)
   return (struct thread_info *) entry;
 }
 
-ptid_t
-gdb_id_to_thread_id (ptid_t gdb_id)
-{
-  struct thread_info *thread = find_thread_ptid (gdb_id);
-
-  return thread ? thread->entry.id : null_ptid;
-}
-
 static void
 free_one_thread (struct inferior_list_entry *inf)
 {
index f229e67336727639d1a1e1cc6d16ac25072e4898..6316fe503e5c4f6593cea02132df72994b5e1801 100644 (file)
@@ -144,7 +144,6 @@ int have_started_inferiors_p (void);
 int have_attached_inferiors_p (void);
 
 ptid_t thread_to_gdb_id (struct thread_info *);
-ptid_t gdb_id_to_thread_id (ptid_t);
 
 void clear_inferiors (void);
 struct inferior_list_entry *find_inferior
index 3de7f163412a7825fe4abbdf3e8f94ddb024d3de..32c9bab3272ce22cbd21ae8b8fa8f130b514c633 100644 (file)
@@ -4139,23 +4139,16 @@ process_serial_event (void)
     case 'H':
       if (own_buf[1] == 'c' || own_buf[1] == 'g' || own_buf[1] == 's')
        {
-         ptid_t gdb_id, thread_id;
-         int pid;
-
          require_running_or_break (own_buf);
 
-         gdb_id = read_ptid (&own_buf[2], NULL);
-
-         pid = ptid_get_pid (gdb_id);
+         ptid_t thread_id = read_ptid (&own_buf[2], NULL);
 
-         if (ptid_equal (gdb_id, null_ptid)
-             || ptid_equal (gdb_id, minus_one_ptid))
+         if (thread_id == null_ptid || thread_id == minus_one_ptid)
            thread_id = null_ptid;
-         else if (pid != 0
-                  && ptid_equal (pid_to_ptid (pid),
-                                 gdb_id))
+         else if (thread_id.is_pid ())
            {
-             thread_info *thread = find_any_thread_of_pid (pid);
+             /* The ptid represents a pid.  */
+             thread_info *thread = find_any_thread_of_pid (thread_id.pid ());
 
              if (thread == NULL)
                {
@@ -4167,8 +4160,8 @@ process_serial_event (void)
            }
          else
            {
-             thread_id = gdb_id_to_thread_id (gdb_id);
-             if (ptid_equal (thread_id, null_ptid))
+             /* The ptid represents a lwp/tid.  */
+             if (find_thread_ptid (thread_id) == NULL)
                {
                  write_enn (own_buf);
                  break;
@@ -4373,13 +4366,10 @@ process_serial_event (void)
 
     case 'T':
       {
-       ptid_t gdb_id, thread_id;
-
        require_running_or_break (own_buf);
 
-       gdb_id = read_ptid (&own_buf[1], NULL);
-       thread_id = gdb_id_to_thread_id (gdb_id);
-       if (ptid_equal (thread_id, null_ptid))
+       ptid_t thread_id = read_ptid (&own_buf[1], NULL);
+       if (find_thread_ptid (thread_id) == NULL)
          {
            write_enn (own_buf);
            break;
This page took 0.038148 seconds and 4 git commands to generate.