Convert location_spec_to_string to a method
This converts location_spec_to_string to a method of location_spec, simplifying the code using it, as it no longer has to use std::unique_ptr::get(). Change-Id: I621bdad8ea084470a2724163f614578caf8f2dd5
This commit is contained in:
parent
7464aeaab4
commit
709438c75a
8 changed files with 27 additions and 49 deletions
|
@ -6007,8 +6007,7 @@ print_breakpoint_location (const breakpoint *b,
|
||||||
set_current_program_space (loc->pspace);
|
set_current_program_space (loc->pspace);
|
||||||
|
|
||||||
if (b->display_canonical)
|
if (b->display_canonical)
|
||||||
uiout->field_string ("what",
|
uiout->field_string ("what", b->locspec->to_string ());
|
||||||
location_spec_to_string (b->locspec.get ()));
|
|
||||||
else if (loc && loc->symtab)
|
else if (loc && loc->symtab)
|
||||||
{
|
{
|
||||||
const struct symbol *sym = loc->symbol;
|
const struct symbol *sym = loc->symbol;
|
||||||
|
@ -6042,8 +6041,7 @@ print_breakpoint_location (const breakpoint *b,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uiout->field_string ("pending",
|
uiout->field_string ("pending", b->locspec->to_string ());
|
||||||
location_spec_to_string (b->locspec.get ()));
|
|
||||||
/* If extra_string is available, it could be holding a condition
|
/* If extra_string is available, it could be holding a condition
|
||||||
or dprintf arguments. In either case, make sure it is printed,
|
or dprintf arguments. In either case, make sure it is printed,
|
||||||
too, but only for non-MI streams. */
|
too, but only for non-MI streams. */
|
||||||
|
@ -6505,7 +6503,7 @@ print_one_breakpoint_location (struct breakpoint *b,
|
||||||
}
|
}
|
||||||
else if (b->locspec != nullptr)
|
else if (b->locspec != nullptr)
|
||||||
{
|
{
|
||||||
const char *str = location_spec_to_string (b->locspec.get ());
|
const char *str = b->locspec->to_string ();
|
||||||
if (str != nullptr)
|
if (str != nullptr)
|
||||||
uiout->field_string ("original-location", str);
|
uiout->field_string ("original-location", str);
|
||||||
}
|
}
|
||||||
|
@ -8282,7 +8280,7 @@ code_breakpoint::code_breakpoint (struct gdbarch *gdbarch_,
|
||||||
{
|
{
|
||||||
/* We already know the marker exists, otherwise, we wouldn't
|
/* We already know the marker exists, otherwise, we wouldn't
|
||||||
see a sal for it. */
|
see a sal for it. */
|
||||||
const char *p = &location_spec_to_string (locspec_.get ())[3];
|
const char *p = &locspec_->to_string ()[3];
|
||||||
const char *endp;
|
const char *endp;
|
||||||
|
|
||||||
p = skip_spaces (p);
|
p = skip_spaces (p);
|
||||||
|
@ -9244,8 +9242,8 @@ void
|
||||||
ranged_breakpoint::print_recreate (struct ui_file *fp) const
|
ranged_breakpoint::print_recreate (struct ui_file *fp) const
|
||||||
{
|
{
|
||||||
gdb_printf (fp, "break-range %s, %s",
|
gdb_printf (fp, "break-range %s, %s",
|
||||||
location_spec_to_string (locspec.get ()),
|
locspec->to_string (),
|
||||||
location_spec_to_string (locspec_range_end.get ()));
|
locspec_range_end->to_string ());
|
||||||
print_recreate_thread (fp);
|
print_recreate_thread (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11353,19 +11351,18 @@ say_where (const breakpoint *b)
|
||||||
a condition or dprintf arguments. */
|
a condition or dprintf arguments. */
|
||||||
if (b->extra_string == NULL)
|
if (b->extra_string == NULL)
|
||||||
{
|
{
|
||||||
gdb_printf (_(" (%s) pending."),
|
gdb_printf (_(" (%s) pending."), b->locspec->to_string ());
|
||||||
location_spec_to_string (b->locspec.get ()));
|
|
||||||
}
|
}
|
||||||
else if (b->type == bp_dprintf)
|
else if (b->type == bp_dprintf)
|
||||||
{
|
{
|
||||||
gdb_printf (_(" (%s,%s) pending."),
|
gdb_printf (_(" (%s,%s) pending."),
|
||||||
location_spec_to_string (b->locspec.get ()),
|
b->locspec->to_string (),
|
||||||
b->extra_string.get ());
|
b->extra_string.get ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gdb_printf (_(" (%s %s) pending."),
|
gdb_printf (_(" (%s %s) pending."),
|
||||||
location_spec_to_string (b->locspec.get ()),
|
b->locspec->to_string (),
|
||||||
b->extra_string.get ());
|
b->extra_string.get ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11393,8 +11390,7 @@ say_where (const breakpoint *b)
|
||||||
/* This is not ideal, but each location may have a
|
/* This is not ideal, but each location may have a
|
||||||
different file name, and this at least reflects the
|
different file name, and this at least reflects the
|
||||||
real situation somewhat. */
|
real situation somewhat. */
|
||||||
gdb_printf (": %s.",
|
gdb_printf (": %s.", b->locspec->to_string ());
|
||||||
location_spec_to_string (b->locspec.get ()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b->loc->next)
|
if (b->loc->next)
|
||||||
|
@ -11659,7 +11655,7 @@ ordinary_breakpoint::print_recreate (struct ui_file *fp) const
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
_("unhandled breakpoint type %d"), (int) type);
|
_("unhandled breakpoint type %d"), (int) type);
|
||||||
|
|
||||||
gdb_printf (fp, " %s", location_spec_to_string (locspec.get ()));
|
gdb_printf (fp, " %s", locspec->to_string ());
|
||||||
|
|
||||||
/* Print out extra_string if this breakpoint is pending. It might
|
/* Print out extra_string if this breakpoint is pending. It might
|
||||||
contain, for example, conditions that were set by the user. */
|
contain, for example, conditions that were set by the user. */
|
||||||
|
@ -11822,8 +11818,7 @@ bkpt_probe_create_sals_from_location_spec (location_spec *locspec,
|
||||||
struct linespec_sals lsal;
|
struct linespec_sals lsal;
|
||||||
|
|
||||||
lsal.sals = parse_probes (locspec, NULL, canonical);
|
lsal.sals = parse_probes (locspec, NULL, canonical);
|
||||||
lsal.canonical
|
lsal.canonical = xstrdup (canonical->locspec->to_string ());
|
||||||
= xstrdup (location_spec_to_string (canonical->locspec.get ()));
|
|
||||||
canonical->lsals.push_back (std::move (lsal));
|
canonical->lsals.push_back (std::move (lsal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11906,7 +11901,7 @@ tracepoint::print_recreate (struct ui_file *fp) const
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
_("unhandled tracepoint type %d"), (int) type);
|
_("unhandled tracepoint type %d"), (int) type);
|
||||||
|
|
||||||
gdb_printf (fp, " %s", location_spec_to_string (locspec.get ()));
|
gdb_printf (fp, " %s", locspec->to_string ());
|
||||||
print_recreate_thread (fp);
|
print_recreate_thread (fp);
|
||||||
|
|
||||||
if (pass_count)
|
if (pass_count)
|
||||||
|
@ -11951,9 +11946,7 @@ dprintf_breakpoint::re_set ()
|
||||||
void
|
void
|
||||||
dprintf_breakpoint::print_recreate (struct ui_file *fp) const
|
dprintf_breakpoint::print_recreate (struct ui_file *fp) const
|
||||||
{
|
{
|
||||||
gdb_printf (fp, "dprintf %s,%s",
|
gdb_printf (fp, "dprintf %s,%s", locspec->to_string (), extra_string.get ());
|
||||||
location_spec_to_string (locspec.get ()),
|
|
||||||
extra_string.get ());
|
|
||||||
print_recreate_thread (fp);
|
print_recreate_thread (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12001,8 +11994,7 @@ strace_marker_create_sals_from_location_spec (location_spec *locspec,
|
||||||
canonical->locspec
|
canonical->locspec
|
||||||
= new_linespec_location_spec (&ptr, symbol_name_match_type::FULL);
|
= new_linespec_location_spec (&ptr, symbol_name_match_type::FULL);
|
||||||
|
|
||||||
lsal.canonical
|
lsal.canonical = xstrdup (canonical->locspec->to_string ());
|
||||||
= xstrdup (location_spec_to_string (canonical->locspec.get ()));
|
|
||||||
canonical->lsals.push_back (std::move (lsal));
|
canonical->lsals.push_back (std::move (lsal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1026,8 +1026,7 @@ elf_gnu_ifunc_resolver_return_stop (code_breakpoint *b)
|
||||||
resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc);
|
resolved_pc = gdbarch_addr_bits_remove (gdbarch, resolved_pc);
|
||||||
|
|
||||||
gdb_assert (current_program_space == b->pspace || b->pspace == NULL);
|
gdb_assert (current_program_space == b->pspace || b->pspace == NULL);
|
||||||
const char *locspec_str = location_spec_to_string (b->locspec.get ());
|
elf_gnu_ifunc_record_cache (b->locspec->to_string (), resolved_pc);
|
||||||
elf_gnu_ifunc_record_cache (locspec_str, resolved_pc);
|
|
||||||
|
|
||||||
b->type = bp_breakpoint;
|
b->type = bp_breakpoint;
|
||||||
update_breakpoint_locations (b, current_program_space,
|
update_breakpoint_locations (b, current_program_space,
|
||||||
|
|
|
@ -189,7 +189,7 @@ bpscm_print_breakpoint_smob (SCM self, SCM port, scm_print_state *pstate)
|
||||||
|
|
||||||
if (b->locspec != nullptr)
|
if (b->locspec != nullptr)
|
||||||
{
|
{
|
||||||
const char *str = location_spec_to_string (b->locspec.get ());
|
const char *str = b->locspec->to_string ();
|
||||||
if (str != nullptr)
|
if (str != nullptr)
|
||||||
gdbscm_printf (port, " @%s", str);
|
gdbscm_printf (port, " @%s", str);
|
||||||
}
|
}
|
||||||
|
@ -859,8 +859,7 @@ gdbscm_breakpoint_location (SCM self)
|
||||||
if (bp_smob->bp->type != bp_breakpoint)
|
if (bp_smob->bp->type != bp_breakpoint)
|
||||||
return SCM_BOOL_F;
|
return SCM_BOOL_F;
|
||||||
|
|
||||||
const char *str
|
const char *str = bp_smob->bp->locspec->to_string ();
|
||||||
= location_spec_to_string (bp_smob->bp->locspec.get ());
|
|
||||||
if (str == nullptr)
|
if (str == nullptr)
|
||||||
str = "";
|
str = "";
|
||||||
|
|
||||||
|
|
|
@ -3149,7 +3149,7 @@ decode_line_full (struct location_spec *locspec, int flags,
|
||||||
|
|
||||||
if (result.size () == 0)
|
if (result.size () == 0)
|
||||||
throw_error (NOT_SUPPORTED_ERROR, _("Location %s not available"),
|
throw_error (NOT_SUPPORTED_ERROR, _("Location %s not available"),
|
||||||
location_spec_to_string (locspec));
|
locspec->to_string ());
|
||||||
|
|
||||||
gdb_assert (result.size () == 1 || canonical->pre_expanded);
|
gdb_assert (result.size () == 1 || canonical->pre_expanded);
|
||||||
canonical->pre_expanded = 1;
|
canonical->pre_expanded = 1;
|
||||||
|
|
|
@ -345,14 +345,6 @@ explicit_location_spec::to_linespec () const
|
||||||
return explicit_to_string_internal (true, this);
|
return explicit_to_string_internal (true, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See description in location.h. */
|
|
||||||
|
|
||||||
const char *
|
|
||||||
location_spec_to_string (struct location_spec *locspec)
|
|
||||||
{
|
|
||||||
return locspec->to_string ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find an instance of the quote character C in the string S that is
|
/* Find an instance of the quote character C in the string S that is
|
||||||
outside of all single- and double-quoted strings (i.e., any quoting
|
outside of all single- and double-quoted strings (i.e., any quoting
|
||||||
other than C). */
|
other than C). */
|
||||||
|
|
|
@ -83,7 +83,12 @@ struct location_spec
|
||||||
/* Return true if this location spec is empty, false otherwise. */
|
/* Return true if this location spec is empty, false otherwise. */
|
||||||
virtual bool empty_p () const = 0;
|
virtual bool empty_p () const = 0;
|
||||||
|
|
||||||
/* Return a string representation of this location. */
|
/* Return a string representation of this location.
|
||||||
|
|
||||||
|
This function may return NULL for unspecified linespecs, e.g,
|
||||||
|
LINESPEC_LOCATION_SPEC and spec_string is NULL.
|
||||||
|
|
||||||
|
The result is cached in the locspec. */
|
||||||
const char *to_string () const
|
const char *to_string () const
|
||||||
{
|
{
|
||||||
if (as_string.empty ())
|
if (as_string.empty ())
|
||||||
|
@ -233,15 +238,6 @@ protected:
|
||||||
std::string compute_string () const override;
|
std::string compute_string () const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Return a string representation of LOCSPEC.
|
|
||||||
This function may return NULL for unspecified linespecs,
|
|
||||||
e.g, LINESPEC_LOCATION_SPEC and spec_string is NULL.
|
|
||||||
|
|
||||||
The result is cached in LOCSPEC. */
|
|
||||||
|
|
||||||
extern const char *
|
|
||||||
location_spec_to_string (location_spec *locspec);
|
|
||||||
|
|
||||||
/* Create a new linespec location spec. */
|
/* Create a new linespec location spec. */
|
||||||
|
|
||||||
extern location_spec_up new_linespec_location_spec
|
extern location_spec_up new_linespec_location_spec
|
||||||
|
|
|
@ -412,7 +412,7 @@ bppy_get_location (PyObject *self, void *closure)
|
||||||
&& obj->bp->type != bp_hardware_breakpoint)
|
&& obj->bp->type != bp_hardware_breakpoint)
|
||||||
Py_RETURN_NONE;
|
Py_RETURN_NONE;
|
||||||
|
|
||||||
const char *str = location_spec_to_string (obj->bp->locspec.get ());
|
const char *str = obj->bp->locspec->to_string ();
|
||||||
if (str == nullptr)
|
if (str == nullptr)
|
||||||
str = "";
|
str = "";
|
||||||
return host_string_to_python_string (str).release ();
|
return host_string_to_python_string (str).release ();
|
||||||
|
|
|
@ -13375,7 +13375,7 @@ remote_target::download_tracepoint (struct bp_location *loc)
|
||||||
if (ret < 0 || ret >= buf.size ())
|
if (ret < 0 || ret >= buf.size ())
|
||||||
error ("%s", err_msg);
|
error ("%s", err_msg);
|
||||||
|
|
||||||
const char *str = location_spec_to_string (b->locspec.get ());
|
const char *str = b->locspec->to_string ();
|
||||||
encode_source_string (b->number, loc->address, "at", str,
|
encode_source_string (b->number, loc->address, "at", str,
|
||||||
buf.data () + strlen (buf.data ()),
|
buf.data () + strlen (buf.data ()),
|
||||||
buf.size () - strlen (buf.data ()));
|
buf.size () - strlen (buf.data ()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue