From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy1-pub.mail.unifiedlayer.com (gproxy1-pub.mail.unifiedlayer.com [69.89.25.95]) by sourceware.org (Postfix) with ESMTPS id E513D385803B for ; Tue, 18 Jan 2022 19:40:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E513D385803B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw13.mail.unifiedlayer.com (unknown [10.0.90.128]) by progateway3.mail.pro1.eigbox.com (Postfix) with ESMTP id 4FBCB100484E4 for ; Tue, 18 Jan 2022 19:40:12 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 9uKxnWP9NEaNC9uKynPhiS; Tue, 18 Jan 2022 19:40:12 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=dJtjJMVb c=1 sm=1 tr=0 ts=61e7179c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=DghFqjY3_ZEA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=0KDp1bZ9XpQl4IE4yNIA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=0s07J2Ah1YzkcZZ83rfYsuHSasrJw8ZkQFZeV5dsupw=; b=At2FqnseEjjH6w5T89hhzzuEb+ Tq47vcx4AmL9ul7oilUUMNgeByIMONmBI2TVAuVLThmAJtTsU7t7Sb26ohcvOqrdEU9O+JLLT5KNi Js1psxmx6YQKp6bVYimwhVMVp; Received: from 75-166-134-30.hlrn.qwest.net ([75.166.134.30]:40582 helo=prentzel.Home) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n9uKx-0015NP-Hd; Tue, 18 Jan 2022 12:40:11 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 05/36] Return bool from breakpoint_ops::print_one Date: Tue, 18 Jan 2022 12:39:36 -0700 Message-Id: <20220118194007.2853108-6-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220118194007.2853108-1-tom@tromey.com> References: <20220118194007.2853108-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.134.30 X-Source-L: No X-Exim-ID: 1n9uKx-0015NP-Hd X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-30.hlrn.qwest.net (prentzel.Home) [75.166.134.30]:40582 X-Source-Auth: tom+tromey.com X-Email-Count: 6 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3031.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 19:40:14 -0000 This changes breakpoint_ops::print_one to return bool, and updates all the implementations and the caller. The caller is changed so that a NULL check is no longer needed -- something that will be impossible with a real method. --- gdb/ada-lang.c | 4 +++- gdb/break-catch-exec.c | 4 +++- gdb/break-catch-fork.c | 4 +++- gdb/break-catch-load.c | 4 +++- gdb/break-catch-sig.c | 4 +++- gdb/break-catch-syscall.c | 4 +++- gdb/break-catch-throw.c | 4 +++- gdb/breakpoint.c | 31 +++++++++++++++++++++---------- gdb/breakpoint.h | 5 +++-- 9 files changed, 45 insertions(+), 19 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 642527e068c..a2a6275fb5f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -11902,7 +11902,7 @@ print_it_exception (bpstat *bs) /* Implement the PRINT_ONE method in the breakpoint_ops structure for all exception catchpoint kinds. */ -static void +static bool print_one_exception (struct breakpoint *b, struct bp_location **last_loc) { struct ui_out *uiout = current_uiout; @@ -11953,6 +11953,8 @@ print_one_exception (struct breakpoint *b, struct bp_location **last_loc) internal_error (__FILE__, __LINE__, _("unexpected catchpoint type")); break; } + + return true; } /* Implement the PRINT_MENTION method in the breakpoint_ops structure diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index c0cf2aeb3b5..adfb506477c 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -94,7 +94,7 @@ print_it_catch_exec (bpstat *bs) return PRINT_SRC_AND_LOC; } -static void +static bool print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) { struct exec_catchpoint *c = (struct exec_catchpoint *) b; @@ -119,6 +119,8 @@ print_one_catch_exec (struct breakpoint *b, struct bp_location **last_loc) if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", "exec"); + + return true; } static void diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index af44a9fe76e..8877099e013 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -127,7 +127,7 @@ print_it_catch_fork (bpstat *bs) /* Implement the "print_one" breakpoint_ops method for fork catchpoints. */ -static void +static bool print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc) { struct fork_catchpoint *c = (struct fork_catchpoint *) b; @@ -153,6 +153,8 @@ print_one_catch_fork (struct breakpoint *b, struct bp_location **last_loc) if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", name); + + return true; } /* Implement the "print_mention" breakpoint_ops method for fork diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 34340c260e6..bfd318fe474 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -189,7 +189,7 @@ print_it_catch_solib (bpstat *bs) return PRINT_SRC_AND_LOC; } -static void +static bool print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) { struct solib_catchpoint *self = (struct solib_catchpoint *) b; @@ -228,6 +228,8 @@ print_one_catch_solib (struct breakpoint *b, struct bp_location **locs) if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", self->is_load ? "load" : "unload"); + + return true; } static void diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index e268a102891..f55f34c0368 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -201,7 +201,7 @@ signal_catchpoint_print_it (bpstat *bs) /* Implement the "print_one" breakpoint_ops method for signal catchpoints. */ -static void +static bool signal_catchpoint_print_one (struct breakpoint *b, struct bp_location **last_loc) { @@ -248,6 +248,8 @@ signal_catchpoint_print_one (struct breakpoint *b, if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", "signal"); + + return true; } /* Implement the "print_mention" breakpoint_ops method for signal diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 9ad8aaa06c8..7c797898940 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -226,7 +226,7 @@ print_it_catch_syscall (bpstat *bs) /* Implement the "print_one" breakpoint_ops method for syscall catchpoints. */ -static void +static bool print_one_catch_syscall (struct breakpoint *b, struct bp_location **last_loc) { @@ -275,6 +275,8 @@ print_one_catch_syscall (struct breakpoint *b, if (uiout->is_mi_like_p ()) uiout->field_string ("catch-type", "syscall"); + + return true; } /* Implement the "print_mention" breakpoint_ops method for syscall diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index d34e5f9ee53..a49736cfd5f 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -253,7 +253,7 @@ print_it_exception_catchpoint (bpstat *bs) return PRINT_SRC_AND_LOC; } -static void +static bool print_one_exception_catchpoint (struct breakpoint *b, struct bp_location **last_loc) { @@ -287,6 +287,8 @@ print_one_exception_catchpoint (struct breakpoint *b, uiout->field_string ("catch-type", "catch"); break; } + + return true; } /* Implement the 'print_one_detail' method. */ diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 06c52bb5b3a..5b3e91c1841 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5999,9 +5999,10 @@ output_thread_groups (struct ui_out *uiout, instead of going via breakpoint_ops::print_one. This makes "maint info breakpoints" show the software breakpoint locations of catchpoints, which are considered internal implementation - detail. */ + detail. Returns true if RAW_LOC is false and if the breakpoint's + print_one method did something; false otherwise. */ -static void +static bool print_one_breakpoint_location (struct breakpoint *b, struct bp_location *loc, int loc_number, @@ -6065,8 +6066,9 @@ print_one_breakpoint_location (struct breakpoint *b, uiout->field_fmt ("enabled", "%c", bpenables[(int) b->enable_state]); /* 5 and 6 */ - if (!raw_loc && b->ops != NULL && b->ops->print_one != NULL) - b->ops->print_one (b, last_loc); + bool result = false; + if (!raw_loc && b->ops != NULL && b->ops->print_one (b, last_loc)) + result = true; else { if (is_watchpoint (b)) @@ -6313,6 +6315,8 @@ print_one_breakpoint_location (struct breakpoint *b, uiout->field_string ("original-location", event_location_to_string (b->location.get ())); } + + return result; } /* See breakpoint.h. */ @@ -6330,7 +6334,8 @@ print_one_breakpoint (struct breakpoint *b, || fix_multi_location_breakpoint_output_globally); gdb::optional bkpt_tuple_emitter (gdb::in_place, uiout, "bkpt"); - print_one_breakpoint_location (b, NULL, 0, last_loc, allflag, false); + bool printed = print_one_breakpoint_location (b, NULL, 0, last_loc, + allflag, false); /* The mi2 broken format: the main breakpoint tuple ends here, the locations are outside. */ @@ -6340,9 +6345,7 @@ print_one_breakpoint (struct breakpoint *b, /* If this breakpoint has custom print function, it's already printed. Otherwise, print individual locations, if any. */ - if (b->ops == NULL - || b->ops->print_one == NULL - || allflag) + if (!printed || allflag) { /* If breakpoint has a single location that is disabled, we print it as if it had several locations, since otherwise it's @@ -9188,7 +9191,7 @@ print_it_ranged_breakpoint (bpstat *bs) /* Implement the "print_one" breakpoint_ops method for ranged breakpoints. */ -static void +static bool print_one_ranged_breakpoint (struct breakpoint *b, struct bp_location **last_loc) { @@ -9208,6 +9211,8 @@ print_one_ranged_breakpoint (struct breakpoint *b, annotate_field (5); print_breakpoint_location (b, bl); *last_loc = bl; + + return true; } /* Implement the "print_one_detail" breakpoint_ops method for @@ -11560,6 +11565,12 @@ base_breakpoint_print_it (bpstat *bs) internal_error_pure_virtual_called (); } +static bool +base_breakpoint_print_one (struct breakpoint *, struct bp_location **) +{ + return false; +} + static void base_breakpoint_print_one_detail (const struct breakpoint *self, struct ui_out *uiout) @@ -11639,7 +11650,7 @@ struct breakpoint_ops base_breakpoint_ops = base_breakpoint_resources_needed, base_breakpoint_works_in_software_mode, base_breakpoint_print_it, - NULL, + base_breakpoint_print_one, base_breakpoint_print_one_detail, base_breakpoint_print_mention, base_breakpoint_print_recreate, diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 01a6e0b7994..99f81b28c30 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -608,8 +608,9 @@ struct breakpoint_ops enum print_stop_action (*print_it) (struct bpstat *bs); /* Display information about this breakpoint, for "info - breakpoints". */ - void (*print_one) (struct breakpoint *, struct bp_location **); + breakpoints". Returns false if this method should use the + default behavior. */ + bool (*print_one) (struct breakpoint *, struct bp_location **); /* Display extra information about this breakpoint, below the normal breakpoint description in "info breakpoints". -- 2.31.1