gdb: implement find_thread_ptid using inferior::thread_map
authorSimon Marchi <simon.marchi@efficios.com>
Tue, 3 Dec 2019 20:19:35 +0000 (15:19 -0500)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 1 Jul 2020 00:01:10 +0000 (20:01 -0400)
Now that non-exited inferior threads are stored in a map, change the
find_thread_ptid function to look up a thread using std::map::find,
instead of iterating on all of the inferior's threads.

Change-Id: I2fa3b0eb48c3e267eabec75b6459da2826df2e3d

gdb/thread.c

index a23884df80d033c5602b706851b75064ad21d189..87257ad731c86cc010b2ecab72f5ca3c2c2b20a3 100644 (file)
@@ -529,11 +529,12 @@ find_thread_ptid (process_stratum_target *targ, ptid_t ptid)
 struct thread_info *
 find_thread_ptid (inferior *inf, ptid_t ptid)
 {
-  for (thread_info *tp : inf->non_exited_threads ())
-    if (tp->ptid == ptid)
-      return tp;
+  auto it = inf->thread_map.find (ptid);
 
-  return NULL;
+  if (it != inf->thread_map.end ())
+    return it->second;
+  else
+    return nullptr;
 }
 
 /* See gdbthread.h.  */
This page took 0.024061 seconds and 4 git commands to generate.