gdb: maintain ptid -> thread map, optimize find_thread_ptid
authorSimon Marchi <simon.marchi@polymtl.ca>
Fri, 11 Jun 2021 22:29:33 +0000 (18:29 -0400)
committerSimon Marchi <simon.marchi@polymtl.ca>
Tue, 13 Jul 2021 00:46:53 +0000 (20:46 -0400)
commit922cc93d5da6a6dc422b7e7a09ee745414d67457
tree4963b5066e4c34a8b7b2331195c977254e55973e
parent71a2349005e74e0d64554f5c88e3632f3ace167a
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>
gdb/inferior.c
gdb/inferior.h
gdb/infrun.c
gdb/regcache.c
gdb/scoped-mock-context.h
gdb/thread.c