public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Fix regression on Windows with WOW64
Date: Thu, 14 Apr 2022 16:02:29 +0000 (GMT)	[thread overview]
Message-ID: <20220414160229.427A33857827@sourceware.org> (raw)

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

commit 7ae6857316e020467f84645ba7c1c5ec6c085bd9
Author: Tom Tromey <tromey@adacore.com>
Date:   Thu Mar 31 07:55:09 2022 -0600

    Fix regression on Windows with WOW64
    
    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.

Diff:
---
 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 c890ee13c6c..2e4c4826797 100644
--- a/gdb/nat/windows-nat.c
+++ b/gdb/nat/windows-nat.c
@@ -183,6 +183,8 @@ windows_process_info::handle_exception (struct target_waitstatus *ourstatus,
   thread_rec (ptid_t (current_event.dwProcessId, current_event.dwThreadId, 0),
 	      DONT_SUSPEND);
 
+  last_sig = GDB_SIGNAL_0;
+
   switch (code)
     {
     case EXCEPTION_ACCESS_VIOLATION:
@@ -243,8 +245,10 @@ windows_process_info::handle_exception (struct target_waitstatus *ourstatus,
 	     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)
 	{
@@ -255,7 +259,7 @@ windows_process_info::handle_exception (struct target_waitstatus *ourstatus,
 	     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;


                 reply	other threads:[~2022-04-14 16: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=20220414160229.427A33857827@sourceware.org \
    --to=tromey@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).