[binutils-gdb] Move software breakpoint recognition code into x86-windows-nat.c

Hannes Domani ssbssa@sourceware.org
Fri Jan 23 19:19:05 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6fc89bae1722dca858cfc22870e91449a5cd7e5d

commit 6fc89bae1722dca858cfc22870e91449a5cd7e5d
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Fri Jan 23 20:07:04 2026 +0100

    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>

Diff:
---
 gdb/windows-nat.c     | 11 +++--------
 gdb/windows-nat.h     |  3 +++
 gdb/x86-windows-nat.c | 11 +++++++++++
 3 files changed, 17 insertions(+), 8 deletions(-)

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 (&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;
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_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.


More information about the Gdb-cvs mailing list