aboutsummaryrefslogtreecommitdiff
path: root/gdb/scoped-mock-context.h
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-06-11 18:29:33 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-07-12 20:46:53 -0400
commit922cc93d5da6a6dc422b7e7a09ee745414d67457 (patch)
tree4963b5066e4c34a8b7b2331195c977254e55973e /gdb/scoped-mock-context.h
parent71a2349005e74e0d64554f5c88e3632f3ace167a (diff)
downloadfsf-binutils-gdb-922cc93d5da6a6dc422b7e7a09ee745414d67457.zip
fsf-binutils-gdb-922cc93d5da6a6dc422b7e7a09ee745414d67457.tar.gz
fsf-binutils-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/scoped-mock-context.h')
-rw-r--r--gdb/scoped-mock-context.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/gdb/scoped-mock-context.h b/gdb/scoped-mock-context.h
index ba3b81e..48fdbac 100644
--- a/gdb/scoped-mock-context.h
+++ b/gdb/scoped-mock-context.h
@@ -51,6 +51,7 @@ struct scoped_mock_context
inferior_list.push_back (mock_inferior);
mock_inferior.thread_list.push_back (mock_thread);
+ mock_inferior.ptid_thread_map[mock_ptid] = &mock_thread;
mock_inferior.gdbarch = gdbarch;
mock_inferior.aspace = mock_pspace.aspace;
mock_inferior.pspace = &mock_pspace;