From: Hannes Domani <ssbssa@yahoo.de>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
Simon Marchi <simark@simark.ca>
Subject: Re: [PATCH] Fix ctrl-c when debugging WOW64 processes
Date: Thu, 17 Sep 2020 20:23:45 +0000 (UTC) [thread overview]
Message-ID: <1811381142.1345868.1600374225078@mail.yahoo.com> (raw)
In-Reply-To: <0c8dc56c-22cd-be59-3fdb-bae6878ea331@simark.ca>
Am Donnerstag, 17. September 2020, 22:00:29 MESZ hat Simon Marchi <simark@simark.ca> Folgendes geschrieben:
> On 2020-09-17 2:03 p.m., Hannes Domani via Gdb-patches wrote:
> > DebugBreakProcess starts a new thread in the target process with the
> > entry point DbgUiRemoteBreakin, where an int3 triggers a breakpoint
> > exception for gdb.
> >
> > But this uses DbgUiRemoteBreakin of the 64bit ntdll.dll even for
> > WOW64 processes.
> > It stops in 64bit code, Wow64GetThreadContext reports a wrong pc without
> > the int3, and gdb lets the target process continue.
> >
> > So this uses DbgUiRemoteBreakin of the 32bit ntdll.dll as the thread
> > entry point for WOW64 processes instead.
>
> Interesting. Is there any reference somewhere that explains that things
> must be done this way when a 64 bit process is debugging a 32 bit
> process?
Sadly, I could find no real reference for this.
It took me quite a few hours to debug/understand this problem.
> In any case, the patch is OK, with the formatting nits below fixed.
>
> > @@ -1522,9 +1524,36 @@ ctrl_c_handler (DWORD event_type)
> > if (!new_console && !attach_flag)
> > return TRUE;
> >
> > - if (!DebugBreakProcess (current_process_handle))
> > - warning (_("Could not interrupt program. "
> > - "Press Ctrl-c in the program console."));
> > +#ifdef __x86_64__
> > + if (wow64_process)
> > + {
> > + /* Call DbgUiRemoteBreakin of the 32bit ntdll.dll in the target process.
> > + DebugBreakProcess would call the one of the 64bit ntdll.dll, which
> > + can't be correctly handled by gdb. */
> > + if (!wow64_dbgbreak)
>
> wow64_dbgbreak == nullptr
>
>
> > + {
> > + CORE_ADDR addr;
> > + if (!find_minimal_symbol_address ("ntdll!DbgUiRemoteBreakin",
> > + &addr, 0))
> > + wow64_dbgbreak = (void *) addr;
> > + }
> > +
> > + if (wow64_dbgbreak)
>
>
> wow64_dbgbreak != nullptr
Pushed with these changes, thanks.
Hannes
next prev parent reply other threads:[~2020-09-17 20:23 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200917180337.1984-1-ssbssa.ref@yahoo.de>
2020-09-17 18:03 ` Hannes Domani
2020-09-17 20:00 ` Simon Marchi
2020-09-17 20:23 ` Hannes Domani [this message]
2020-09-17 20:17 ` Tom Tromey
2020-09-17 20:56 ` Hannes Domani
2020-09-18 14:27 ` Hannes Domani
2020-09-18 15:48 ` Simon Marchi
2020-09-18 16:09 ` Hannes Domani
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=1811381142.1345868.1600374225078@mail.yahoo.com \
--to=ssbssa@yahoo.de \
--cc=gdb-patches@sourceware.org \
--cc=simark@simark.ca \
/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