aboutsummaryrefslogtreecommitdiff
path: root/gdb/nat
diff options
context:
space:
mode:
authorHannes Domani <ssbssa@yahoo.de>2020-09-23 18:16:24 +0200
committerHannes Domani <ssbssa@yahoo.de>2020-09-24 19:01:22 +0200
commit99bb393f1d107cf2c4016c486f85625d362027a7 (patch)
tree4f39cc9663e5066636eca71bdefffca999bda68b /gdb/nat
parent6eee0315f6767ba932f19513af1ff432e5071bea (diff)
downloadgdb-99bb393f1d107cf2c4016c486f85625d362027a7.zip
gdb-99bb393f1d107cf2c4016c486f85625d362027a7.tar.gz
gdb-99bb393f1d107cf2c4016c486f85625d362027a7.tar.bz2
Handle 64bit breakpoints of WOW64 processes as SIGINT
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.
Diffstat (limited to 'gdb/nat')
-rw-r--r--gdb/nat/windows-nat.c15
-rw-r--r--gdb/nat/windows-nat.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index be6db97..2cbbc0f 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -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:
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index f742db2..9bfcb16 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -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