public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH + 12.1] Fix regression on Windows with WOW64
@ 2022-04-04 13:02 Tom Tromey
  2022-04-14 15:56 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-04-04 13:02 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Internally at AdaCore, we recently started testing a 64-bit gdb
debugging 32-bit processes.  This failed with gdb head, but not with
gdb 11.

The tests fail like this:

     Starting program: [...].exe
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for WOW64_IMAGE_SECTION.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?
     warning: Could not load shared library symbols for NOT_AN_IMAGE.
     Do you need "set solib-search-path" or "set sysroot"?

After some debugging and bisecting, to my surprise the bug was
introduced by commit 183be222 ("gdb, gdbserver: make target_waitstatus
safe").

The problem occurs in handle_exception.  Previously the code did:

    -  ourstatus->kind = TARGET_WAITKIND_STOPPED;
    [...]
	 case EXCEPTION_BREAKPOINT:
    [...]
    -	  ourstatus->kind = TARGET_WAITKIND_SPURIOUS;
    [...]
	   /* FALLTHROUGH */
	 case STATUS_WX86_BREAKPOINT:
	   DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
    -      ourstatus->value.sig = GDB_SIGNAL_TRAP;
    [...]
    -  last_sig = ourstatus->value.sig;

However, in the new code, the fallthrough case does:

    +      ourstatus->set_stopped (GDB_SIGNAL_TRAP);

... which changes the 'kind' in 'ourstatus' after falling through.

This patch rearranges the 'last_sig' setting to more closely match
what was done before (this is probably not strictly needed but also
seemed harmless), and removes the fall-through in the
'ignore_first_breakpoint' case when __x86_64__ is defined.
---
 gdb/nat/windows-nat.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/nat/windows-nat.c b/gdb/nat/windows-nat.c
index 21445f3f859..27d7911a30e 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -201,6 +201,8 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
   thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0),
 	      DONT_SUSPEND);
 
+  last_sig = GDB_SIGNAL_0;
+
   switch (code)
     {
     case EXCEPTION_ACCESS_VIOLATION:
@@ -261,8 +263,10 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
 	     on startup, first a BREAKPOINT for the 64bit ntdll.dll,
 	     then a WX86_BREAKPOINT for the 32bit ntdll.dll.
 	     Here we only care about the WX86_BREAKPOINT's.  */
+	  DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - ignore_first_breakpoint");
 	  ourstatus->set_spurious ();
 	  ignore_first_breakpoint = false;
+	  break;
 	}
       else if (wow64_process)
 	{
@@ -273,7 +277,7 @@ handle_exception (struct target_waitstatus *ourstatus, bool debug_exceptions)
 	     gdb lets the target process continue.
 	     So handle it as SIGINT instead, then the target is stopped
 	     unconditionally.  */
-	  DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT");
+	  DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_BREAKPOINT - wow64_process");
 	  rec->ExceptionCode = DBG_CONTROL_C;
 	  ourstatus->set_stopped (GDB_SIGNAL_INT);
 	  break;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH + 12.1] Fix regression on Windows with WOW64
  2022-04-04 13:02 [PATCH + 12.1] Fix regression on Windows with WOW64 Tom Tromey
@ 2022-04-14 15:56 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2022-04-14 15:56 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey

>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> Internally at AdaCore, we recently started testing a 64-bit gdb
Tom> debugging 32-bit processes.  This failed with gdb head, but not with
Tom> gdb 11.

[...]

Tom> This patch rearranges the 'last_sig' setting to more closely match
Tom> what was done before (this is probably not strictly needed but also
Tom> seemed harmless), and removes the fall-through in the
Tom> 'ignore_first_breakpoint' case when __x86_64__ is defined.

I'm checking this in now, and backporting it to GDB 12 as well.

Tom

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-14 15:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04 13:02 [PATCH + 12.1] Fix regression on Windows with WOW64 Tom Tromey
2022-04-14 15:56 ` Tom Tromey

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).