From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12790 invoked by alias); 2 Mar 2011 15:26:51 -0000 Received: (qmail 12779 invoked by uid 22791); 2 Mar 2011 15:26:50 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from e24smtp03.br.ibm.com (HELO e24smtp03.br.ibm.com) (32.104.18.24) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Mar 2011 15:26:45 +0000 Received: from /spool/local by e24smtp03.br.ibm.com with XMail ESMTP for from ; Wed, 2 Mar 2011 12:26:39 -0300 Received: from d24relay01.br.ibm.com ([9.8.31.16]) by e24smtp03.br.ibm.com ([10.172.0.139]) with XMail ESMTP; Wed, 2 Mar 2011 12:26:38 -0300 Received: from d24av05.br.ibm.com (d24av05.br.ibm.com [9.18.232.44]) by d24relay01.br.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p22FOMcb3199038 for ; Wed, 2 Mar 2011 12:24:22 -0300 Received: from d24av05.br.ibm.com (loopback [127.0.0.1]) by d24av05.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p22FQaqD020078 for ; Wed, 2 Mar 2011 12:26:36 -0300 Received: from [9.12.227.128] ([9.12.227.128]) by d24av05.br.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p22FQY7W019983 for ; Wed, 2 Mar 2011 12:26:35 -0300 Subject: [RFA] Reposition NULL check in print_it_typical From: Thiago Jung Bauermann To: gdb-patches ml Content-Type: text/plain; charset="UTF-8" Date: Wed, 02 Mar 2011 15:26:00 -0000 Message-ID: <1299079590.22436.5.camel@hactar> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit x-cbid: 11030215-9254-0000-0000-000000B65128 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: 2011-03/txt/msg00103.txt.bz2 Hi, This is a cleanup that was part of my ranged breakpoints patch and Ulrich asked me to submit separately. It makes more sense to have the NULL check at print_it_typical's caller, since it would also be needed in breakpoint_ops.print_it implementations. As a bonus, we get rid of a FIXME. No regressions on ppc-linux and ppc64-linux. Ok? -- []'s Thiago Jung Bauermann IBM Linux Technology Center 2011-03-02 Thiago Jung Bauermann * breakpointc (print_it_typical): Move NULL check from here... (print_bp_stop_message): ... to here. Index: gdb.git/gdb/breakpoint.c =================================================================== --- gdb.git.orig/gdb/breakpoint.c 2011-03-01 00:38:26.000000000 -0300 +++ gdb.git/gdb/breakpoint.c 2011-03-01 19:11:02.000000000 -0300 @@ -3309,11 +3309,6 @@ print_it_typical (bpstat bs) int bp_temp = 0; enum print_stop_action result; - /* bs->breakpoint_at can be NULL if it was a momentary breakpoint - which has since been deleted. */ - if (bs->breakpoint_at == NULL) - return PRINT_UNKNOWN; - gdb_assert (bs->bp_location_at != NULL); bl = bs->bp_location_at; @@ -3519,10 +3514,14 @@ print_bp_stop_message (bpstat bs) { struct breakpoint *b = bs->breakpoint_at; + /* bs->breakpoint_at can be NULL if it was a momentary breakpoint + which has since been deleted. */ + if (b == NULL) + return PRINT_UNKNOWN; + /* Normal case. Call the breakpoint's print_it method, or print_it_typical. */ - /* FIXME: how breakpoint can ever be NULL here? */ - if (b != NULL && b->ops != NULL && b->ops->print_it != NULL) + if (b->ops != NULL && b->ops->print_it != NULL) return b->ops->print_it (b); else return print_it_typical (bs);