From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4025 invoked by alias); 28 Feb 2012 17:27:12 -0000 Received: (qmail 4017 invoked by uid 22791); 28 Feb 2012 17:27:11 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,TW_GJ,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 28 Feb 2012 17:26:50 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1SHQnqo004180 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 12:26:49 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1SHQnwo031448; Tue, 28 Feb 2012 12:26:49 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q1SHQmLS015490; Tue, 28 Feb 2012 12:26:48 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: RFA: fix PR breakpoints/13776 Date: Tue, 28 Feb 2012 17:51:00 -0000 Message-ID: <878vjmswbr.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.93 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain 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: 2012-02/txt/msg00665.txt.bz2 I'd appreciate comments on this patch. I have no idea whether it is the best way to fix the problem. Bug 13776 concerns 'next'ing over an exit. For the trivial: #include int main (void) { exit (0); } We get this behavior: (gdb) start Temporary breakpoint 1, main () at exit0.c:5 5 exit (0); (gdb) next [Inferior 1 (process 2428) exited normally] warning: Error removing breakpoint 0 warning: Error removing breakpoint 0 warning: Error removing breakpoint 0 The bug is that exit_inferior ends up calling delete_longjmp_breakpoint, which tries to delete the longjmp breakpoints -- but as the inferior is dead, this fails. This patch fixes this problem by moving the breakpoint_init_inferior call earlier in generic_mourn_inferior. This causes the breakpoints to be marked as uninserted before they are deleted. While doing this I noticed that after the inferior exits, we are left with a step-resume breakpoint: (gdb) maint info b Num Type Disp Enb Address What [...] 0 step resume dstp y 0x00000000004004d2 inf 1 thread 1 stop only in thread 1 The breakpoint.c patch causes this to be removed as well. Built and regtested on x86-64 Fedora 16. Tom 2012-02-28 Tom Tromey PR breakpoints/13776: * target.c (generic_mourn_inferior): Call breakpoint_init_inferior earlier. * breakpoint.c (breakpoint_init_inferior): Delete step-resume breakpoints. diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index db05b97..048cc63 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -3341,6 +3341,10 @@ breakpoint_init_inferior (enum inf_context context) (gdb) tar rem :9999 # remote Windows gdbserver. */ + case bp_step_resume: + + /* Also remove step-resume breakpoints. */ + delete_breakpoint (b); break; diff --git a/gdb/target.c b/gdb/target.c index 1f408f6..65a6c23 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -3583,13 +3583,14 @@ generic_mourn_inferior (void) ptid = inferior_ptid; inferior_ptid = null_ptid; + breakpoint_init_inferior (inf_exited); + if (!ptid_equal (ptid, null_ptid)) { int pid = ptid_get_pid (ptid); exit_inferior (pid); } - breakpoint_init_inferior (inf_exited); registers_changed (); reopen_exec_file ();