From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id BFA6A385734E for ; Mon, 2 May 2022 22:16:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BFA6A385734E 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 progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 30A6A10048761 for ; Mon, 2 May 2022 22:16:01 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id leKmnLhMKY8ycleKnnuwFJ; Mon, 02 May 2022 22:16:01 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=TZJTCTch c=1 sm=1 tr=0 ts=62705821 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=oZkIemNP1mAA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=1HFl6eFZwvh3ww8S9HYA: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=toc/qDtdlJX5o27h4Sm/w3C66Gqe07l3xMW1SNCjRAw=; b=rL2mzrY6gU8qEGNFaiROsx3J58 CkMTh08ohw9VdeAeG9gew6Y8+aN6fA4Fbxvs4RA2YVmD5ic6XyOh+LwVMXolTsj4JYf88F7MWdV+f ricKKAZpcaMa/8KuLWNuSsnq2; Received: from 71-211-158-194.hlrn.qwest.net ([71.211.158.194]:45574 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 1nleKm-002KA3-AQ; Mon, 02 May 2022 16:16:00 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 18/18] Introduce catchpoint class Date: Mon, 2 May 2022 16:15:53 -0600 Message-Id: <20220502221553.1394743-19-tom@tromey.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220502221553.1394743-1-tom@tromey.com> References: <20220502221553.1394743-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: 71.211.158.194 X-Source-L: No X-Exim-ID: 1nleKm-002KA3-AQ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 71-211-158-194.hlrn.qwest.net (prentzel.Home) [71.211.158.194]:45574 X-Source-Auth: tom+tromey.com X-Email-Count: 19 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3029.9 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, T_SCC_BODY_TEXT_LINE 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: Mon, 02 May 2022 22:16:04 -0000 This introduces a catchpoint class that is used as the base class for all catchpoints. init_catchpoint is rewritten to be a constructor instead. This changes the hierarchy a little -- some catchpoints now inherit from base_breakpoint whereas previously they did not. This isn't a problem, as long as re_set is redefined in catchpoint. --- gdb/break-catch-exec.c | 10 +++++----- gdb/break-catch-fork.c | 13 ++++++------- gdb/break-catch-load.c | 13 +++++++------ gdb/break-catch-sig.c | 10 +++++----- gdb/break-catch-syscall.c | 1 - gdb/break-catch-throw.c | 10 +++++----- gdb/breakpoint.c | 19 +++++++------------ gdb/breakpoint.h | 22 ++++++++++++++-------- 8 files changed, 49 insertions(+), 49 deletions(-) diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index c828b50cc62..07417ee499c 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -34,10 +34,10 @@ A breakpoint is really of this type iff its ops pointer points to CATCH_EXEC_BREAKPOINT_OPS. */ -struct exec_catchpoint : public breakpoint +struct exec_catchpoint : public catchpoint { - explicit exec_catchpoint (struct gdbarch *gdbarch) - : breakpoint (gdbarch, bp_catchpoint) + exec_catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string) + : catchpoint (gdbarch, temp, cond_string) { } @@ -208,8 +208,8 @@ catch_exec_command_1 (const char *arg, int from_tty, if ((*arg != '\0') && !isspace (*arg)) error (_("Junk at end of arguments.")); - std::unique_ptr c (new exec_catchpoint (gdbarch)); - init_catchpoint (c.get (), gdbarch, temp, cond_string); + std::unique_ptr c + (new exec_catchpoint (gdbarch, temp, cond_string)); install_breakpoint (0, std::move (c), 1); } diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index 05dd674a66c..1f8deec6a62 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -32,10 +32,11 @@ catchpoint. A breakpoint is really of this type iff its ops pointer points to CATCH_FORK_BREAKPOINT_OPS. */ -struct fork_catchpoint : public breakpoint +struct fork_catchpoint : public catchpoint { - explicit fork_catchpoint (struct gdbarch *gdbarch, bool is_vfork_) - : breakpoint (gdbarch, bp_catchpoint), + fork_catchpoint (struct gdbarch *gdbarch, bool temp, + const char *cond_string, bool is_vfork_) + : catchpoint (gdbarch, temp, cond_string), is_vfork (is_vfork_) { } @@ -186,10 +187,8 @@ create_fork_vfork_event_catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string, bool is_vfork) { - std::unique_ptr c (new fork_catchpoint (gdbarch, - is_vfork)); - - init_catchpoint (c.get (), gdbarch, temp, cond_string); + std::unique_ptr c + (new fork_catchpoint (gdbarch, temp, cond_string, is_vfork)); install_breakpoint (0, std::move (c), 1); } diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 8579f4e3b23..617ee2b694d 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -33,10 +33,12 @@ A breakpoint is really of this type iff its ops pointer points to CATCH_SOLIB_BREAKPOINT_OPS. */ -struct solib_catchpoint : public breakpoint +struct solib_catchpoint : public catchpoint { - solib_catchpoint (struct gdbarch *gdbarch, bool is_load_, const char *arg) - : breakpoint (gdbarch, bp_catchpoint), + solib_catchpoint (struct gdbarch *gdbarch, bool temp, + const char *cond_string, + bool is_load_, const char *arg) + : catchpoint (gdbarch, temp, cond_string), is_load (is_load_), regex (arg == nullptr ? nullptr : make_unique_xstrdup (arg)), compiled (arg == nullptr @@ -229,11 +231,10 @@ add_solib_catchpoint (const char *arg, bool is_load, bool is_temp, bool enabled) if (*arg == '\0') arg = nullptr; - std::unique_ptr c (new solib_catchpoint (gdbarch, + std::unique_ptr c (new solib_catchpoint (gdbarch, is_temp, + nullptr, is_load, arg)); - init_catchpoint (c.get (), gdbarch, is_temp, NULL); - c->enable_state = enabled ? bp_enabled : bp_disabled; install_breakpoint (0, std::move (c), 1); diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index 4430dd0b2b8..57a6255dc33 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -38,11 +38,12 @@ /* An instance of this type is used to represent a signal catchpoint. */ -struct signal_catchpoint : public breakpoint +struct signal_catchpoint : public catchpoint { - signal_catchpoint (struct gdbarch *gdbarch, std::vector &&sigs, + signal_catchpoint (struct gdbarch *gdbarch, bool temp, + std::vector &&sigs, bool catch_all_) - : breakpoint (gdbarch, bp_catchpoint), + : catchpoint (gdbarch, temp, nullptr), signals_to_be_caught (std::move (sigs)), catch_all (catch_all_) { @@ -325,8 +326,7 @@ create_signal_catchpoint (int tempflag, std::vector &&filter, struct gdbarch *gdbarch = get_current_arch (); std::unique_ptr c - (new signal_catchpoint (gdbarch, std::move (filter), catch_all)); - init_catchpoint (c.get (), gdbarch, tempflag, nullptr); + (new signal_catchpoint (gdbarch, tempflag, std::move (filter), catch_all)); install_breakpoint (0, std::move (c), 1); } diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 5ed15ac8bf9..d79ced47a12 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -355,7 +355,6 @@ create_syscall_event_catchpoint (int tempflag, std::vector &&filter) std::unique_ptr c (new syscall_catchpoint (gdbarch, std::move (filter))); - init_catchpoint (c.get (), gdbarch, tempflag, nullptr); install_breakpoint (0, std::move (c), 1); } diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 0237af7b2a7..f15fa531519 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -65,12 +65,13 @@ static const struct exception_names exception_functions[] = /* The type of an exception catchpoint. */ -struct exception_catchpoint : public base_breakpoint +struct exception_catchpoint : public catchpoint { exception_catchpoint (struct gdbarch *gdbarch, + bool temp, const char *cond_string, enum exception_event_kind kind_, std::string &&except_rx) - : base_breakpoint (gdbarch, bp_catchpoint), + : catchpoint (gdbarch, temp, cond_string), kind (kind_), exception_rx (std::move (except_rx)), pattern (exception_rx.empty () @@ -371,9 +372,8 @@ handle_gnu_v3_exceptions (int tempflag, std::string &&except_rx, struct gdbarch *gdbarch = get_current_arch (); std::unique_ptr cp - (new exception_catchpoint (gdbarch, ex_event, std::move (except_rx))); - - init_catchpoint (cp.get (), gdbarch, tempflag, cond_string); + (new exception_catchpoint (gdbarch, tempflag, cond_string, + ex_event, std::move (except_rx))); cp->re_set (); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4c7542a52c8..9abc1443d96 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7804,23 +7804,18 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile) /* See breakpoint.h. */ -void -init_catchpoint (struct breakpoint *b, - struct gdbarch *gdbarch, bool temp, - const char *cond_string) +catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp, + const char *cond_string_) + : base_breakpoint (gdbarch, bp_catchpoint) { symtab_and_line sal; sal.pspace = current_program_space; - /* This should already have been set in the constructor. */ - gdb_assert (b->type == bp_catchpoint); - init_raw_breakpoint (b, sal, bp_catchpoint); + init_raw_breakpoint (this, sal, bp_catchpoint); - if (cond_string == nullptr) - b->cond_string.reset (); - else - b->cond_string = make_unique_xstrdup (cond_string); - b->disposition = temp ? disp_del : disp_donttouch; + if (cond_string_ != nullptr) + cond_string = make_unique_xstrdup (cond_string_); + disposition = temp ? disp_del : disp_donttouch; } void diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index d244e8daec0..ac738fd7c2d 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1012,6 +1012,20 @@ struct tracepoint : public breakpoint int static_trace_marker_id_idx = 0; }; +/* The base class for catchpoints. */ + +struct catchpoint : public base_breakpoint +{ + /* If TEMP is true, then make the breakpoint temporary. If + COND_STRING is not NULL, then store it in the breakpoint. */ + catchpoint (struct gdbarch *gdbarch, bool temp, const char *cond_string); + + void re_set () override + { + /* For catchpoints, the default is to do nothing. */ + } +}; + /* The following stuff is an abstract data type "bpstat" ("breakpoint status"). This provides the ability to determine whether we have @@ -1440,14 +1454,6 @@ extern void int enabled, int from_tty); -/* Initialize a new breakpoint of the bp_catchpoint kind. If TEMP - is true, then make the breakpoint temporary. If COND_STRING is - not NULL, then store it in the breakpoint. */ - -extern void init_catchpoint (struct breakpoint *b, - struct gdbarch *gdbarch, bool temp, - const char *cond_string); - /* Add breakpoint B on the breakpoint list, and notify the user, the target and breakpoint_created observers of its existence. If INTERNAL is non-zero, the breakpoint number will be allocated from -- 2.34.1