diff options
author | Pedro Alves <pedro@palves.net> | 2023-05-08 17:09:58 +0100 |
---|---|---|
committer | Pedro Alves <pedro@palves.net> | 2024-05-08 00:39:55 +0100 |
commit | 446babcd70ae2fb4fd3ef2f83efba4b74c38b170 (patch) | |
tree | c3b879e380d82455a0bbb9a86edf0ce06f0aa96a /gdbserver | |
parent | cefdca26f9579f49757827a8271fb8cd74a3f60a (diff) | |
download | fsf-binutils-gdb-446babcd70ae2fb4fd3ef2f83efba4b74c38b170.zip fsf-binutils-gdb-446babcd70ae2fb4fd3ef2f83efba4b74c38b170.tar.gz fsf-binutils-gdb-446babcd70ae2fb4fd3ef2f83efba4b74c38b170.tar.bz2 |
Windows gdb+gdbserver: New find_thread, replaces thread_rec(DONT_INVALIDATE_CONTEXT)
The goal of the next few patches is to eliminate thread_rec
completely. This is the first patch in that effort.
thread_rec(DONT_INVALIDATE_CONTEXT) is really just a thread lookup
with no side effects, so this adds a find_thread function that lets
you do that.
Change-Id: Ie486badce00e234b10caa478b066c34537103e3f
Diffstat (limited to 'gdbserver')
-rw-r--r-- | gdbserver/win32-low.cc | 30 | ||||
-rw-r--r-- | gdbserver/win32-low.h | 1 |
2 files changed, 19 insertions, 12 deletions
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc index cc314df..5a57eed 100644 --- a/gdbserver/win32-low.cc +++ b/gdbserver/win32-low.cc @@ -142,6 +142,17 @@ win32_require_context (windows_thread_info *th) /* See nat/windows-nat.h. */ windows_thread_info * +gdbserver_windows_process::find_thread (ptid_t ptid) +{ + thread_info *thread = find_thread_ptid (ptid); + if (thread == nullptr) + return nullptr; + return (windows_thread_info *) thread_target_data (thread); +} + +/* See nat/windows-nat.h. */ + +windows_thread_info * gdbserver_windows_process::thread_rec (ptid_t ptid, thread_disposition_type disposition) { @@ -150,8 +161,7 @@ gdbserver_windows_process::thread_rec return NULL; windows_thread_info *th = (windows_thread_info *) thread_target_data (thread); - if (disposition != DONT_INVALIDATE_CONTEXT) - win32_require_context (th); + win32_require_context (th); return th; } @@ -162,7 +172,7 @@ child_add_thread (DWORD pid, DWORD tid, HANDLE h, void *tlb) windows_thread_info *th; ptid_t ptid = ptid_t (pid, tid, 0); - if ((th = windows_process.thread_rec (ptid, DONT_INVALIDATE_CONTEXT))) + if ((th = windows_process.find_thread (ptid))) return th; CORE_ADDR base = (CORE_ADDR) (uintptr_t) tlb; @@ -822,7 +832,7 @@ win32_process_target::resume (thread_resume *resume_info, size_t n) /* Get context for the currently selected thread. */ ptid = debug_event_ptid (&windows_process.current_event); - th = windows_process.thread_rec (ptid, DONT_INVALIDATE_CONTEXT); + th = windows_process.find_thread (ptid); if (th) { win32_prepare_to_resume (th); @@ -974,8 +984,7 @@ maybe_adjust_pc () child_fetch_inferior_registers (regcache, -1); windows_thread_info *th - = windows_process.thread_rec (current_thread_ptid (), - DONT_INVALIDATE_CONTEXT); + = windows_process.find_thread (current_thread_ptid ()); th->stopped_at_software_breakpoint = false; if (windows_process.current_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT @@ -1375,8 +1384,7 @@ win32_process_target::supports_get_tib_address () int win32_process_target::get_tib_address (ptid_t ptid, CORE_ADDR *addr) { - windows_thread_info *th; - th = windows_process.thread_rec (ptid, DONT_INVALIDATE_CONTEXT); + windows_thread_info *th = windows_process.find_thread (ptid); if (th == NULL) return 0; if (addr != NULL) @@ -1397,8 +1405,7 @@ bool win32_process_target::stopped_by_sw_breakpoint () { windows_thread_info *th - = windows_process.thread_rec (current_thread_ptid (), - DONT_INVALIDATE_CONTEXT); + = windows_process.find_thread (current_thread_ptid ()); return th == nullptr ? false : th->stopped_at_software_breakpoint; } @@ -1424,8 +1431,7 @@ const char * win32_process_target::thread_name (ptid_t thread) { windows_thread_info *th - = windows_process.thread_rec (current_thread_ptid (), - DONT_INVALIDATE_CONTEXT); + = windows_process.find_thread (current_thread_ptid ()); return th->thread_name (); } diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h index ff997df..c725c18 100644 --- a/gdbserver/win32-low.h +++ b/gdbserver/win32-low.h @@ -174,6 +174,7 @@ public: struct gdbserver_windows_process : public windows_nat::windows_process_info { + windows_nat::windows_thread_info *find_thread (ptid_t ptid) override; windows_nat::windows_thread_info *thread_rec (ptid_t ptid, windows_nat::thread_disposition_type disposition) override; |