From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from outbound-ss-761.bluehost.com (outbound-ss-761.bluehost.com [74.220.211.250]) by sourceware.org (Postfix) with ESMTPS id 213D5385781C for ; Tue, 18 Jan 2022 19:40:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 213D5385781C 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 cmgw14.mail.unifiedlayer.com (unknown [10.0.90.129]) by progateway8.mail.pro1.eigbox.com (Postfix) with ESMTP id 905AE1005DDA3 for ; Tue, 18 Jan 2022 19:40:16 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 9uL1nj8432s5d9uL2nNMyk; Tue, 18 Jan 2022 19:40:16 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=BOh2EHcG c=1 sm=1 tr=0 ts=61e717a0 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=qiV3g01gg5UOu3fyJAkA: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=SbrPdX1WAPg5bSpjSngLh4wue+gCYmkvsn5o6JleivE=; b=iuUHJVyGcm5+LPYssxiZH1gEnv FxNuvky+4y7crEcJXRkrtYzfxQnG1vx73ADvfNiULhqun3GmlU8rMSMY3eaergFj8RafcryN2gT0a SNJCDbWZHdj06PSjENDjKYbcA; Received: from 75-166-134-30.hlrn.qwest.net ([75.166.134.30]:40584 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 1n9uL1-0015TE-8X; Tue, 18 Jan 2022 12:40:15 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 16/36] Convert break-catch-throw to vtable ops Date: Tue, 18 Jan 2022 12:39:47 -0700 Message-Id: <20220118194007.2853108-17-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: 1n9uL1-0015TE-8X X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-30.hlrn.qwest.net (prentzel.Home) [75.166.134.30]:40584 X-Source-Auth: tom+tromey.com X-Email-Count: 17 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, RCVD_IN_MSPIKE_H2, 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:19 -0000 This converts break-catch-throw.c to use vtable_breakpoint_ops. --- gdb/break-catch-throw.c | 138 +++++++++++++++------------------------- 1 file changed, 53 insertions(+), 85 deletions(-) diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 86a8fe4ffc6..f41a8090e0c 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -63,12 +63,26 @@ static const struct exception_names exception_functions[] = { "-probe-stap libstdcxx:catch", "__cxa_begin_catch" } }; -static struct breakpoint_ops gnu_v3_exception_catchpoint_ops; - /* The type of an exception catchpoint. */ struct exception_catchpoint : public base_breakpoint { + void re_set () override; + enum print_stop_action print_it (struct bpstat *bs) override; + bool print_one (struct bp_location **) override; + void print_mention () override; + void print_recreate (struct ui_file *fp) override; + void print_one_detail (struct ui_out *) const override; + void check_status (struct bpstat *bs) override; + struct bp_location *allocate_location () override; + + /* FIXME this is temporary - until ordinary breakpoints have been + converted. */ + int resources_needed (const struct bp_location *) override + { + return 1; + } + /* The kind of exception catchpoint. */ enum exception_event_kind kind; @@ -89,7 +103,7 @@ struct exception_catchpoint : public base_breakpoint bool is_exception_catchpoint (breakpoint *bp) { - return bp->ops == &gnu_v3_exception_catchpoint_ops; + return dynamic_cast (bp) != nullptr; } @@ -130,27 +144,16 @@ fetch_probe_arguments (struct value **arg0, struct value **arg1) -/* A helper function that returns a value indicating the kind of the - exception catchpoint B. */ - -static enum exception_event_kind -classify_exception_breakpoint (struct breakpoint *b) -{ - struct exception_catchpoint *cp = (struct exception_catchpoint *) b; - - return cp->kind; -} - /* Implement the 'check_status' method. */ -static void -check_status_exception_catchpoint (struct bpstat *bs) +void +exception_catchpoint::check_status (struct bpstat *bs) { struct exception_catchpoint *self = (struct exception_catchpoint *) bs->breakpoint_at; std::string type_name; - bkpt_breakpoint_ops.check_status (bs); + this->breakpoint::check_status (bs); if (bs->stop == 0) return; @@ -185,11 +188,10 @@ check_status_exception_catchpoint (struct bpstat *bs) /* Implement the 're_set' method. */ -static void -re_set_exception_catchpoint (struct breakpoint *self) +void +exception_catchpoint::re_set () { std::vector sals; - enum exception_event_kind kind = classify_exception_breakpoint (self); struct program_space *filter_pspace = current_program_space; /* We first try to use the probe interface. */ @@ -211,8 +213,7 @@ re_set_exception_catchpoint (struct breakpoint *self) explicit_loc.function_name = ASTRDUP (exception_functions[kind].function); event_location_up location = new_explicit_location (&explicit_loc); - sals = self->ops->decode_location (self, location.get (), - filter_pspace); + sals = this->decode_location (location.get (), filter_pspace); } catch (const gdb_exception_error &ex) { @@ -223,24 +224,22 @@ re_set_exception_catchpoint (struct breakpoint *self) } } - update_breakpoint_locations (self, filter_pspace, sals, {}); + update_breakpoint_locations (this, filter_pspace, sals, {}); } -static enum print_stop_action -print_it_exception_catchpoint (bpstat *bs) +enum print_stop_action +exception_catchpoint::print_it (bpstat *bs) { struct ui_out *uiout = current_uiout; - struct breakpoint *b = bs->breakpoint_at; int bp_temp; - enum exception_event_kind kind = classify_exception_breakpoint (b); - annotate_catchpoint (b->number); + annotate_catchpoint (number); maybe_print_thread_hit_breakpoint (uiout); - bp_temp = b->disposition == disp_del; + bp_temp = disposition == disp_del; uiout->text (bp_temp ? "Temporary catchpoint " : "Catchpoint "); - uiout->field_signed ("bkptno", b->number); + uiout->field_signed ("bkptno", number); uiout->text ((kind == EX_EVENT_THROW ? " (exception thrown), " : (kind == EX_EVENT_CATCH ? " (exception caught), " : " (exception rethrown), "))); @@ -248,18 +247,16 @@ print_it_exception_catchpoint (bpstat *bs) { uiout->field_string ("reason", async_reason_lookup (EXEC_ASYNC_BREAKPOINT_HIT)); - uiout->field_string ("disp", bpdisp_text (b->disposition)); + uiout->field_string ("disp", bpdisp_text (disposition)); } return PRINT_SRC_AND_LOC; } -static bool -print_one_exception_catchpoint (struct breakpoint *b, - struct bp_location **last_loc) +bool +exception_catchpoint::print_one (struct bp_location **last_loc) { struct value_print_options opts; struct ui_out *uiout = current_uiout; - enum exception_event_kind kind = classify_exception_breakpoint (b); get_user_print_options (&opts); @@ -293,48 +290,41 @@ print_one_exception_catchpoint (struct breakpoint *b, /* Implement the 'print_one_detail' method. */ -static void -print_one_detail_exception_catchpoint (const struct breakpoint *b, - struct ui_out *uiout) +void +exception_catchpoint::print_one_detail (struct ui_out *uiout) const { - const struct exception_catchpoint *cp - = (const struct exception_catchpoint *) b; - - if (!cp->exception_rx.empty ()) + if (!exception_rx.empty ()) { uiout->text (_("\tmatching: ")); - uiout->field_string ("regexp", cp->exception_rx); + uiout->field_string ("regexp", exception_rx); uiout->text ("\n"); } } -static void -print_mention_exception_catchpoint (struct breakpoint *b) +void +exception_catchpoint::print_mention () { struct ui_out *uiout = current_uiout; int bp_temp; - enum exception_event_kind kind = classify_exception_breakpoint (b); - bp_temp = b->disposition == disp_del; + bp_temp = disposition == disp_del; uiout->message ("%s %d %s", (bp_temp ? _("Temporary catchpoint ") : _("Catchpoint")), - b->number, + number, (kind == EX_EVENT_THROW ? _("(throw)") : (kind == EX_EVENT_CATCH ? _("(catch)") : _("(rethrow)")))); } -/* Implement the "print_recreate" breakpoint_ops method for throw and - catch catchpoints. */ +/* Implement the "print_recreate" method for throw and catch + catchpoints. */ -static void -print_recreate_exception_catchpoint (struct breakpoint *b, - struct ui_file *fp) +void +exception_catchpoint::print_recreate (struct ui_file *fp) { int bp_temp; - enum exception_event_kind kind = classify_exception_breakpoint (b); - bp_temp = b->disposition == disp_del; + bp_temp = disposition == disp_del; fprintf_unfiltered (fp, bp_temp ? "tcatch " : "catch "); switch (kind) { @@ -348,16 +338,16 @@ print_recreate_exception_catchpoint (struct breakpoint *b, fprintf_unfiltered (fp, "rethrow"); break; } - print_recreate_thread (b, fp); + print_recreate_thread (this, fp); } -/* Implement the "allocate_location" breakpoint_ops method for throw - and catch catchpoints. */ +/* Implement the "allocate_location" method for throw and catch + catchpoints. */ -static bp_location * -allocate_location_exception_catchpoint (breakpoint *self) +bp_location * +exception_catchpoint::allocate_location () { - return new bp_location (self, bp_loc_software_breakpoint); + return new bp_location (this, bp_loc_software_breakpoint); } static void @@ -376,12 +366,12 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx, std::unique_ptr cp (new exception_catchpoint ()); init_catchpoint (cp.get (), get_current_arch (), tempflag, cond_string, - &gnu_v3_exception_catchpoint_ops); + &vtable_breakpoint_ops); cp->kind = ex_event; cp->exception_rx = std::move (except_rx); cp->pattern = std::move (pattern); - re_set_exception_catchpoint (cp.get ()); + cp->re_set (); install_breakpoint (0, std::move (cp), 1); } @@ -517,32 +507,10 @@ static const struct internalvar_funcs exception_funcs = -static void -initialize_throw_catchpoint_ops (void) -{ - struct breakpoint_ops *ops; - - initialize_breakpoint_ops (); - - /* GNU v3 exception catchpoints. */ - ops = &gnu_v3_exception_catchpoint_ops; - *ops = bkpt_breakpoint_ops; - ops->re_set = re_set_exception_catchpoint; - ops->print_it = print_it_exception_catchpoint; - ops->print_one = print_one_exception_catchpoint; - ops->print_mention = print_mention_exception_catchpoint; - ops->print_recreate = print_recreate_exception_catchpoint; - ops->print_one_detail = print_one_detail_exception_catchpoint; - ops->check_status = check_status_exception_catchpoint; - ops->allocate_location = allocate_location_exception_catchpoint; -} - void _initialize_break_catch_throw (); void _initialize_break_catch_throw () { - initialize_throw_catchpoint_ops (); - /* Add catch and tcatch sub-commands. */ add_catch_command ("catch", _("\ Catch an exception, when caught."), -- 2.31.1