From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 968633858002; Fri, 17 Jun 2022 09:23:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 968633858002 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Pedro Alves To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Convert location_spec_type to a method X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: 238dc9af03392ecd8129ee54a340efd736782cf9 X-Git-Newrev: 7464aeaab47ca3fb7127223fe372489c9c7ed69e Message-Id: <20220617092335.968633858002@sourceware.org> Date: Fri, 17 Jun 2022 09:23:35 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2022 09:23:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7464aeaab47c= a3fb7127223fe372489c9c7ed69e commit 7464aeaab47ca3fb7127223fe372489c9c7ed69e Author: Pedro Alves Date: Fri May 27 16:33:56 2022 +0100 Convert location_spec_type to a method =20 This converts location_spec_type to location_spec::type(). =20 Change-Id: Iff4cbfafb1cf3d22adfa142ff939b4a148e52273 Diff: --- 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 bfa9e68fdbe..e3739a772de 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -8453,7 +8453,7 @@ parse_breakpoint_sals (location_spec *locspec, { struct symtab_and_line cursal; =20 - if (location_spec_type (locspec) =3D=3D LINESPEC_LOCATION_SPEC) + if (locspec->type () =3D=3D LINESPEC_LOCATION_SPEC) { const char *spec =3D as_linespec_location_spec (locspec)->spec_strin= g; =20 @@ -8505,7 +8505,7 @@ parse_breakpoint_sals (location_spec *locspec, { const char *spec =3D NULL; =20 - if (location_spec_type (locspec) =3D=3D LINESPEC_LOCATION_SPEC) + if (locspec->type () =3D=3D LINESPEC_LOCATION_SPEC) spec =3D as_linespec_location_spec (locspec)->spec_string; =20 if (!cursal.symtab @@ -8768,7 +8768,7 @@ breakpoint_ops_for_location_spec (const location_spec= *locspec, { if (locspec !=3D nullptr) return (breakpoint_ops_for_location_spec_type - (location_spec_type (locspec), is_tracepoint)); + (locspec->type (), is_tracepoint)); return &code_breakpoint_ops; } =20 @@ -11673,7 +11673,7 @@ std::vector code_breakpoint::decode_location_spec (location_spec *locspec, program_space *search_pspace) { - if (location_spec_type (locspec) =3D=3D PROBE_LOCATION_SPEC) + if (locspec->type () =3D=3D PROBE_LOCATION_SPEC) return bkpt_probe_decode_location_spec (this, locspec, search_pspace); =20 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; =20 - 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 =20 /* See description in location.h. */ =20 -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 =3D=3D LINESPEC_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D LINESPEC_LOCATION_SPEC); return static_cast (locspec); } =20 @@ -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 =3D=3D ADDRESS_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D ADDRESS_LOCATION_SPEC); return static_cast (locspec); } =20 @@ -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 =3D=3D PROBE_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D PROBE_LOCATION_SPEC); return static_cast (locspec); } =20 @@ -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 =3D=3D EXPLICIT_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D EXPLICIT_LOCATION_SPEC); return static_cast (locspec); } =20 @@ -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 =3D=3D EXPLICIT_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D EXPLICIT_LOCATION_SPEC); return static_cast (locspec); } =20 diff --git a/gdb/location.h b/gdb/location.h index f3b63320c2e..9ba3a20731b 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -93,8 +93,11 @@ struct location_spec return as_string.c_str (); } =20 - /* 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; + } =20 /* 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: =20 explicit location_spec (enum location_spec_type t) - : type (t) + : m_type (t) { } =20 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) { } =20 location_spec (const location_spec &other) - : type (other.type), - as_string (other.as_string) + : as_string (other.as_string), + m_type (other.m_type) { } =20 /* Compute the string representation of this object. This is called by to_string when needed. */ virtual std::string compute_string () const =3D 0; + +private: + /* The type of this location specification. */ + enum location_spec_type m_type; }; =20 /* A "normal" linespec. */ @@ -226,11 +233,6 @@ protected: std::string compute_string () const override; }; =20 -/* 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 =3D NULL, *provider =3D NULL, *name, *p; const char *arg_start, *cs; =20 - gdb_assert (location_spec_type (locspec) =3D=3D PROBE_LOCATION_SPEC); + gdb_assert (locspec->type () =3D=3D PROBE_LOCATION_SPEC); arg_start =3D locspec->to_string (); =20 cs =3D arg_start;