From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28486 invoked by alias); 9 Apr 2007 02:08:34 -0000 Received: (qmail 28478 invoked by uid 22791); 9 Apr 2007 02:08:33 -0000 X-Spam-Check-By: sourceware.org Received: from ug-out-1314.google.com (HELO ug-out-1314.google.com) (66.249.92.172) by sourceware.org (qpsmtpd/0.31) with ESMTP; Mon, 09 Apr 2007 03:08:31 +0100 Received: by ug-out-1314.google.com with SMTP id 75so1597428ugb for ; Sun, 08 Apr 2007 19:08:29 -0700 (PDT) Received: by 10.67.32.19 with SMTP id k19mr4910355ugj.1176084509019; Sun, 08 Apr 2007 19:08:29 -0700 (PDT) Received: from ?88.210.120.87? ( [88.210.120.87]) by mx.google.com with ESMTP id u9sm16558082muf.2007.04.08.19.08.26; Sun, 08 Apr 2007 19:08:28 -0700 (PDT) Message-ID: <46199F9C.1060803@portugalmail.pt> Date: Mon, 09 Apr 2007 02:08:00 -0000 From: Pedro Alves User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pt-BR; rv:1.8.0.10) Gecko/20070221 Thunderbird/1.5.0.10 Mnenhy/0.7.4.0 MIME-Version: 1.0 To: gdb-patches@sourceware.org Subject: Re: [Cygwin] Fix for: detaching crashes the inferior. References: <4618D3F7.3040700@portugalmail.pt> <4619748C.5080007@portugalmail.pt> In-Reply-To: <4619748C.5080007@portugalmail.pt> Content-Type: multipart/mixed; boundary="------------040908080303020405030708" X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-04/txt/msg00062.txt.bz2 This is a multi-part message in MIME format. --------------040908080303020405030708 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 911 Pedro Alves wrote: > Pedro Alves wrote: >> Hi all, >> >> Detaching on Cygwin often crashes the inferior, either >> when gdb attaches to the inferior, or when gdb launches >> the inferior as a child. >> Here is a new version. The real reason for the crashes is that we should be setting the context back to the inferior, as gdb's copy contains an adjusted PC. With win32_continue we would resume the inferior at the wrong address. win32_resume takes care of that, so the simple fix is to use it when detaching. The current code uses delete_command to remove breakpoints, but that leaves the internal breakpoints behind - not something we want. Is there a case where we can get to to_detach without remove_breakpoints being called? I don't think there is - we always get here through normal_stop, right? If there isn't, I'll just remove the call to it I'm introducing in the patch. Cheers, Pedro Alves --------------040908080303020405030708 Content-Type: text/x-diff; name="win32_detach.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="win32_detach.diff" Content-length: 998 2007-04-09 Pedro Alves * win32-nat.c (win32_detach): Remove breakpoints with remove_breakpoints instead of delete_command. Resume inferior with win32_resume instead of win32_continue. --- gdb/win32-nat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) Index: src/gdb/win32-nat.c =================================================================== --- src.orig/gdb/win32-nat.c 2007-04-08 12:11:22.000000000 +0100 +++ src/gdb/win32-nat.c 2007-04-09 02:48:50.000000000 +0100 @@ -1775,8 +1775,13 @@ win32_detach (char *args, int from_tty) if (has_detach_ability ()) { - delete_command (NULL, 0); - win32_continue (DBG_CONTINUE, -1); + ptid_t ptid = {-1}; + + /* Don't leave breakpoints in the inferior. */ + remove_breakpoints (); + + win32_resume (ptid, 0, TARGET_SIGNAL_0); + if (!DebugActiveProcessStop (current_event.dwProcessId)) { error (_("Can't detach process %lu (error %lu)"), --------------040908080303020405030708--