aboutsummaryrefslogtreecommitdiff
path: root/gdb/symtab.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-09-09 17:41:30 -0600
committerTom Tromey <tom@tromey.com>2024-01-28 10:58:16 -0700
commit88ff5355adfee1c015ce98f0d79475f53678a7bb (patch)
tree679a3870ede3ca135ddfdd8c5b4ad36941b1a21e /gdb/symtab.c
parent8370bcc7b7b966ea86a7c87ba1549e607da7ac25 (diff)
downloadgdb-88ff5355adfee1c015ce98f0d79475f53678a7bb.zip
gdb-88ff5355adfee1c015ce98f0d79475f53678a7bb.tar.gz
gdb-88ff5355adfee1c015ce98f0d79475f53678a7bb.tar.bz2
Introduce "scripting" domains
The Python and Guile code exposed the internal domain constants both as attributes of symbols and as values to pass to lookup functions. Now, perfect backward compatibility here can't be achieved: some symbols are going to have domain changes by the end of this series. However, it seemed to me that we can preserve lookups using the basic domain values. This patch implements this by exporting the "or"-able search constants with an extra bit set. Then it introduces some functions to convert such constants to domain_search_flags. This will be used by the Python and Guile code, so that both old- and new-style lookups will work properly; and while preserving the idea that the domain constants can be compared to a symbol's domain.
Diffstat (limited to 'gdb/symtab.c')
-rw-r--r--gdb/symtab.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 76a771b..6d24d2f 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -330,6 +330,48 @@ domain_name (domain_search_flags flags)
/* See symtab.h. */
+domain_search_flags
+from_scripting_domain (int val)
+{
+ if ((val & SCRIPTING_SEARCH_FLAG) == 0)
+ {
+ /* VAL should be one of the domain constants. Verify this and
+ convert it to a search constant. */
+ switch (val)
+ {
+#define DOMAIN(X) \
+ case X ## _DOMAIN: break;
+#include "sym-domains.def"
+#undef DOMAIN
+ default:
+ error (_("unrecognized domain constant"));
+ }
+ domain_search_flags result = to_search_flags ((domain_enum) val);
+ if (val == VAR_DOMAIN)
+ {
+ /* This matches the historical practice. */
+ result |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
+ }
+ return result;
+ }
+ else
+ {
+ /* VAL is several search constants or'd together. Verify
+ this. */
+ val &= ~SCRIPTING_SEARCH_FLAG;
+ int check = val;
+#define DOMAIN(X) \
+ check &= ~ (int) SEARCH_ ## X ## _DOMAIN;
+#include "sym-domains.def"
+#undef DOMAIN
+ if (check != 0)
+ error (_("unrecognized domain constant"));
+ return (domain_search_flag) val;
+ }
+}
+
+/* See symtab.h. */
+
CORE_ADDR
linetable_entry::pc (const struct objfile *objfile) const
{