From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9436 invoked by alias); 1 Oct 2009 16:05:50 -0000 Received: (qmail 9384 invoked by uid 22791); 1 Oct 2009 16:05:48 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS 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; Thu, 01 Oct 2009 16:05:42 +0000 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n91G5eVn000615 for ; Thu, 1 Oct 2009 12:05:41 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n91G5dph002250 for ; Thu, 1 Oct 2009 12:05:40 -0400 Message-ID: <4AC4D353.3010605@redhat.com> Date: Thu, 01 Oct 2009 16:05:00 -0000 From: Phil Muldoon User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.1) Gecko/20090814 Fedora/3.0-2.6.b3.fc11 Lightning/1.0pre Thunderbird/3.0b3 MIME-Version: 1.0 To: gdb-patches ml Subject: [patch] Add cleanup branch for std::terminate breakpoints in call_function_by_hand Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: 2009-10/txt/msg00011.txt.bz2 This patches fixes a breakpoint leak that may occur when an inferior function call is performed within a C++ executable. It adds a do_cleanup call at one of the function exit entry points. (call_function_by_hand can exit in several different scenarios, depending on the result of the inferior call). I decided to place a condition around the do_cleanup over a null_cleanup just to save endless null_cleanup calls when the inferior is a C executable (the cleanup is never needed there, as the breakpoint is not set). Apologies for introducing this bug a few months back, and finding and fixing it during this busy (release) time! I tested this on x86_64 with no regressions. Regards Phil ChangeLog 2009-10-01 Phil Muldoon * infcall.c (call_function_by_hand): Add a new cleanup branch for std::terminate breakpoint. -- Index: infcall.c =================================================================== RCS file: /cvs/src/src/gdb/infcall.c,v retrieving revision 1.121 diff -u -r1.121 infcall.c --- infcall.c 28 Jul 2009 16:39:06 -0000 1.121 +++ infcall.c 1 Oct 2009 15:00:38 -0000 @@ -441,6 +441,7 @@ struct gdbarch *gdbarch; struct breakpoint *terminate_bp = NULL; struct minimal_symbol *tm; + struct cleanup *terminate_bp_cleanup; ptid_t call_thread_ptid; struct gdb_exception e; const char *name; @@ -772,7 +773,7 @@ /* Register a clean-up for unwind_on_terminating_exception_breakpoint. */ if (terminate_bp) - make_cleanup_delete_breakpoint (terminate_bp); + terminate_bp_cleanup = make_cleanup_delete_breakpoint (terminate_bp); /* - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - SNIP - If you're looking to implement asynchronous dummy-frames, then @@ -987,6 +988,11 @@ internal_error (__FILE__, __LINE__, _("... should not be here")); } + /* If we get here and the std::terminate() breakpoint has been set, + it has to be cleaned manually. */ + if (terminate_bp) + do_cleanups (terminate_bp_cleanup); +