From: Pedro Alves Date: Mon, 23 May 2022 19:15:18 +0000 (+0100) Subject: event_location -> location_spec X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=264f98902f27497f7494933628b0f5c4e117fe59;p=binutils-gdb.git event_location -> location_spec 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: breakpoint::location; breakpoint::loc; "location" is the location spec, and "loc" is the resolved locations. And then, we have a method called "locations()", which returns the resolved locations as range... The location spec type is presently called event_location: /* Location we used to set the breakpoint. */ event_location_up location; and it is described like this: /* The base class for all an event locations used to set a stop event in the inferior. */ struct event_location { 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. 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. Change-Id: I5814124798aa2b2003e79496e78f95c74e5eddca --- 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 enable_state = enabled ? bp_enabled : bp_disabled; disposition = tempflag ? disp_del : disp_donttouch; - location = string_to_event_location (&addr_string_, - language_def (language_ada)); + locspec = string_to_location_spec (&addr_string_, + language_def (language_ada)); language = language_ada; } 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; - event_location_up location - = new_linespec_location (&exp, symbol_name_match_type::WILD); - decode_line_full (location.get (), DECODE_LINE_FUNFIRSTLINE, NULL, + location_spec_up locspec + = 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 = 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 - = new_probe_location (exception_functions[kind].probe); - sals = parse_probes (location.get (), filter_pspace, NULL); + location_spec_up locspec + = new_probe_location_spec (exception_functions[kind].probe); + sals = 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 = ASTRDUP (exception_functions[kind].function); - event_location_up location = new_explicit_location (&explicit_loc); - sals = this->decode_location (location.get (), filter_pspace); + location_spec_up locspec = new_explicit_location_spec (&explicit_loc); + sals = 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 *); 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); 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); -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); static int can_use_hardware_watchpoint @@ -159,9 +159,9 @@ static void enable_breakpoint_disp (struct breakpoint *, enum bpdisp, static void decref_bp_location (struct bp_location **loc); -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); static bool bl_address_is_meaningful (bp_location *loc); @@ -218,30 +218,30 @@ static bool is_masked_watchpoint (const struct breakpoint *b); static int strace_marker_p (struct breakpoint *b); -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); const struct breakpoint_ops code_breakpoint_ops = { - create_sals_from_location_default, + create_sals_from_location_spec_default, create_breakpoints_sal, }; /* Breakpoints set on probes. */ static const struct breakpoint_ops bkpt_probe_breakpoint_ops = { - bkpt_probe_create_sals_from_location, + bkpt_probe_create_sals_from_location_spec, create_breakpoints_sal, }; /* Tracepoints set on probes. */ static const struct breakpoint_ops tracepoint_probe_breakpoint_ops = { - tracepoint_probe_create_sals_from_location, + tracepoint_probe_create_sals_from_location_spec, create_breakpoints_sal, }; @@ -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 = add_location (sal_start); @@ -360,8 +360,8 @@ struct ranged_breakpoint : public ordinary_breakpoint disposition = disp_donttouch; - location = std::move (start_location); - location_range_end = std::move (end_location); + locspec = std::move (start_locspec); + locspec_range_end = std::move (end_locspec); } int breakpoint_hit (const struct bp_location *bl, @@ -381,8 +381,8 @@ struct static_marker_tracepoint : public tracepoint { using tracepoint::tracepoint; - std::vector decode_location - (struct event_location *location, + std::vector decode_location_spec + (struct location_spec *locspec, struct program_space *search_pspace) override; }; @@ -3390,7 +3390,7 @@ create_overlay_event_breakpoint (void) bp_overlay_event); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->locspec = new_explicit_location_spec (&explicit_loc); if (overlay_debugging == ovly_auto) { @@ -3447,7 +3447,7 @@ create_longjmp_master_breakpoint_probe (objfile *objfile) b = create_internal_breakpoint (gdbarch, p->get_relocated_address (objfile), bp_longjmp_master); - b->location = new_probe_location ("-probe-stap libc:longjmp"); + b->locspec = new_probe_location_spec ("-probe-stap libc:longjmp"); b->enable_state = bp_disabled; } @@ -3497,7 +3497,7 @@ create_longjmp_master_breakpoint_names (objfile *objfile) b = create_internal_breakpoint (gdbarch, addr, bp_longjmp_master); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->locspec = new_explicit_location_spec (&explicit_loc); b->enable_state = 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 = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->locspec = new_explicit_location_spec (&explicit_loc); b->enable_state = bp_disabled; } } @@ -3630,7 +3630,7 @@ create_exception_master_breakpoint_probe (objfile *objfile) b = create_internal_breakpoint (gdbarch, p->get_relocated_address (objfile), bp_exception_master); - b->location = new_probe_location ("-probe-stap libgcc:unwind"); + b->locspec = new_probe_location_spec ("-probe-stap libgcc:unwind"); b->enable_state = bp_disabled; } @@ -3677,7 +3677,7 @@ create_exception_master_breakpoint_hook (objfile *objfile) b = create_internal_breakpoint (gdbarch, addr, bp_exception_master); initialize_explicit_location (&explicit_loc); explicit_loc.function_name = ASTRDUP (func_name); - b->location = new_explicit_location (&explicit_loc); + b->locspec = new_explicit_location_spec (&explicit_loc); b->enable_state = bp_disabled; return true; @@ -3709,9 +3709,10 @@ create_exception_master_breakpoint (void) /* Does B have a location spec? */ static int -breakpoint_event_location_empty_p (const struct breakpoint *b) +breakpoint_location_spec_empty_p (const struct breakpoint *b) { - return b->location != NULL && event_location_empty_p (b->location.get ()); + return (b->locspec != nullptr + && location_spec_empty_p (b->locspec.get ())); } 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); 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 = 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, uiout->field_string ("original-location", w->exp_string.get ()); } - else if (b->location != NULL - && event_location_to_string (b->location.get ()) != NULL) - uiout->field_string ("original-location", - event_location_to_string (b->location.get ())); + else if (b->locspec != nullptr) + { + const char *str = location_spec_to_string (b->locspec.get ()); + if (str != nullptr) + uiout->field_string ("original-location", str); + } } return result; @@ -7534,8 +7538,8 @@ create_thread_event_breakpoint (struct gdbarch *gdbarch, CORE_ADDR address) b = create_internal_breakpoint (gdbarch, address, bp_thread_event); b->enable_state = bp_enabled; - /* location has to be used or breakpoint_re_set will delete me. */ - b->location = new_address_location (b->loc->address, NULL, 0); + /* locspec has to be used or breakpoint_re_set will delete me. */ + b->locspec = new_address_location_spec (b->loc->address, NULL, 0); update_global_location_list_nothrow (UGLL_MAY_INSERT); @@ -8243,7 +8247,7 @@ update_dprintf_commands (const char *args, int from_tty, 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 *gdbarch_, { /* We already know the marker exists, otherwise, we wouldn't see a sal for it. */ - const char *p = &event_location_to_string (location_.get ())[3]; + const char *p = &location_spec_to_string (locspec_.get ())[3]; const char *endp; p = skip_spaces (p); @@ -8360,17 +8364,17 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_, } display_canonical = display_canonical_; - if (location_ != nullptr) - location = std::move (location_); + if (locspec_ != nullptr) + locspec = std::move (locspec_); else - location = new_address_location (this->loc->address, NULL, 0); + locspec = new_address_location_spec (this->loc->address, NULL, 0); filter = std::move (filter_); } 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, = 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 - = (canonical->location != NULL - ? copy_event_location (canonical->location.get ()) : NULL); + location_spec_up locspec + = (canonical->locspec != NULL + ? copy_location_spec (canonical->locspec.get ()) : NULL); gdb::unique_xmalloc_ptr filter_string (lsal.canonical != NULL ? xstrdup (lsal.canonical) : NULL); 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, } } -/* 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). The array and the line spec strings are allocated on the heap, it is the caller's responsibility to free them. */ static void -parse_breakpoint_sals (struct event_location *location, +parse_breakpoint_sals (location_spec *locspec, struct linespec_result *canonical) { struct symtab_and_line cursal; - if (event_location_type (location) == LINESPEC_LOCATION) + if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) { - const char *spec = get_linespec_location (location)->spec_string; + const char *spec = get_linespec_location (locspec)->spec_string; if (spec == NULL) { @@ -8513,15 +8517,15 @@ parse_breakpoint_sals (struct event_location *location, { const char *spec = NULL; - if (event_location_type (location) == LINESPEC_LOCATION) - spec = get_linespec_location (location)->spec_string; + if (location_spec_type (locspec) == LINESPEC_LOCATION_SPEC) + spec = get_linespec_location (locspec)->spec_string; if (!cursal.symtab || (spec != NULL && strchr ("+-", spec[0]) != NULL && spec[1] != '[')) { - 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 *location, } } - decode_line_full (location, DECODE_LINE_FUNFIRSTLINE, NULL, + decode_line_full (locspec, DECODE_LINE_FUNFIRSTLINE, NULL, cursal.symtab, cursal.line, canonical, NULL, NULL); } @@ -8749,19 +8753,19 @@ decode_static_tracepoint_spec (const char **arg_p) according to IS_TRACEPOINT. */ 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_type, + bool is_tracepoint) { if (is_tracepoint) { - if (location_type == PROBE_LOCATION) + if (locspec_type == PROBE_LOCATION_SPEC) return &tracepoint_probe_breakpoint_ops; else return &code_breakpoint_ops; } else { - if (location_type == PROBE_LOCATION) + if (locspec_type == 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. */ 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 != nullptr) - return breakpoint_ops_for_event_location_type - (event_location_type (location), is_tracepoint); + if (locspec != nullptr) + return (breakpoint_ops_for_location_spec_type + (location_spec_type (locspec), is_tracepoint)); return &code_breakpoint_ops; } @@ -8784,7 +8788,7 @@ breakpoint_ops_for_event_location (const struct event_location *location, 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, 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 = new_breakpoint_from_type (gdbarch, type_wanted); - b->location = copy_event_location (location); + b->locspec = copy_location_spec (locspec); if (parse_extra) b->cond_string = NULL; @@ -8987,12 +8991,13 @@ break_command_1 (const char *arg, int flag, int from_tty) ? bp_hardware_breakpoint : bp_breakpoint); - event_location_up location = string_to_event_location (&arg, current_language); - const struct breakpoint_ops *ops = breakpoint_ops_for_event_location - (location.get (), false /* is_tracepoint */); + location_spec_up locspec = string_to_location_spec (&arg, current_language); + const struct breakpoint_ops *ops + = breakpoint_ops_for_location_spec (locspec.get (), + false /* is_tracepoint */); 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 = string_to_event_location (&arg, current_language); + location_spec_up locspec = string_to_location_spec (&arg, current_language); /* 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) } 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); } @@ -9312,9 +9317,9 @@ break_range_command (const char *arg, int from_tty) error(_("No address range specified.")); arg_start = arg; - event_location_up start_location = string_to_event_location (&arg, - current_language); - parse_breakpoint_sals (start_location.get (), &canonical_start); + location_spec_up start_locspec + = string_to_location_spec (&arg, current_language); + parse_breakpoint_sals (start_locspec.get (), &canonical_start); if (arg[0] != ',') error (_("Too few arguments.")); @@ -9333,18 +9338,19 @@ break_range_command (const char *arg, int from_tty) arg++; /* Skip the comma. */ arg = skip_spaces (arg); - /* Parse the end location. */ + /* Parse the end location specification. */ arg_start = arg; /* 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 = 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 + = 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); @@ -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))); install_breakpoint (false, std::move (br), true); } @@ -10447,14 +10453,14 @@ until_break_command (const char *arg, int from_tty, int anywhere) /* Set a breakpoint where the user wants it and at return from this function. */ - event_location_up location = string_to_event_location (&arg, current_language); + location_spec_up locspec = string_to_location_spec (&arg, current_language); std::vector sals = (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)); if (sals.empty ()) @@ -11360,18 +11366,18 @@ say_where (const breakpoint *b) if (b->extra_string == NULL) { gdb_printf (_(" (%s) pending."), - event_location_to_string (b->location.get ())); + location_spec_to_string (b->locspec.get ())); } else if (b->type == 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 ())); } if (b->loc->next) @@ -11477,8 +11483,8 @@ breakpoint::print_recreate (struct ui_file *fp) const } 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); - gdb_printf (fp, " %s", event_location_to_string (location.get ())); + gdb_printf (fp, " %s", location_spec_to_string (locspec.get ())); /* 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_file *fp) const } 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) == PROBE_LOCATION) - return bkpt_probe_decode_location (this, location, search_pspace); + if (location_spec_type (locspec) == PROBE_LOCATION_SPEC) + return bkpt_probe_decode_location_spec (this, locspec, search_pspace); - return decode_location_default (this, location, search_pspace); + return decode_location_spec_default (this, locspec, search_pspace); } /* Virtual table for internal breakpoints. */ @@ -11821,24 +11827,25 @@ longjmp_breakpoint::~longjmp_breakpoint () } 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) { struct linespec_sals lsal; - lsal.sals = parse_probes (location, NULL, canonical); + lsal.sals = parse_probes (locspec, NULL, canonical); lsal.canonical - = xstrdup (event_location_to_string (canonical->location.get ())); + = xstrdup (location_spec_to_string (canonical->locspec.get ())); canonical->lsals.push_back (std::move (lsal)); } 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 = parse_probes (location, search_pspace, NULL); + std::vector sals + = 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) const internal_error (__FILE__, __LINE__, _("unhandled tracepoint type %d"), (int) type); - gdb_printf (fp, " %s", event_location_to_string (location.get ())); + gdb_printf (fp, " %s", location_spec_to_string (locspec.get ())); print_recreate_thread (fp); if (pass_count) @@ -11921,12 +11928,12 @@ tracepoint::print_recreate (struct ui_file *fp) const /* Virtual table for tracepoints on static probes. */ 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); } 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'). */ 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; - arg = arg_start = get_linespec_location (location)->spec_string; + arg = arg_start = get_linespec_location (locspec)->spec_string; lsal.sals = decode_static_tracepoint_spec (&arg); std::string str (arg_start, arg - arg_start); const char *ptr = str.c_str (); - canonical->location - = new_linespec_location (&ptr, symbol_name_match_type::FULL); + canonical->locspec + = new_linespec_location_spec (&ptr, symbol_name_match_type::FULL); lsal.canonical - = xstrdup (event_location_to_string (canonical->location.get ())); + = xstrdup (location_spec_to_string (canonical->locspec.get ())); canonical->lsals.push_back (std::move (lsal)); } @@ -12034,14 +12041,14 @@ strace_marker_create_breakpoints_sal (struct gdbarch *gdbarch, for (size_t i = 0; i < lsal.sals.size (); i++) { - event_location_up location - = copy_event_location (canonical->location.get ()); + location_spec_up locspec + = copy_location_spec (canonical->locspec.get ()); 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 gdbarch *gdbarch, } 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 = get_linespec_location (location)->spec_string; + const char *s = get_linespec_location (locspec)->spec_string; std::vector sals = decode_static_tracepoint_spec (&s); if (sals.size () > static_trace_marker_id_idx) @@ -12082,7 +12089,7 @@ static_marker_tracepoint::decode_location (struct event_location *location, /* Static tracepoints with marker (`-m'). */ static struct breakpoint_ops strace_marker_breakpoint_ops = { - strace_marker_create_sals_from_location, + strace_marker_create_sals_from_location_spec, strace_marker_create_breakpoints_sal, }; @@ -12411,13 +12418,13 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal) b->loc->line_number = sal2.line; b->loc->symtab = sym != NULL ? sal2.symtab : NULL; - b->location.reset (NULL); + b->locspec.reset (nullptr); initialize_explicit_location (&explicit_loc); explicit_loc.source_filename = ASTRDUP (symtab_to_filename_for_display (sal2.symtab)); explicit_loc.line_offset.offset = b->loc->line_number; explicit_loc.line_offset.sign = LINE_OFFSET_NONE; - b->location = new_explicit_location (&explicit_loc); + b->locspec = new_explicit_location_spec (&explicit_loc); /* 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); } -/* 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. */ 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; @@ -12633,7 +12640,7 @@ location_to_sals (struct breakpoint *b, struct event_location *location, try { - sals = b->decode_location (location, search_pspace); + sals = 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; int found; - std::vector sals = location_to_sals (b, b->location.get (), - filter_pspace, &found); + std::vector sals + = location_spec_to_sals (b, b->locspec.get (), filter_pspace, &found); if (found) expanded = std::move (sals); - if (b->location_range_end != NULL) + if (b->locspec_range_end != nullptr) { std::vector sals_end - = location_to_sals (b, b->location_range_end.get (), - filter_pspace, &found); + = location_spec_to_sals (b, b->locspec_range_end.get (), + filter_pspace, &found); if (found) expanded_end = 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. */ 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); } /* Decode the line represented by S by calling decode_line_full. This is the default function for the `decode_location' method of breakpoint_ops. */ 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; - 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 ()); @@ -13510,13 +13517,13 @@ set_tracepoint_count (int num) static void trace_command (const char *arg, int from_tty) { - event_location_up location = string_to_event_location (&arg, - current_language); - const struct breakpoint_ops *ops = breakpoint_ops_for_event_location - (location.get (), true /* is_tracepoint */); + location_spec_up locspec = string_to_location_spec (&arg, + current_language); + const struct breakpoint_ops *ops = breakpoint_ops_for_location_spec + (locspec.get (), true /* is_tracepoint */); 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 = string_to_event_location (&arg, - current_language); + location_spec_up locspec = 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; /* 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 = &strace_marker_breakpoint_ops; - location = new_linespec_location (&arg, symbol_name_match_type::FULL); + locspec = new_linespec_location_spec (&arg, + symbol_name_match_type::FULL); type = bp_static_marker_tracepoint; } else { ops = &code_breakpoint_ops; - location = string_to_event_location (&arg, current_language); + locspec = string_to_location_spec (&arg, current_language); type = bp_static_tracepoint; } 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); - event_location_up location = string_to_event_location (&addr_str, - current_language); + location_spec_up locspec = 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 from_tty) /* This help string is used to consolidate all the help string for specifying locations used by several commands. */ -#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 location as described below.\n\ \n\ With no argument, clears all breakpoints in the line that the selected frame\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); @@ -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); 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 = NULL; /* 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 = NULL; @@ -562,14 +562,15 @@ enum print_stop_action struct breakpoint_ops { - /* Create SALs from location, storing the result in linespec_result. + /* Create SALs from location spec, storing the result in + linespec_result. For an explanation about the arguments, see the function - `create_sals_from_location_default'. + `create_sals_from_location_spec_default'. 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); /* This method will be responsible for creating a breakpoint given its SALs. 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; - /* 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. - 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); /* 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 = NULL; - /* Location we used to set the breakpoint. */ - event_location_up location; + /* The location specification we used to set the breakpoint. */ + location_spec_up locspec; /* The filter that should be passed to decode_line_full when re-setting this breakpoint. This may be NULL. */ gdb::unique_xmalloc_ptr filter; - /* 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; /* 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; }; @@ -1460,13 +1461,14 @@ extern void extern void install_breakpoint (int internal, std::unique_ptr &&b, int update_gll); -/* 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. */ -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); /* 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 = 1 << 0 }; -/* 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. This function has two major modes of operations, selected by the PARSE_EXTRA parameter. - 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. 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. */ 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) /* Now should only be one argument -- decode it in SAL. */ arg1 = arg; - event_location_up location = string_to_event_location (&arg1, - current_language); + location_spec_up locspec = string_to_location_spec (&arg1, + current_language); if (*arg1) error (_("Junk at end of line specification.")); - std::vector sals = decode_line_1 (location.get (), + std::vector sals = decode_line_1 (locspec.get (), DECODE_LINE_LIST_MODE, NULL, NULL, 0); @@ -1241,18 +1241,18 @@ list_command (const char *arg, int from_tty) dummy_beg = 1; else { - event_location_up location = 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 + = 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 == arg) error (_("Junk at end of line specification.")); - sals = decode_line_1 (location.get (), DECODE_LINE_LIST_MODE, + sals = 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 = arg1; - event_location_up location - = string_to_event_location (&arg1, current_language); + location_spec_up locspec + = string_to_location_spec (&arg1, current_language); if (*arg1) error (_("Junk at end of line specification.")); std::vector sals_end = (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)); 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) 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 - = get_explicit_location (location); + = get_explicit_location (locspec); /* True if the option expects an argument. */ bool needs_arg = true; @@ -846,19 +846,19 @@ skip_keyword (completion_tracker &tracker, return -1; } -/* 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. */ 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 != '-') return; @@ -916,7 +916,7 @@ complete_explicit_location (completion_tracker &tracker, } /* 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 = text; explicit_completion_info completion_info; - event_location_up location - = string_to_explicit_location (©, current_language, - &completion_info); + location_spec_up locspec + = string_to_explicit_location_spec (©, current_language, + &completion_info); if (completion_info.quoted_arg_start != NULL && completion_info.quoted_arg_end == NULL) { @@ -954,7 +954,7 @@ location_completer (struct cmd_list_element *ignore, tracker.advance_custom_word_point_by (1); } - if (completion_info.saw_explicit_location_option) + if (completion_info.saw_explicit_location_spec_option) { if (*copy != '\0') { @@ -987,15 +987,15 @@ location_completer (struct cmd_list_element *ignore, - text); text = completion_info.last_option; - 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); } } /* This is an address or linespec location. */ - else if (location != NULL) + else if (locspec != nullptr) { /* Handle non-explicit location options. */ @@ -1008,7 +1008,7 @@ location_completer (struct cmd_list_element *ignore, text = copy; symbol_name_match_type match_type - = get_explicit_location (location.get ())->func_name_match_type; + = 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 = gdbarch_addr_bits_remove (gdbarch, resolved_pc); gdb_assert (current_program_space == b->pspace || b->pspace == NULL); - elf_gnu_ifunc_record_cache (event_location_to_string (b->location.get ()), - resolved_pc); + const char *locspec_str = location_spec_to_string (b->locspec.get ()); + elf_gnu_ifunc_record_cache (locspec_str, resolved_pc); b->type = 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_print_state *pstate) gdbscm_printf (port, " hit:%d", b->hit_count); gdbscm_printf (port, " ignore:%d", b->ignore_count); - if (b->location != nullptr) + if (b->locspec != nullptr) { - const char *str = event_location_to_string (b->location.get ()); + const char *str = location_spec_to_string (b->locspec.get ()); if (str != nullptr) gdbscm_printf (port, " @%s", str); } @@ -448,10 +448,10 @@ gdbscm_register_breakpoint_x (SCM self) pending_breakpoint_scm = self; location = bp_smob->spec.location; copy = skip_spaces (location); - event_location_up eloc - = string_to_event_location_basic (©, - current_language, - symbol_name_match_type::WILD); + location_spec_up locspec + = string_to_location_spec_basic (©, + current_language, + symbol_name_match_type::WILD); try { @@ -463,9 +463,9 @@ gdbscm_register_breakpoint_x (SCM self) case bp_breakpoint: { const breakpoint_ops *ops = - 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 = bpscm_get_valid_breakpoint_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); - const char *str; if (bp_smob->bp->type != bp_breakpoint) return SCM_BOOL_F; - str = event_location_to_string (bp_smob->bp->location.get ()); - if (! str) + const char *str + = location_spec_to_string (bp_smob->bp->locspec.get ()); + if (str == nullptr) str = ""; 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; /* If canonicalization was not requested, no need to do anything. */ @@ -1998,9 +1998,9 @@ canonicalize_linespec (struct linespec_state *state, const linespec *ls) return; /* Save everything as an explicit location. */ - state->canonical->location - = new_explicit_location (&ls->explicit_loc); - canon = state->canonical->location.get (); + state->canonical->locspec + = new_explicit_location_spec (&ls->explicit_loc); + canon = state->canonical->locspec.get (); explicit_loc = get_explicit_location (canon); if (explicit_loc->label_name != 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)); } /* Given a line offset in LS, construct the relevant SALs. */ @@ -3061,22 +3061,22 @@ linespec_complete (completion_tracker &tracker, const char *text, } /* A helper function for decode_line_full and decode_line_1 to - turn LOCATION into std::vector. */ + turn LOCSPEC into std::vector. */ 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; - switch (event_location_type (location)) + switch (location_spec_type (locspec)) { - case LINESPEC_LOCATION: + case LINESPEC_LOCATION_SPEC: { PARSER_STATE (parser)->is_linespec = 1; try { - const linespec_location *ls = get_linespec_location (location); + const linespec_location *ls = get_linespec_location (locspec); result = parse_linespec (parser, ls->spec_string, ls->match_type); } @@ -3087,17 +3087,17 @@ event_location_to_sals (linespec_parser *parser, } break; - case ADDRESS_LOCATION: + case ADDRESS_LOCATION_SPEC: { - const char *addr_string = get_address_string_location (location); - CORE_ADDR addr = get_address_location (location); + const char *addr_string = get_address_string_location (locspec); + CORE_ADDR addr = get_address_location (locspec); if (addr_string != NULL) { addr = linespec_expression_to_pc (&addr_string); if (PARSER_STATE (parser)->canonical != NULL) - PARSER_STATE (parser)->canonical->location - = copy_event_location (location); + PARSER_STATE (parser)->canonical->locspec + = copy_location_spec (locspec); } result = convert_address_location_to_sals (PARSER_STATE (parser), @@ -3105,24 +3105,24 @@ event_location_to_sals (linespec_parser *parser, } break; - case EXPLICIT_LOCATION: + case EXPLICIT_LOCATION_SPEC: { const struct explicit_location *explicit_loc; - explicit_loc = get_explicit_location_const (location); + explicit_loc = get_explicit_location_const (locspec); result = convert_explicit_location_to_sals (PARSER_STATE (parser), PARSER_RESULT (parser), explicit_loc); } break; - case PROBE_LOCATION: + case PROBE_LOCATION_SPEC: /* Probes are handled by their own decoders. */ gdb_assert_not_reached ("attempt to decode probe location"); break; default: - gdb_assert_not_reached ("unhandled event location type"); + gdb_assert_not_reached ("unhandled location spec type"); } return result; @@ -3131,7 +3131,7 @@ event_location_to_sals (linespec_parser *parser, /* See linespec.h. */ 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, scoped_restore_current_program_space restore_pspace; - std::vector result = event_location_to_sals (&parser, - location); + std::vector result = location_spec_to_sals (&parser, + locspec); state = PARSER_STATE (&parser); if (result.size () == 0) throw_error (NOT_SUPPORTED_ERROR, _("Location %s not available"), - event_location_to_string (location)); + location_spec_to_string (locspec)); gdb_assert (result.size () == 1 || canonical->pre_expanded); canonical->pre_expanded = 1; @@ -3200,7 +3200,7 @@ decode_line_full (struct event_location *location, int flags, /* See linespec.h. */ 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, scoped_restore_current_program_space restore_pspace; - return event_location_to_sals (&parser, location); + return location_spec_to_sals (&parser, locspec); } /* 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 = get_current_source_symtab_and_line (); - event_location_up location = string_to_event_location (&string, - current_language); + location_spec_up locspec = string_to_location_spec (&string, + current_language); std::vector sals - = decode_line_1 (location.get (), flags, NULL, cursal.symtab, cursal.line); + = decode_line_1 (locspec.get (), flags, NULL, cursal.symtab, cursal.line); 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 == 0) error (_("Empty line specification.")); - event_location_up location = string_to_event_location (&string, - current_language); + location_spec_up locspec = string_to_location_spec (&string, + current_language); std::vector sals = (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)); if (*string) error (_("Junk at end of line specification: %s"), string); @@ -3364,8 +3364,8 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg) else str = saved_arg; - self->canonical->location - = new_linespec_location (&str, symbol_name_match_type::FULL); + self->canonical->locspec + = new_linespec_location_spec (&str, symbol_name_match_type::FULL); } } 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 = false; - /* 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; /* 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. */ 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); -/* 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. @@ -124,7 +124,7 @@ extern std::vector strcmp sense) to FILTER will be returned; all others will be filtered out. */ -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. This file is part of GDB. @@ -32,17 +32,17 @@ static std::string explicit_location_to_string (const struct explicit_location *explicit_loc); -/* 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. */ -struct event_location +struct location_spec { - virtual ~event_location () = default; + virtual ~location_spec () = default; /* Clone this object. */ - virtual event_location_up clone () const = 0; + virtual location_spec_up clone () const = 0; - /* Return true if this location is empty, false otherwise. */ + /* Return true if this location spec is empty, false otherwise. */ virtual bool empty_p () const = 0; /* Return a string representation of this location. */ @@ -55,29 +55,29 @@ struct event_location return as_string.c_str (); } - DISABLE_COPY_AND_ASSIGN (event_location); + DISABLE_COPY_AND_ASSIGN (location_spec); - /* The type of this breakpoint specification. */ - enum event_location_type type; + /* The type of this location specification. */ + enum location_spec_type type; - /* 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; protected: - explicit event_location (enum event_location_type t) + explicit location_spec (enum location_spec_type t) : type (t) { } - 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)) { } - 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: }; /* 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)) { } - 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)); } bool empty_p () const override @@ -108,8 +108,8 @@ struct event_location_probe : public event_location protected: - 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) { } @@ -120,11 +120,11 @@ protected: }; /* 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 = match_type; if (*linespec != NULL) @@ -144,14 +144,14 @@ struct event_location_linespec : public event_location } } - ~event_location_linespec () + ~linespec_location_spec () { xfree (linespec_location.spec_string); } - 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)); } bool empty_p () const override @@ -163,8 +163,8 @@ struct event_location_linespec : public event_location protected: - explicit event_location_linespec (const event_location_linespec *to_clone) - : 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 != nullptr) @@ -186,20 +186,20 @@ protected: }; /* 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 != nullptr) as_string = std::string (addr_string, addr_string_len); } - 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)); } bool empty_p () const override @@ -211,8 +211,8 @@ struct event_location_address : public event_location protected: - 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: } }; -/* 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); } - ~event_location_explicit () + ~explicit_location_spec () { xfree (explicit_loc.source_filename); xfree (explicit_loc.function_name); xfree (explicit_loc.label_name); } - 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)); } bool empty_p () const override @@ -257,8 +257,8 @@ struct event_location_explicit : public event_location protected: - explicit event_location_explicit (const event_location_explicit *to_clone) - : 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: /* See description in location.h. */ -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; } /* See description in location.h. */ @@ -307,99 +307,99 @@ initialize_explicit_location (struct explicit_location *explicit_loc) /* See description in location.h. */ -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)); } /* See description in location.h. */ const linespec_location * -get_linespec_location (const struct event_location *location) +get_linespec_location (const location_spec *locspec) { - gdb_assert (location->type == LINESPEC_LOCATION); - return &((event_location_linespec *) location)->linespec_location; + gdb_assert (locspec->type == LINESPEC_LOCATION_SPEC); + return &((linespec_location_spec *) locspec)->linespec_location; } /* See description in location.h. */ -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)); } /* See description in location.h. */ CORE_ADDR -get_address_location (const struct event_location *location) +get_address_location (const location_spec *locspec) { - gdb_assert (location->type == ADDRESS_LOCATION); - return ((event_location_address *) location)->address; + gdb_assert (locspec->type == ADDRESS_LOCATION_SPEC); + return ((address_location_spec *) locspec)->address; } /* See description in location.h. */ const char * -get_address_string_location (const struct event_location *location) +get_address_string_location (const location_spec *locspec) { - gdb_assert (location->type == ADDRESS_LOCATION); - return location->to_string (); + gdb_assert (locspec->type == ADDRESS_LOCATION_SPEC); + return locspec->to_string (); } /* See description in location.h. */ -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))); } /* See description in location.h. */ const char * -get_probe_location (const struct event_location *location) +get_probe_location_spec_string (const location_spec *locspec) { - gdb_assert (location->type == PROBE_LOCATION); - return location->to_string (); + gdb_assert (locspec->type == PROBE_LOCATION_SPEC); + return locspec->to_string (); } /* See description in location.h. */ -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)); } /* See description in location.h. */ struct explicit_location * -get_explicit_location (struct event_location *location) +get_explicit_location (location_spec *locspec) { - gdb_assert (location->type == EXPLICIT_LOCATION); - return &((event_location_explicit *) location)->explicit_loc; + gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC); + return &((explicit_location_spec *) locspec)->explicit_loc; } /* See description in location.h. */ 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 == EXPLICIT_LOCATION); - return &((event_location_explicit *) location)->explicit_loc; + gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC); + return &((explicit_location_spec *) locspec)->explicit_loc; } -/* 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. - 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. */ static std::string explicit_to_string_internal (bool as_linespec, @@ -473,24 +473,24 @@ explicit_location_to_linespec (const struct explicit_location *explicit_loc) /* See description in location.h. */ -event_location_up -copy_event_location (const struct event_location *src) +location_spec_up +copy_location_spec (const location_spec *src) { return src->clone (); } void -event_location_deleter::operator() (event_location *location) const +location_spec_deleter::operator() (location_spec *locspec) const { - delete location; + delete locspec; } /* See description in location.h. */ 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 (); } /* 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; } -/* 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. */ 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 = *inp; @@ -630,7 +630,7 @@ is_cp_operator (const char *start, const char *comma) } /* 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; } -/* 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. */ 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 = *inp; @@ -771,10 +772,10 @@ explicit_location_lex_one_function (const char **inp, /* See description in location.h. */ -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] == '-' && (*argp)[1] == 'p')) return NULL; - std::unique_ptr location - (new event_location_explicit ((const explicit_location *) nullptr)); + std::unique_ptr locspec + (new explicit_location_spec ((const explicit_location *) nullptr)); /* Process option/argument pairs. dprintf_command requires that processing stop on ','. */ @@ -817,7 +818,7 @@ string_to_explicit_location (const char **argp, /* Get the option string. */ gdb::unique_xmalloc_ptr opt - = explicit_location_lex_one (argp, language, NULL); + = explicit_location_spec_lex_one (argp, language, NULL); /* Use the length of the option to allow abbreviations. */ len = 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 = true; + completion_info->saw_explicit_location_spec_option = true; } oarg = std::move (arg); have_oarg = oarg != NULL; @@ -854,36 +855,37 @@ string_to_explicit_location (const char **argp, if (strncmp (opt.get (), "-source", len) == 0) { - set_oarg (explicit_location_lex_one (argp, language, - completion_info)); - location->explicit_loc.source_filename = oarg.release (); + set_oarg (explicit_location_spec_lex_one (argp, language, + completion_info)); + locspec->explicit_loc.source_filename = oarg.release (); } else if (strncmp (opt.get (), "-function", len) == 0) { - set_oarg (explicit_location_lex_one_function (argp, language, - completion_info)); - location->explicit_loc.function_name = oarg.release (); + set_oarg (explicit_location_spec_lex_one_function (argp, language, + completion_info)); + locspec->explicit_loc.function_name = oarg.release (); } else if (strncmp (opt.get (), "-qualified", len) == 0) { - location->explicit_loc.func_name_match_type + locspec->explicit_loc.func_name_match_type = symbol_name_match_type::FULL; } else if (strncmp (opt.get (), "-line", len) == 0) { - set_oarg (explicit_location_lex_one (argp, language, NULL)); + set_oarg (explicit_location_spec_lex_one (argp, language, NULL)); *argp = skip_spaces (*argp); if (have_oarg) { - location->explicit_loc.line_offset + locspec->explicit_loc.line_offset = linespec_parse_line_offset (oarg.get ()); continue; } } else if (strncmp (opt.get (), "-label", len) == 0) { - set_oarg (explicit_location_lex_one (argp, language, completion_info)); - location->explicit_loc.label_name = oarg.release (); + set_oarg (explicit_location_spec_lex_one (argp, language, + completion_info)); + locspec->explicit_loc.label_name = 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, /* One special error check: If a source filename was given without offset, function, or label, issue an error. */ - if (location->explicit_loc.source_filename != NULL - && location->explicit_loc.function_name == NULL - && location->explicit_loc.label_name == NULL - && (location->explicit_loc.line_offset.sign == LINE_OFFSET_UNKNOWN) + if (locspec->explicit_loc.source_filename != NULL + && locspec->explicit_loc.function_name == NULL + && locspec->explicit_loc.label_name == NULL + && (locspec->explicit_loc.line_offset.sign == LINE_OFFSET_UNKNOWN) && completion_info == NULL) { error (_("Source filename requires function, label, or " "line offset.")); } - return event_location_up (location.release ()); + return location_spec_up (locspec.release ()); } /* See description in location.h. */ -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; /* Try the input as a probe spec. */ cs = *stringp; if (cs != NULL && probe_linespec_to_static_ops (&cs) != NULL) { - location = new_probe_location (*stringp); + locspec = new_probe_location_spec (*stringp); *stringp += strlen (*stringp); } else { - /* Try an address location. */ + /* Try an address location spec. */ if (*stringp != NULL && **stringp == '*') { const char *arg, *orig; @@ -953,69 +955,72 @@ string_to_event_location_basic (const char **stringp, orig = arg = *stringp; addr = linespec_expression_to_pc (&arg); - location = new_address_location (addr, orig, arg - orig); + locspec = new_address_location_spec (addr, orig, arg - orig); *stringp += arg - orig; } else { /* Everything else is a linespec. */ - location = new_linespec_location (stringp, match_type); + locspec = new_linespec_location_spec (stringp, match_type); } } - return location; + return locspec; } /* See description in location.h. */ -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; - /* Try an explicit location. */ + /* Try an explicit location spec. */ orig = arg = *stringp; - event_location_up location = string_to_explicit_location (&arg, language, NULL); - if (location != NULL) + location_spec_up locspec + = string_to_explicit_location_spec (&arg, language, NULL); + if (locspec != nullptr) { /* It was a valid explicit location. Advance STRINGP to the end of input. */ *stringp += arg - orig; - /* 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; /* 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 - = 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 + = dynamic_cast (locspec.get ()); gdb_assert (xloc != nullptr); match_type = xloc->explicit_loc.func_name_match_type; } - /* 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); } /* See description in location.h. */ 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 (); } /* See description in location.h. */ 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 = std::move (string); + locspec->as_string = 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. This file is part of GDB. @@ -22,7 +22,7 @@ #include "symtab.h" struct language_defn; -struct event_location; +struct location_spec; /* An enumeration of possible signs for a line offset. */ @@ -50,22 +50,21 @@ struct line_offset enum offset_relative_sign sign; }; -/* 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. */ -enum event_location_type +enum location_spec_type { /* A traditional linespec. */ - LINESPEC_LOCATION, + LINESPEC_LOCATION_SPEC, - /* An address in the inferior. */ - ADDRESS_LOCATION, + /* An address location spec. */ + ADDRESS_LOCATION_SPEC, - /* An explicit location. */ - EXPLICIT_LOCATION, + /* An explicit location spec. */ + EXPLICIT_LOCATION_SPEC, - /* A probe location. */ - PROBE_LOCATION + /* A probe location spec. */ + PROBE_LOCATION_SPEC }; /* A traditional linespec. */ @@ -79,7 +78,7 @@ struct linespec_location char *spec_string; }; -/* 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; }; -/* Return the type of the given event location. */ +/* Return the type of the given location spec. */ -extern enum event_location_type - event_location_type (const struct event_location *); +extern enum location_spec_type + location_spec_type (const location_spec *); /* 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. */ -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); -/* 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. - The result is cached in LOCATION. */ + The result is cached in LOCSPEC. */ extern const char * - event_location_to_string (struct event_location *location); + location_spec_to_string (location_spec *locspec); -/* A deleter for a struct event_location. */ +/* A deleter for a struct location_spec. */ -struct event_location_deleter +struct location_spec_deleter { - void operator() (event_location *location) const; + void operator() (location_spec *locspec) const; }; -/* 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; -/* Create a new linespec location. */ +/* Create a new linespec location spec. */ -extern event_location_up new_linespec_location +extern location_spec_up new_linespec_location_spec (const char **linespec, symbol_name_match_type match_type); -/* 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). */ extern const linespec_location * - get_linespec_location (const struct event_location *location); + get_linespec_location (const location_spec *locspec); -/* 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. */ -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); -/* 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. */ extern CORE_ADDR - get_address_location (const struct event_location *location); + get_address_location (const location_spec *locspec); -/* 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. */ extern const char * - get_address_string_location (const struct event_location *location); + get_address_string_location (const location_spec *locspec); /* Create a new probe location. */ -extern event_location_up new_probe_location (std::string &&probe); +extern location_spec_up new_probe_location_spec (std::string &&probe); -/* 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. */ extern const char * - get_probe_location (const struct event_location *location); + get_probe_location_spec_string (const location_spec *locspec); /* Initialize the given explicit location. */ extern void - initialize_explicit_location (struct explicit_location *explicit_loc); + initialize_explicit_location (explicit_location *locspec); /* Create a new explicit location. If not NULL, EXPLICIT is checked for validity. If invalid, an exception is thrown. */ -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); -/* 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. */ extern struct explicit_location * - get_explicit_location (struct event_location *location); + get_explicit_location (location_spec *locspec); /* A const version of the above. */ -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); -/* Return a copy of the given SRC location. */ +/* Return a copy of the given SRC location spec. */ -extern event_location_up - copy_event_location (const struct event_location *src); +extern location_spec_up copy_location_spec (const location_spec *src); -/* 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. 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. 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. MATCH_TYPE should be either WILD or FULL. If -q/--qualified is specified in the input string, it will take precedence over this parameter. */ -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 = symbol_name_match_type::WILD); -/* 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. */ -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); -/* 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_arg_start = NULL; const char *quoted_arg_end = NULL; - /* True if we saw an explicit location option, as opposed to only - flags that affect both explicit locations and linespecs, like - "-qualified". */ - bool saw_explicit_location_option = false; + /* True if we saw an explicit location spec option, as opposed to + only flags that affect both explicit location specs and + linespecs, like "-qualified". */ + bool saw_explicit_location_spec_option = false; }; -/* Attempt to convert the input string in *ARGP into an explicit location. - ARGP is advanced past any processed input. Returns an event_location - (malloc'd) if an explicit location was successfully found in *ARGP, - NULL otherwise. +/* Attempt to convert the input string in *ARGP into an explicit + location spec. ARGP is advanced past any processed input. Returns + a location_spec (malloc'd) if an explicit location spec was + successfully found in *ARGP, NULL otherwise. If COMPLETION_INFO is NULL, this function may call error() if *ARGP looks like improperly formed input, e.g., if it is called with missing argument parameters or invalid options. If COMPLETION_INFO is not NULL, this function will not throw any exceptions. */ -extern event_location_up - string_to_explicit_location (const char **argp, - const struct language_defn *language, - explicit_completion_info *completion_info); +extern location_spec_up + string_to_explicit_location_spec (const char **argp, + const struct language_defn *language, + explicit_completion_info *completion_info); -/* A convenience function for testing for unset locations. */ +/* A convenience function for testing for unset location specs. */ -extern int event_location_empty_p (const struct event_location *location); +extern int location_spec_empty_p (const location_spec *locspec); -/* Set the location's string representation. */ +/* Set the location specs's string representation. */ -extern void - set_event_location_string (struct event_location *location, - std::string &&string); +extern void set_location_spec_string (struct location_spec *locspec, + std::string &&string); #endif /* LOCATION_H */ diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index d4a7562b281..dab0a471abc 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -179,7 +179,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) int tracepoint = 0; symbol_name_match_type match_type = symbol_name_match_type::WILD; enum bptype type_wanted; - event_location_up location; + location_spec_up locspec; const struct breakpoint_ops *ops; int is_explicit = 0; struct explicit_location explicit_loc; @@ -322,7 +322,7 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) A simulator or an emulator could conceivably implement fast regular non-jump based tracepoints. */ type_wanted = hardware ? bp_fast_tracepoint : bp_tracepoint; - ops = breakpoint_ops_for_event_location (nullptr, true); + ops = breakpoint_ops_for_location_spec (nullptr, true); } else if (dprintf) { @@ -348,17 +348,17 @@ mi_cmd_break_insert_1 (int dprintf, const char *command, char **argv, int argc) explicit_loc.func_name_match_type = match_type; - location = new_explicit_location (&explicit_loc); + locspec = new_explicit_location_spec (&explicit_loc); } else { - location = string_to_event_location_basic (&address, current_language, - match_type); + locspec = string_to_location_spec_basic (&address, current_language, + match_type); if (*address) error (_("Garbage '%s' at end of location"), address); } - create_breakpoint (get_current_arch (), location.get (), condition, thread, + create_breakpoint (get_current_arch (), locspec.get (), condition, thread, extra_string.c_str (), force_condition, 0 /* condition and thread are valid. */, diff --git a/gdb/probe.c b/gdb/probe.c index f0a40f5face..0b056eb88db 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -114,7 +114,7 @@ parse_probes_in_pspace (const static_probe_ops *spops, /* See definition in probe.h. */ std::vector -parse_probes (const struct event_location *location, +parse_probes (const location_spec *locspec, struct program_space *search_pspace, struct linespec_result *canonical) { @@ -122,8 +122,8 @@ parse_probes (const struct event_location *location, char *objfile_namestr = NULL, *provider = NULL, *name, *p; const char *arg_start, *cs; - gdb_assert (event_location_type (location) == PROBE_LOCATION); - arg_start = get_probe_location (location); + gdb_assert (location_spec_type (locspec) == PROBE_LOCATION_SPEC); + arg_start = get_probe_location_spec_string (locspec); cs = arg_start; const static_probe_ops *spops = probe_linespec_to_static_ops (&cs); @@ -204,7 +204,7 @@ parse_probes (const struct event_location *location, std::string canon (arg_start, arg_end - arg_start); canonical->special_display = 1; canonical->pre_expanded = 1; - canonical->location = new_probe_location (std::move (canon)); + canonical->locspec = new_probe_location_spec (std::move (canon)); } return result; diff --git a/gdb/probe.h b/gdb/probe.h index 5fc4d22a6f4..fe933154663 100644 --- a/gdb/probe.h +++ b/gdb/probe.h @@ -22,7 +22,7 @@ #include "symtab.h" -struct event_location; +struct location_spec; struct linespec_result; /* Structure useful for passing the header names in the method @@ -263,7 +263,7 @@ struct bound_probe throws an error. */ extern std::vector parse_probes - (const struct event_location *loc, + (const location_spec *locspec, struct program_space *pspace, struct linespec_result *canon); diff --git a/gdb/python/py-breakpoint.c b/gdb/python/py-breakpoint.c index 74de0d90e23..029ced74136 100644 --- a/gdb/python/py-breakpoint.c +++ b/gdb/python/py-breakpoint.c @@ -412,8 +412,8 @@ bppy_get_location (PyObject *self, void *closure) && obj->bp->type != bp_hardware_breakpoint) Py_RETURN_NONE; - const char *str = event_location_to_string (obj->bp->location.get ()); - if (! str) + const char *str = location_spec_to_string (obj->bp->locspec.get ()); + if (str == nullptr) str = ""; return host_string_to_python_string (str).release (); } @@ -821,7 +821,7 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) case bp_breakpoint: case bp_hardware_breakpoint: { - event_location_up location; + location_spec_up locspec; symbol_name_match_type func_name_match_type = (qualified != NULL && PyObject_IsTrue (qualified) ? symbol_name_match_type::FULL @@ -833,9 +833,9 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) copy_holder (xstrdup (skip_spaces (spec))); const char *copy = copy_holder.get (); - location = string_to_event_location (©, - current_language, - func_name_match_type); + locspec = string_to_location_spec (©, + current_language, + func_name_match_type); } else { @@ -852,14 +852,14 @@ bppy_init (PyObject *self, PyObject *args, PyObject *kwargs) explicit_loc.func_name_match_type = func_name_match_type; - location = new_explicit_location (&explicit_loc); + locspec = new_explicit_location_spec (&explicit_loc); } - const struct breakpoint_ops *ops = - breakpoint_ops_for_event_location (location.get (), false); + const struct breakpoint_ops *ops + = breakpoint_ops_for_location_spec (locspec.get (), false); create_breakpoint (gdbpy_enter::get_gdbarch (), - location.get (), NULL, -1, NULL, false, + locspec.get (), NULL, -1, NULL, false, 0, temporary_bp, type, 0, diff --git a/gdb/python/py-finishbreakpoint.c b/gdb/python/py-finishbreakpoint.c index df54d3643ab..c80096f6810 100644 --- a/gdb/python/py-finishbreakpoint.c +++ b/gdb/python/py-finishbreakpoint.c @@ -296,10 +296,10 @@ bpfinishpy_init (PyObject *self, PyObject *args, PyObject *kwargs) try { /* Set a breakpoint on the return address. */ - event_location_up location - = new_address_location (get_frame_pc (prev_frame), NULL, 0); + location_spec_up locspec + = new_address_location_spec (get_frame_pc (prev_frame), NULL, 0); create_breakpoint (gdbpy_enter::get_gdbarch (), - location.get (), NULL, thread, NULL, false, + locspec.get (), NULL, thread, NULL, false, 0, 1 /*temp_flag*/, bp_breakpoint, diff --git a/gdb/python/python.c b/gdb/python/python.c index 7faad2bfa35..8f526bba84e 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -868,7 +868,7 @@ gdbpy_decode_line (PyObject *self, PyObject *args) const char *arg = NULL; gdbpy_ref<> result; gdbpy_ref<> unparsed; - event_location_up location; + location_spec_up locspec; if (! PyArg_ParseTuple (args, "|s", &arg)) return NULL; @@ -883,17 +883,17 @@ gdbpy_decode_line (PyObject *self, PyObject *args) } if (arg != NULL) - location = string_to_event_location_basic (&arg, current_language, - symbol_name_match_type::WILD); + locspec = string_to_location_spec_basic (&arg, current_language, + symbol_name_match_type::WILD); std::vector decoded_sals; symtab_and_line def_sal; gdb::array_view sals; try { - if (location != NULL) + if (locspec != NULL) { - decoded_sals = decode_line_1 (location.get (), 0, NULL, NULL, 0); + decoded_sals = decode_line_1 (locspec.get (), 0, NULL, NULL, 0); sals = decoded_sals; } else diff --git a/gdb/remote.c b/gdb/remote.c index f41e6ce82c2..7bcd6e3e336 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -13368,15 +13368,15 @@ remote_target::download_tracepoint (struct bp_location *loc) if (packet_support (PACKET_TracepointSource) == PACKET_ENABLE) { - if (b->location != NULL) + if (b->locspec != nullptr) { ret = snprintf (buf.data (), buf.size (), "QTDPsrc:"); if (ret < 0 || ret >= buf.size ()) error ("%s", err_msg); - encode_source_string (b->number, loc->address, "at", - event_location_to_string (b->location.get ()), + const char *str = location_spec_to_string (b->locspec.get ()); + encode_source_string (b->number, loc->address, "at", str, buf.data () + strlen (buf.data ()), buf.size () - strlen (buf.data ())); putpkt (buf.data ()); diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 44d16b55bca..75ac0cef3b0 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2477,10 +2477,10 @@ info_scope_command (const char *args_in, int from_tty) error (_("requires an argument (function, " "line or *addr) to define a scope")); - event_location_up location = string_to_event_location (&args, - current_language); + location_spec_up locspec = string_to_location_spec (&args, + current_language); std::vector sals - = decode_line_1 (location.get (), DECODE_LINE_FUNFIRSTLINE, + = decode_line_1 (locspec.get (), DECODE_LINE_FUNFIRSTLINE, NULL, NULL, 0); if (sals.empty ()) {