public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "gdb.bugs at mfriebe dot de" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/14018] New: Win32 fails to continue with "winerr 5" (pc register not available) after SigTrap while process paused
Date: Tue, 24 Apr 2012 22:45:00 -0000	[thread overview]
Message-ID: <bug-14018-4717@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=14018

             Bug #: 14018
           Summary: Win32 fails to continue with "winerr 5" (pc register
                    not available) after SigTrap while process paused
           Product: gdb
           Version: 7.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: gdb
        AssignedTo: unassigned@sourceware.org
        ReportedBy: gdb.bugs@mfriebe.de
    Classification: Unclassified


Created attachment 6366
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6366
pascal (src and bin) for reproducing

This bug appears to be a regression. It is present it 7.3 and 7.4. But was not
in previous 7.x)

On Windows in order to pause a running process for debugging, it is custom to
call 
CreateRemoteThread(handle_to_debugged_process, 0,0, GetProcAddress(hMod,
'DebugBreak') ...)

This leads to GDB reporting:
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint
trap",frame=


However if the above happens, while the app is already paused (e.g. after
reaching a breakpoint) then the app can not be continued.
This can not always be avoided. It may happen as a race condition, where the
breakpoint is hit, just before the signal could be sent.

The first continue will correctly lead to another pause/interrupt reporting the
SigTrap.
Trying to continue from this will report 

-exec-continue
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"

-exec-continue
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"


**** To reproduce (using Free Pascal)  Win 32 / Vista (probably any other too)
intel

I have included a helper app (in pascal) to trigger the SigTrap (source and
bin).
Compile with:  fpc.exe dbgbrk.pas 

The app to be debugged is test.exe 
compile:   fpc.exe -g test.pas

Run gdb:
   gdb -i mi test.exe

-break-insert test.pas:4
-exec-run

~"Starting program: B:\\dbg\\test.exe \n"
=thread-group-started,id="i1",pid="8372"
=thread-created,id="1",group-id="i1"
~"[New Thread 8372.0x26c4]\n"
....
*stopped,reason="breakpoint-hit",disp="keep",bkptno="1",frame={addr="0x004013f9",func="FOO"

Take the PID reported by gdb (in the example 8372) and run (while the app is
paused at the break point)

   dbgbrk.exe 8372


-exec-continue

^running
....
*stopped,reason="signal-received",signal-name="SIGTRAP",signal-meaning="Trace/breakpoint
trap",

-exec-continue
^running
....
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"


-exec-continue
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2012-04-24 22:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24 22:45 gdb.bugs at mfriebe dot de [this message]
2012-04-28 14:02 ` [Bug win32/14018] " gdb.bugs at mfriebe dot de
2012-11-01 14:39 ` andre.poenitz at digia dot com
2013-09-09 13:27 ` orgads at gmail dot com
2013-11-21 14:35 ` david.schulz at digia dot com
2013-11-21 14:49 ` brobecker at gnat dot com
2014-04-19  8:20 ` cvs-commit at gcc dot gnu.org
2014-04-19  8:27 ` cvs-commit at gcc dot gnu.org
2014-04-21 15:40 ` brobecker at gnat dot com
2014-05-05 21:54 ` cvs-commit at gcc dot gnu.org
2021-09-22 16:58 ` mervegunesli at aol dot com
2021-09-22 17:04 ` mark at klomp dot org

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=bug-14018-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).