Move software breakpoint recognition code into x86-windows-nat.c

Approved-By: Tom Tromey <tom@tromey.com>
Reviewed-By: Christina Schimpe <christina.schimpe@intel.com>
This commit is contained in:
Hannes Domani 2026-01-23 20:07:04 +01:00
parent 0a4381e008
commit 6fc89bae17
3 changed files with 17 additions and 8 deletions

View file

@ -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 (&current_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;

View file

@ -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,

View file

@ -65,6 +65,8 @@ struct x86_windows_nat_target final : public x86_nat_target<windows_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.