aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-03-02 15:20:29 -0700
committerTom Tromey <tom@tromey.com>2024-01-28 10:58:16 -0700
commit25f31e1820dcec2f0c073c28cbf88646c7c2af97 (patch)
tree68e9094901fd332bb2d45e2086e78f7ffc15e805 /gdb/symtab.c
parent271157878868b0549ea00aa5de6be813ae5d3663 (diff)
downloadgdb-25f31e1820dcec2f0c073c28cbf88646c7c2af97.zip
gdb-25f31e1820dcec2f0c073c28cbf88646c7c2af97.tar.gz
gdb-25f31e1820dcec2f0c073c28cbf88646c7c2af97.tar.bz2
Add domain_search_flags
This adds a new flag enum type, domain_search_flags, which is the flag version of domain_enum. Nothing uses this yet, but the goal here is to have all symbol searches and lookups use these flags. The new names are chosen to exactly parallel domain_enum.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index b1deb9d..779e1ff 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -331,6 +331,21 @@ search_domain_name (enum search_domain e)
/* See symtab.h. */
+std::string
+domain_name (domain_search_flags flags)
+{
+ static constexpr domain_search_flags::string_mapping mapping[] = {
+#define DOMAIN(X) \
+ MAP_ENUM_FLAG (SEARCH_ ## X ## _DOMAIN),
+#include "sym-domains.def"
+#undef DOMAIN
+ };
+
+ return flags.to_string (mapping);
+}
+
+/* See symtab.h. */
+
CORE_ADDR
linetable_entry::pc (const struct objfile *objfile) const
{
@@ -2666,6 +2681,41 @@ symbol_matches_domain (enum language symbol_language,
/* See symtab.h. */
+bool
+symbol::matches (domain_search_flags flags) const
+{
+ if (language () != language_c
+ && language () != language_objc
+ && language () != language_opencl)
+ {
+ /* Only C languages distinguish tag and type namespaces. */
+ if ((flags & SEARCH_TYPE_DOMAIN) != 0)
+ flags |= SEARCH_STRUCT_DOMAIN;
+ }
+
+ if ((flags & SEARCH_FUNCTION_DOMAIN) != 0
+ && domain () == VAR_DOMAIN
+ && aclass () == LOC_BLOCK)
+ return true;
+
+ if ((flags & SEARCH_VAR_DOMAIN) != 0
+ && domain () == VAR_DOMAIN)
+ return true;
+
+ if ((flags & SEARCH_TYPE_DOMAIN) != 0
+ && domain () == VAR_DOMAIN
+ && aclass () == LOC_TYPEDEF)
+ return true;
+
+ if ((flags & SEARCH_STRUCT_DOMAIN) != 0
+ && domain () == STRUCT_DOMAIN)
+ return true;
+
+ return search_flags_matches (flags, m_domain);
+}
+
+/* See symtab.h. */
+
struct type *
lookup_transparent_type (const char *name)
{