public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Hannes Domani <ssbssa@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix debugging of WOW64 processes
Date: Fri, 10 Apr 2020 11:02:36 +0000 (GMT)	[thread overview]
Message-ID: <20200410110236.556EE385B835@sourceware.org> (raw)

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

commit 13302e956fb7a0c700f53f16d985c9e6207e331c
Author: Hannes Domani <ssbssa@yahoo.de>
Date:   Thu Apr 9 16:33:20 2020 +0200

    Fix debugging of WOW64 processes
    
    The new code regarding pending stops only checks for EXCEPTION_BREAKPOINT,
    but for WOW64 processes STATUS_WX86_BREAKPOINT is necessary as well.
    
    Also, ignore_first_breakpoint is used now in nat/windows-nat.c as well,
    but was not available there.
    
    gdb/ChangeLog:
    
    2020-04-10  Hannes Domani  <ssbssa@yahoo.de>
    
            * nat/windows-nat.c (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
            Move to...
            * nat/windows-nat.h (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
            ... here.
            * windows-nat.c (windows_nat_target::get_windows_debug_event):
            Check for STATUS_WX86_BREAKPOINT.
            (windows_nat_target::wait): Same.

Diff:
---
 gdb/ChangeLog         | 10 ++++++++++
 gdb/nat/windows-nat.c |  7 ++++---
 gdb/nat/windows-nat.h |  8 ++++++++
 gdb/windows-nat.c     | 13 ++++++++-----
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2c347fc473d..a961511b46c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,13 @@
+2020-04-10  Hannes Domani  <ssbssa@yahoo.de>
+
+	* nat/windows-nat.c (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
+	Move to...
+	* nat/windows-nat.h (STATUS_WX86_BREAKPOINT, STATUS_WX86_SINGLE_STEP):
+	... here.
+	* windows-nat.c (windows_nat_target::get_windows_debug_event):
+	Check for STATUS_WX86_BREAKPOINT.
+	(windows_nat_target::wait): Same.
+
 2020-04-10  Tom de Vries  <tdevries@suse.de>
 
 	PR cli/25808
diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 94e7f572c0a..cd7c1d177c6 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -20,9 +20,6 @@
 #include "nat/windows-nat.h"
 #include "gdbsupport/common-debug.h"
 
-#define STATUS_WX86_BREAKPOINT 0x4000001F
-#define STATUS_WX86_SINGLE_STEP 0x4000001E
-
 namespace windows_nat
 {
 
@@ -44,6 +41,10 @@ DWORD desired_stop_thread_id = -1;
 std::vector<pending_stop> pending_stops;
 EXCEPTION_RECORD siginfo_er;
 
+#ifdef __x86_64__
+bool ignore_first_breakpoint = false;
+#endif
+
 /* Note that 'debug_events' must be locally defined in the relevant
    functions.  */
 #define DEBUG_EVENTS(x)	if (debug_events) debug_printf x
diff --git a/gdb/nat/windows-nat.h b/gdb/nat/windows-nat.h
index 0597120c218..aea1519672d 100644
--- a/gdb/nat/windows-nat.h
+++ b/gdb/nat/windows-nat.h
@@ -25,6 +25,9 @@
 #include "gdbsupport/gdb_optional.h"
 #include "target/waitstatus.h"
 
+#define STATUS_WX86_BREAKPOINT 0x4000001F
+#define STATUS_WX86_SINGLE_STEP 0x4000001E
+
 namespace windows_nat
 {
 
@@ -202,6 +205,11 @@ extern std::vector<pending_stop> pending_stops;
 /* Contents of $_siginfo */
 extern EXCEPTION_RECORD siginfo_er;
 
+#ifdef __x86_64__
+/* Ignore first breakpoint exception of WOW64 process */
+extern bool ignore_first_breakpoint;
+#endif
+
 /* Return the name of the DLL referenced by H at ADDRESS.  UNICODE
    determines what sort of string is read from the inferior.  Returns
    the name of the DLL, or NULL on error.  If a name is returned, it
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index cdaca8d0cbf..881240c6934 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -235,7 +235,6 @@ static int saw_create;
 static int open_process_used = 0;
 #ifdef __x86_64__
 static bool wow64_process = false;
-static bool ignore_first_breakpoint = false;
 #endif
 
 /* User options.  */
@@ -1721,8 +1720,10 @@ windows_nat_target::get_windows_debug_event (int pid,
 		     thread_id, 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
+	       == EXCEPTION_BREAKPOINT)
+	      || (current_event.u.Exception.ExceptionRecord.ExceptionCode
+		  == STATUS_WX86_BREAKPOINT))
 	  && windows_initialization_done)
 	{
 	  ptid_t ptid = ptid_t (current_event.dwProcessId, thread_id, 0);
@@ -1801,8 +1802,10 @@ windows_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	    {
 	      current_windows_thread->stopped_at_software_breakpoint = false;
 	      if (current_event.dwDebugEventCode == EXCEPTION_DEBUG_EVENT
-		  && (current_event.u.Exception.ExceptionRecord.ExceptionCode
-		      == EXCEPTION_BREAKPOINT)
+		  && ((current_event.u.Exception.ExceptionRecord.ExceptionCode
+		       == EXCEPTION_BREAKPOINT)
+		      || (current_event.u.Exception.ExceptionRecord.ExceptionCode
+			  == STATUS_WX86_BREAKPOINT))
 		  && windows_initialization_done)
 		current_windows_thread->stopped_at_software_breakpoint = true;
 	    }


                 reply	other threads:[~2020-04-10 11:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200410110236.556EE385B835@sourceware.org \
    --to=ssbssa@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).