From: Hannes Domani via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/3] Handle 64bit breakpoints of WOW64 processes as SIGINT
Date: Wed, 23 Sep 2020 19:21:20 +0200 [thread overview]
Message-ID: <20200923172122.2089-1-ssbssa@yahoo.de> (raw)
In-Reply-To: <20200923172122.2089-1-ssbssa.ref@yahoo.de>
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/nat/windows-nat.c | 8 ++++++++
gdb/nat/windows-nat.h | 2 ++
gdb/windows-nat.c | 1 -
gdbserver/win32-low.cc | 4 ----
gdbserver/win32-low.h | 2 --
5 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index be6db9719a..a277156138 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,13 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
ignore_first_breakpoint = false;
}
+ else if (wow64_process)
+ {
+ 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 f742db2acc..9bfcb16865 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
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index ec5e428126..1e8e21446f 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -235,7 +235,6 @@ static std::vector<windows_thread_info *> thread_list;
static int saw_create;
static int open_process_used = 0;
#ifdef __x86_64__
-static bool wow64_process = false;
static void *wow64_dbgbreak;
#endif
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index a11cc74092..588a23a643 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -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;
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index f3b44776ae..258eeb3506 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -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
--
2.27.0
next parent reply other threads:[~2020-09-23 17:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200923172122.2089-1-ssbssa.ref@yahoo.de>
2020-09-23 17:21 ` Hannes Domani via Gdb-patches [this message]
2020-09-23 17:21 ` [PATCH 2/3] Revert "Fix ctrl-c when debugging WOW64 processes" Hannes Domani via Gdb-patches
2020-09-23 17:21 ` [PATCH 3/3] Remove call of GenerateConsoleCtrlEvent Hannes Domani via Gdb-patches
2020-09-24 3:35 ` Simon Marchi
2020-09-24 14:40 ` Eli Zaretskii via Gdb-patches
2020-09-24 15:01 ` Hannes Domani via Gdb-patches
2020-09-24 3:30 ` [PATCH 1/3] Handle 64bit breakpoints of WOW64 processes as SIGINT Simon Marchi
2020-09-24 15:26 ` Hannes Domani via Gdb-patches
2020-09-24 15:29 ` Simon Marchi
2020-09-24 16:37 ` Hannes Domani via Gdb-patches
2020-09-24 16:42 ` Simon Marchi
2020-09-24 17:05 ` Hannes Domani via Gdb-patches
2020-09-24 17:22 ` Joel Brobecker
2020-09-24 17:51 ` Hannes Domani via Gdb-patches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200923172122.2089-1-ssbssa@yahoo.de \
--to=gdb-patches@sourceware.org \
--cc=ssbssa@yahoo.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox