public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "david.schulz at digia dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug win32/14018] Win32 fails to continue with "winerr 5" (pc register not available) after SigTrap while process paused
Date: Thu, 21 Nov 2013 14:35:00 -0000	[thread overview]
Message-ID: <bug-14018-4717-b79zbeli0U@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-14018-4717@http.sourceware.org/bugzilla/>

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

David Schulz <david.schulz at digia dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |david.schulz at digia dot com

--- Comment #3 from David Schulz <david.schulz at digia dot com> ---
Can also be reproduced with the following C++ Code:

#include <windows.h>

int main()
{    
    while (true)
        DebugBreakProcess(GetCurrentProcess());
}

Start gdb:

gdb -ex run <Executable of the code above>.exe

After startup enter:

break main.cpp:6
command
continue
end
handle SIGTRAP nostop
continue

After some lines telling you that the program received a SIGTRAP the following
error is shown:
&"warning: SuspendThread failed. (winerr 5)\n"
^error,msg="PC register is not available"

The breakpoint is important because SuspendThread is just called when the gdb
requests the thread contexts (see gdb/windows-nat.c:thread_rec()). 

The gdb commands and the code above actually emulates the QtCreator which
inserts a breakpoint to a running inferior, and this breakpoint is hit directly
after it was inserted.
To give you a time line of the QtCreator behavior:
 - everything runs (QtCreator, gdb, inferior)
 - request insert breakpoint
 - interrupt inferior
 - wait for gdb to tell QtCreator it has stopped
 - insert breakpoint
 - tell the gdb to continue execution
 - breakpoint in inferior is hit
 - BOOM: gdb stops with the error message: PC register is not available

The actual problem is that the gdb has not the rights to suspend the Thread
(winerr 5 == ERROR_ACCESS_DENIED). As the only threads in this process are the
main thread and the DebugBreak threads it looks like the gdb has not the rights
to suspend the DebugBreak threads in some states (it occures not on every break
so it has to be a special thread state). 
A possible Solution could be to check if you have the rights to suspend that
thread (should be done anyway according to the documentation:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686345(v=vs.85).aspx).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


  parent reply	other threads:[~2013-11-21 14:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24 22:45 [Bug gdb/14018] New: " gdb.bugs at mfriebe dot de
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 [this message]
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-b79zbeli0U@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).