* gdb fails to resume after "DebugBreak" (SigTrap)
@ 2012-03-21 15:55 Martin
0 siblings, 0 replies; only message in thread
From: Martin @ 2012-03-21 15:55 UTC (permalink / raw)
To: gdb
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2012-03-21 15:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-21 15:55 gdb fails to resume after "DebugBreak" (SigTrap) Martin
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).