From: Martin <lazarus@mfriebe.de>
To: gdb@sourceware.org
Subject: gdb fails to resume after "DebugBreak" (SigTrap)
Date: Wed, 21 Mar 2012 15:55:00 -0000 [thread overview]
Message-ID: <4F69F9BB.2050904@mfriebe.de> (raw)
Here is an issue I discovered with GDB. Unfortunately, I have no exact
steps for reproduction. (I have an app using Lazarus and FreePascal,
that can reproduce it, but that is too big)
The problem is, if an app, receives a "pause request" while already
paused. GDB will then fail to resume.
I believe this is a windows problem. (All GDB I use are from the mingw site)
It appears that the issue may have been fixed in 7.0.50 (was still
present in 7.0.0) and been re-introduced in 7.3. At least I have not yet
been able to get it with any of the versions in between. (But it might
just have been luck)
Anyway here is what I have.
1)
In order to interrupt a debugged app on windows, the following functions
are used. (pascal, but should be similar in other languages)
DebugBreakAddr := GetProcAddress(GetModuleHandle(kernel32),
'DebugBreak');
CreatRThread :=
GetProcAddress(GetModuleHandle(kernel32)'CreateRemoteThread');
Then the proccess is opened:
OpenProcess(PROCESS_CREATE_THREAD or PROCESS_QUERY_INFORMATION or
PROCESS_VM_OPERATION or PROCESS_VM_WRITE or PROCESS_VM_READ, False,
TargetPID);
hThread := CreatRThread (hProcess, nil, 0, DebugBreakAddr, nil, 0,
FPauseRequestInThreadID);
AFAIK This will lead to a SigTrap being sent to the app, and gdb will
interrupt the app.
2)
if the app has reached a breakpoint, and is in paused state, then if the
above signal is sent it will be seen by gdb, as soon as gdb continues
the app.
gdb will correctly stop, in response to the SigTrap:
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint
trap",frame={addr="0x77b5884f",func="ntdll!DbgUiConvertStateChangeStructure",args=[],from="C:\\Windows\\system32\\ntdll.dll"},thread-id="2",stopped-threads="all"
Trying to continue the app, sometimes result in this error:
-exec-continue
^running
*running,thread-id="all"
(gdb)
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"
(gdb)
Earlier version (6.x) of gdb, would just return the app "exited
normally" (despite it certainly didn't exit "normally", as it did not
finish)
reply other threads:[~2012-03-21 15:55 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=4F69F9BB.2050904@mfriebe.de \
--to=lazarus@mfriebe.de \
--cc=gdb@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).