From: Hannes Domani Date: Fri, 23 Jan 2026 19:07:04 +0000 (+0100) Subject: Move software breakpoint recognition code into x86-windows-nat.c X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6fc89bae1722dca858cfc22870e91449a5cd7e5d;p=thirdparty%2Fbinutils-gdb.git Move software breakpoint recognition code into x86-windows-nat.c Approved-By: Tom Tromey Reviewed-By: Christina Schimpe --- diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index a8698c15c88..3d1a75d1cc8 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -1146,10 +1146,7 @@ windows_nat_target::get_windows_debug_event thread_id, windows_process->desired_stop_thread_id); if (current_event->dwDebugEventCode == EXCEPTION_DEBUG_EVENT - && ((current_event->u.Exception.ExceptionRecord.ExceptionCode - == EXCEPTION_BREAKPOINT) - || (current_event->u.Exception.ExceptionRecord.ExceptionCode - == STATUS_WX86_BREAKPOINT)) + && is_sw_breakpoint (¤t_event->u.Exception.ExceptionRecord) && windows_process->windows_initialization_done) { ptid_t ptid = ptid_t (current_event->dwProcessId, thread_id, 0); @@ -1200,10 +1197,8 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus, th->stopped_at_software_breakpoint = false; if (windows_process->current_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT - && ((windows_process->current_event.u.Exception.ExceptionRecord.ExceptionCode - == EXCEPTION_BREAKPOINT) - || (windows_process->current_event.u.Exception.ExceptionRecord.ExceptionCode - == STATUS_WX86_BREAKPOINT)) + && is_sw_breakpoint (&windows_process->current_event + .u.Exception.ExceptionRecord) && windows_process->windows_initialization_done) { th->stopped_at_software_breakpoint = true; diff --git a/gdb/windows-nat.h b/gdb/windows-nat.h index 537264a9231..8263729554b 100644 --- a/gdb/windows-nat.h +++ b/gdb/windows-nat.h @@ -215,6 +215,9 @@ protected: virtual void store_one_register (const struct regcache *regcache, windows_thread_info *th, int r) = 0; + /* Determine if ER contains a software-breakpoint. */ + virtual bool is_sw_breakpoint (const EXCEPTION_RECORD *er) const = 0; + private: windows_thread_info *add_thread (ptid_t ptid, HANDLE h, void *tlb, diff --git a/gdb/x86-windows-nat.c b/gdb/x86-windows-nat.c index 4e38181c55c..f8830809694 100644 --- a/gdb/x86-windows-nat.c +++ b/gdb/x86-windows-nat.c @@ -65,6 +65,8 @@ struct x86_windows_nat_target final : public x86_nat_target windows_thread_info *th, int r) override; void store_one_register (const struct regcache *regcache, windows_thread_info *th, int r) override; + + bool is_sw_breakpoint (const EXCEPTION_RECORD *er) const override; }; /* The current process. */ @@ -280,6 +282,15 @@ x86_windows_nat_target::store_one_register (const struct regcache *regcache, regcache->raw_collect (r, context_ptr + x86_windows_process.mappings[r]); } +/* See windows-nat.h. */ + +bool +x86_windows_nat_target::is_sw_breakpoint (const EXCEPTION_RECORD *er) const +{ + return (er->ExceptionCode == EXCEPTION_BREAKPOINT + || er->ExceptionCode == STATUS_WX86_BREAKPOINT); +} + /* Hardware watchpoint support, adapted from go32-nat.c code. */ /* Pass the address ADDR to the inferior in the I'th debug register.