From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by sourceware.org (Postfix) with ESMTPS id 6351238288D0 for ; Fri, 27 May 2022 18:03:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6351238288D0 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-f51.google.com with SMTP id e2so6846685wrc.1 for ; Fri, 27 May 2022 11:03:07 -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=YfNQeYnz/LTe3SkTxjpOMDNMVKU8y6tAV61zLAX7sjc=; b=zFfjKcjL8ZMBCZiiXafvzHwVSJThyRJxNO5R/73zbicoemQonOUf08LQUV21pJA1ke ak0nP9PkcYKcX41tp5e/hcNPJUUsKzzGUfiHHPC5uccKo0pG46a2f4J90J+chHc4gqNj vici6sZ0ZEOHSx1vN0ZR6zVeHa5gi1NM7uv84fwLZHUciEDn1I1+/bUTHF55c5eB/fCI hijZMpKOW3LzN/yz9o2nY5xKmS8SEI3QOGot2iGIuqZ42OoYgK8Yod6Ps2V93LrH3dLN 9oYKFLd1mQTP0mrKHPbMq0XIreZRHyNh689YvgftkVPrAaGt14Gz/g8oQKnxI1looFbt ARlg== X-Gm-Message-State: AOAM531RI1e+XXcLI2VVzTDlnECC1dPNfGnSydADVwAtnSPirNRu2UyF CULbg27LoqWKjfjDFA8ytk/zdzMdHWo= X-Google-Smtp-Source: ABdhPJy9tMS4aGqQ04MBaO3iP6x9d9yUxoPUUw5kN4+1ANRoU1KPBRwkZuxjjMaOhF1BhzRjSse9rw== X-Received: by 2002:a05:6000:1548:b0:20f:c4bb:defd with SMTP id 8-20020a056000154800b0020fc4bbdefdmr26953662wry.210.1653674586201; Fri, 27 May 2022 11:03:06 -0700 (PDT) Received: from localhost ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id w17-20020adff9d1000000b0020cdcb0efa2sm1784603wrr.34.2022.05.27.11.03.04 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 May 2022 11:03:05 -0700 (PDT) From: Pedro Alves To: gdb-patches@sourceware.org Subject: [PATCH 5/7] Convert location_spec_type to a method Date: Fri, 27 May 2022 19:02:46 +0100 Message-Id: <20220527180248.2990723-6-pedro@palves.net> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220527180248.2990723-1-pedro@palves.net> References: <20220527180248.2990723-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: Fri, 27 May 2022 18:03:09 -0000 This converts location_spec_type to location_spec::type(). Change-Id: Iff4cbfafb1cf3d22adfa142ff939b4a148e52273 --- gdb/breakpoint.c | 8 ++++---- gdb/linespec.c | 2 +- gdb/location.c | 18 +++++------------- gdb/location.h | 26 ++++++++++++++------------ gdb/probe.c | 2 +- 5 files changed, 25 insertions(+), 31 deletions(-) diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ea54c6c161b..9f5514d8a1b 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8453,7 +8453,7 @@ parse_breakpoint_sals (location_spec *locspec, { struct symtab_and_line cursal; - if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) + if (locspec->type () == LINESPEC_LOCATION_SPEC) { const char *spec = as_linespec_location_spec (locspec)->spec_string; @@ -8505,7 +8505,7 @@ parse_breakpoint_sals (location_spec *locspec, { const char *spec = NULL; - if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) + if (locspec->type () == LINESPEC_LOCATION_SPEC) spec = as_linespec_location_spec (locspec)->spec_string; if (!cursal.symtab @@ -8768,7 +8768,7 @@ breakpoint_ops_for_location_spec (const location_spec *locspec, { if (locspec != nullptr) return (breakpoint_ops_for_location_spec_type - (location_spec_type (locspec), is_tracepoint)); + (locspec->type (), is_tracepoint)); return &code_breakpoint_ops; } @@ -11673,7 +11673,7 @@ std::vector code_breakpoint::decode_location_spec (location_spec *locspec, program_space *search_pspace) { - if (location_spec_type (locspec) == PROBE_LOCATION_SPEC) + if (locspec->type () == PROBE_LOCATION_SPEC) return bkpt_probe_decode_location_spec (this, locspec, search_pspace); return decode_location_spec_default (this, locspec, search_pspace); diff --git a/gdb/linespec.c b/gdb/linespec.c index f992477b1d6..976e728a301 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -3062,7 +3062,7 @@ location_spec_to_sals (linespec_parser *parser, { std::vector result; - switch (location_spec_type (locspec)) + switch (locspec->type ()) { case LINESPEC_LOCATION_SPEC: { diff --git a/gdb/location.c b/gdb/location.c index ae056f35296..9643ea857a3 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -206,14 +206,6 @@ explicit_location_spec::compute_string () const /* See description in location.h. */ -enum location_spec_type -location_spec_type (const location_spec *locspec) -{ - return locspec->type; -} - -/* See description in location.h. */ - location_spec_up new_linespec_location_spec (const char **linespec, symbol_name_match_type match_type) @@ -227,7 +219,7 @@ new_linespec_location_spec (const char **linespec, const linespec_location_spec * as_linespec_location_spec (const location_spec *locspec) { - gdb_assert (locspec->type == LINESPEC_LOCATION_SPEC); + gdb_assert (locspec->type () == LINESPEC_LOCATION_SPEC); return static_cast (locspec); } @@ -246,7 +238,7 @@ new_address_location_spec (CORE_ADDR addr, const char *addr_string, const address_location_spec * as_address_location_spec (const location_spec *locspec) { - gdb_assert (locspec->type == ADDRESS_LOCATION_SPEC); + gdb_assert (locspec->type () == ADDRESS_LOCATION_SPEC); return static_cast (locspec); } @@ -263,7 +255,7 @@ new_probe_location_spec (std::string &&probe) const probe_location_spec * as_probe_location_spec (const location_spec *locspec) { - gdb_assert (locspec->type == PROBE_LOCATION_SPEC); + gdb_assert (locspec->type () == PROBE_LOCATION_SPEC); return static_cast (locspec); } @@ -272,7 +264,7 @@ as_probe_location_spec (const location_spec *locspec) const explicit_location_spec * as_explicit_location_spec (const location_spec *locspec) { - gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC); + gdb_assert (locspec->type () == EXPLICIT_LOCATION_SPEC); return static_cast (locspec); } @@ -281,7 +273,7 @@ as_explicit_location_spec (const location_spec *locspec) explicit_location_spec * as_explicit_location_spec (location_spec *locspec) { - gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC); + gdb_assert (locspec->type () == EXPLICIT_LOCATION_SPEC); return static_cast (locspec); } diff --git a/gdb/location.h b/gdb/location.h index 2b825ef0cb0..9783daadac6 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -93,8 +93,11 @@ struct location_spec return as_string.c_str (); } - /* The type of this location specification. */ - enum location_spec_type type; + /* Return this location spec's type. */ + enum location_spec_type type () const + { + return m_type; + } /* Cached string representation of this location spec. This is used, e.g., to save location specs to file. */ @@ -103,25 +106,29 @@ struct location_spec protected: explicit location_spec (enum location_spec_type t) - : type (t) + : m_type (t) { } location_spec (enum location_spec_type t, std::string &&str) - : type (t), - as_string (std::move (str)) + : as_string (std::move (str)), + m_type (t) { } location_spec (const location_spec &other) - : type (other.type), - as_string (other.as_string) + : as_string (other.as_string), + m_type (other.m_type) { } /* Compute the string representation of this object. This is called by to_string when needed. */ virtual std::string compute_string () const = 0; + +private: + /* The type of this location specification. */ + enum location_spec_type m_type; }; /* A "normal" linespec. */ @@ -226,11 +233,6 @@ struct probe_location_spec : public location_spec std::string compute_string () const override; }; -/* Return the type of the given location spec. */ - -extern enum location_spec_type - location_spec_type (const location_spec *); - /* Return a string representation of LOCSPEC. This function may return NULL for unspecified linespecs, e.g, LINESPEC_LOCATION_SPEC and spec_string is NULL. diff --git a/gdb/probe.c b/gdb/probe.c index 5371b7eca46..ad7af77f722 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -122,7 +122,7 @@ parse_probes (const location_spec *locspec, char *objfile_namestr = NULL, *provider = NULL, *name, *p; const char *arg_start, *cs; - gdb_assert (location_spec_type (locspec) == PROBE_LOCATION_SPEC); + gdb_assert (locspec->type () == PROBE_LOCATION_SPEC); arg_start = locspec->to_string (); cs = arg_start; -- 2.36.0