mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-08-06 06:45:56 +08:00
gdb: maintain ptid -> thread map, optimize find_thread_ptid
When debugging a large number of threads (thousands), looking up a thread by ptid_t using the inferior::thread_list linked list can add up. Add inferior::thread_map, an std::unordered_map indexed by ptid_t, and change the find_thread_ptid function to look up a thread using std::unordered_map::find, instead of iterating on all of the inferior's threads. This should make it faster to look up a thread from its ptid. Change-Id: I3a8da0a839e18dee5bb98b8b7dbeb7f3dfa8ae1c Co-Authored-By: Pedro Alves <pedro@palves.net>
This commit is contained in:
@ -63,6 +63,8 @@ struct thread_info;
|
||||
#include "process-stratum-target.h"
|
||||
#include "displaced-stepping.h"
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
struct infcall_suspend_state;
|
||||
struct infcall_control_state;
|
||||
|
||||
@ -391,6 +393,10 @@ public:
|
||||
/* This inferior's thread list, sorted by creation order. */
|
||||
intrusive_list<thread_info> thread_list;
|
||||
|
||||
/* A map of ptid_t to thread_info*, for average O(1) ptid_t lookup.
|
||||
Exited threads do not appear in the map. */
|
||||
std::unordered_map<ptid_t, thread_info *, hash_ptid> ptid_thread_map;
|
||||
|
||||
/* Returns a range adapter covering the inferior's threads,
|
||||
including exited threads. Used like this:
|
||||
|
||||
|
Reference in New Issue
Block a user