Remove find_inferior_id
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:34 +0000 (20:36 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:34 +0000 (20:36 -0500)
Remove find_inferior_id, replacing its usages with find_thread_ptid.
find_thread_ptid was implemented using find_inferior_id, so move the
implementation there instead.

gdb/gdbserver/ChangeLog:

* inferiors.c (find_inferior_id): Remove.
(find_thread_ptid): Move implemention from find_inferior_id to
here.
* inferiors.h (find_inferior_id): Remove.
* server.c (handle_status): Use find_thread_ptid.
(process_serial_event): Likewise.
* thread-db.c (find_one_thread): Likewise.
(thread_db_thread_handle): Likewise.
* win32-low.c (thread_rec): Likewise.
(child_delete_thread): Likewise.
(win32_thread_alive): Likewise.
(get_child_debug_event): Likewise.

gdb/gdbserver/ChangeLog
gdb/gdbserver/inferiors.c
gdb/gdbserver/inferiors.h
gdb/gdbserver/server.c
gdb/gdbserver/thread-db.c
gdb/gdbserver/win32-low.c

index 967dff0dc0ba4fb95d6d739c81c3ed7481d6c49e..3b7eb441a28128177beb1c238e5c9628b03aa683 100644 (file)
@@ -1,3 +1,18 @@
+2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * inferiors.c (find_inferior_id): Remove.
+       (find_thread_ptid): Move implemention from find_inferior_id to
+       here.
+       * inferiors.h (find_inferior_id): Remove.
+       * server.c (handle_status): Use find_thread_ptid.
+       (process_serial_event): Likewise.
+       * thread-db.c (find_one_thread): Likewise.
+       (thread_db_thread_handle): Likewise.
+       * win32-low.c (thread_rec): Likewise.
+       (child_delete_thread): Likewise.
+       (win32_thread_alive): Likewise.
+       (get_child_debug_event): Likewise.
+
 2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * linux-mips-low.c (update_watch_registers_callback): Return
index f4101c7513b08761301e02e99045d5f1f5629fa3..be3f3ef3c1daf8544aa84dba66b55ddca88f1044 100644 (file)
@@ -42,16 +42,6 @@ find_inferior (std::list<thread_info *> *thread_list,
   });
 }
 
-thread_info *
-find_inferior_id (std::list<thread_info *> *thread_list, ptid_t id)
-{
-  gdb_assert (thread_list == &all_threads);
-
-  return find_thread ([&] (thread_info *thread) {
-    return thread->id == id;
-  });
-}
-
 thread_info *
 find_inferior_in_random (std::list<thread_info *> *thread_list,
                         int (*func) (thread_info *, void *),
@@ -120,7 +110,9 @@ get_first_thread (void)
 struct thread_info *
 find_thread_ptid (ptid_t ptid)
 {
-  return (struct thread_info *) find_inferior_id (&all_threads, ptid);
+  return find_thread ([&] (thread_info *thread) {
+    return thread->id == ptid;
+  });
 }
 
 /* Find a thread associated with the given PROCESS, or NULL if no
index 4c66a74305c52a502e24649ecca13bedacc71e1e..a8a374eb1f74ea706dee78835097178125ed940c 100644 (file)
@@ -142,8 +142,6 @@ void clear_inferiors (void);
 
 thread_info *find_inferior (std::list<thread_info *> *thread_list,
                            int (*func) (thread_info *, void *), void *arg);
-thread_info *find_inferior_id (std::list<thread_info *> *thread_list,
-                              ptid_t id);
 thread_info *find_inferior_in_random (std::list<thread_info *> *thread_list,
                                      int (*func) (thread_info *, void *),
                                      void *arg);
index f0dac9569af7660662455aad9b9393a55539d654..26c4a01c9c4e63a11bc40b352c5310cbc8fc8da1 100644 (file)
@@ -3355,7 +3355,7 @@ handle_status (char *own_buf)
       if (last_status.kind != TARGET_WAITKIND_IGNORE
          && last_status.kind != TARGET_WAITKIND_EXITED
          && last_status.kind != TARGET_WAITKIND_SIGNALLED)
-       thread = find_inferior_id (&all_threads, last_ptid);
+       thread = find_thread_ptid (last_ptid);
 
       /* If the last event thread is not found for some reason, look
         for some other thread that might have an event to report.  */
@@ -4081,9 +4081,7 @@ process_serial_event (void)
                  /* GDB is telling us to choose any thread.  Check if
                     the currently selected thread is still valid. If
                     it is not, select the first available.  */
-                 struct thread_info *thread =
-                   (struct thread_info *) find_inferior_id (&all_threads,
-                                                            general_thread);
+                 thread_info *thread = find_thread_ptid (general_thread);
                  if (thread == NULL)
                    thread = get_first_thread ();
                  thread_id = thread->id;
index 67970f4ecac46a2d7b0aaea4790b1497f371efa8..537758cfb771c83679a24785b030db559b718cdc 100644 (file)
@@ -165,13 +165,12 @@ find_one_thread (ptid_t ptid)
   td_thrhandle_t th;
   td_thrinfo_t ti;
   td_err_e err;
-  struct thread_info *inferior;
   struct lwp_info *lwp;
   struct thread_db *thread_db = current_process ()->priv->thread_db;
   int lwpid = ptid_get_lwp (ptid);
 
-  inferior = (struct thread_info *) find_inferior_id (&all_threads, ptid);
-  lwp = get_thread_lwp (inferior);
+  thread_info *thread = find_thread_ptid (ptid);
+  lwp = get_thread_lwp (thread);
   if (lwp->thread_known)
     return 1;
 
@@ -452,8 +451,7 @@ thread_db_thread_handle (ptid_t ptid, gdb_byte **handle, int *handle_len)
 {
   struct thread_db *thread_db;
   struct lwp_info *lwp;
-  struct thread_info *thread
-    = (struct thread_info *) find_inferior_id (&all_threads, ptid);
+  thread_info *thread = find_thread_ptid (ptid);
 
   if (thread == NULL)
     return false;
index c7684b74ba815f7146285041f502ff866ab3db50..fecab84b2f1f8b114ccb124155de8c7414d7f52f 100644 (file)
@@ -193,14 +193,11 @@ win32_require_context (win32_thread_info *th)
 static win32_thread_info *
 thread_rec (ptid_t ptid, int get_context)
 {
-  struct thread_info *thread;
-  win32_thread_info *th;
-
-  thread = (struct thread_info *) find_inferior_id (&all_threads, ptid);
+  thread_info *thread = find_thread_ptid (ptid);
   if (thread == NULL)
     return NULL;
 
-  th = (win32_thread_info *) thread_target_data (thread);
+  win32_thread_info *th = (win32_thread_info *) thread_target_data (thread);
   if (get_context)
     win32_require_context (th);
   return th;
@@ -244,14 +241,11 @@ delete_thread_info (thread_info *thread)
 static void
 child_delete_thread (DWORD pid, DWORD tid)
 {
-  ptid_t ptid;
-
   /* If the last thread is exiting, just return.  */
   if (all_threads.size () == 1)
     return;
 
-  ptid = ptid_build (pid, tid, 0);
-  thread_info *thread = find_inferior_id (&all_threads, ptid);
+  thread_info *thread = find_thread_ptid (ptid_t (pid, tid));
   if (thread == NULL)
     return;
 
@@ -892,15 +886,9 @@ win32_join (int pid)
 static int
 win32_thread_alive (ptid_t ptid)
 {
-  int res;
-
   /* Our thread list is reliable; don't bother to poll target
      threads.  */
-  if (find_inferior_id (&all_threads, ptid) != NULL)
-    res = 1;
-  else
-    res = 0;
-  return res;
+  return find_thread_ptid (ptid) != NULL;
 }
 
 /* Resume the inferior process.  RESUME_INFO describes how we want
@@ -1582,8 +1570,7 @@ get_child_debug_event (struct target_waitstatus *ourstatus)
     }
 
   ptid = debug_event_ptid (&current_event);
-  current_thread =
-    (struct thread_info *) find_inferior_id (&all_threads, ptid);
+  current_thread = find_thread_ptid (ptid);
   return 1;
 }
 
This page took 0.037787 seconds and 4 git commands to generate.