From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1551) id 4F0BB3858292; Fri, 17 Jun 2022 09:23:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F0BB3858292 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] event_location -> location_spec X-Act-Checkin: binutils-gdb X-Git-Author: Pedro Alves X-Git-Refname: refs/heads/master X-Git-Oldrev: 14e283ff4e0656327179a5b69954796af3807b66 X-Git-Newrev: 264f98902f27497f7494933628b0f5c4e117fe59 Message-Id: <20220617092315.4F0BB3858292@sourceware.org> Date: Fri, 17 Jun 2022 09:23:15 +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:15 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D264f98902f27= 497f7494933628b0f5c4e117fe59 commit 264f98902f27497f7494933628b0f5c4e117fe59 Author: Pedro Alves Date: Mon May 23 20:15:18 2022 +0100 event_location -> location_spec =20 Currently, GDB internally uses the term "location" for both the location specification the user input (linespec, explicit location, or an address location), and for actual resolved locations, like the breakpoint locations, or the result of decoding a location spec to SaLs. This is expecially confusing in the breakpoints module, as struct breakpoint has these two fields: =20 breakpoint::location; breakpoint::loc; =20 "location" is the location spec, and "loc" is the resolved locations. =20 And then, we have a method called "locations()", which returns the resolved locations as range... =20 The location spec type is presently called event_location: =20 /* Location we used to set the breakpoint. */ event_location_up location; =20 and it is described like this: =20 /* The base class for all an event locations used to set a stop event in the inferior. */ =20 struct event_location { =20 and even that is incorrect... Location specs are used for finding actual locations in the program in scenarios that have nothing to do with stop events. E.g., "list" works with location specs. =20 To clean all this confusion up, this patch renames "event_location" to "location_spec" throughout, and then all the variables that hold a location spec, they are renamed to include "spec" in their name, like e.g., "location" -> "locspec". Similarly, functions that work with location specs, and currently have just "location" in their name are renamed to include "spec" in their name too. =20 Change-Id: I5814124798aa2b2003e79496e78f95c74e5eddca Diff: --- gdb/ada-lang.c | 4 +- gdb/ax-gdb.c | 6 +- gdb/break-catch-throw.c | 10 +- gdb/breakpoint.c | 348 ++++++++++++++++++++---------------= ---- gdb/breakpoint.h | 62 +++---- gdb/cli/cli-cmds.c | 32 ++-- gdb/completer.c | 40 ++--- gdb/elfread.c | 4 +- gdb/guile/scm-breakpoint.c | 22 +-- gdb/linespec.c | 72 ++++---- gdb/linespec.h | 12 +- gdb/location.c | 329 ++++++++++++++++++------------------ gdb/location.h | 183 ++++++++++---------- gdb/mi/mi-cmd-break.c | 12 +- gdb/probe.c | 8 +- gdb/probe.h | 4 +- gdb/python/py-breakpoint.c | 20 +-- gdb/python/py-finishbreakpoint.c | 6 +- gdb/python/python.c | 10 +- gdb/remote.c | 6 +- gdb/tracepoint.c | 6 +- 21 files changed, 605 insertions(+), 591 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6ab01fd27d4..93e0c67613f 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12144,8 +12144,8 @@ struct ada_catchpoint : public code_breakpoint =20 enable_state =3D enabled ? bp_enabled : bp_disabled; disposition =3D tempflag ? disp_del : disp_donttouch; - location =3D string_to_event_location (&addr_string_, - language_def (language_ada)); + locspec =3D string_to_location_spec (&addr_string_, + language_def (language_ada)); language =3D language_ada; } =20 diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index f8ea8adc626..1fccfde559e 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -2526,9 +2526,9 @@ maint_agent_command_1 (const char *exp, int eval) { struct linespec_result canonical; =20 - event_location_up location - =3D new_linespec_location (&exp, symbol_name_match_type::WILD); - decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, + location_spec_up locspec + =3D new_linespec_location_spec (&exp, symbol_name_match_type::WILD); + decode_line_full (locspec.get (), DECODE_LINE_FUNFIRSTLINE, NULL, NULL, 0, &canonical, NULL, NULL); exp =3D skip_spaces (exp); diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 66cf80be1c5..3ef4b972d4f 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -215,9 +215,9 @@ exception_catchpoint::re_set () /* We first try to use the probe interface. */ try { - event_location_up location - =3D new_probe_location (exception_functions[kind].probe); - sals =3D parse_probes (location.get (), filter_pspace, NULL); + location_spec_up locspec + =3D new_probe_location_spec (exception_functions[kind].probe); + sals =3D parse_probes (locspec.get (), filter_pspace, NULL); } catch (const gdb_exception_error &e) { @@ -230,8 +230,8 @@ exception_catchpoint::re_set () initialize_explicit_location (&explicit_loc); explicit_loc.function_name =3D ASTRDUP (exception_functions[kind].function); - event_location_up location =3D new_explicit_location (&explicit_loc); - sals =3D this->decode_location (location.get (), filter_pspace); + location_spec_up locspec =3D new_explicit_location_spec (&explicit_loc); + sals =3D this->decode_location_spec (locspec.get (), filter_pspace); } catch (const gdb_exception_error &ex) { diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index ed932a19ed7..ab88a38e0a3 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -90,8 +90,8 @@ static void map_breakpoint_numbers (const char *, static void breakpoint_re_set_default (code_breakpoint *); =20 static void - create_sals_from_location_default (struct event_location *location, - struct linespec_result *canonical); + create_sals_from_location_spec_default (location_spec *locspec, + linespec_result *canonical); =20 static void create_breakpoints_sal (struct gdbarch *, struct linespec_result *, @@ -102,8 +102,8 @@ static void create_breakpoints_sal (struct gdbarch *, int, int, int, int, unsigned); =20 -static std::vector decode_location_default - (struct breakpoint *b, struct event_location *location, +static std::vector decode_location_spec_default + (struct breakpoint *b, struct location_spec *locspec, struct program_space *search_pspace); =20 static int can_use_hardware_watchpoint @@ -159,9 +159,9 @@ static void enable_breakpoint_disp (struct breakpoint *= , enum bpdisp, =20 static void decref_bp_location (struct bp_location **loc); =20 -static std::vector bkpt_probe_decode_location +static std::vector bkpt_probe_decode_location_spec (struct breakpoint *b, - struct event_location *location, + location_spec *locspec, struct program_space *search_pspace); =20 static bool bl_address_is_meaningful (bp_location *loc); @@ -218,30 +218,30 @@ static bool is_masked_watchpoint (const struct breakp= oint *b); =20 static int strace_marker_p (struct breakpoint *b); =20 -static void bkpt_probe_create_sals_from_location - (struct event_location *location, +static void bkpt_probe_create_sals_from_location_spec + (location_spec *locspec, struct linespec_result *canonical); -static void tracepoint_probe_create_sals_from_location - (struct event_location *location, +static void tracepoint_probe_create_sals_from_location_spec + (location_spec *locspec, struct linespec_result *canonical); =20 const struct breakpoint_ops code_breakpoint_ops =3D { - create_sals_from_location_default, + create_sals_from_location_spec_default, create_breakpoints_sal, }; =20 /* Breakpoints set on probes. */ static const struct breakpoint_ops bkpt_probe_breakpoint_ops =3D { - bkpt_probe_create_sals_from_location, + bkpt_probe_create_sals_from_location_spec, create_breakpoints_sal, }; =20 /* Tracepoints set on probes. */ static const struct breakpoint_ops tracepoint_probe_breakpoint_ops =3D { - tracepoint_probe_create_sals_from_location, + tracepoint_probe_create_sals_from_location_spec, create_breakpoints_sal, }; =20 @@ -351,8 +351,8 @@ struct ranged_breakpoint : public ordinary_breakpoint explicit ranged_breakpoint (struct gdbarch *gdbarch, const symtab_and_line &sal_start, int length, - event_location_up start_location, - event_location_up end_location) + location_spec_up start_locspec, + location_spec_up end_locspec) : ordinary_breakpoint (gdbarch, bp_hardware_breakpoint) { bp_location *bl =3D add_location (sal_start); @@ -360,8 +360,8 @@ struct ranged_breakpoint : public ordinary_breakpoint =20 disposition =3D disp_donttouch; =20 - location =3D std::move (start_location); - location_range_end =3D std::move (end_location); + locspec =3D std::move (start_locspec); + locspec_range_end =3D std::move (end_locspec); } =20 int breakpoint_hit (const struct bp_location *bl, @@ -381,8 +381,8 @@ struct static_marker_tracepoint : public tracepoint { using tracepoint::tracepoint; =20 - std::vector decode_location - (struct event_location *location, + std::vector decode_location_spec + (struct location_spec *locspec, struct program_space *search_pspace) override; }; =20 @@ -3390,7 +3390,7 @@ create_overlay_event_breakpoint (void) bp_overlay_event); initialize_explicit_location (&explicit_loc); explicit_loc.function_name =3D ASTRDUP (func_name); - b->location =3D new_explicit_location (&explicit_loc); + b->locspec =3D new_explicit_location_spec (&explicit_loc); =20 if (overlay_debugging =3D=3D ovly_auto) { @@ -3447,7 +3447,7 @@ create_longjmp_master_breakpoint_probe (objfile *objf= ile) b =3D create_internal_breakpoint (gdbarch, p->get_relocated_address (objfile), bp_longjmp_master); - b->location =3D new_probe_location ("-probe-stap libc:longjmp"); + b->locspec =3D new_probe_location_spec ("-probe-stap libc:longjmp"); b->enable_state =3D bp_disabled; } =20 @@ -3497,7 +3497,7 @@ create_longjmp_master_breakpoint_names (objfile *objf= ile) b =3D create_internal_breakpoint (gdbarch, addr, bp_longjmp_master); initialize_explicit_location (&explicit_loc); explicit_loc.function_name =3D ASTRDUP (func_name); - b->location =3D new_explicit_location (&explicit_loc); + b->locspec =3D new_explicit_location_spec (&explicit_loc); b->enable_state =3D bp_disabled; installed_bp++; } @@ -3580,7 +3580,7 @@ create_std_terminate_master_breakpoint (void) bp_std_terminate_master); initialize_explicit_location (&explicit_loc); explicit_loc.function_name =3D ASTRDUP (func_name); - b->location =3D new_explicit_location (&explicit_loc); + b->locspec =3D new_explicit_location_spec (&explicit_loc); b->enable_state =3D bp_disabled; } } @@ -3630,7 +3630,7 @@ create_exception_master_breakpoint_probe (objfile *ob= jfile) b =3D create_internal_breakpoint (gdbarch, p->get_relocated_address (objfile), bp_exception_master); - b->location =3D new_probe_location ("-probe-stap libgcc:unwind"); + b->locspec =3D new_probe_location_spec ("-probe-stap libgcc:unwind"); b->enable_state =3D bp_disabled; } =20 @@ -3677,7 +3677,7 @@ create_exception_master_breakpoint_hook (objfile *obj= file) b =3D create_internal_breakpoint (gdbarch, addr, bp_exception_master); initialize_explicit_location (&explicit_loc); explicit_loc.function_name =3D ASTRDUP (func_name); - b->location =3D new_explicit_location (&explicit_loc); + b->locspec =3D new_explicit_location_spec (&explicit_loc); b->enable_state =3D bp_disabled; =20 return true; @@ -3709,9 +3709,10 @@ create_exception_master_breakpoint (void) /* Does B have a location spec? */ =20 static int -breakpoint_event_location_empty_p (const struct breakpoint *b) +breakpoint_location_spec_empty_p (const struct breakpoint *b) { - return b->location !=3D NULL && event_location_empty_p (b->location.get = ()); + return (b->locspec !=3D nullptr + && location_spec_empty_p (b->locspec.get ())); } =20 void @@ -3825,7 +3826,7 @@ update_breakpoints_after_exec (void) /* Without a symbolic address, we have little hope of the pre-exec() address meaning the same thing in the post-exec() a.out. */ - if (breakpoint_event_location_empty_p (b)) + if (breakpoint_location_spec_empty_p (b)) { delete_breakpoint (b); continue; @@ -6019,7 +6020,8 @@ print_breakpoint_location (const breakpoint *b, set_current_program_space (loc->pspace); =20 if (b->display_canonical) - uiout->field_string ("what", event_location_to_string (b->location.get= ())); + uiout->field_string ("what", + location_spec_to_string (b->locspec.get ())); else if (loc && loc->symtab) { const struct symbol *sym =3D loc->symbol; @@ -6054,7 +6056,7 @@ print_breakpoint_location (const breakpoint *b, else { uiout->field_string ("pending", - event_location_to_string (b->location.get ())); + location_spec_to_string (b->locspec.get ())); /* If extra_string is available, it could be holding a condition or dprintf arguments. In either case, make sure it is printed, too, but only for non-MI streams. */ @@ -6514,10 +6516,12 @@ print_one_breakpoint_location (struct breakpoint *b, =20 uiout->field_string ("original-location", w->exp_string.get ()); } - else if (b->location !=3D NULL - && event_location_to_string (b->location.get ()) !=3D NULL) - uiout->field_string ("original-location", - event_location_to_string (b->location.get ())); + else if (b->locspec !=3D nullptr) + { + const char *str =3D location_spec_to_string (b->locspec.get ()); + if (str !=3D nullptr) + uiout->field_string ("original-location", str); + } } =20 return result; @@ -7534,8 +7538,8 @@ create_thread_event_breakpoint (struct gdbarch *gdbar= ch, CORE_ADDR address) b =3D create_internal_breakpoint (gdbarch, address, bp_thread_event); =20 b->enable_state =3D bp_enabled; - /* location has to be used or breakpoint_re_set will delete me. */ - b->location =3D new_address_location (b->loc->address, NULL, 0); + /* locspec has to be used or breakpoint_re_set will delete me. */ + b->locspec =3D new_address_location_spec (b->loc->address, NULL, 0); =20 update_global_location_list_nothrow (UGLL_MAY_INSERT); =20 @@ -8243,7 +8247,7 @@ update_dprintf_commands (const char *args, int from_t= ty, code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, enum bptype type_, gdb::array_view sals, - event_location_up &&location_, + location_spec_up &&locspec_, gdb::unique_xmalloc_ptr filter_, gdb::unique_xmalloc_ptr cond_string_, gdb::unique_xmalloc_ptr extra_string_, @@ -8291,7 +8295,7 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdb= arch_, { /* We already know the marker exists, otherwise, we wouldn't see a sal for it. */ - const char *p =3D &event_location_to_string (location_.get ())[3]; + const char *p =3D &location_spec_to_string (locspec_.get ())[3]; const char *endp; =20 p =3D skip_spaces (p); @@ -8360,17 +8364,17 @@ code_breakpoint::code_breakpoint (struct gdbarch *g= dbarch_, } =20 display_canonical =3D display_canonical_; - if (location_ !=3D nullptr) - location =3D std::move (location_); + if (locspec_ !=3D nullptr) + locspec =3D std::move (locspec_); else - location =3D new_address_location (this->loc->address, NULL, 0); + locspec =3D new_address_location_spec (this->loc->address, NULL, 0); filter =3D std::move (filter_); } =20 static void create_breakpoint_sal (struct gdbarch *gdbarch, gdb::array_view sals, - event_location_up &&location, + location_spec_up &&locspec, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, gdb::unique_xmalloc_ptr extra_string, @@ -8384,7 +8388,7 @@ create_breakpoint_sal (struct gdbarch *gdbarch, =3D new_breakpoint_from_type (gdbarch, type, sals, - std::move (location), + std::move (locspec), std::move (filter), std::move (cond_string), std::move (extra_string), @@ -8429,14 +8433,14 @@ create_breakpoints_sal (struct gdbarch *gdbarch, { /* Note that 'location' can be NULL in the case of a plain 'break', without arguments. */ - event_location_up location - =3D (canonical->location !=3D NULL - ? copy_event_location (canonical->location.get ()) : NULL); + location_spec_up locspec + =3D (canonical->locspec !=3D NULL + ? copy_location_spec (canonical->locspec.get ()) : NULL); gdb::unique_xmalloc_ptr filter_string (lsal.canonical !=3D NULL ? xstrdup (lsal.canonical) : NULL); =20 create_breakpoint_sal (gdbarch, lsal.sals, - std::move (location), + std::move (locspec), std::move (filter_string), std::move (cond_string), std::move (extra_string), @@ -8447,23 +8451,23 @@ create_breakpoints_sal (struct gdbarch *gdbarch, } } =20 -/* Parse LOCATION which is assumed to be a SAL specification possibly +/* Parse LOCSPEC which is assumed to be a SAL specification possibly followed by conditionals. On return, SALS contains an array of SAL - addresses found. LOCATION points to the end of the SAL (for - linespec locations). + addresses found. LOCSPEC points to the end of the SAL (for + linespec locspecs). =20 The array and the line spec strings are allocated on the heap, it is the caller's responsibility to free them. */ =20 static void -parse_breakpoint_sals (struct event_location *location, +parse_breakpoint_sals (location_spec *locspec, struct linespec_result *canonical) { struct symtab_and_line cursal; =20 - if (event_location_type (location) =3D=3D LINESPEC_LOCATION) + if (location_spec_type (locspec) =3D=3D LINESPEC_LOCATION_SPEC) { - const char *spec =3D get_linespec_location (location)->spec_string; + const char *spec =3D get_linespec_location (locspec)->spec_string; =20 if (spec =3D=3D NULL) { @@ -8513,15 +8517,15 @@ parse_breakpoint_sals (struct event_location *locat= ion, { const char *spec =3D NULL; =20 - if (event_location_type (location) =3D=3D LINESPEC_LOCATION) - spec =3D get_linespec_location (location)->spec_string; + if (location_spec_type (locspec) =3D=3D LINESPEC_LOCATION_SPEC) + spec =3D get_linespec_location (locspec)->spec_string; =20 if (!cursal.symtab || (spec !=3D NULL && strchr ("+-", spec[0]) !=3D NULL && spec[1] !=3D '[')) { - decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL, + decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, NULL, get_last_displayed_symtab (), get_last_displayed_line (), canonical, NULL, NULL); @@ -8529,7 +8533,7 @@ parse_breakpoint_sals (struct event_location *locatio= n, } } =20 - decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL, + decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, NULL, cursal.symtab, cursal.line, canonical, NULL, NULL); } =20 @@ -8749,19 +8753,19 @@ decode_static_tracepoint_spec (const char **arg_p) according to IS_TRACEPOINT. */ =20 static const struct breakpoint_ops * -breakpoint_ops_for_event_location_type (enum event_location_type location_= type, - bool is_tracepoint) +breakpoint_ops_for_location_spec_type (enum location_spec_type locspec_typ= e, + bool is_tracepoint) { if (is_tracepoint) { - if (location_type =3D=3D PROBE_LOCATION) + if (locspec_type =3D=3D PROBE_LOCATION_SPEC) return &tracepoint_probe_breakpoint_ops; else return &code_breakpoint_ops; } else { - if (location_type =3D=3D PROBE_LOCATION) + if (locspec_type =3D=3D PROBE_LOCATION_SPEC) return &bkpt_probe_breakpoint_ops; else return &code_breakpoint_ops; @@ -8771,12 +8775,12 @@ breakpoint_ops_for_event_location_type (enum event_= location_type location_type, /* See breakpoint.h. */ =20 const struct breakpoint_ops * -breakpoint_ops_for_event_location (const struct event_location *location, - bool is_tracepoint) +breakpoint_ops_for_location_spec (const location_spec *locspec, + bool is_tracepoint) { - if (location !=3D nullptr) - return breakpoint_ops_for_event_location_type - (event_location_type (location), is_tracepoint); + if (locspec !=3D nullptr) + return (breakpoint_ops_for_location_spec_type + (location_spec_type (locspec), is_tracepoint)); return &code_breakpoint_ops; } =20 @@ -8784,7 +8788,7 @@ breakpoint_ops_for_event_location (const struct event= _location *location, =20 int create_breakpoint (struct gdbarch *gdbarch, - struct event_location *location, + location_spec *locspec, const char *cond_string, int thread, const char *extra_string, bool force_condition, int parse_extra, @@ -8808,7 +8812,7 @@ create_breakpoint (struct gdbarch *gdbarch, =20 try { - ops->create_sals_from_location (location, &canonical); + ops->create_sals_from_location_spec (locspec, &canonical); } catch (const gdb_exception_error &e) { @@ -8932,7 +8936,7 @@ create_breakpoint (struct gdbarch *gdbarch, { std::unique_ptr b =3D new_breakpoint_from_type (gdbarch, type_wanted); - b->location =3D copy_event_location (location); + b->locspec =3D copy_location_spec (locspec); =20 if (parse_extra) b->cond_string =3D NULL; @@ -8987,12 +8991,13 @@ break_command_1 (const char *arg, int flag, int fro= m_tty) ? bp_hardware_breakpoint : bp_breakpoint); =20 - event_location_up location =3D string_to_event_location (&arg, current_l= anguage); - const struct breakpoint_ops *ops =3D breakpoint_ops_for_event_location - (location.get (), false /* is_tracepoint */); + location_spec_up locspec =3D string_to_location_spec (&arg, current_lang= uage); + const struct breakpoint_ops *ops + =3D breakpoint_ops_for_location_spec (locspec.get (), + false /* is_tracepoint */); =20 create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), NULL, 0, arg, false, 1 /* parse arg */, tempflag, type_wanted, 0 /* Ignore count */, @@ -9091,7 +9096,7 @@ thbreak_command (const char *arg, int from_tty) static void dprintf_command (const char *arg, int from_tty) { - event_location_up location =3D string_to_event_location (&arg, current_l= anguage); + location_spec_up locspec =3D string_to_location_spec (&arg, current_lang= uage); =20 /* If non-NULL, ARG should have been advanced past the location; the next character must be ','. */ @@ -9107,7 +9112,7 @@ dprintf_command (const char *arg, int from_tty) } =20 create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), NULL, 0, arg, false, 1 /* parse arg */, 0, bp_dprintf, 0 /* Ignore count */, @@ -9251,8 +9256,8 @@ void ranged_breakpoint::print_recreate (struct ui_file *fp) const { gdb_printf (fp, "break-range %s, %s", - event_location_to_string (location.get ()), - event_location_to_string (location_range_end.get ())); + location_spec_to_string (locspec.get ()), + location_spec_to_string (locspec_range_end.get ())); print_recreate_thread (fp); } =20 @@ -9312,9 +9317,9 @@ break_range_command (const char *arg, int from_tty) error(_("No address range specified.")); =20 arg_start =3D arg; - event_location_up start_location =3D string_to_event_location (&arg, - current_language); - parse_breakpoint_sals (start_location.get (), &canonical_start); + location_spec_up start_locspec + =3D string_to_location_spec (&arg, current_language); + parse_breakpoint_sals (start_locspec.get (), &canonical_start); =20 if (arg[0] !=3D ',') error (_("Too few arguments.")); @@ -9333,18 +9338,19 @@ break_range_command (const char *arg, int from_tty) arg++; /* Skip the comma. */ arg =3D skip_spaces (arg); =20 - /* Parse the end location. */ + /* Parse the end location specification. */ =20 arg_start =3D arg; =20 /* We call decode_line_full directly here instead of using - parse_breakpoint_sals because we need to specify the start location's - symtab and line as the default symtab and line for the end of the - range. This makes it possible to have ranges like "foo.c:27, +14", - where +14 means 14 lines from the start location. */ - event_location_up end_location =3D string_to_event_location (&arg, - current_language); - decode_line_full (end_location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, + parse_breakpoint_sals because we need to specify the start + location spec's symtab and line as the default symtab and line + for the end of the range. This makes it possible to have ranges + like "foo.c:27, +14", where +14 means 14 lines from the start + location spec. */ + location_spec_up end_locspec + =3D string_to_location_spec (&arg, current_language); + decode_line_full (end_locspec.get (), DECODE_LINE_FUNFIRSTLINE, NULL, sal_start.symtab, sal_start.line, &canonical_end, NULL, NULL); =20 @@ -9380,8 +9386,8 @@ break_range_command (const char *arg, int from_tty) std::unique_ptr br (new ranged_breakpoint (get_current_arch (), sal_start, length, - std::move (start_location), - std::move (end_location))); + std::move (start_locspec), + std::move (end_locspec))); =20 install_breakpoint (false, std::move (br), true); } @@ -10447,14 +10453,14 @@ until_break_command (const char *arg, int from_tt= y, int anywhere) /* Set a breakpoint where the user wants it and at return from this function. */ =20 - event_location_up location =3D string_to_event_location (&arg, current_l= anguage); + location_spec_up locspec =3D string_to_location_spec (&arg, current_lang= uage); =20 std::vector sals =3D (last_displayed_sal_is_valid () - ? decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, + ? decode_line_1 (locspec.get (), DECODE_LINE_FUNFIRSTLINE, NULL, get_last_displayed_symtab (), get_last_displayed_line ()) - : decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, + : decode_line_1 (locspec.get (), DECODE_LINE_FUNFIRSTLINE, NULL, NULL, 0)); =20 if (sals.empty ()) @@ -11360,18 +11366,18 @@ say_where (const breakpoint *b) if (b->extra_string =3D=3D NULL) { gdb_printf (_(" (%s) pending."), - event_location_to_string (b->location.get ())); + location_spec_to_string (b->locspec.get ())); } else if (b->type =3D=3D bp_dprintf) { gdb_printf (_(" (%s,%s) pending."), - event_location_to_string (b->location.get ()), + location_spec_to_string (b->locspec.get ()), b->extra_string.get ()); } else { gdb_printf (_(" (%s %s) pending."), - event_location_to_string (b->location.get ()), + location_spec_to_string (b->locspec.get ()), b->extra_string.get ()); } } @@ -11400,7 +11406,7 @@ say_where (const breakpoint *b) different file name, and this at least reflects the real situation somewhat. */ gdb_printf (": %s.", - event_location_to_string (b->location.get ())); + location_spec_to_string (b->locspec.get ())); } =20 if (b->loc->next) @@ -11477,8 +11483,8 @@ breakpoint::print_recreate (struct ui_file *fp) con= st } =20 std::vector -breakpoint::decode_location (struct event_location *location, - struct program_space *search_pspace) +breakpoint::decode_location_spec (location_spec *locspec, + program_space *search_pspace) { internal_error_pure_virtual_called (); } @@ -11489,7 +11495,7 @@ void code_breakpoint::re_set () { /* FIXME: is this still reachable? */ - if (breakpoint_event_location_empty_p (this)) + if (breakpoint_location_spec_empty_p (this)) { /* Anything without a location can't be re-set. */ delete_breakpoint (this); @@ -11665,7 +11671,7 @@ ordinary_breakpoint::print_recreate (struct ui_file= *fp) const internal_error (__FILE__, __LINE__, _("unhandled breakpoint type %d"), (int) type); =20 - gdb_printf (fp, " %s", event_location_to_string (location.get ())); + gdb_printf (fp, " %s", location_spec_to_string (locspec.get ())); =20 /* Print out extra_string if this breakpoint is pending. It might contain, for example, conditions that were set by the user. */ @@ -11676,13 +11682,13 @@ ordinary_breakpoint::print_recreate (struct ui_fi= le *fp) const } =20 std::vector -code_breakpoint::decode_location (struct event_location *location, - struct program_space *search_pspace) +code_breakpoint::decode_location_spec (location_spec *locspec, + program_space *search_pspace) { - if (event_location_type (location) =3D=3D PROBE_LOCATION) - return bkpt_probe_decode_location (this, location, search_pspace); + if (location_spec_type (locspec) =3D=3D PROBE_LOCATION_SPEC) + return bkpt_probe_decode_location_spec (this, locspec, search_pspace); =20 - return decode_location_default (this, location, search_pspace); + return decode_location_spec_default (this, locspec, search_pspace); } =20 /* Virtual table for internal breakpoints. */ @@ -11821,24 +11827,25 @@ longjmp_breakpoint::~longjmp_breakpoint () } =20 static void -bkpt_probe_create_sals_from_location (struct event_location *location, - struct linespec_result *canonical) +bkpt_probe_create_sals_from_location_spec (location_spec *locspec, + struct linespec_result *canonical) =20 { struct linespec_sals lsal; =20 - lsal.sals =3D parse_probes (location, NULL, canonical); + lsal.sals =3D parse_probes (locspec, NULL, canonical); lsal.canonical - =3D xstrdup (event_location_to_string (canonical->location.get ())); + =3D xstrdup (location_spec_to_string (canonical->locspec.get ())); canonical->lsals.push_back (std::move (lsal)); } =20 static std::vector -bkpt_probe_decode_location (struct breakpoint *b, - struct event_location *location, - struct program_space *search_pspace) +bkpt_probe_decode_location_spec (struct breakpoint *b, + location_spec *locspec, + program_space *search_pspace) { - std::vector sals =3D parse_probes (location, search_psp= ace, NULL); + std::vector sals + =3D parse_probes (locspec, search_pspace, NULL); if (sals.empty ()) error (_("probe not found")); return sals; @@ -11911,7 +11918,7 @@ tracepoint::print_recreate (struct ui_file *fp) con= st internal_error (__FILE__, __LINE__, _("unhandled tracepoint type %d"), (int) type); =20 - gdb_printf (fp, " %s", event_location_to_string (location.get ())); + gdb_printf (fp, " %s", location_spec_to_string (locspec.get ())); print_recreate_thread (fp); =20 if (pass_count) @@ -11921,12 +11928,12 @@ tracepoint::print_recreate (struct ui_file *fp) c= onst /* Virtual table for tracepoints on static probes. */ =20 static void -tracepoint_probe_create_sals_from_location - (struct event_location *location, +tracepoint_probe_create_sals_from_location_spec + (location_spec *locspec, struct linespec_result *canonical) { /* We use the same method for breakpoint on probes. */ - bkpt_probe_create_sals_from_location (location, canonical); + bkpt_probe_create_sals_from_location_spec (locspec, canonical); } =20 void @@ -11957,7 +11964,7 @@ void dprintf_breakpoint::print_recreate (struct ui_file *fp) const { gdb_printf (fp, "dprintf %s,%s", - event_location_to_string (location.get ()), + location_spec_to_string (locspec.get ()), extra_string.get ()); print_recreate_thread (fp); } @@ -11992,22 +11999,22 @@ dprintf_breakpoint::after_condition_true (struct = bpstat *bs) markers (`-m'). */ =20 static void -strace_marker_create_sals_from_location (struct event_location *location, - struct linespec_result *canonical) +strace_marker_create_sals_from_location_spec (location_spec *locspec, + struct linespec_result *canonical) { struct linespec_sals lsal; const char *arg_start, *arg; =20 - arg =3D arg_start =3D get_linespec_location (location)->spec_string; + arg =3D arg_start =3D get_linespec_location (locspec)->spec_string; lsal.sals =3D decode_static_tracepoint_spec (&arg); =20 std::string str (arg_start, arg - arg_start); const char *ptr =3D str.c_str (); - canonical->location - =3D new_linespec_location (&ptr, symbol_name_match_type::FULL); + canonical->locspec + =3D new_linespec_location_spec (&ptr, symbol_name_match_type::FULL); =20 lsal.canonical - =3D xstrdup (event_location_to_string (canonical->location.get ())); + =3D xstrdup (location_spec_to_string (canonical->locspec.get ())); canonical->lsals.push_back (std::move (lsal)); } =20 @@ -12034,14 +12041,14 @@ strace_marker_create_breakpoints_sal (struct gdba= rch *gdbarch, =20 for (size_t i =3D 0; i < lsal.sals.size (); i++) { - event_location_up location - =3D copy_event_location (canonical->location.get ()); + location_spec_up locspec + =3D copy_location_spec (canonical->locspec.get ()); =20 std::unique_ptr tp (new tracepoint (gdbarch, type_wanted, lsal.sals[i], - std::move (location), + std::move (locspec), NULL, std::move (cond_string), std::move (extra_string), @@ -12063,10 +12070,10 @@ strace_marker_create_breakpoints_sal (struct gdba= rch *gdbarch, } =20 std::vector -static_marker_tracepoint::decode_location (struct event_location *location, - struct program_space *search_pspace) +static_marker_tracepoint::decode_location_spec (location_spec *locspec, + program_space *search_pspace) { - const char *s =3D get_linespec_location (location)->spec_string; + const char *s =3D get_linespec_location (locspec)->spec_string; =20 std::vector sals =3D decode_static_tracepoint_spec (&s); if (sals.size () > static_trace_marker_id_idx) @@ -12082,7 +12089,7 @@ static_marker_tracepoint::decode_location (struct e= vent_location *location, /* Static tracepoints with marker (`-m'). */ static struct breakpoint_ops strace_marker_breakpoint_ops =3D { - strace_marker_create_sals_from_location, + strace_marker_create_sals_from_location_spec, strace_marker_create_breakpoints_sal, }; =20 @@ -12411,13 +12418,13 @@ update_static_tracepoint (struct breakpoint *b, s= truct symtab_and_line sal) b->loc->line_number =3D sal2.line; b->loc->symtab =3D sym !=3D NULL ? sal2.symtab : NULL; =20 - b->location.reset (NULL); + b->locspec.reset (nullptr); initialize_explicit_location (&explicit_loc); explicit_loc.source_filename =3D ASTRDUP (symtab_to_filename_for_display (sal2.symtab)); explicit_loc.line_offset.offset =3D b->loc->line_number; explicit_loc.line_offset.sign =3D LINE_OFFSET_NONE; - b->location =3D new_explicit_location (&explicit_loc); + b->locspec =3D new_explicit_location_spec (&explicit_loc); =20 /* Might be nice to check if function changed, and warn if so. */ @@ -12620,12 +12627,12 @@ update_breakpoint_locations (code_breakpoint *b, gdb::observers::breakpoint_modified.notify (b); } =20 -/* Find the SaL locations corresponding to the given LOCATION. +/* Find the SaL locations corresponding to the given LOCSPEC. On return, FOUND will be 1 if any SaL was found, zero otherwise. */ =20 static std::vector -location_to_sals (struct breakpoint *b, struct event_location *location, - struct program_space *search_pspace, int *found) +location_spec_to_sals (struct breakpoint *b, location_spec *locspec, + struct program_space *search_pspace, int *found) { struct gdb_exception exception; =20 @@ -12633,7 +12640,7 @@ location_to_sals (struct breakpoint *b, struct even= t_location *location, =20 try { - sals =3D b->decode_location (location, search_pspace); + sals =3D b->decode_location_spec (locspec, search_pspace); } catch (gdb_exception_error &e) { @@ -12715,16 +12722,16 @@ breakpoint_re_set_default (code_breakpoint *b) std::vector expanded, expanded_end; =20 int found; - std::vector sals =3D location_to_sals (b, b->location.g= et (), - filter_pspace, &found); + std::vector sals + =3D location_spec_to_sals (b, b->locspec.get (), filter_pspace, &found= ); if (found) expanded =3D std::move (sals); =20 - if (b->location_range_end !=3D NULL) + if (b->locspec_range_end !=3D nullptr) { std::vector sals_end - =3D location_to_sals (b, b->location_range_end.get (), - filter_pspace, &found); + =3D location_spec_to_sals (b, b->locspec_range_end.get (), + filter_pspace, &found); if (found) expanded_end =3D std::move (sals_end); } @@ -12736,23 +12743,23 @@ breakpoint_re_set_default (code_breakpoint *b) calls parse_breakpoint_sals. Return 1 for success, zero for failure. = */ =20 static void -create_sals_from_location_default (struct event_location *location, - struct linespec_result *canonical) +create_sals_from_location_spec_default (location_spec *locspec, + struct linespec_result *canonical) { - parse_breakpoint_sals (location, canonical); + parse_breakpoint_sals (locspec, canonical); } =20 /* Decode the line represented by S by calling decode_line_full. This is = the default function for the `decode_location' method of breakpoint_ops. */ =20 static std::vector -decode_location_default (struct breakpoint *b, - struct event_location *location, - struct program_space *search_pspace) +decode_location_spec_default (struct breakpoint *b, + location_spec *locspec, + program_space *search_pspace) { struct linespec_result canonical; =20 - decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, search_pspace, + decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, search_pspace, NULL, 0, &canonical, multiple_symbols_all, b->filter.get ()); =20 @@ -13510,13 +13517,13 @@ set_tracepoint_count (int num) static void trace_command (const char *arg, int from_tty) { - event_location_up location =3D string_to_event_location (&arg, - current_language); - const struct breakpoint_ops *ops =3D breakpoint_ops_for_event_location - (location.get (), true /* is_tracepoint */); + location_spec_up locspec =3D string_to_location_spec (&arg, + current_language); + const struct breakpoint_ops *ops =3D breakpoint_ops_for_location_spec + (locspec.get (), true /* is_tracepoint */); =20 create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), NULL, 0, arg, false, 1 /* parse arg */, 0 /* tempflag */, bp_tracepoint /* type_wanted */, @@ -13531,10 +13538,10 @@ trace_command (const char *arg, int from_tty) static void ftrace_command (const char *arg, int from_tty) { - event_location_up location =3D string_to_event_location (&arg, - current_language); + location_spec_up locspec =3D string_to_location_spec (&arg, + current_language); create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), NULL, 0, arg, false, 1 /* parse arg */, 0 /* tempflag */, bp_fast_tracepoint /* type_wanted */, @@ -13552,7 +13559,7 @@ static void strace_command (const char *arg, int from_tty) { const struct breakpoint_ops *ops; - event_location_up location; + location_spec_up locspec; enum bptype type; =20 /* Decide if we are dealing with a static tracepoint marker (`-m'), @@ -13560,18 +13567,19 @@ strace_command (const char *arg, int from_tty) if (arg && startswith (arg, "-m") && isspace (arg[2])) { ops =3D &strace_marker_breakpoint_ops; - location =3D new_linespec_location (&arg, symbol_name_match_type::FU= LL); + locspec =3D new_linespec_location_spec (&arg, + symbol_name_match_type::FULL); type =3D bp_static_marker_tracepoint; } else { ops =3D &code_breakpoint_ops; - location =3D string_to_event_location (&arg, current_language); + locspec =3D string_to_location_spec (&arg, current_language); type =3D bp_static_tracepoint; } =20 create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), NULL, 0, arg, false, 1 /* parse arg */, 0 /* tempflag */, type /* type_wanted */, @@ -13637,10 +13645,10 @@ create_tracepoint_from_upload (struct uploaded_tp= *utp) "has no source form, ignoring it"), utp->number); =20 - event_location_up location =3D string_to_event_location (&addr_str, - current_language); + location_spec_up locspec =3D string_to_location_spec (&addr_str, + current_language); if (!create_breakpoint (get_current_arch (), - location.get (), + locspec.get (), utp->cond_string.get (), -1, addr_str, false /* force_condition */, 0 /* parse cond/thread */, @@ -14054,7 +14062,7 @@ save_tracepoints_command (const char *args, int fro= m_tty) /* This help string is used to consolidate all the help string for specify= ing locations used by several commands. */ =20 -#define LOCATION_HELP_STRING \ +#define LOCATION_SPEC_HELP_STRING \ "Linespecs are colon-separated lists of location parameters, such as\n\ source filename, function name, label name, and line number.\n\ Example: To specify the start of a label named \"the_top\" in the\n\ @@ -14101,7 +14109,7 @@ CONDITION is a boolean expression.\n\ \n\ With the \"-force-condition\" flag, the condition is defined even when\n\ it is invalid for all current locations.\n\ -\n" LOCATION_HELP_STRING "\n\n\ +\n" LOCATION_SPEC_HELP_STRING "\n\n\ Multiple breakpoints at one place are permitted, and useful if their\n\ conditions are different.\n\ \n\ @@ -14370,7 +14378,7 @@ Argument may be a linespec, explicit, or address lo= cation as described below.\n\ \n\ With no argument, clears all breakpoints in the line that the selected fra= me\n\ is executing in.\n" -"\n" LOCATION_HELP_STRING "\n\n\ +"\n" LOCATION_SPEC_HELP_STRING "\n\n\ See also the \"delete\" command which clears breakpoints by number.")); add_com_alias ("cl", clear_cmd, class_breakpoint, 1); =20 @@ -14531,7 +14539,7 @@ tracing library. You can inspect it when analyzing= the trace buffer,\n\ by printing the $_sdata variable like any other convenience variable.\n\ \n\ CONDITION is a boolean expression.\n\ -\n" LOCATION_HELP_STRING "\n\n\ +\n" LOCATION_SPEC_HELP_STRING "\n\n\ Multiple tracepoints at one place are permitted, and useful if their\n\ conditions are different.\n\ \n\ @@ -14688,7 +14696,7 @@ range (including START-LOCATION and END-LOCATION)."= )); Set a dynamic printf at specified location.\n\ dprintf location,format string,arg1,arg2,...\n\ location may be a linespec, explicit, or address location.\n" -"\n" LOCATION_HELP_STRING)); +"\n" LOCATION_SPEC_HELP_STRING)); set_cmd_completer (c, location_completer); =20 add_setshow_enum_cmd ("dprintf-style", class_support, diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 566f1285e46..f7884defce1 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -502,7 +502,7 @@ public: struct symtab *symtab =3D NULL; =20 /* The symbol found by the location parser, if any. This may be used to - ascertain when an event location was set at a different location than + ascertain when a location spec was set at a different location than the one originally selected by parsing, e.g., inlined symbols. */ const struct symbol *symbol =3D NULL; =20 @@ -562,14 +562,15 @@ enum print_stop_action =20 struct breakpoint_ops { - /* Create SALs from location, storing the result in linespec_result. + /* Create SALs from location spec, storing the result in + linespec_result. =20 For an explanation about the arguments, see the function - `create_sals_from_location_default'. + `create_sals_from_location_spec_default'. =20 This function is called inside `create_breakpoint'. */ - void (*create_sals_from_location) (struct event_location *location, - struct linespec_result *canonical); + void (*create_sals_from_location_spec) (location_spec *locspec, + struct linespec_result *canonical); =20 /* This method will be responsible for creating a breakpoint given its S= ALs. Usually, it just calls `create_breakpoints_sal' (for ordinary @@ -709,14 +710,14 @@ struct breakpoint /* Print to FP the CLI command that recreates this breakpoint. */ virtual void print_recreate (struct ui_file *fp) const; =20 - /* Given the location (second parameter), this method decodes it and - returns the SAL locations related to it. For ordinary + /* Given the location spec (second parameter), this method decodes + it and returns the SAL locations related to it. For ordinary breakpoints, it calls `decode_line_full'. If SEARCH_PSPACE is not NULL, symbol search is restricted to just that program space. =20 - This function is called inside `location_to_sals'. */ - virtual std::vector decode_location - (struct event_location *location, + This function is called inside `location_spec_to_sals'. */ + virtual std::vector decode_location_spec + (location_spec *locspec, struct program_space *search_pspace); =20 /* Return true if this breakpoint explains a signal. See @@ -774,16 +775,16 @@ struct breakpoint non-thread-specific ordinary breakpoints this is NULL. */ program_space *pspace =3D NULL; =20 - /* Location we used to set the breakpoint. */ - event_location_up location; + /* The location specification we used to set the breakpoint. */ + location_spec_up locspec; =20 /* The filter that should be passed to decode_line_full when re-setting this breakpoint. This may be NULL. */ gdb::unique_xmalloc_ptr filter; =20 - /* For a ranged breakpoint, the location we used to find the end of - the range. */ - event_location_up location_range_end; + /* For a ranged breakpoint, the location specification we used to + find the end of the range. */ + location_spec_up locspec_range_end; =20 /* Architecture we used to set the breakpoint. */ struct gdbarch *gdbarch; @@ -859,7 +860,7 @@ struct code_breakpoint : public breakpoint location" from the address in the SAL. */ code_breakpoint (struct gdbarch *gdbarch, bptype type, gdb::array_view sals, - event_location_up &&location, + location_spec_up &&locspec, gdb::unique_xmalloc_ptr filter, gdb::unique_xmalloc_ptr cond_string, gdb::unique_xmalloc_ptr extra_string, @@ -882,8 +883,8 @@ struct code_breakpoint : public breakpoint const address_space *aspace, CORE_ADDR bp_addr, const target_waitstatus &ws) override; - std::vector decode_location - (struct event_location *location, + std::vector decode_location_spec + (struct location_spec *locspec, struct program_space *search_pspace) override; }; =20 @@ -1460,13 +1461,14 @@ extern void extern void install_breakpoint (int internal, std::unique_ptr = &&b, int update_gll); =20 -/* Returns the breakpoint ops appropriate for use with with LOCATION and - according to IS_TRACEPOINT. Use this to ensure, for example, that you = pass - the correct ops to create_breakpoint for probe locations. If LOCATION = is - NULL, returns code_breakpoint_ops. */ +/* Returns the breakpoint ops appropriate for use with with LOCSPEC + and according to IS_TRACEPOINT. Use this to ensure, for example, + that you pass the correct ops to create_breakpoint for probe + location specs. If LOCSPEC is NULL, returns + code_breakpoint_ops. */ =20 -extern const struct breakpoint_ops *breakpoint_ops_for_event_location - (const struct event_location *location, bool is_tracepoint); +extern const struct breakpoint_ops *breakpoint_ops_for_location_spec + (const location_spec *locspec, bool is_tracepoint); =20 /* Flags that can be passed down to create_breakpoint, etc., to affect breakpoint creation in several ways. */ @@ -1478,15 +1480,15 @@ enum breakpoint_create_flags CREATE_BREAKPOINT_FLAGS_INSERTED =3D 1 << 0 }; =20 -/* Set a breakpoint. This function is shared between CLI and MI functions - for setting a breakpoint at LOCATION. +/* Set a breakpoint. This function is shared between CLI and MI + functions for setting a breakpoint at LOCSPEC. =20 This function has two major modes of operations, selected by the PARSE_EXTRA parameter. =20 - If PARSE_EXTRA is zero, LOCATION is just the breakpoint's location, - with condition, thread, and extra string specified by the COND_STRING, - THREAD, and EXTRA_STRING parameters. + If PARSE_EXTRA is zero, LOCSPEC is just the breakpoint's location + spec, with condition, thread, and extra string specified by the + COND_STRING, THREAD, and EXTRA_STRING parameters. =20 If PARSE_EXTRA is non-zero, this function will attempt to extract the condition, thread, and extra string from EXTRA_STRING, ignoring @@ -1503,7 +1505,7 @@ enum breakpoint_create_flags Returns true if any breakpoint was created; false otherwise. */ =20 extern int create_breakpoint (struct gdbarch *gdbarch, - struct event_location *location, + struct location_spec *locspec, const char *cond_string, int thread, const char *extra_string, bool force_condition, diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index 31911ebe61f..18fb6e6d869 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -970,13 +970,13 @@ edit_command (const char *arg, int from_tty) =20 /* Now should only be one argument -- decode it in SAL. */ arg1 =3D arg; - event_location_up location =3D string_to_event_location (&arg1, - current_language); + location_spec_up locspec =3D string_to_location_spec (&arg1, + current_language); =20 if (*arg1) error (_("Junk at end of line specification.")); =20 - std::vector sals =3D decode_line_1 (location.get (), + std::vector sals =3D decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); =20 @@ -1241,18 +1241,18 @@ list_command (const char *arg, int from_tty) dummy_beg =3D 1; else { - event_location_up location =3D string_to_event_location (&arg1, - current_language); - - /* We know that the ARG string is not empty, yet the attempt to parse - a location from the string consumed no characters. This most - likely means that the first thing in ARG looks like a location - condition, and so the string_to_event_location call stopped - parsing. */ + location_spec_up locspec + =3D string_to_location_spec (&arg1, current_language); + + /* We know that the ARG string is not empty, yet the attempt to + parse a location spec from the string consumed no characters. + This most likely means that the first thing in ARG looks like + a location spec condition, and so the string_to_location_spec + call stopped parsing. */ if (arg1 =3D=3D arg) error (_("Junk at end of line specification.")); =20 - sals =3D decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + sals =3D decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); filter_sals (sals); if (sals.empty ()) @@ -1297,17 +1297,17 @@ list_command (const char *arg, int from_tty) know it was ambiguous. */ const char *end_arg =3D arg1; =20 - event_location_up location - =3D string_to_event_location (&arg1, current_language); + location_spec_up locspec + =3D string_to_location_spec (&arg1, current_language); =20 if (*arg1) error (_("Junk at end of line specification.")); =20 std::vector sals_end =3D (dummy_beg - ? decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + ? decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0) - : decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + : decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, sal.symtab, sal.line)); =20 filter_sals (sals_end); diff --git a/gdb/completer.c b/gdb/completer.c index fea3eb9329d..2ec8d2eb594 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -707,13 +707,13 @@ string_or_empty (const char *string) =20 static void collect_explicit_location_matches (completion_tracker &tracker, - struct event_location *location, + location_spec *locspec, enum explicit_location_match_type what, const char *word, const struct language_defn *language) { const struct explicit_location *explicit_loc - =3D get_explicit_location (location); + =3D get_explicit_location (locspec); =20 /* True if the option expects an argument. */ bool needs_arg =3D true; @@ -846,19 +846,19 @@ skip_keyword (completion_tracker &tracker, return -1; } =20 -/* A completer function for explicit locations. This function +/* A completer function for explicit location specs. This function completes both options ("-source", "-line", etc) and values. If completing a quoted string, then QUOTED_ARG_START and QUOTED_ARG_END point to the quote characters. LANGUAGE is the current language. */ =20 static void -complete_explicit_location (completion_tracker &tracker, - struct event_location *location, - const char *text, - const language_defn *language, - const char *quoted_arg_start, - const char *quoted_arg_end) +complete_explicit_location_spec (completion_tracker &tracker, + location_spec *locspec, + const char *text, + const language_defn *language, + const char *quoted_arg_start, + const char *quoted_arg_end) { if (*text !=3D '-') return; @@ -916,7 +916,7 @@ complete_explicit_location (completion_tracker &tracker, } =20 /* Now gather matches */ - collect_explicit_location_matches (tracker, location, what, text, + collect_explicit_location_matches (tracker, locspec, what, text, language); } } @@ -943,9 +943,9 @@ location_completer (struct cmd_list_element *ignore, const char *copy =3D text; =20 explicit_completion_info completion_info; - event_location_up location - =3D string_to_explicit_location (©, current_language, - &completion_info); + location_spec_up locspec + =3D string_to_explicit_location_spec (©, current_language, + &completion_info); if (completion_info.quoted_arg_start !=3D NULL && completion_info.quoted_arg_end =3D=3D NULL) { @@ -954,7 +954,7 @@ location_completer (struct cmd_list_element *ignore, tracker.advance_custom_word_point_by (1); } =20 - if (completion_info.saw_explicit_location_option) + if (completion_info.saw_explicit_location_spec_option) { if (*copy !=3D '\0') { @@ -987,15 +987,15 @@ location_completer (struct cmd_list_element *ignore, - text); text =3D completion_info.last_option; =20 - complete_explicit_location (tracker, location.get (), text, - current_language, - completion_info.quoted_arg_start, - completion_info.quoted_arg_end); + complete_explicit_location_spec (tracker, locspec.get (), text, + current_language, + completion_info.quoted_arg_start, + completion_info.quoted_arg_end); =20 } } /* This is an address or linespec location. */ - else if (location !=3D NULL) + else if (locspec !=3D nullptr) { /* Handle non-explicit location options. */ =20 @@ -1008,7 +1008,7 @@ location_completer (struct cmd_list_element *ignore, text =3D copy; =20 symbol_name_match_type match_type - =3D get_explicit_location (location.get ())->func_name_match_type; + =3D get_explicit_location (locspec.get ())->func_name_match_type; complete_address_and_linespec_locations (tracker, text, match_type); } } diff --git a/gdb/elfread.c b/gdb/elfread.c index 32cb27c8967..2fe02805d01 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -1026,8 +1026,8 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *= b) resolved_pc =3D gdbarch_addr_bits_remove (gdbarch, resolved_pc); =20 gdb_assert (current_program_space =3D=3D b->pspace || b->pspace =3D=3D N= ULL); - elf_gnu_ifunc_record_cache (event_location_to_string (b->location.get ()= ), - resolved_pc); + const char *locspec_str =3D location_spec_to_string (b->locspec.get ()); + elf_gnu_ifunc_record_cache (locspec_str, resolved_pc); =20 b->type =3D bp_breakpoint; update_breakpoint_locations (b, current_program_space, diff --git a/gdb/guile/scm-breakpoint.c b/gdb/guile/scm-breakpoint.c index d6c89aa8c71..c358f0ba99d 100644 --- a/gdb/guile/scm-breakpoint.c +++ b/gdb/guile/scm-breakpoint.c @@ -187,9 +187,9 @@ bpscm_print_breakpoint_smob (SCM self, SCM port, scm_pr= int_state *pstate) gdbscm_printf (port, " hit:%d", b->hit_count); gdbscm_printf (port, " ignore:%d", b->ignore_count); =20 - if (b->location !=3D nullptr) + if (b->locspec !=3D nullptr) { - const char *str =3D event_location_to_string (b->location.get ()); + const char *str =3D location_spec_to_string (b->locspec.get ()); if (str !=3D nullptr) gdbscm_printf (port, " @%s", str); } @@ -448,10 +448,10 @@ gdbscm_register_breakpoint_x (SCM self) pending_breakpoint_scm =3D self; location =3D bp_smob->spec.location; copy =3D skip_spaces (location); - event_location_up eloc - =3D string_to_event_location_basic (©, - current_language, - symbol_name_match_type::WILD); + location_spec_up locspec + =3D string_to_location_spec_basic (©, + current_language, + symbol_name_match_type::WILD); =20 try { @@ -463,9 +463,9 @@ gdbscm_register_breakpoint_x (SCM self) case bp_breakpoint: { const breakpoint_ops *ops =3D - breakpoint_ops_for_event_location (eloc.get (), false); + breakpoint_ops_for_location_spec (locspec.get (), false); create_breakpoint (get_current_arch (), - eloc.get (), NULL, -1, NULL, false, + locspec.get (), NULL, -1, NULL, false, 0, temporary, bp_breakpoint, 0, @@ -855,13 +855,13 @@ gdbscm_breakpoint_location (SCM self) { breakpoint_smob *bp_smob =3D bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_N= AME); - const char *str; =20 if (bp_smob->bp->type !=3D bp_breakpoint) return SCM_BOOL_F; =20 - str =3D event_location_to_string (bp_smob->bp->location.get ()); - if (! str) + const char *str + =3D location_spec_to_string (bp_smob->bp->locspec.get ()); + if (str =3D=3D nullptr) str =3D ""; =20 return gdbscm_scm_from_c_string (str); diff --git a/gdb/linespec.c b/gdb/linespec.c index c9558c8ae36..b12f5c87733 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -1990,7 +1990,7 @@ linespec_parse_basic (linespec_parser *parser) static void canonicalize_linespec (struct linespec_state *state, const linespec *ls) { - struct event_location *canon; + location_spec *canon; struct explicit_location *explicit_loc; =20 /* If canonicalization was not requested, no need to do anything. */ @@ -1998,9 +1998,9 @@ canonicalize_linespec (struct linespec_state *state, = const linespec *ls) return; =20 /* Save everything as an explicit location. */ - state->canonical->location - =3D new_explicit_location (&ls->explicit_loc); - canon =3D state->canonical->location.get (); + state->canonical->locspec + =3D new_explicit_location_spec (&ls->explicit_loc); + canon =3D state->canonical->locspec.get (); explicit_loc =3D get_explicit_location (canon); =20 if (explicit_loc->label_name !=3D NULL) @@ -2019,8 +2019,8 @@ canonicalize_linespec (struct linespec_state *state, = const linespec *ls) /* If this location originally came from a linespec, save a string representation of it for display and saving to file. */ if (state->is_linespec) - set_event_location_string (canon, - explicit_location_to_linespec (explicit_loc)); + set_location_spec_string (canon, + explicit_location_to_linespec (explicit_loc)); } =20 /* Given a line offset in LS, construct the relevant SALs. */ @@ -3061,22 +3061,22 @@ linespec_complete (completion_tracker &tracker, con= st char *text, } =20 /* A helper function for decode_line_full and decode_line_1 to - turn LOCATION into std::vector. */ + turn LOCSPEC into std::vector. */ =20 static std::vector -event_location_to_sals (linespec_parser *parser, - const struct event_location *location) +location_spec_to_sals (linespec_parser *parser, + const location_spec *locspec) { std::vector result; =20 - switch (event_location_type (location)) + switch (location_spec_type (locspec)) { - case LINESPEC_LOCATION: + case LINESPEC_LOCATION_SPEC: { PARSER_STATE (parser)->is_linespec =3D 1; try { - const linespec_location *ls =3D get_linespec_location (location); + const linespec_location *ls =3D get_linespec_location (locspec); result =3D parse_linespec (parser, ls->spec_string, ls->match_type); } @@ -3087,17 +3087,17 @@ event_location_to_sals (linespec_parser *parser, } break; =20 - case ADDRESS_LOCATION: + case ADDRESS_LOCATION_SPEC: { - const char *addr_string =3D get_address_string_location (location); - CORE_ADDR addr =3D get_address_location (location); + const char *addr_string =3D get_address_string_location (locspec); + CORE_ADDR addr =3D get_address_location (locspec); =20 if (addr_string !=3D NULL) { addr =3D linespec_expression_to_pc (&addr_string); if (PARSER_STATE (parser)->canonical !=3D NULL) - PARSER_STATE (parser)->canonical->location - =3D copy_event_location (location); + PARSER_STATE (parser)->canonical->locspec + =3D copy_location_spec (locspec); } =20 result =3D convert_address_location_to_sals (PARSER_STATE (parser), @@ -3105,24 +3105,24 @@ event_location_to_sals (linespec_parser *parser, } break; =20 - case EXPLICIT_LOCATION: + case EXPLICIT_LOCATION_SPEC: { const struct explicit_location *explicit_loc; =20 - explicit_loc =3D get_explicit_location_const (location); + explicit_loc =3D get_explicit_location_const (locspec); result =3D convert_explicit_location_to_sals (PARSER_STATE (parser), PARSER_RESULT (parser), explicit_loc); } break; =20 - case PROBE_LOCATION: + case PROBE_LOCATION_SPEC: /* Probes are handled by their own decoders. */ gdb_assert_not_reached ("attempt to decode probe location"); break; =20 default: - gdb_assert_not_reached ("unhandled event location type"); + gdb_assert_not_reached ("unhandled location spec type"); } =20 return result; @@ -3131,7 +3131,7 @@ event_location_to_sals (linespec_parser *parser, /* See linespec.h. */ =20 void -decode_line_full (struct event_location *location, int flags, +decode_line_full (struct location_spec *locspec, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical, @@ -3156,13 +3156,13 @@ decode_line_full (struct event_location *location, = int flags, =20 scoped_restore_current_program_space restore_pspace; =20 - std::vector result =3D event_location_to_sals (&parser, - location); + std::vector result =3D location_spec_to_sals (&parser, + locspec); state =3D PARSER_STATE (&parser); =20 if (result.size () =3D=3D 0) throw_error (NOT_SUPPORTED_ERROR, _("Location %s not available"), - event_location_to_string (location)); + location_spec_to_string (locspec)); =20 gdb_assert (result.size () =3D=3D 1 || canonical->pre_expanded); canonical->pre_expanded =3D 1; @@ -3200,7 +3200,7 @@ decode_line_full (struct event_location *location, in= t flags, /* See linespec.h. */ =20 std::vector -decode_line_1 (const struct event_location *location, int flags, +decode_line_1 (const location_spec *locspec, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line) @@ -3211,7 +3211,7 @@ decode_line_1 (const struct event_location *location,= int flags, =20 scoped_restore_current_program_space restore_pspace; =20 - return event_location_to_sals (&parser, location); + return location_spec_to_sals (&parser, locspec); } =20 /* See linespec.h. */ @@ -3226,10 +3226,10 @@ decode_line_with_current_source (const char *string= , int flags) and get a default source symtab+line or it will recursively call us! = */ symtab_and_line cursal =3D get_current_source_symtab_and_line (); =20 - event_location_up location =3D string_to_event_location (&string, - current_language); + location_spec_up locspec =3D string_to_location_spec (&string, + current_language); std::vector sals - =3D decode_line_1 (location.get (), flags, NULL, cursal.symtab, cursal= .line); + =3D decode_line_1 (locspec.get (), flags, NULL, cursal.symtab, cursal.= line); =20 if (*string) error (_("Junk at end of line specification: %s"), string); @@ -3245,14 +3245,14 @@ decode_line_with_last_displayed (const char *string= , int flags) if (string =3D=3D 0) error (_("Empty line specification.")); =20 - event_location_up location =3D string_to_event_location (&string, - current_language); + location_spec_up locspec =3D string_to_location_spec (&string, + current_language); std::vector sals =3D (last_displayed_sal_is_valid () - ? decode_line_1 (location.get (), flags, NULL, + ? decode_line_1 (locspec.get (), flags, NULL, get_last_displayed_symtab (), get_last_displayed_line ()) - : decode_line_1 (location.get (), flags, NULL, NULL, 0)); + : decode_line_1 (locspec.get (), flags, NULL, NULL, 0)); =20 if (*string) error (_("Junk at end of line specification: %s"), string); @@ -3364,8 +3364,8 @@ decode_objc (struct linespec_state *self, linespec *l= s, const char *arg) else str =3D saved_arg; =20 - self->canonical->location - =3D new_linespec_location (&str, symbol_name_match_type::FULL); + self->canonical->locspec + =3D new_linespec_location_spec (&str, symbol_name_match_type::FULL); } } =20 diff --git a/gdb/linespec.h b/gdb/linespec.h index bb8975548a3..9d3e84d19fc 100644 --- a/gdb/linespec.h +++ b/gdb/linespec.h @@ -70,9 +70,9 @@ struct linespec_result object. */ bool pre_expanded =3D false; =20 - /* If PRE_EXPANDED is non-zero, this is set to the location entered - by the user. */ - event_location_up location; + /* If PRE_EXPANDED is true, this is set to the location spec + entered by the user. */ + location_spec_up locspec; =20 /* The sals. The vector will be freed by the destructor. */ std::vector lsals; @@ -81,11 +81,11 @@ struct linespec_result /* Decode a linespec using the provided default symtab and line. */ =20 extern std::vector - decode_line_1 (const struct event_location *location, int flags, + decode_line_1 (const location_spec *locspec, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line); =20 -/* Parse LOCATION and return results. This is the "full" +/* Parse LOCSPEC and return results. This is the "full" interface to this module, which handles multiple results properly. =20 @@ -124,7 +124,7 @@ extern std::vector strcmp sense) to FILTER will be returned; all others will be filtered out. */ =20 -extern void decode_line_full (struct event_location *location, int flags, +extern void decode_line_full (struct location_spec *locspec, int flags, struct program_space *search_pspace, struct symtab *default_symtab, int default_line, struct linespec_result *canonical, diff --git a/gdb/location.c b/gdb/location.c index 0459980ab8c..14a5aebff17 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -1,4 +1,4 @@ -/* Data structures and API for event locations in GDB. +/* Data structures and API for location specs in GDB. Copyright (C) 2013-2022 Free Software Foundation, Inc. =20 This file is part of GDB. @@ -32,17 +32,17 @@ static std::string explicit_location_to_string (const struct explicit_location *explicit_loc); =20 -/* The base class for all an event locations used to set a stop event - in the inferior. */ +/* The base class for all location specs used to match actual + locations in the inferior. */ =20 -struct event_location +struct location_spec { - virtual ~event_location () =3D default; + virtual ~location_spec () =3D default; =20 /* Clone this object. */ - virtual event_location_up clone () const =3D 0; + virtual location_spec_up clone () const =3D 0; =20 - /* Return true if this location is empty, false otherwise. */ + /* Return true if this location spec is empty, false otherwise. */ virtual bool empty_p () const =3D 0; =20 /* Return a string representation of this location. */ @@ -55,29 +55,29 @@ struct event_location return as_string.c_str (); } =20 - DISABLE_COPY_AND_ASSIGN (event_location); + DISABLE_COPY_AND_ASSIGN (location_spec); =20 - /* The type of this breakpoint specification. */ - enum event_location_type type; + /* The type of this location specification. */ + enum location_spec_type type; =20 - /* Cached string representation of this location. This is used, - e.g., to save stop event locations to file. */ + /* Cached string representation of this location spec. This is + used, e.g., to save location specs to file. */ mutable std::string as_string; =20 protected: =20 - explicit event_location (enum event_location_type t) + explicit location_spec (enum location_spec_type t) : type (t) { } =20 - event_location (enum event_location_type t, std::string &&str) + location_spec (enum location_spec_type t, std::string &&str) : type (t), as_string (std::move (str)) { } =20 - explicit event_location (const event_location *to_clone) + explicit location_spec (const location_spec *to_clone) : type (to_clone->type), as_string (to_clone->as_string) { @@ -89,16 +89,16 @@ protected: }; =20 /* A probe. */ -struct event_location_probe : public event_location +struct probe_location_spec : public location_spec { - explicit event_location_probe (std::string &&probe) - : event_location (PROBE_LOCATION, std::move (probe)) + explicit probe_location_spec (std::string &&probe) + : location_spec (PROBE_LOCATION_SPEC, std::move (probe)) { } =20 - event_location_up clone () const override + location_spec_up clone () const override { - return event_location_up (new event_location_probe (this)); + return location_spec_up (new probe_location_spec (this)); } =20 bool empty_p () const override @@ -108,8 +108,8 @@ struct event_location_probe : public event_location =20 protected: =20 - explicit event_location_probe (const event_location_probe *to_clone) - : event_location (to_clone) + explicit probe_location_spec (const probe_location_spec *to_clone) + : location_spec (to_clone) { } =20 @@ -120,11 +120,11 @@ protected: }; =20 /* A "normal" linespec. */ -struct event_location_linespec : public event_location +struct linespec_location_spec : public location_spec { - event_location_linespec (const char **linespec, - symbol_name_match_type match_type) - : event_location (LINESPEC_LOCATION) + linespec_location_spec (const char **linespec, + symbol_name_match_type match_type) + : location_spec (LINESPEC_LOCATION_SPEC) { linespec_location.match_type =3D match_type; if (*linespec !=3D NULL) @@ -144,14 +144,14 @@ struct event_location_linespec : public event_location } } =20 - ~event_location_linespec () + ~linespec_location_spec () { xfree (linespec_location.spec_string); } =20 - event_location_up clone () const override + location_spec_up clone () const override { - return event_location_up (new event_location_linespec (this)); + return location_spec_up (new linespec_location_spec (this)); } =20 bool empty_p () const override @@ -163,8 +163,8 @@ struct event_location_linespec : public event_location =20 protected: =20 - explicit event_location_linespec (const event_location_linespec *to_clon= e) - : event_location (to_clone), + explicit linespec_location_spec (const linespec_location_spec *to_clone) + : location_spec (to_clone), linespec_location (to_clone->linespec_location) { if (linespec_location.spec_string !=3D nullptr) @@ -186,20 +186,20 @@ protected: }; =20 /* An address in the inferior. */ -struct event_location_address : public event_location +struct address_location_spec : public location_spec { - event_location_address (CORE_ADDR addr, const char *addr_string, - int addr_string_len) - : event_location (ADDRESS_LOCATION), + address_location_spec (CORE_ADDR addr, const char *addr_string, + int addr_string_len) + : location_spec (ADDRESS_LOCATION_SPEC), address (addr) { if (addr_string !=3D nullptr) as_string =3D std::string (addr_string, addr_string_len); } =20 - event_location_up clone () const override + location_spec_up clone () const override { - return event_location_up (new event_location_address (this)); + return location_spec_up (new address_location_spec (this)); } =20 bool empty_p () const override @@ -211,8 +211,8 @@ struct event_location_address : public event_location =20 protected: =20 - event_location_address (const event_location_address *to_clone) - : event_location (to_clone), + address_location_spec (const address_location_spec *to_clone) + : location_spec (to_clone), address (to_clone->address) { } @@ -224,25 +224,25 @@ protected: } }; =20 -/* An explicit location. */ -struct event_location_explicit : public event_location +/* An explicit location spec. */ +struct explicit_location_spec : public location_spec { - explicit event_location_explicit (const struct explicit_location *loc) - : event_location (EXPLICIT_LOCATION) + explicit explicit_location_spec (const struct explicit_location *loc) + : location_spec (EXPLICIT_LOCATION_SPEC) { copy_loc (loc); } =20 - ~event_location_explicit () + ~explicit_location_spec () { xfree (explicit_loc.source_filename); xfree (explicit_loc.function_name); xfree (explicit_loc.label_name); } =20 - event_location_up clone () const override + location_spec_up clone () const override { - return event_location_up (new event_location_explicit (this)); + return location_spec_up (new explicit_location_spec (this)); } =20 bool empty_p () const override @@ -257,8 +257,8 @@ struct event_location_explicit : public event_location =20 protected: =20 - explicit event_location_explicit (const event_location_explicit *to_clon= e) - : event_location (to_clone) + explicit explicit_location_spec (const explicit_location_spec *to_clone) + : location_spec (to_clone) { copy_loc (&to_clone->explicit_loc); } @@ -289,10 +289,10 @@ private: =20 /* See description in location.h. */ =20 -enum event_location_type -event_location_type (const struct event_location *location) +enum location_spec_type +location_spec_type (const location_spec *locspec) { - return location->type; + return locspec->type; } =20 /* See description in location.h. */ @@ -307,99 +307,99 @@ initialize_explicit_location (struct explicit_locatio= n *explicit_loc) =20 /* See description in location.h. */ =20 -event_location_up -new_linespec_location (const char **linespec, - symbol_name_match_type match_type) +location_spec_up +new_linespec_location_spec (const char **linespec, + symbol_name_match_type match_type) { - return event_location_up (new event_location_linespec (linespec, - match_type)); + return location_spec_up (new linespec_location_spec (linespec, + match_type)); } =20 /* See description in location.h. */ =20 const linespec_location * -get_linespec_location (const struct event_location *location) +get_linespec_location (const location_spec *locspec) { - gdb_assert (location->type =3D=3D LINESPEC_LOCATION); - return &((event_location_linespec *) location)->linespec_location; + gdb_assert (locspec->type =3D=3D LINESPEC_LOCATION_SPEC); + return &((linespec_location_spec *) locspec)->linespec_location; } =20 /* See description in location.h. */ =20 -event_location_up -new_address_location (CORE_ADDR addr, const char *addr_string, - int addr_string_len) +location_spec_up +new_address_location_spec (CORE_ADDR addr, const char *addr_string, + int addr_string_len) { - return event_location_up (new event_location_address (addr, addr_string, - addr_string_len)); + return location_spec_up (new address_location_spec (addr, addr_string, + addr_string_len)); } =20 /* See description in location.h. */ =20 CORE_ADDR -get_address_location (const struct event_location *location) +get_address_location (const location_spec *locspec) { - gdb_assert (location->type =3D=3D ADDRESS_LOCATION); - return ((event_location_address *) location)->address; + gdb_assert (locspec->type =3D=3D ADDRESS_LOCATION_SPEC); + return ((address_location_spec *) locspec)->address; } =20 /* See description in location.h. */ =20 const char * -get_address_string_location (const struct event_location *location) +get_address_string_location (const location_spec *locspec) { - gdb_assert (location->type =3D=3D ADDRESS_LOCATION); - return location->to_string (); + gdb_assert (locspec->type =3D=3D ADDRESS_LOCATION_SPEC); + return locspec->to_string (); } =20 /* See description in location.h. */ =20 -event_location_up -new_probe_location (std::string &&probe) +location_spec_up +new_probe_location_spec (std::string &&probe) { - return event_location_up (new event_location_probe (std::move (probe))); + return location_spec_up (new probe_location_spec (std::move (probe))); } =20 /* See description in location.h. */ =20 const char * -get_probe_location (const struct event_location *location) +get_probe_location_spec_string (const location_spec *locspec) { - gdb_assert (location->type =3D=3D PROBE_LOCATION); - return location->to_string (); + gdb_assert (locspec->type =3D=3D PROBE_LOCATION_SPEC); + return locspec->to_string (); } =20 /* See description in location.h. */ =20 -event_location_up -new_explicit_location (const struct explicit_location *explicit_loc) +location_spec_up +new_explicit_location_spec (const explicit_location *explicit_loc) { - return event_location_up (new event_location_explicit (explicit_loc)); + return location_spec_up (new explicit_location_spec (explicit_loc)); } =20 /* See description in location.h. */ =20 struct explicit_location * -get_explicit_location (struct event_location *location) +get_explicit_location (location_spec *locspec) { - gdb_assert (location->type =3D=3D EXPLICIT_LOCATION); - return &((event_location_explicit *) location)->explicit_loc; + gdb_assert (locspec->type =3D=3D EXPLICIT_LOCATION_SPEC); + return &((explicit_location_spec *) locspec)->explicit_loc; } =20 /* See description in location.h. */ =20 const struct explicit_location * -get_explicit_location_const (const struct event_location *location) +get_explicit_location_const (const location_spec *locspec) { - gdb_assert (location->type =3D=3D EXPLICIT_LOCATION); - return &((event_location_explicit *) location)->explicit_loc; + gdb_assert (locspec->type =3D=3D EXPLICIT_LOCATION_SPEC); + return &((explicit_location_spec *) locspec)->explicit_loc; } =20 -/* This convenience function returns a malloc'd string which - represents the location in EXPLICIT_LOC. +/* Return a string representation of the explicit location spec in + EXPLICIT_LOCSPEC. =20 - AS_LINESPEC is true if this string should be a linespec. - Otherwise it will be output in explicit form. */ + AS_LINESPEC is true if this string should be a linespec. Otherwise + it will be output in explicit form. */ =20 static std::string explicit_to_string_internal (bool as_linespec, @@ -473,24 +473,24 @@ explicit_location_to_linespec (const struct explicit_= location *explicit_loc) =20 /* See description in location.h. */ =20 -event_location_up -copy_event_location (const struct event_location *src) +location_spec_up +copy_location_spec (const location_spec *src) { return src->clone (); } =20 void -event_location_deleter::operator() (event_location *location) const +location_spec_deleter::operator() (location_spec *locspec) const { - delete location; + delete locspec; } =20 /* See description in location.h. */ =20 const char * -event_location_to_string (struct event_location *location) +location_spec_to_string (struct location_spec *locspec) { - return location->to_string (); + return locspec->to_string (); } =20 /* Find an instance of the quote character C in the string S that is @@ -523,14 +523,14 @@ find_end_quote (const char *s, char end_quote_char) return 0; } =20 -/* A lexer for explicit locations. This function will advance INP - past any strings that it lexes. Returns a malloc'd copy of the +/* A lexer for explicit location specs. This function will advance + INP past any strings that it lexes. Returns a malloc'd copy of the lexed string or NULL if no lexing was done. */ =20 static gdb::unique_xmalloc_ptr -explicit_location_lex_one (const char **inp, - const struct language_defn *language, - explicit_completion_info *completion_info) +explicit_location_spec_lex_one (const char **inp, + const struct language_defn *language, + explicit_completion_info *completion_info) { const char *start =3D *inp; =20 @@ -630,7 +630,7 @@ is_cp_operator (const char *start, const char *comma) } =20 /* When scanning the input string looking for the next explicit - location option/delimiter, we jump to the next option by looking + location spec option/delimiter, we jump to the next option by looking for ",", and "-". Such a character can also appear in C++ symbols like "operator," and "operator-". So when we find such a character, we call this function to check if we found such a @@ -673,15 +673,16 @@ first_of (const char *first, const char *new_tok) return first; } =20 -/* A lexer for functions in explicit locations. This function will +/* A lexer for functions in explicit location specs. This function will advance INP past a function until the next option, or until end of string. Returns a malloc'd copy of the lexed string or NULL if no lexing was done. */ =20 static gdb::unique_xmalloc_ptr -explicit_location_lex_one_function (const char **inp, - const struct language_defn *language, - explicit_completion_info *completion_info) +explicit_location_spec_lex_one_function + (const char **inp, + const struct language_defn *language, + explicit_completion_info *completion_info) { const char *start =3D *inp; =20 @@ -771,10 +772,10 @@ explicit_location_lex_one_function (const char **inp, =20 /* See description in location.h. */ =20 -event_location_up -string_to_explicit_location (const char **argp, - const struct language_defn *language, - explicit_completion_info *completion_info) +location_spec_up +string_to_explicit_location_spec (const char **argp, + const struct language_defn *language, + explicit_completion_info *completion_info) { /* It is assumed that input beginning with '-' and a non-digit character is an explicit location. "-p" is reserved, though, @@ -786,8 +787,8 @@ string_to_explicit_location (const char **argp, || ((*argp)[0] =3D=3D '-' && (*argp)[1] =3D=3D 'p')) return NULL; =20 - std::unique_ptr location - (new event_location_explicit ((const explicit_location *) nullptr)); + std::unique_ptr locspec + (new explicit_location_spec ((const explicit_location *) nullptr)); =20 /* Process option/argument pairs. dprintf_command requires that processing stop on ','. */ @@ -817,7 +818,7 @@ string_to_explicit_location (const char **argp, =20 /* Get the option string. */ gdb::unique_xmalloc_ptr opt - =3D explicit_location_lex_one (argp, language, NULL); + =3D explicit_location_spec_lex_one (argp, language, NULL); =20 /* Use the length of the option to allow abbreviations. */ len =3D strlen (opt.get ()); @@ -845,7 +846,7 @@ string_to_explicit_location (const char **argp, /* We do this here because the set of options that take arguments matches the set of explicit location options. */ - completion_info->saw_explicit_location_option =3D true; + completion_info->saw_explicit_location_spec_option =3D true; } oarg =3D std::move (arg); have_oarg =3D oarg !=3D NULL; @@ -854,36 +855,37 @@ string_to_explicit_location (const char **argp, =20 if (strncmp (opt.get (), "-source", len) =3D=3D 0) { - set_oarg (explicit_location_lex_one (argp, language, - completion_info)); - location->explicit_loc.source_filename =3D oarg.release (); + set_oarg (explicit_location_spec_lex_one (argp, language, + completion_info)); + locspec->explicit_loc.source_filename =3D oarg.release (); } else if (strncmp (opt.get (), "-function", len) =3D=3D 0) { - set_oarg (explicit_location_lex_one_function (argp, language, - completion_info)); - location->explicit_loc.function_name =3D oarg.release (); + set_oarg (explicit_location_spec_lex_one_function (argp, language, + completion_info)); + locspec->explicit_loc.function_name =3D oarg.release (); } else if (strncmp (opt.get (), "-qualified", len) =3D=3D 0) { - location->explicit_loc.func_name_match_type + locspec->explicit_loc.func_name_match_type =3D symbol_name_match_type::FULL; } else if (strncmp (opt.get (), "-line", len) =3D=3D 0) { - set_oarg (explicit_location_lex_one (argp, language, NULL)); + set_oarg (explicit_location_spec_lex_one (argp, language, NULL)); *argp =3D skip_spaces (*argp); if (have_oarg) { - location->explicit_loc.line_offset + locspec->explicit_loc.line_offset =3D linespec_parse_line_offset (oarg.get ()); continue; } } else if (strncmp (opt.get (), "-label", len) =3D=3D 0) { - set_oarg (explicit_location_lex_one (argp, language, completion_info)); - location->explicit_loc.label_name =3D oarg.release (); + set_oarg (explicit_location_spec_lex_one (argp, language, + completion_info)); + locspec->explicit_loc.label_name =3D oarg.release (); } /* Only emit an "invalid argument" error for options that look like option strings. */ @@ -913,39 +915,39 @@ string_to_explicit_location (const char **argp, =20 /* One special error check: If a source filename was given without offset, function, or label, issue an error. */ - if (location->explicit_loc.source_filename !=3D NULL - && location->explicit_loc.function_name =3D=3D NULL - && location->explicit_loc.label_name =3D=3D NULL - && (location->explicit_loc.line_offset.sign =3D=3D LINE_OFFSET_UNKNO= WN) + if (locspec->explicit_loc.source_filename !=3D NULL + && locspec->explicit_loc.function_name =3D=3D NULL + && locspec->explicit_loc.label_name =3D=3D NULL + && (locspec->explicit_loc.line_offset.sign =3D=3D LINE_OFFSET_UNKNOW= N) && completion_info =3D=3D NULL) { error (_("Source filename requires function, label, or " "line offset.")); } =20 - return event_location_up (location.release ()); + return location_spec_up (locspec.release ()); } =20 /* See description in location.h. */ =20 -event_location_up -string_to_event_location_basic (const char **stringp, - const struct language_defn *language, - symbol_name_match_type match_type) +location_spec_up +string_to_location_spec_basic (const char **stringp, + const struct language_defn *language, + symbol_name_match_type match_type) { - event_location_up location; + location_spec_up locspec; const char *cs; =20 /* Try the input as a probe spec. */ cs =3D *stringp; if (cs !=3D NULL && probe_linespec_to_static_ops (&cs) !=3D NULL) { - location =3D new_probe_location (*stringp); + locspec =3D new_probe_location_spec (*stringp); *stringp +=3D strlen (*stringp); } else { - /* Try an address location. */ + /* Try an address location spec. */ if (*stringp !=3D NULL && **stringp =3D=3D '*') { const char *arg, *orig; @@ -953,69 +955,72 @@ string_to_event_location_basic (const char **stringp, =20 orig =3D arg =3D *stringp; addr =3D linespec_expression_to_pc (&arg); - location =3D new_address_location (addr, orig, arg - orig); + locspec =3D new_address_location_spec (addr, orig, arg - orig); *stringp +=3D arg - orig; } else { /* Everything else is a linespec. */ - location =3D new_linespec_location (stringp, match_type); + locspec =3D new_linespec_location_spec (stringp, match_type); } } =20 - return location; + return locspec; } =20 /* See description in location.h. */ =20 -event_location_up -string_to_event_location (const char **stringp, - const struct language_defn *language, - symbol_name_match_type match_type) +location_spec_up +string_to_location_spec (const char **stringp, + const struct language_defn *language, + symbol_name_match_type match_type) { const char *arg, *orig; =20 - /* Try an explicit location. */ + /* Try an explicit location spec. */ orig =3D arg =3D *stringp; - event_location_up location =3D string_to_explicit_location (&arg, langua= ge, NULL); - if (location !=3D NULL) + location_spec_up locspec + =3D string_to_explicit_location_spec (&arg, language, NULL); + if (locspec !=3D nullptr) { /* It was a valid explicit location. Advance STRINGP to the end of input. */ *stringp +=3D arg - orig; =20 - /* If the user really specified a location, then we're done. */ - if (!event_location_empty_p (location.get ())) - return location; + /* If the user really specified a location spec, then we're + done. */ + if (!location_spec_empty_p (locspec.get ())) + return locspec; =20 /* Otherwise, the user _only_ specified optional flags like - "-qualified", otherwise string_to_explicit_location would - have thrown an error. Save the flags for "basic" linespec - parsing below and discard the explicit location. */ - event_location_explicit *xloc - =3D dynamic_cast (location.get ()); + "-qualified", otherwise string_to_explicit_location_spec + would have thrown an error. Save the flags for "basic" + linespec parsing below and discard the explicit location + spec. */ + explicit_location_spec *xloc + =3D dynamic_cast (locspec.get ()); gdb_assert (xloc !=3D nullptr); match_type =3D xloc->explicit_loc.func_name_match_type; } =20 - /* Everything else is a "basic" linespec, address, or probe - location. */ - return string_to_event_location_basic (stringp, language, match_type); + /* Everything else is a "basic" linespec, address, or probe location + spec. */ + return string_to_location_spec_basic (stringp, language, match_type); } =20 /* See description in location.h. */ =20 int -event_location_empty_p (const struct event_location *location) +location_spec_empty_p (const location_spec *locspec) { - return location->empty_p (); + return locspec->empty_p (); } =20 /* See description in location.h. */ =20 void -set_event_location_string (struct event_location *location, - std::string &&string) +set_location_spec_string (struct location_spec *locspec, + std::string &&string) { - location->as_string =3D std::move (string); + locspec->as_string =3D std::move (string); } diff --git a/gdb/location.h b/gdb/location.h index ff21c1c21cc..602998de298 100644 --- a/gdb/location.h +++ b/gdb/location.h @@ -1,4 +1,4 @@ -/* Data structures and API for event locations in GDB. +/* Data structures and API for location specs in GDB. Copyright (C) 2013-2022 Free Software Foundation, Inc. =20 This file is part of GDB. @@ -22,7 +22,7 @@ #include "symtab.h" =20 struct language_defn; -struct event_location; +struct location_spec; =20 /* An enumeration of possible signs for a line offset. */ =20 @@ -50,22 +50,21 @@ struct line_offset enum offset_relative_sign sign; }; =20 -/* An enumeration of the various ways to specify a stop event - location (used with create_breakpoint). */ +/* An enumeration of the various ways to specify a location spec. */ =20 -enum event_location_type +enum location_spec_type { /* A traditional linespec. */ - LINESPEC_LOCATION, + LINESPEC_LOCATION_SPEC, =20 - /* An address in the inferior. */ - ADDRESS_LOCATION, + /* An address location spec. */ + ADDRESS_LOCATION_SPEC, =20 - /* An explicit location. */ - EXPLICIT_LOCATION, + /* An explicit location spec. */ + EXPLICIT_LOCATION_SPEC, =20 - /* A probe location. */ - PROBE_LOCATION + /* A probe location spec. */ + PROBE_LOCATION_SPEC }; =20 /* A traditional linespec. */ @@ -79,7 +78,7 @@ struct linespec_location char *spec_string; }; =20 -/* An explicit location. This structure is used to bypass the +/* An explicit location spec. This structure is used to bypass the parsing done on linespecs. It still has the same requirements as linespecs, though. For example, source_filename requires at least one other field. */ @@ -104,136 +103,137 @@ struct explicit_location struct line_offset line_offset; }; =20 -/* Return the type of the given event location. */ +/* Return the type of the given location spec. */ =20 -extern enum event_location_type - event_location_type (const struct event_location *); +extern enum location_spec_type + location_spec_type (const location_spec *); =20 /* Return a linespec string representation of the given explicit - location. The location must already be canonicalized/valid. */ + location spec. The location spec must already be + canonicalized/valid. */ =20 -extern std::string - explicit_location_to_linespec (const struct explicit_location *explicit_= loc); +extern std::string explicit_location_to_linespec + (const explicit_location *explicit_locspec); =20 -/* Return a string representation of the LOCATION. +/* Return a string representation of LOCSPEC. This function may return NULL for unspecified linespecs, - e.g, LINESPEC_LOCATION and spec_string is NULL. + e.g, LINESPEC_LOCATION_SPEC and spec_string is NULL. =20 - The result is cached in LOCATION. */ + The result is cached in LOCSPEC. */ =20 extern const char * - event_location_to_string (struct event_location *location); + location_spec_to_string (location_spec *locspec); =20 -/* A deleter for a struct event_location. */ +/* A deleter for a struct location_spec. */ =20 -struct event_location_deleter +struct location_spec_deleter { - void operator() (event_location *location) const; + void operator() (location_spec *locspec) const; }; =20 -/* A unique pointer for event_location. */ -typedef std::unique_ptr - event_location_up; +/* A unique pointer for location_spec. */ +typedef std::unique_ptr + location_spec_up; =20 -/* Create a new linespec location. */ +/* Create a new linespec location spec. */ =20 -extern event_location_up new_linespec_location +extern location_spec_up new_linespec_location_spec (const char **linespec, symbol_name_match_type match_type); =20 -/* Return the linespec location of the given event_location (which - must be of type LINESPEC_LOCATION). */ +/* Return the linespec location spec of the given location_spec (which + must be of type LINESPEC_LOCATION_SPEC). */ =20 extern const linespec_location * - get_linespec_location (const struct event_location *location); + get_linespec_location (const location_spec *locspec); =20 -/* Create a new address location. - ADDR is the address corresponding to this event_location. +/* Create a new address location spec. + ADDR is the address corresponding to this location_spec. ADDR_STRING, a string of ADDR_STRING_LEN characters, is the expression that was parsed to determine the address ADDR. */ =20 -extern event_location_up new_address_location (CORE_ADDR addr, - const char *addr_string, - int addr_string_len); +extern location_spec_up new_address_location_spec (CORE_ADDR addr, + const char *addr_string, + int addr_string_len); =20 -/* Return the address location (a CORE_ADDR) of the given event_location - (which must be of type ADDRESS_LOCATION). */ +/* Return the address (a CORE_ADDR) of the given location_spec, which + must be of type ADDRESS_LOCATION_SPEC. */ =20 extern CORE_ADDR - get_address_location (const struct event_location *location); + get_address_location (const location_spec *locspec); =20 -/* Return the expression (a string) that was used to compute the address - of the given event_location (which must be of type ADDRESS_LOCATION). = */ +/* Return the expression (a string) that was used to compute the + address of the given location_spec, which must be of type + ADDRESS_LOCATION_SPEC. */ =20 extern const char * - get_address_string_location (const struct event_location *location); + get_address_string_location (const location_spec *locspec); =20 /* Create a new probe location. */ =20 -extern event_location_up new_probe_location (std::string &&probe); +extern location_spec_up new_probe_location_spec (std::string &&probe); =20 -/* Return the probe location (a string) of the given event_location - (which must be of type PROBE_LOCATION). */ +/* Return the probe location spec string of the given location_spec, + which must be of type PROBE_LOCATION_SPEC. */ =20 extern const char * - get_probe_location (const struct event_location *location); + get_probe_location_spec_string (const location_spec *locspec); =20 /* Initialize the given explicit location. */ =20 extern void - initialize_explicit_location (struct explicit_location *explicit_loc); + initialize_explicit_location (explicit_location *locspec); =20 /* Create a new explicit location. If not NULL, EXPLICIT is checked for validity. If invalid, an exception is thrown. */ =20 -extern event_location_up - new_explicit_location (const struct explicit_location *explicit_loc); +extern location_spec_up + new_explicit_location_spec (const explicit_location *locspec); =20 -/* Return the explicit location of the given event_location - (which must be of type EXPLICIT_LOCATION). */ +/* Return the explicit location spec of the given location_spec, which + must be of type EXPLICIT_LOCATION. */ =20 extern struct explicit_location * - get_explicit_location (struct event_location *location); + get_explicit_location (location_spec *locspec); =20 /* A const version of the above. */ =20 -extern const struct explicit_location * - get_explicit_location_const (const struct event_location *location); +extern const explicit_location * + get_explicit_location_const (const location_spec *locspec); =20 -/* Return a copy of the given SRC location. */ +/* Return a copy of the given SRC location spec. */ =20 -extern event_location_up - copy_event_location (const struct event_location *src); +extern location_spec_up copy_location_spec (const location_spec *src); =20 -/* Attempt to convert the input string in *ARGP into an event_location. +/* Attempt to convert the input string in *ARGP into a location_spec. ARGP is advanced past any processed input. Always returns a non-nullptr - event_location unique pointer object. + location_spec unique pointer object. =20 This function may call error() if *ARGP looks like properly formed, but invalid, input, e.g., if it is called with missing argument parameters or invalid options. =20 This function is intended to be used by CLI commands and will parse - explicit locations in a CLI-centric way. Other interfaces should use - string_to_event_location_basic if they want to maintain support for - legacy specifications of probe, address, and linespec locations. + explicit location specs in a CLI-centric way. Other interfaces should = use + string_to_location_spec_basic if they want to maintain support for + legacy specifications of probe, address, and linespec location specs. =20 MATCH_TYPE should be either WILD or FULL. If -q/--qualified is specifi= ed in the input string, it will take precedence over this parameter. */ =20 -extern event_location_up string_to_event_location +extern location_spec_up string_to_location_spec (const char **argp, const struct language_defn *language, symbol_name_match_type match_type =3D symbol_name_match_type::WILD); =20 -/* Like string_to_event_location, but does not attempt to parse - explicit locations. MATCH_TYPE indicates how function names should - be matched. */ +/* Like string_to_location_spec, but does not attempt to parse + explicit location specs. MATCH_TYPE indicates how function names + should be matched. */ =20 -extern event_location_up - string_to_event_location_basic (const char **argp, - const struct language_defn *language, - symbol_name_match_type match_type); +extern location_spec_up + string_to_location_spec_basic (const char **argp, + const struct language_defn *language, + symbol_name_match_type match_type); =20 -/* Structure filled in by string_to_explicit_location to aid the +/* Structure filled in by string_to_explicit_location_spec to aid the completer. */ struct explicit_completion_info { @@ -249,35 +249,34 @@ struct explicit_completion_info const char *quoted_ar[...] [diff truncated at 100000 bytes]