diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2021-06-11 18:29:33 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2021-07-12 20:46:53 -0400 |
commit | 922cc93d5da6a6dc422b7e7a09ee745414d67457 (patch) | |
tree | 4963b5066e4c34a8b7b2331195c977254e55973e /gdb/regcache.c | |
parent | 71a2349005e74e0d64554f5c88e3632f3ace167a (diff) | |
download | gdb-922cc93d5da6a6dc422b7e7a09ee745414d67457.zip gdb-922cc93d5da6a6dc422b7e7a09ee745414d67457.tar.gz gdb-922cc93d5da6a6dc422b7e7a09ee745414d67457.tar.bz2 |
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>
Diffstat (limited to 'gdb/regcache.c')
-rw-r--r-- | gdb/regcache.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/gdb/regcache.c b/gdb/regcache.c index 21fa25d..ac44d71 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -2044,8 +2044,13 @@ regcache_thread_ptid_changed () target1.mock_inferior.pid = old_ptid.pid (); target1.mock_thread.ptid = old_ptid; + target1.mock_inferior.ptid_thread_map.clear (); + target1.mock_inferior.ptid_thread_map[old_ptid] = &target1.mock_thread; + target2.mock_inferior.pid = old_ptid.pid (); target2.mock_thread.ptid = old_ptid; + target2.mock_inferior.ptid_thread_map.clear (); + target2.mock_inferior.ptid_thread_map[old_ptid] = &target2.mock_thread; gdb_assert (regcaches.empty ()); |