]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Handle 64bit breakpoints of WOW64 processes as SIGINT
authorHannes Domani <ssbssa@yahoo.de>
Wed, 23 Sep 2020 16:16:24 +0000 (18:16 +0200)
committerHannes Domani <ssbssa@yahoo.de>
Thu, 24 Sep 2020 17:47:26 +0000 (19:47 +0200)
When a WOW64 process triggers a breakpoint exception in 64bit code (which
happens when a 64bit gdb calls DebugBreakProcess for a 32bit target),
gdb ignores the breakpoint (because Wow64GetThreadContext can only report
the pc of 32bit code, and there is not int3 at this location).

But if these 64bit breakpoint exceptions are handled as SIGINT, gdb
doesn't check for int3, and always stops the target.

gdb/ChangeLog:

2020-09-23  Hannes Domani  <ssbssa@yahoo.de>

* nat/windows-nat.c (handle_exception): Handle 64bit breakpoints
in WOW64 processes as SIGINT.
* nat/windows-nat.h: Make wow64_process a shared variable.
* windows-nat.c: Remove static wow64_process variable.

gdbserver/ChangeLog:

2020-09-23  Hannes Domani  <ssbssa@yahoo.de>

* win32-low.cc: Remove local wow64_process variable.
* win32-low.h: Remove local wow64_process variable.

gdb/ChangeLog
gdb/nat/windows-nat.c
gdb/nat/windows-nat.h
gdb/windows-nat.c
gdbserver/ChangeLog
gdbserver/win32-low.cc
gdbserver/win32-low.h

index 3ed1809624a7306f3857585af2ac034ec0325504..f26afc042da9b4a3cfa03b654fc05b9d0149ef69 100644 (file)
@@ -1,3 +1,10 @@
+2020-09-23  Hannes Domani  <ssbssa@yahoo.de>
+
+       * nat/windows-nat.c (handle_exception): Handle 64bit breakpoints
+       in WOW64 processes as SIGINT.
+       * nat/windows-nat.h: Make wow64_process a shared variable.
+       * windows-nat.c: Remove static wow64_process variable.
+
 2020-09-18  Victor Collod  <vcollod@nvidia.com>
 
        PR gdb/26635
index be6db9719a0b37b8ad4db089ac70bf626fd592ef..2cbbc0f2ccb03f3c6e5073cce5d960afbbe7e359 100644 (file)
@@ -41,6 +41,7 @@ std::vector<pending_stop> pending_stops;
 EXCEPTION_RECORD siginfo_er;
 
 #ifdef __x86_64__
+bool wow64_process = false;
 bool ignore_first_breakpoint = false;
 #endif
 
@@ -240,6 +241,20 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
          ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
          ignore_first_breakpoint = false;
        }
+      else if (wow64_process)
+       {
+         /* This breakpoint exception is triggered for WOW64 processes when
+            reaching an int3 instruction in 64bit code.
+            gdb checks for int3 in case of SIGTRAP, this fails because
+            Wow64GetThreadContext can only report the pc of 32bit code, and
+            gdb lets the target process continue.
+            So handle it as SIGINT instead, then the target is stopped
+            unconditionally.  */
+         DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
+         rec->ExceptionCode = DBG_CONTROL_C;
+         ourstatus->value.sig = GDB_SIGNAL_INT;
+         break;
+       }
 #endif
       /* FALLTHROUGH */
     case STATUS_WX86_BREAKPOINT:
index f742db2acc8e71167075ae4716c1dfa3041bd585..9bfcb16865c471a51d6694f6ddf4d4e2c84e4e6a 100644 (file)
@@ -215,6 +215,8 @@ extern std::vector<pending_stop> pending_stops;
 extern EXCEPTION_RECORD siginfo_er;
 
 #ifdef __x86_64__
+/* The target is a WOW64 process */
+extern bool wow64_process;
 /* Ignore first breakpoint exception of WOW64 process */
 extern bool ignore_first_breakpoint;
 #endif
index 188a920cbb061f0d8639340ffec40b7d9afd4b3b..f9172c3a7f8ce0379bd99cb07c1f0d2735c5d0c3 100644 (file)
@@ -233,9 +233,6 @@ static std::vector<windows_thread_info *> thread_list;
 /* Counts of things.  */
 static int saw_create;
 static int open_process_used = 0;
-#ifdef __x86_64__
-static bool wow64_process = false;
-#endif
 
 /* User options.  */
 static bool new_console = false;
index 0c8af7c6c101dd286ff3aa6415708b71fac376ee..9c224c1756904606654362153cf236de73ab8eee 100644 (file)
@@ -1,3 +1,8 @@
+2020-09-23  Hannes Domani  <ssbssa@yahoo.de>
+
+       * win32-low.cc: Remove local wow64_process variable.
+       * win32-low.h: Remove local wow64_process variable.
+
 2020-09-10  Kamil Rytarowski  <n54@gmx.com>
 
        * netbsd-low.cc: Add.
index a11cc740925a13edb7c2e689998cd215fc32abfa..588a23a64375583791b3aabf638b505271c01172 100644 (file)
@@ -91,10 +91,6 @@ static int faked_breakpoint = 0;
 /* True if current_process_handle needs to be closed.  */
 static bool open_process_used = false;
 
-#ifdef __x86_64__
-bool wow64_process = false;
-#endif
-
 const struct target_desc *win32_tdesc;
 #ifdef __x86_64__
 const struct target_desc *wow64_win32_tdesc;
index f3b44776ae1c56db62352f70307286dcefe67b2e..258eeb35060275509f46784722349d3295b9c3bc 100644 (file)
@@ -30,8 +30,6 @@ extern const struct target_desc *win32_tdesc;
 #ifdef __x86_64__
 extern const struct target_desc *wow64_win32_tdesc;
 
-extern bool wow64_process;
-
 typedef BOOL (WINAPI *winapi_Wow64GetThreadContext) (HANDLE, PWOW64_CONTEXT);
 extern winapi_Wow64GetThreadContext win32_Wow64GetThreadContext;
 #endif