/* Data structures and API for location specs in GDB.
- Copyright (C) 2013-2022 Free Software Foundation, Inc.
+ Copyright (C) 2013-2023 Free Software Foundation, Inc.
This file is part of GDB.
#include "defs.h"
#include "gdbsupport/gdb_assert.h"
+#include "gdbsupport/gdb-checked-static-cast.h"
#include "location.h"
#include "symtab.h"
#include "language.h"
std::string probe_location_spec::compute_string () const
{
- return std::move (as_string);
+ return std::move (m_as_string);
}
/* A "normal" linespec. */
address (addr)
{
if (addr_string != nullptr)
- as_string = std::string (addr_string, addr_string_len);
+ m_as_string = std::string (addr_string, addr_string_len);
}
location_spec_up
/* See description in location.h. */
-enum location_spec_type
-location_spec_type (const location_spec *locspec)
-{
- return locspec->type;
-}
-
-/* See description in location.h. */
-
location_spec_up
new_linespec_location_spec (const char **linespec,
symbol_name_match_type match_type)
const linespec_location_spec *
as_linespec_location_spec (const location_spec *locspec)
{
- gdb_assert (locspec->type == LINESPEC_LOCATION_SPEC);
- return static_cast<const linespec_location_spec *> (locspec);
+ gdb_assert (locspec->type () == LINESPEC_LOCATION_SPEC);
+ return gdb::checked_static_cast<const linespec_location_spec *> (locspec);
}
/* See description in location.h. */
const address_location_spec *
as_address_location_spec (const location_spec *locspec)
{
- gdb_assert (locspec->type == ADDRESS_LOCATION_SPEC);
- return static_cast<const address_location_spec *> (locspec);
+ gdb_assert (locspec->type () == ADDRESS_LOCATION_SPEC);
+ return gdb::checked_static_cast<const address_location_spec *> (locspec);
}
/* See description in location.h. */
const probe_location_spec *
as_probe_location_spec (const location_spec *locspec)
{
- gdb_assert (locspec->type == PROBE_LOCATION_SPEC);
- return static_cast<const probe_location_spec *> (locspec);
+ gdb_assert (locspec->type () == PROBE_LOCATION_SPEC);
+ return gdb::checked_static_cast<const probe_location_spec *> (locspec);
}
/* See description in location.h. */
const explicit_location_spec *
as_explicit_location_spec (const location_spec *locspec)
{
- gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC);
- return static_cast<const explicit_location_spec *> (locspec);
+ gdb_assert (locspec->type () == EXPLICIT_LOCATION_SPEC);
+ return gdb::checked_static_cast<const explicit_location_spec *> (locspec);
}
/* See description in location.h. */
explicit_location_spec *
as_explicit_location_spec (location_spec *locspec)
{
- gdb_assert (locspec->type == EXPLICIT_LOCATION_SPEC);
- return static_cast<explicit_location_spec *> (locspec);
+ gdb_assert (locspec->type () == EXPLICIT_LOCATION_SPEC);
+ return gdb::checked_static_cast<explicit_location_spec *> (locspec);
}
/* Return a string representation of the explicit location spec in
return explicit_to_string_internal (true, this);
}
-/* See description in location.h. */
-
-location_spec_up
-copy_location_spec (const location_spec *src)
-{
- return src->clone ();
-}
-
-/* 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
outside of all single- and double-quoted strings (i.e., any quoting
other than C). */
/* If the user really specified a location spec, then we're
done. */
- if (!location_spec_empty_p (locspec.get ()))
+ if (!locspec->empty_p ())
return locspec;
/* Otherwise, the user _only_ specified optional flags like
linespec parsing below and discard the explicit location
spec. */
explicit_location_spec *xloc
- = dynamic_cast<explicit_location_spec *> (locspec.get ());
- gdb_assert (xloc != nullptr);
+ = gdb::checked_static_cast<explicit_location_spec *> (locspec.get ());
match_type = xloc->func_name_match_type;
}
spec. */
return string_to_location_spec_basic (stringp, language, match_type);
}
-
-/* See description in location.h. */
-
-int
-location_spec_empty_p (const location_spec *locspec)
-{
- return locspec->empty_p ();
-}
-
-/* See description in location.h. */
-
-void
-set_location_spec_string (struct location_spec *locspec,
- std::string &&string)
-{
- locspec->as_string = std::move (string);
-}