From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11793 invoked by alias); 22 Jul 2009 17:02:29 -0000 Received: (qmail 10739 invoked by uid 22791); 22 Jul 2009 17:02:26 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate7.de.ibm.com (HELO mtagate7.de.ibm.com) (195.212.29.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 22 Jul 2009 17:02:19 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate7.de.ibm.com (8.14.3/8.13.8) with ESMTP id n6MH2FJh119336 for ; Wed, 22 Jul 2009 17:02:15 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n6MH2Goq2703570 for ; Wed, 22 Jul 2009 19:02:16 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n6MH2GxF001702 for ; Wed, 22 Jul 2009 19:02:16 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id n6MH2FWQ001690 for ; Wed, 22 Jul 2009 19:02:15 +0200 Message-Id: <200907221702.n6MH2FWQ001690@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Wed, 22 Jul 2009 19:02:15 +0200 Subject: [rfc] Improve handling of failing remove_breakpoint calls To: gdb-patches@sourceware.org Date: Wed, 22 Jul 2009 17:15:00 -0000 From: "Ulrich Weigand" MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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-07/txt/msg00542.txt.bz2 Hello, one more breakpoint-related issue arose from the Cell debugger: in some cases, GDB is unable to remove a breakpoint from a main SPU stand-alone exectuable if the corresponding SPU context was already removed. This causes remove_breakpoint to return failure. Now for the most part, this doesn't really have any effect (there are a few callers that under certain circumstances issue a warning or error, but those do not apply in the Cell case). However, there is one big problem: the loops across all breakpoint locations in remove_breakpoints and similar functions will themselves terminate as soon as any of the remove_breakpoint calls fail. They will not even attempt to remove any of the *other* locations on the chain -- even if those could be removed without problem. This has quite weird effects if certain internal breakpoints (e.g. solib event breakpoints) are not removed when GDB assumes they were, causing GDB to loop endlessly in some cases. It seems to me there is really no point for this behaviour: those routines should simply attempt to remove *all* breakpoint locations, and simply return a summary status reporting where there all could be removed or whether there was an error with any of them. The following patch implements this idea. Tested on powerpc64-linux with no regressions. Any comments? I'm planning to commit this within a week or so. Bye, Ulrich ChangeLog: * breakpoint.c (remove_breakpoints): If removing one breakpoint location fails, still continue to remove other locations. (remove_hw_watchpoints): Likewise. (detach_breakpoints): Likewise. Index: src/gdb/breakpoint.c =================================================================== --- src.orig/gdb/breakpoint.c +++ src/gdb/breakpoint.c @@ -1409,36 +1409,28 @@ int remove_breakpoints (void) { struct bp_location *b; - int val; + int val = 0; ALL_BP_LOCATIONS (b) { if (b->inserted) - { - val = remove_breakpoint (b, mark_uninserted); - if (val != 0) - return val; - } + val |= remove_breakpoint (b, mark_uninserted); } - return 0; + return val; } int remove_hw_watchpoints (void) { struct bp_location *b; - int val; + int val = 0; ALL_BP_LOCATIONS (b) { if (b->inserted && b->loc_type == bp_loc_hardware_watchpoint) - { - val = remove_breakpoint (b, mark_uninserted); - if (val != 0) - return val; - } + val |= remove_breakpoint (b, mark_uninserted); } - return 0; + return val; } int @@ -1663,7 +1655,7 @@ int detach_breakpoints (int pid) { struct bp_location *b; - int val; + int val = 0; struct cleanup *old_chain = save_inferior_ptid (); if (pid == PIDGET (inferior_ptid)) @@ -1674,17 +1666,10 @@ detach_breakpoints (int pid) ALL_BP_LOCATIONS (b) { if (b->inserted) - { - val = remove_breakpoint (b, mark_inserted); - if (val != 0) - { - do_cleanups (old_chain); - return val; - } - } + val |= remove_breakpoint (b, mark_inserted); } do_cleanups (old_chain); - return 0; + return val; } static int -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com