Remove usage of find_inferior in linux_mourn
authorSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:37 +0000 (20:36 -0500)
committerSimon Marchi <simon.marchi@polymtl.ca>
Sun, 3 Dec 2017 01:36:37 +0000 (20:36 -0500)
Replace with for_each_thread with pid filtering.  The callback becomes
trivial enough that it's better to inline it.

gdb/gdbserver/ChangeLog:

* linux-low.c (delete_lwp_callback): Remove.
(linux_mourn): Use for_each_thread.

gdb/gdbserver/ChangeLog
gdb/gdbserver/linux-low.c

index ce3cfc993dfc0c2883535d207bdec61f26b65b90..faee0c6496e70760d2450130049c1f9a0764213d 100644 (file)
@@ -1,3 +1,8 @@
+2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
+
+       * linux-low.c (delete_lwp_callback): Remove.
+       (linux_mourn): Use for_each_thread.
+
 2017-12-02  Simon Marchi  <simon.marchi@polymtl.ca>
 
        * linux-low.c (linux_detach_lwp_callback): Return void, remove
index c495c2414578f829501e85c48163184425d75bc4..498af11a79107654f5ea00d96d46fe9d537ec7aa 100644 (file)
@@ -1643,18 +1643,6 @@ linux_detach (int pid)
 
 /* Remove all LWPs that belong to process PROC from the lwp list.  */
 
-static int
-delete_lwp_callback (thread_info *thread, void *proc)
-{
-  struct lwp_info *lwp = get_thread_lwp (thread);
-  struct process_info *process = (struct process_info *) proc;
-
-  if (pid_of (thread) == pid_of (process))
-    delete_lwp (lwp);
-
-  return 0;
-}
-
 static void
 linux_mourn (struct process_info *process)
 {
@@ -1664,7 +1652,10 @@ linux_mourn (struct process_info *process)
   thread_db_mourn (process);
 #endif
 
-  find_inferior (&all_threads, delete_lwp_callback, process);
+  for_each_thread (process->pid, [] (thread_info *thread)
+    {
+      delete_lwp (get_thread_lwp (thread));
+    });
 
   /* Freeing all private data.  */
   priv = process->priv;