aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-21 11:07:28 -0600
committerTom Tromey <tom@tromey.com>2022-04-12 09:31:15 -0600
commitb2bc564fe817f857b4915903f16026472acfbdcc (patch)
treeeb1dd6d22659e8cd209722ea9b778e1068c687c0 /gdb/symtab.h
parent073954a792b3911f07b1dd22a8e0ffcc89ed3080 (diff)
downloadgdb-b2bc564fe817f857b4915903f16026472acfbdcc.zip
gdb-b2bc564fe817f857b4915903f16026472acfbdcc.tar.gz
gdb-b2bc564fe817f857b4915903f16026472acfbdcc.tar.bz2
Add name splitting
The new DWARF index code works by keeping names pre-split. That is, rather than storing a symbol name like "a::b::c", the names "a", "b", and "c" will be stored separately. This patch introduces some helper code to split a full name into its components.
Diffstat (limited to 'gdb/symtab.h')
-rw-r--r--gdb/symtab.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 11e8995..4a33c7a 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -36,6 +36,7 @@
#include "gdbsupport/iterator-range.h"
#include "completer.h"
#include "gdb-demangle.h"
+#include "split-name.h"
/* Opaque declarations. */
struct ui_file;
@@ -121,6 +122,21 @@ class ada_lookup_name_info final
bool verbatim_p () const
{ return m_verbatim_p; }
+ /* A wrapper for ::split_name that handles some Ada-specific
+ peculiarities. */
+ std::vector<gdb::string_view> split_name () const
+ {
+ if (m_verbatim_p || m_standard_p)
+ {
+ std::vector<gdb::string_view> result;
+ if (m_standard_p)
+ result.emplace_back ("standard");
+ result.emplace_back (m_encoded_name);
+ return result;
+ }
+ return ::split_name (m_encoded_name.c_str (), split_style::UNDERSCORE);
+ }
+
private:
/* The Ada-encoded lookup name. */
std::string m_encoded_name;
@@ -272,6 +288,27 @@ class lookup_name_info final
}
}
+ /* A wrapper for ::split_name (see split-name.h) that splits this
+ name, and that handles any language-specific peculiarities. */
+ std::vector<gdb::string_view> split_name (language lang) const
+ {
+ if (lang == language_ada)
+ return ada ().split_name ();
+ split_style style = split_style::NONE;
+ switch (lang)
+ {
+ case language_cplus:
+ case language_rust:
+ style = split_style::CXX;
+ break;
+ case language_d:
+ case language_go:
+ style = split_style::DOT;
+ break;
+ }
+ return ::split_name (language_lookup_name (lang), style);
+ }
+
/* Get the Ada-specific lookup info. */
const ada_lookup_name_info &ada () const
{