From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by sourceware.org (Postfix) with ESMTPS id 3F9E03856DDC for ; Mon, 16 May 2022 18:41:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3F9E03856DDC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f49.google.com with SMTP id u3so21732971wrg.3 for ; Mon, 16 May 2022 11:41:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1y5hNQXuerGNthxL6mgaGBeIU2LgEWvLTaA6qB03g/U=; b=2CyTlTYtUTzpAqHE2/X4qLgE0yGY/Q2GHsI8lOO+lbif+liSyyzskvJOt4j1GWMjUL 06M2rDS5Bj8VV48yxqb/hJNrwRDgpK+jA4KOEit/E7YsV3N30LBAiWFg2HyNb1gahaag eaHwS8axM+FTLOPaOYJbNSfwDnXASLkfLmyhvor+iAex8fjwciEYFluLrBSQnvNvh0Sl QFeeqynh8O9Lpfo58/kuClfzVMfOdrZDUSVbY3Da6gd9TemAinV+4FQZ9FLSIfwCfBxN irDnqVfG3T9U8UKMEt5NuqdW5alxc1NXChR7211a5IefZ3sanqM49UaD45GBEQOfBzOF MS2w== X-Gm-Message-State: AOAM532hv/3Cna7akUXy4wbouaI9zdfAm4DkgDUY+TxmeQ5RUHfRuGD9 F23AvAUUTVCKFbWIQxd26EUJZeinDto= X-Google-Smtp-Source: ABdhPJxtF4PdVxjd8KEae1pzIvWeMDUSpvOOLAGahAorQzRjShAS8Mv+tiTYE7eqPDwkVanlquwAqg== X-Received: by 2002:a5d:6489:0:b0:20c:6c3b:d49e with SMTP id o9-20020a5d6489000000b0020c6c3bd49emr16015339wri.75.1652726468796; Mon, 16 May 2022 11:41:08 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id l16-20020a05600c1d1000b0039444973258sm137702wms.0.2022.05.16.11.41.07 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 May 2022 11:41:07 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 17/23] Move common bits of catchpoint/exception_catchpoint to breakpoint's ctor Date: Mon, 16 May 2022 19:40:24 +0100 Message-Id: <20220516184030.665489-18-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220516184030.665489-1-pedro@palves.net> References: <20220516184030.665489-1-pedro@palves.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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, 16 May 2022 18:41:11 -0000 Move common bits of catchpoint and exception_catchpoint to breakpoint's ctor, to avoid duplicating code. Change-Id: I3a115180f4d496426522f1d89a3875026aea3cf2 --- gdb/break-catch-throw.c | 6 +----- gdb/breakpoint.c | 24 ++++++++++++++++++------ gdb/breakpoint.h | 10 ++-------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 90fc3e6d325..a6f477b712a 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -73,7 +73,7 @@ struct exception_catchpoint : public base_breakpoint bool temp, const char *cond_string_, enum exception_event_kind kind_, std::string &&except_rx) - : base_breakpoint (gdbarch, bp_catchpoint), + : base_breakpoint (gdbarch, bp_catchpoint, temp, cond_string_), kind (kind_), exception_rx (std::move (except_rx)), pattern (exception_rx.empty () @@ -81,10 +81,6 @@ struct exception_catchpoint : public base_breakpoint : new compiled_regex (exception_rx.c_str (), REG_NOSUB, _("invalid type-matching regexp"))) { - if (cond_string_ != nullptr) - cond_string = make_unique_xstrdup (cond_string_); - disposition = temp ? disp_del : disp_donttouch; - pspace = current_program_space; re_set (); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index bb433463c55..4dce43b1e6b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -7725,17 +7725,29 @@ disable_breakpoints_in_freed_objfile (struct objfile *objfile) /* See breakpoint.h. */ +breakpoint::breakpoint (struct gdbarch *gdbarch_, enum bptype bptype, + bool temp, const char *cond_string_) + : type (bptype), + disposition (temp ? disp_del : disp_donttouch), + gdbarch (gdbarch_), + language (current_language->la_language), + input_radix (::input_radix), + cond_string (cond_string_ != nullptr + ? make_unique_xstrdup (cond_string_) + : nullptr), + related_breakpoint (this) +{ +} + +/* See breakpoint.h. */ + catchpoint::catchpoint (struct gdbarch *gdbarch, bool temp, - const char *cond_string_) - : breakpoint (gdbarch, bp_catchpoint) + const char *cond_string) + : breakpoint (gdbarch, bp_catchpoint, temp, cond_string) { add_dummy_location (this, current_program_space); pspace = current_program_space; - - 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 21dd8d53b2d..af69af6863b 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -620,14 +620,8 @@ using bp_location_range = next_range; struct breakpoint { - breakpoint (struct gdbarch *gdbarch_, enum bptype bptype) - : type (bptype), - gdbarch (gdbarch_), - language (current_language->la_language), - input_radix (::input_radix), - related_breakpoint (this) - { - } + breakpoint (struct gdbarch *gdbarch_, enum bptype bptype, + bool temp = true, const char *cond_string = nullptr); DISABLE_COPY_AND_ASSIGN (breakpoint); -- 2.36.0