From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10677 invoked by alias); 21 Mar 2012 15:55:09 -0000 Received: (qmail 10659 invoked by uid 22791); 21 Mar 2012 15:55:07 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from smtprelay05.ispgateway.de (HELO smtprelay05.ispgateway.de) (80.67.31.99) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 21 Mar 2012 15:54:43 +0000 Received: from [94.195.205.30] (helo=[192.168.1.62]) by smtprelay05.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1SANs1-0003S0-Kk; Wed, 21 Mar 2012 16:54:41 +0100 Message-ID: <4F69F9BB.2050904@mfriebe.de> Date: Wed, 21 Mar 2012 15:55:00 -0000 From: Martin User-Agent: Mozilla/5.0 (Windows NT 6.0; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2 MIME-Version: 1.0 To: gdb@sourceware.org Subject: gdb fails to resume after "DebugBreak" (SigTrap) Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Df-Sender: bGF6YXJ1c0BtZnJpZWJlLmRl Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2012-03/txt/msg00058.txt.bz2 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)