aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.h
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.h
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.h')
-rw-r--r--gdb/symtab.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 7465f7b..953b6c1 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -905,6 +905,48 @@ enum domain_enum
extern const char *domain_name (domain_enum);
+/* Flags used for searching symbol tables. These can be combined to
+ let the search match multiple kinds of symbol. */
+enum domain_search_flag
+{
+#define DOMAIN(X) \
+ SEARCH_ ## X ## _DOMAIN = (1 << X ## _DOMAIN),
+#include "sym-domains.def"
+#undef DOMAIN
+};
+DEF_ENUM_FLAGS_TYPE (enum domain_search_flag, domain_search_flags);
+
+/* A convenience constant to search for any symbol. */
+constexpr domain_search_flags SEARCH_ALL
+ = ((domain_search_flags) 0
+#define DOMAIN(X) | SEARCH_ ## X ## _DOMAIN
+#include "sym-domains.def"
+#undef DOMAIN
+ );
+
+/* A convenience define for "C-like" name lookups, matching variables,
+ types, and functions. */
+#define SEARCH_VFT \
+ (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN | SEARCH_TYPE_DOMAIN)
+
+/* Return a string representing the given flags. */
+extern std::string domain_name (domain_search_flags);
+
+/* Convert a symbol domain to search flags. */
+static inline domain_search_flags
+to_search_flags (domain_enum domain)
+{
+ return domain_search_flags (domain_search_flag (1 << domain));
+}
+
+/* Return true if the given domain matches the given flags, false
+ otherwise. */
+static inline bool
+search_flags_matches (domain_search_flags flags, domain_enum domain)
+{
+ return (flags & to_search_flags (domain)) != 0;
+}
+
/* Searching domains, used when searching for symbols. Element numbers are
hardcoded in GDB, check all enum uses before changing it. */
@@ -1265,6 +1307,9 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
return symbol_matches_domain (language (), domain (), d);
}
+ /* Return true if this symbol's domain matches FLAGS. */
+ bool matches (domain_search_flags flags) const;
+
domain_enum domain () const
{
return m_domain;