public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 00/30] Restructure symbol domains
@ 2024-01-18 20:31 Tom Tromey
  2024-01-18 20:31 ` [PATCH v2 01/30] Fix bug in cooked index scanner Tom Tromey
                   ` (30 more replies)
  0 siblings, 31 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii

v2 note: I was planning to check this in, but re-testing showed some
regressions.  I've fixed them here, basically DW_TAG_entry_point
caused some problems necessitating a fix in one patch, and a new patch
to fix a latent bug.  I plan to check this in relatively soon.

gdb's symbol domains have long needed some restructuring.

The current symbol domains are C-centric, with the "struct" domain
being separate from types (which is not the case in non-C languages)
and function and types being lumped in with variables.  This latter
decision makes it impossible to search the symbol table for a
function, resulting in bugs like PR 30158, where "main" was found as a
namespace, causing a crash.

This series adds new symbol domains for types and functions, and
changes the various symbol-lookup functions to allow multiple domains
to be searched at once.

Then, the symbol readers are changed to use the new domains.

Finally, selected bits of code are changed to be more precise in which
domains they search.

symbol_matches_domain currently has a C++-specific hack.  This hack
handles the C++ language rule where a tag is also entered as a
typedef.  While working on this series, I discovered that the
non-DWARF symbol readers will actually emit a second typedef symbol.
DWARF could do this as well, at some memory expense; and while I
consider this to be cleaner in an abstract way, for the time being
I've left the hack in place.

I regression tested this on x86-64 Fedora 38.  I also regression
tested using the debug-names and gdb-index target boards.

---
Changes in v2:
- Added patch to fix DW_TAG_entry_point
- Link to v1: https://inbox.sourceware.org/gdb-patches/20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com

---
Tom Tromey (30):
      Fix bug in cooked index scanner
      Small cleanup in DWARF reader
      Fix latent bug in DW_TAG_entry_point handling
      Make nsalias.exp more reliable
      Fix latent bug in mdebugread.c
      Give names to unspecified types
      Remove NR_DOMAINS
      Simplify symbol_to_info_string
      Split up a big 'if' in symtab.c
      Use a .def file for domain_enum
      Add two new symbol domains
      Add domain_search_flags
      Replace search_domain with domain_search_flags
      Remove a check of VAR_DOMAIN
      Introduce "scripting" domains
      Use domain_search_flags in lookup_global_symbol_language
      Use domain_search_flags in lookup_symbol et al
      Remove some obsolete Python constants
      Remove old symbol_matches_domain
      Use the new symbol domains
      Simplify some symbol searches in Ada code
      Simplify some symbol searches in linespec.c
      Only search for "main" as a function
      Only look for functions in expand_symtabs_for_function
      Use a function-domain search in inside_main_func
      Only search types in cp_lookup_rtti_type
      Only search types in lookup_typename
      Only search for functions in rust_structop::evaluate_funcall
      Refine search in cp_search_static_and_baseclasses
      Document new Python and Guile constants

 gdb/NEWS                                 |  12 +
 gdb/ada-exp.y                            |  13 +-
 gdb/ada-lang.c                           |  79 +++--
 gdb/ada-lang.h                           |   6 +-
 gdb/ada-tasks.c                          |  17 +-
 gdb/alpha-mdebug-tdep.c                  |   2 +-
 gdb/ax-gdb.c                             |   5 +-
 gdb/block.c                              |  24 +-
 gdb/block.h                              |  15 +-
 gdb/c-exp.y                              |  19 +-
 gdb/c-lang.c                             |   2 +-
 gdb/c-valprint.c                         |   2 +-
 gdb/coffread.c                           |   5 +-
 gdb/compile/compile-c-symbols.c          |  17 +-
 gdb/compile/compile-cplus-symbols.c      |  15 +-
 gdb/compile/compile-cplus-types.c        |   8 +-
 gdb/compile/compile-object-load.c        |   6 +-
 gdb/cp-namespace.c                       |  66 +++--
 gdb/cp-support.c                         |  10 +-
 gdb/cp-support.h                         |   8 +-
 gdb/ctfread.c                            |   2 +-
 gdb/d-exp.y                              |  12 +-
 gdb/d-lang.c                             |   2 +-
 gdb/d-lang.h                             |   9 +-
 gdb/d-namespace.c                        |  24 +-
 gdb/doc/guile.texi                       |  13 +
 gdb/doc/python.texi                      |  30 +-
 gdb/dwarf2/ada-imported.c                |   2 +-
 gdb/dwarf2/cooked-index.c                |  12 +
 gdb/dwarf2/cooked-index.h                |  46 +--
 gdb/dwarf2/index-write.c                 |   7 +-
 gdb/dwarf2/loc.c                         |   2 +-
 gdb/dwarf2/read-debug-names.c            | 128 ++-------
 gdb/dwarf2/read-gdb-index.c              |  37 ++-
 gdb/dwarf2/read.c                        | 103 +++++--
 gdb/dwarf2/read.h                        |   2 +-
 gdb/dwarf2/tag.h                         |  79 +++++
 gdb/eval.c                               |   5 +-
 gdb/f-exp.y                              |   8 +-
 gdb/f-lang.c                             |   2 +-
 gdb/f-lang.h                             |   2 +-
 gdb/f-valprint.c                         |   2 +-
 gdb/fbsd-tdep.c                          |   5 +-
 gdb/frame.c                              |   9 +-
 gdb/ft32-tdep.c                          |   3 +-
 gdb/gdbtypes.c                           |  35 ++-
 gdb/gnu-v3-abi.c                         |   2 +-
 gdb/go-exp.y                             |   9 +-
 gdb/guile/scm-frame.c                    |   2 +-
 gdb/guile/scm-symbol.c                   |  25 +-
 gdb/infrun.c                             |   2 +-
 gdb/jit.c                                |   2 +-
 gdb/language.c                           |   5 +-
 gdb/language.h                           |   4 +-
 gdb/linespec.c                           |  67 +++--
 gdb/m2-exp.y                             |  10 +-
 gdb/mdebugread.c                         |   6 +-
 gdb/mi/mi-cmd-stack.c                    |   5 +-
 gdb/mi/mi-symbol-cmds.c                  |  35 +--
 gdb/moxie-tdep.c                         |   3 +-
 gdb/objc-lang.c                          |   4 +-
 gdb/objfiles.h                           |   7 +-
 gdb/p-exp.y                              |  19 +-
 gdb/p-valprint.c                         |   2 +-
 gdb/parse.c                              |   3 +-
 gdb/printcmd.c                           |   2 +-
 gdb/psymtab.c                            |  41 +--
 gdb/psymtab.h                            |   5 +-
 gdb/python/py-frame.c                    |   3 +-
 gdb/python/py-objfile.c                  |   6 +-
 gdb/python/py-symbol.c                   |  53 ++--
 gdb/python/python.c                      |   2 +-
 gdb/quick-symbol.h                       |  10 +-
 gdb/rust-lang.c                          |   7 +-
 gdb/rust-lang.h                          |   2 +-
 gdb/rust-parse.c                         |   8 +-
 gdb/source.c                             |   5 +-
 gdb/stabsread.c                          |   8 +-
 gdb/stack.c                              |   4 +-
 gdb/sym-domains.def                      |  58 ++++
 gdb/symfile-debug.c                      |  26 +-
 gdb/symfile.c                            |   9 +-
 gdb/symfile.h                            |   2 +-
 gdb/symmisc.c                            |   3 +-
 gdb/symtab.c                             | 480 +++++++++++++++++--------------
 gdb/symtab.h                             | 177 ++++++------
 gdb/testsuite/gdb.ada/info_auto_lang.exp |   4 +-
 gdb/testsuite/gdb.ada/ptype-o.exp        |   2 +-
 gdb/testsuite/gdb.cp/nsalias.exp         |   2 +-
 gdb/testsuite/gdb.fortran/info-types.exp |   2 +-
 gdb/valops.c                             |  14 +-
 gdb/value.c                              |   6 +-
 gdb/xcoffread.c                          |   9 +-
 gdb/xstormy16-tdep.c                     |   3 +-
 94 files changed, 1129 insertions(+), 948 deletions(-)
---
base-commit: 0d656dfe5b406289faef7f35fb87fb0a00dd64f3
change-id: 20231120-submit-domain-hacks-2-1c1e66b4d560

Best regards,
-- 
Tom Tromey <tom@tromey.com>


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 01/30] Fix bug in cooked index scanner
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
@ 2024-01-18 20:31 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 02/30] Small cleanup in DWARF reader Tom Tromey
                   ` (29 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:31 UTC (permalink / raw)
  To: gdb-patches

Testing this entire series pointed out that the cooked index scanner
disagrees with new_symbol about certain symbols.  In particular,
new_symbol has this comment:

    Ada and Fortran subprograms, whether marked external or
    not, are always stored as a global symbol, because we want

This patch updates the scanner to match.

I don't know why the current code does not cause failures.

It's maybe worth noting that incremental CU expansion -- creating
symtabs directly from the index -- would eliminate this sort of bug.
---
 gdb/dwarf2/read.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 8f2b7a35f27..7b523d93e07 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16405,6 +16405,12 @@ cooked_indexer::scan_attributes (dwarf2_per_cu_data *scanning_per_cu,
 	      || abbrev->tag == DW_TAG_enumeration_type
 	      || abbrev->tag == DW_TAG_enumerator))
 	*flags &= ~IS_STATIC;
+
+      /* Keep in sync with new_symbol.  */
+      if (abbrev->tag == DW_TAG_subprogram
+	  && (m_language == language_ada
+	      || m_language == language_fortran))
+	*flags &= ~IS_STATIC;
     }
 
   return info_ptr;

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 02/30] Small cleanup in DWARF reader
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
  2024-01-18 20:31 ` [PATCH v2 01/30] Fix bug in cooked index scanner Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 03/30] Fix latent bug in DW_TAG_entry_point handling Tom Tromey
                   ` (28 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

I noticed a couple of spots in dwarf/read.c:new_symbol that call
add_symbol_to_list.  However, this function is generally written to
set list_to_add, and then have a single call to add_symbol_to_list at
the end.  This patch cleans up this discrepancy.

Note that new_symbol is overlong and should probably be split up.
---
 gdb/dwarf2/read.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 7b523d93e07..b55b208ff4b 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -19053,7 +19053,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	    sym->set_aclass_index (LOC_OPTIMIZED_OUT);
 	  sym->set_type (builtin_type (objfile)->builtin_core_addr);
 	  sym->set_domain (LABEL_DOMAIN);
-	  add_symbol_to_list (sym, cu->list_in_scope);
+	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_entry_point:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
@@ -19392,7 +19392,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_common_block:
 	  sym->set_aclass_index (LOC_COMMON_BLOCK);
 	  sym->set_domain (COMMON_BLOCK_DOMAIN);
-	  add_symbol_to_list (sym, cu->list_in_scope);
+	  list_to_add = cu->list_in_scope;
 	  break;
 	default:
 	  /* Not a tag we recognize.  Hopefully we aren't processing

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 03/30] Fix latent bug in DW_TAG_entry_point handling
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
  2024-01-18 20:31 ` [PATCH v2 01/30] Fix bug in cooked index scanner Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 02/30] Small cleanup in DWARF reader Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 04/30] Make nsalias.exp more reliable Tom Tromey
                   ` (27 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

A DW_TAG_entry_point symbol inherits its extern/static property from
the enclosing subroutine.  This is encoded in new_symbol -- but the
cooked indexer does not agree.
---
 gdb/dwarf2/read.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index b55b208ff4b..a4b8a855e24 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16526,6 +16526,13 @@ cooked_indexer::index_dies (cutu_reader *reader,
 				  info_ptr, abbrev, &name, &linkage_name,
 				  &flags, &sibling, &this_parent_entry,
 				  &defer, false);
+      /* A DW_TAG_entry_point inherits its static/extern property from
+	 the enclosing subroutine.  */
+      if (abbrev->tag == DW_TAG_entry_point)
+	{
+	  flags &= ~IS_STATIC;
+	  flags |= parent_entry->flags & IS_STATIC;
+	}
 
       if (abbrev->tag == DW_TAG_namespace
 	  && m_language == language_cplus

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 04/30] Make nsalias.exp more reliable
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (2 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 03/30] Fix latent bug in DW_TAG_entry_point handling Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 05/30] Fix latent bug in mdebugread.c Tom Tromey
                   ` (26 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

nsalias.exp tries to detect a complaint that is issued when expanding
a CU.  However, the test is a bit funny in that, while gdb does
currently expand the CU and issue the complaint, it also emits this
error:

    No symbol "N100" in current context.

This series will change gdb such that this CU is not expanded -- which
makes sense, the symbol in question doesn't actually match the lookups
that are done.

So, to make the test more robust, a direct request to expand symtabs
is done instead.
---
 gdb/testsuite/gdb.cp/nsalias.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.cp/nsalias.exp b/gdb/testsuite/gdb.cp/nsalias.exp
index b727437abc2..0c29e6f2d40 100644
--- a/gdb/testsuite/gdb.cp/nsalias.exp
+++ b/gdb/testsuite/gdb.cp/nsalias.exp
@@ -324,5 +324,5 @@ if { $readnow_p } {
     global gdb_file_cmd_msg
     gdb_assert {[regexp $re $gdb_file_cmd_msg]} $test
 } else {
-    gdb_test "print N100::x" $re $test
+    gdb_test "maint expand-symtabs" $re $test
 }

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 05/30] Fix latent bug in mdebugread.c
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (3 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 04/30] Make nsalias.exp more reliable Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 06/30] Give names to unspecified types Tom Tromey
                   ` (25 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

mdebugread.c makes a label symbol but puts it into VAR_DOMAIN.  I
think LABEL_DOMAIN is more appropriate.

I don't have a way to test this.
---
 gdb/mdebugread.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 73df0ed8165..13c9401d171 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -711,7 +711,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 
     case stLabel:		/* label, goes into current block.  */
       s = new_symbol (name);
-      s->set_domain (VAR_DOMAIN);	/* So that it can be used */
+      s->set_domain (LABEL_DOMAIN);	/* So that it can be used */
       s->set_aclass_index (LOC_LABEL);	/* but not misused.  */
       s->set_section_index (section_index);
       s->set_value_address (sh->value);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 06/30] Give names to unspecified types
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (4 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 05/30] Fix latent bug in mdebugread.c Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 07/30] Remove NR_DOMAINS Tom Tromey
                   ` (24 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

A patch later in this series will change check_typedef to also look in
the type domain.  This change by itself caused a regression, but one
that revealed some peculiar behavior.

The regression is in nullptr_t.exp, where examining a std::nullptr_t
will change from the correct:

    typedef decltype(nullptr) std::nullptr_t;

to

    typedef void std::nullptr_t;

Right now, the DWARF reader marks all unspecified types as stub types.
However, this interacts weirdly with check_typedef, which currently
does not try to resolve types -- only struct-domain objects.

My first attempt here was to fix this by changing void types not to be
stub types, as I didn't see what value that provided.  However, this
caused another regression, because call_function_by_hand_dummy checks
for stub-ness:

  if (values_type == NULL || values_type->is_stub ())
    values_type = default_return_type;

I'm not really sure why it does this rather than check for
TYPE_CODE_VOID.

While looking into this, I found another oddity: the DWARF reader
correctly creates a type named 'decltype(nullptr)' when it seems a
DW_TAG_unspecified_type -- but it creates a symbol named "void"
instead.

This patch changes the DWARF reader to give the symbol the correct
name.  This avoids the regression.
---
 gdb/dwarf2/read.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a4b8a855e24..078edd8c842 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -6593,6 +6593,7 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
     case DW_TAG_subrange_type:
     case DW_TAG_generic_subrange:
     case DW_TAG_typedef:
+    case DW_TAG_unspecified_type:
       /* Add a typedef symbol for the type definition, if it has a
 	 DW_AT_name.  */
       new_symbol (die, read_type_die (die, cu), cu);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 07/30] Remove NR_DOMAINS
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (5 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 06/30] Give names to unspecified types Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 08/30] Simplify symbol_to_info_string Tom Tromey
                   ` (23 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

NR_DOMAINS is only used for a static assert, but we no longer need it
now.  If we add too many constants to this enum, GCC will warn about
the bitfield overflow:

    error: ‘symbol::m_domain’ is too small to hold all values of ‘enum domain_enum’
---
 gdb/symtab.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/gdb/symtab.h b/gdb/symtab.h
index eecd999b7e6..3f2d98add1e 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -922,15 +922,11 @@ enum domain_enum
   /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
      They also always use LOC_COMMON_BLOCK.  */
   COMMON_BLOCK_DOMAIN,
-
-  /* This must remain last.  */
-  NR_DOMAINS
 };
 
 /* The number of bits in a symbol used to represent the domain.  */
 
 #define SYMBOL_DOMAIN_BITS 3
-static_assert (NR_DOMAINS <= (1 << SYMBOL_DOMAIN_BITS));
 
 extern const char *domain_name (domain_enum);
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 08/30] Simplify symbol_to_info_string
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (6 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 07/30] Remove NR_DOMAINS Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 09/30] Split up a big 'if' in symtab.c Tom Tromey
                   ` (22 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

Thi simplifies symbol_to_info_string, removing the 'kind' parameter
and instead having it use the symbol's domain.
---
 gdb/mi/mi-symbol-cmds.c |  2 +-
 gdb/symtab.c            | 44 ++++++++++++++++++--------------------------
 gdb/symtab.h            |  6 ++----
 3 files changed, 21 insertions(+), 31 deletions(-)

diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index d3ec16fcb21..758f5974706 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -87,7 +87,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
       type_print (sym->type (), "", &tmp_stream, -1);
       uiout->field_string ("type", tmp_stream.string ());
 
-      std::string str = symbol_to_info_string (sym, block, kind);
+      std::string str = symbol_to_info_string (sym, block);
       uiout->field_string ("description", str);
     }
 }
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7c0a69108d4..b408941f998 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5054,19 +5054,19 @@ global_symbol_searcher::search () const
 /* See symtab.h.  */
 
 std::string
-symbol_to_info_string (struct symbol *sym, int block,
-		       enum search_domain kind)
+symbol_to_info_string (struct symbol *sym, int block)
 {
   std::string str;
 
   gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK);
 
-  if (kind != TYPES_DOMAIN && block == STATIC_BLOCK)
+  if (block == STATIC_BLOCK
+      && sym->domain () == VAR_DOMAIN
+      && sym->aclass () != LOC_TYPEDEF)
     str += "static ";
 
   /* Typedef that is not a C++ class.  */
-  if (kind == TYPES_DOMAIN
-      && sym->domain () != STRUCT_DOMAIN)
+  if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF)
     {
       string_file tmp_stream;
 
@@ -5085,9 +5085,7 @@ symbol_to_info_string (struct symbol *sym, int block,
       str += tmp_stream.string ();
     }
   /* variable, func, or typedef-that-is-c++-class.  */
-  else if (kind < TYPES_DOMAIN
-	   || (kind == TYPES_DOMAIN
-	       && sym->domain () == STRUCT_DOMAIN))
+  else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN)
     {
       string_file tmp_stream;
 
@@ -5102,23 +5100,21 @@ symbol_to_info_string (struct symbol *sym, int block,
   /* Printing of modules is currently done here, maybe at some future
      point we might want a language specific method to print the module
      symbol so that we can customise the output more.  */
-  else if (kind == MODULES_DOMAIN)
+  else if (sym->domain () == MODULE_DOMAIN)
     str += sym->print_name ();
 
   return str;
 }
 
-/* Helper function for symbol info commands, for example 'info functions',
-   'info variables', etc.  KIND is the kind of symbol we searched for, and
-   BLOCK is the type of block the symbols was found in, either GLOBAL_BLOCK
-   or STATIC_BLOCK.  SYM is the symbol we found.  If LAST is not NULL,
-   print file and line number information for the symbol as well.  Skip
-   printing the filename if it matches LAST.  */
+/* Helper function for symbol info commands, for example 'info
+   functions', 'info variables', etc.  BLOCK is the type of block the
+   symbols was found in, either GLOBAL_BLOCK or STATIC_BLOCK.  SYM is
+   the symbol we found.  If LAST is not NULL, print file and line
+   number information for the symbol as well.  Skip printing the
+   filename if it matches LAST.  */
 
 static void
-print_symbol_info (enum search_domain kind,
-		   struct symbol *sym,
-		   int block, const char *last)
+print_symbol_info (struct symbol *sym, int block, const char *last)
 {
   scoped_switch_to_sym_language_if_auto l (sym);
   struct symtab *s = sym->symtab ();
@@ -5140,7 +5136,7 @@ print_symbol_info (enum search_domain kind,
 	gdb_puts ("\t");
     }
 
-  std::string str = symbol_to_info_string (sym, block, kind);
+  std::string str = symbol_to_info_string (sym, block);
   gdb_printf ("%s\n", str.c_str ());
 }
 
@@ -5236,10 +5232,7 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms,
 	}
       else
 	{
-	  print_symbol_info (kind,
-			     p.symbol,
-			     p.block,
-			     last_filename);
+	  print_symbol_info (p.symbol, p.block, last_filename);
 	  last_filename
 	    = symtab_to_filename_for_display (p.symbol->symtab ());
 	}
@@ -5475,7 +5468,7 @@ rbreak_command (const char *regexp, int from_tty)
 	  string = string_printf ("%s:'%s'", fullname,
 				  p.symbol->linkage_name ());
 	  break_command (&string[0], from_tty);
-	  print_symbol_info (FUNCTIONS_DOMAIN, p.symbol, p.block, NULL);
+	  print_symbol_info (p.symbol, p.block, nullptr);
 	}
       else
 	{
@@ -6838,8 +6831,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 	  last_filename = "";
 	}
 
-      print_symbol_info (FUNCTIONS_DOMAIN, q.symbol, q.block,
-			 last_filename);
+      print_symbol_info (q.symbol, q.block, last_filename);
       last_filename
 	= symtab_to_filename_for_display (q.symbol->symtab ());
     }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 3f2d98add1e..0a5f2633fe8 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2664,11 +2664,9 @@ extern std::vector<module_symbol_search> search_module_symbols
 
 /* Convert a global or static symbol SYM (based on BLOCK, which should be
    either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
-   type commands (e.g. 'info variables', 'info functions', etc).  KIND is
-   the type of symbol that was searched for which gave us SYM.  */
+   type commands (e.g. 'info variables', 'info functions', etc).  */
 
-extern std::string symbol_to_info_string (struct symbol *sym, int block,
-					  enum search_domain kind);
+extern std::string symbol_to_info_string (struct symbol *sym, int block);
 
 extern bool treg_matches_sym_type_name (const compiled_regex &treg,
 					const struct symbol *sym);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 09/30] Split up a big 'if' in symtab.c
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (7 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 08/30] Simplify symbol_to_info_string Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 10/30] Use a .def file for domain_enum Tom Tromey
                   ` (21 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

global_symbol_searcher::add_matching_symbols in symtab.c has a
gigantic 'if' statement -- 33 lines of conditional expression.  This
patch splits it up into a series of separate 'if's.
---
 gdb/symtab.c | 83 ++++++++++++++++++++++++++++++++++++------------------------
 1 file changed, 50 insertions(+), 33 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index b408941f998..2020210c5f4 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -4855,39 +4855,56 @@ global_symbol_searcher::add_matching_symbols
 	      /* Check first sole REAL_SYMTAB->FILENAME.  It does
 		 not need to be a substring of symtab_to_fullname as
 		 it may contain "./" etc.  */
-	      if ((file_matches (real_symtab->filename, filenames, false)
-		   || ((basenames_may_differ
-			|| file_matches (lbasename (real_symtab->filename),
-					 filenames, true))
-		       && file_matches (symtab_to_fullname (real_symtab),
-					filenames, false)))
-		  && ((!preg.has_value ()
-		       || preg->exec (sym->natural_name (), 0,
-				      NULL, 0) == 0)
-		      && ((kind == VARIABLES_DOMAIN
-			   && sym->aclass () != LOC_TYPEDEF
-			   && sym->aclass () != LOC_UNRESOLVED
-			   && sym->aclass () != LOC_BLOCK
-			   /* LOC_CONST can be used for more than
-			      just enums, e.g., c++ static const
-			      members.  We only want to skip enums
-			      here.  */
-			   && !(sym->aclass () == LOC_CONST
-				&& (sym->type ()->code ()
-				    == TYPE_CODE_ENUM))
-			   && (!treg.has_value ()
-			       || treg_matches_sym_type_name (*treg, sym)))
-			  || (kind == FUNCTIONS_DOMAIN
-			      && sym->aclass () == LOC_BLOCK
-			      && (!treg.has_value ()
-				  || treg_matches_sym_type_name (*treg,
-								 sym)))
-			  || (kind == TYPES_DOMAIN
-			      && sym->aclass () == LOC_TYPEDEF
-			      && sym->domain () != MODULE_DOMAIN)
-			  || (kind == MODULES_DOMAIN
-			      && sym->domain () == MODULE_DOMAIN
-			      && sym->line () != 0))))
+	      if (!(file_matches (real_symtab->filename, filenames, false)
+		    || ((basenames_may_differ
+			 || file_matches (lbasename (real_symtab->filename),
+					  filenames, true))
+			&& file_matches (symtab_to_fullname (real_symtab),
+					 filenames, false))))
+		continue;
+
+	      if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
+						    nullptr, 0) == 0)
+		continue;
+
+	      bool matches = false;
+	      if (!matches && kind == VARIABLES_DOMAIN)
+		{
+		  if (sym->aclass () != LOC_TYPEDEF
+		      && sym->aclass () != LOC_UNRESOLVED
+		      && sym->aclass () != LOC_BLOCK
+		      /* LOC_CONST can be used for more than
+			 just enums, e.g., c++ static const
+			 members.  We only want to skip enums
+			 here.  */
+		      && !(sym->aclass () == LOC_CONST
+			   && (sym->type ()->code ()
+			       == TYPE_CODE_ENUM))
+		      && (!treg.has_value ()
+			  || treg_matches_sym_type_name (*treg, sym)))
+		    matches = true;
+		}
+	      if (!matches && kind == FUNCTIONS_DOMAIN)
+		{
+		  if (sym->aclass () == LOC_BLOCK
+		      && (!treg.has_value ()
+			  || treg_matches_sym_type_name (*treg,
+							 sym)))
+		    matches = true;
+		}
+	      if (!matches && kind == TYPES_DOMAIN)
+		{
+		  if (sym->aclass () == LOC_TYPEDEF
+		      && sym->domain () != MODULE_DOMAIN)
+		    matches = true;
+		}
+	      if (!matches && kind == MODULES_DOMAIN)
+		{
+		  if (sym->domain () == MODULE_DOMAIN
+		      && sym->line () != 0)
+		    matches = true;
+		}
+	      if (matches)
 		{
 		  if (result_set->size () < m_max_search_results)
 		    {

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 10/30] Use a .def file for domain_enum
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (8 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 09/30] Split up a big 'if' in symtab.c Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-29 17:57   ` Lancelot SIX
  2024-01-18 20:32 ` [PATCH v2 11/30] Add two new symbol domains Tom Tromey
                   ` (20 subsequent siblings)
  30 siblings, 1 reply; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

Future patches will change and reuse the names from domain_enum.  This
patch makes this less error-prone by having a single point to define
these names, using the typical gdb ".def" file.
---
 gdb/guile/scm-symbol.c | 18 ++++++++++--------
 gdb/python/py-symbol.c | 21 ++++++++-------------
 gdb/sym-domains.def    | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 gdb/symtab.c           | 10 ++++------
 gdb/symtab.h           | 31 +++----------------------------
 5 files changed, 72 insertions(+), 55 deletions(-)

diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index 801c3f13b96..bf5fe24f23d 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -693,16 +693,18 @@ static const scheme_integer_constant symbol_integer_constants[] =
   X (LOC_OPTIMIZED_OUT),
   X (LOC_COMPUTED),
   X (LOC_REGPARM_ADDR),
-
-  X (UNDEF_DOMAIN),
-  X (VAR_DOMAIN),
-  X (STRUCT_DOMAIN),
-  X (LABEL_DOMAIN),
-  X (VARIABLES_DOMAIN),
-  X (FUNCTIONS_DOMAIN),
-  X (TYPES_DOMAIN),
 #undef X
 
+#define DOMAIN(X) \
+  { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN },
+#include "sym-domains.def"
+#undef DOMAIN
+
+  /* These were never correct.  */
+  { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN },
+  { "SYMBOL_FUNCTIONS_DOMAIN", VAR_DOMAIN },
+  { "SYMBOL_TYPES_DOMAIN", VAR_DOMAIN },
+
   END_INTEGER_CONSTANTS
 };
 
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 82ea5c59c63..52a25b632e0 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -670,20 +670,15 @@ gdbpy_initialize_symbols (void)
       || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_COMMON_BLOCK",
 				  LOC_COMMON_BLOCK) < 0
       || PyModule_AddIntConstant (gdb_module, "SYMBOL_LOC_REGPARM_ADDR",
-				  LOC_REGPARM_ADDR) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_UNDEF_DOMAIN",
-				  UNDEF_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_VAR_DOMAIN",
-				  VAR_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_STRUCT_DOMAIN",
-				  STRUCT_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_LABEL_DOMAIN",
-				  LABEL_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_MODULE_DOMAIN",
-				  MODULE_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_COMMON_BLOCK_DOMAIN",
-				  COMMON_BLOCK_DOMAIN) < 0)
+				  LOC_REGPARM_ADDR) < 0)
+    return -1;
+
+#define DOMAIN(X)							\
+  if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN",	\
+			       X ## _DOMAIN) < 0)			\
     return -1;
+#include "sym-domains.def"
+#undef DOMAIN
 
   /* These remain defined for compatibility, but as they were never
      correct, they are no longer documented.  Eventually we can remove
diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def
new file mode 100644
index 00000000000..251c66fa04b
--- /dev/null
+++ b/gdb/sym-domains.def
@@ -0,0 +1,47 @@
+/* Symbol domains  -*- c++ -*-
+
+   Copyright (C) 2023 Free Software Foundation, Inc.
+
+   This file is part of GDB.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+/* UNDEF_DOMAIN is used when a domain has not been discovered or
+   none of the following apply.  This usually indicates an error either
+   in the symbol information or in gdb's handling of symbols.  */
+
+DOMAIN (UNDEF)
+
+/* VAR_DOMAIN is the usual domain.  In C, this contains variables,
+   function names, typedef names and enum type values.  */
+
+DOMAIN (VAR)
+
+/* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
+   Thus, if `struct foo' is used in a C program, it produces a symbol named
+   `foo' in the STRUCT_DOMAIN.  */
+
+DOMAIN (STRUCT)
+
+/* MODULE_DOMAIN is used in Fortran to hold module type names.  */
+
+DOMAIN (MODULE)
+
+/* LABEL_DOMAIN may be used for names of labels (for gotos).  */
+
+DOMAIN (LABEL)
+
+/* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
+   They also always use LOC_COMMON_BLOCK.  */
+DOMAIN (COMMON_BLOCK)
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 2020210c5f4..b1deb9d6767 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -305,12 +305,10 @@ domain_name (domain_enum e)
 {
   switch (e)
     {
-    case UNDEF_DOMAIN: return "UNDEF_DOMAIN";
-    case VAR_DOMAIN: return "VAR_DOMAIN";
-    case STRUCT_DOMAIN: return "STRUCT_DOMAIN";
-    case MODULE_DOMAIN: return "MODULE_DOMAIN";
-    case LABEL_DOMAIN: return "LABEL_DOMAIN";
-    case COMMON_BLOCK_DOMAIN: return "COMMON_BLOCK_DOMAIN";
+#define DOMAIN(X)				\
+      case X ## _DOMAIN: return #X "_DOMAIN";
+#include "sym-domains.def"
+#undef DOMAIN
     default: gdb_assert_not_reached ("bad domain_enum");
     }
 }
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 0a5f2633fe8..7e841c4033f 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -894,34 +894,9 @@ struct minimal_symbol : public general_symbol_info
 
 enum domain_enum
 {
-  /* UNDEF_DOMAIN is used when a domain has not been discovered or
-     none of the following apply.  This usually indicates an error either
-     in the symbol information or in gdb's handling of symbols.  */
-
-  UNDEF_DOMAIN,
-
-  /* VAR_DOMAIN is the usual domain.  In C, this contains variables,
-     function names, typedef names and enum type values.  */
-
-  VAR_DOMAIN,
-
-  /* STRUCT_DOMAIN is used in C to hold struct, union and enum type names.
-     Thus, if `struct foo' is used in a C program, it produces a symbol named
-     `foo' in the STRUCT_DOMAIN.  */
-
-  STRUCT_DOMAIN,
-
-  /* MODULE_DOMAIN is used in Fortran to hold module type names.  */
-
-  MODULE_DOMAIN,
-
-  /* LABEL_DOMAIN may be used for names of labels (for gotos).  */
-
-  LABEL_DOMAIN,
-
-  /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
-     They also always use LOC_COMMON_BLOCK.  */
-  COMMON_BLOCK_DOMAIN,
+#define DOMAIN(X) X ## _DOMAIN,
+#include "sym-domains.def"
+#undef DOMAIN
 };
 
 /* The number of bits in a symbol used to represent the domain.  */

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 11/30] Add two new symbol domains
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (9 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 10/30] Use a .def file for domain_enum Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 12/30] Add domain_search_flags Tom Tromey
                   ` (19 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This adds two new symbol domain constants, TYPE_DOMAIN and
FUNCTION_DOMAIN.

Historically, gdb was a C debugger, and the symbol tables continue to
reflect this.  In particular, symbol domains match the C language,
with VAR_DOMAIN including variables, functions, and types.

However, other languages have other approaches to namespacing.  And,
in any case, it is often useful for other parts of gdb to be able to
distinguish between some domains at lookup time, without resorting to
examining a symbol's location -- in some situations, this sort of
filtering happens too late.

Nothing uses these new domains yet, but the idea behind the patch is
to separate symbols into more domains and then let the
language-specific parts of gdb implement their semantics in terms of
these categories.
---
 gdb/sym-domains.def | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def
index 251c66fa04b..cea25a5f5b3 100644
--- a/gdb/sym-domains.def
+++ b/gdb/sym-domains.def
@@ -45,3 +45,12 @@ DOMAIN (LABEL)
 /* Fortran common blocks.  Their naming must be separate from VAR_DOMAIN.
    They also always use LOC_COMMON_BLOCK.  */
 DOMAIN (COMMON_BLOCK)
+
+/* TYPE_DOMAIN is for types and typedefs.  Note that tags are not
+   found here, see STRUCT_DOMAIN above.  */
+
+DOMAIN (TYPE)
+
+/* FUNCTION_DOMAIN is for functions and methods.  */
+
+DOMAIN (FUNCTION)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 12/30] Add domain_search_flags
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (10 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 11/30] Add two new symbol domains Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 13/30] Replace search_domain with domain_search_flags Tom Tromey
                   ` (18 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

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.
---
 gdb/symtab.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 gdb/symtab.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index b1deb9d6767..779e1ff82fe 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)
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 7e841c4033f..c02a58367c6 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.  */
 
@@ -1250,6 +1292,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;

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 13/30] Replace search_domain with domain_search_flags
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (11 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 12/30] Add domain_search_flags Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 14/30] Remove a check of VAR_DOMAIN Tom Tromey
                   ` (17 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This patch changes gdb to replace search_domain with
domain_search_flags everywhere.  search_domain is removed.
---
 gdb/ada-lang.c                      |   6 +-
 gdb/compile/compile-cplus-symbols.c |   2 +-
 gdb/dwarf2/cooked-index.c           |  36 ++++++++++
 gdb/dwarf2/cooked-index.h           |  24 +------
 gdb/dwarf2/read-debug-names.c       | 122 ++++++++++-----------------------
 gdb/dwarf2/read-gdb-index.c         |  33 +++++----
 gdb/dwarf2/read.c                   |   6 +-
 gdb/linespec.c                      |  33 ++++-----
 gdb/mi/mi-symbol-cmds.c             |  33 ++++-----
 gdb/objfiles.h                      |   2 +-
 gdb/psymtab.c                       |  14 ++--
 gdb/psymtab.h                       |   2 +-
 gdb/python/py-symbol.c              |   2 +-
 gdb/python/python.c                 |   2 +-
 gdb/quick-symbol.h                  |   2 +-
 gdb/symfile-debug.c                 |  12 ++--
 gdb/symfile.c                       |   2 +-
 gdb/symfile.h                       |   2 +-
 gdb/symmisc.c                       |   2 +-
 gdb/symtab.c                        | 130 +++++++++++++++++++-----------------
 gdb/symtab.h                        |  36 ++--------
 21 files changed, 221 insertions(+), 282 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index c04c48e2e90..4eea4e6609e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5514,7 +5514,7 @@ map_matching_symbols (struct objfile *objfile,
 				    global
 				    ? SEARCH_GLOBAL_BLOCK
 				    : SEARCH_STATIC_BLOCK,
-				    domain, ALL_DOMAIN);
+				    domain, SEARCH_ALL);
 
   const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
   for (compunit_symtab *symtab : objfile->compunits ())
@@ -12997,7 +12997,7 @@ ada_add_global_exceptions (compiled_regex *preg,
 			   },
 			   NULL,
 			   SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-			   VARIABLES_DOMAIN);
+			   SEARCH_VAR_DOMAIN);
 
   /* Iterate over all objfiles irrespective of scope or linker namespaces
      so we get all exceptions anywhere in the progspace.  */
@@ -13542,7 +13542,7 @@ class ada_language : public language_defn
 			     NULL,
 			     NULL,
 			     SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-			     ALL_DOMAIN);
+			     SEARCH_ALL);
 
     /* At this point scan through the misc symbol vectors and add each
        symbol you find to the list.  Eventually we want to ignore
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index e4bbaa9a2b0..dbdabe94e1e 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -368,7 +368,7 @@ gcc_cplus_convert_symbol (void *datum,
 
       symbol_searcher searcher;
       searcher.find_all_symbols (identifier, current_language,
-				 ALL_DOMAIN, nullptr, nullptr);
+				 SEARCH_ALL, nullptr, nullptr);
 
       /* Convert any found symbols.  */
       for (const auto &it : searcher.matching_symbols ())
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index e4f112b6ee0..2430dbd40f4 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -199,6 +199,42 @@ test_compare ()
 
 /* See cooked-index.h.  */
 
+bool
+cooked_index_entry::matches (domain_search_flags kind) const
+{
+  /* Just reject type declarations.  */
+  if ((flags & IS_TYPE_DECLARATION) != 0)
+    return false;
+
+  if ((kind & SEARCH_VAR_DOMAIN) != 0
+      && (tag == DW_TAG_variable
+	  || tag == DW_TAG_constant
+	  || tag == DW_TAG_enumerator))
+    return true;
+
+  if ((kind & SEARCH_STRUCT_DOMAIN) != 0
+      && (tag == DW_TAG_structure_type
+	  || tag == DW_TAG_class_type
+	  || tag == DW_TAG_union_type
+	  || tag == DW_TAG_enumeration_type))
+    return true;
+
+  if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module)
+    return true;
+
+  if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag))
+    return true;
+
+  if ((kind & SEARCH_FUNCTION_DOMAIN) != 0
+      && (tag == DW_TAG_subprogram
+	  || tag == DW_TAG_entry_point))
+    return true;
+
+  return false;
+}
+
+/* See cooked-index.h.  */
+
 const char *
 cooked_index_entry::full_name (struct obstack *storage, bool for_main) const
 {
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index ebaed04753c..8fc54f9b994 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -160,29 +160,7 @@ struct cooked_index_entry : public allocate_on_obstack
   }
 
   /* Return true if this entry matches KIND.  */
-  bool matches (enum search_domain kind) const
-  {
-    /* Just reject type declarations.  */
-    if ((flags & IS_TYPE_DECLARATION) != 0)
-      return false;
-
-    switch (kind)
-      {
-      case VARIABLES_DOMAIN:
-	return (tag == DW_TAG_variable
-		|| tag == DW_TAG_constant
-		|| tag == DW_TAG_enumerator);
-      case FUNCTIONS_DOMAIN:
-	return (tag == DW_TAG_subprogram
-		|| tag == DW_TAG_entry_point);
-      case TYPES_DOMAIN:
-	return tag_is_type (tag);
-      case MODULES_DOMAIN:
-	return tag == DW_TAG_module;
-      }
-
-    return true;
-  }
+  bool matches (domain_search_flags kind) const;
 
   /* Construct the fully-qualified name of this entry and return a
      pointer to it.  If allocation is needed, it will be done on
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index a2a9fd425ae..91aeb70fac8 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -92,7 +92,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) override;
+     domain_search_flags kind) override;
 };
 
 quick_symbol_functions_up
@@ -526,7 +526,7 @@ class dw2_debug_names_iterator
   {}
 
   dw2_debug_names_iterator (const mapped_debug_names &map,
-			    search_domain search, uint32_t namei,
+			    domain_search_flags search, uint32_t namei,
 			    dwarf2_per_objfile *per_objfile,
 			    domain_enum domain = UNDEF_DOMAIN)
     : m_map (map),
@@ -564,7 +564,7 @@ class dw2_debug_names_iterator
 
   /* The kind of symbol we're looking for.  */
   const domain_enum m_domain = UNDEF_DOMAIN;
-  const search_domain m_search = ALL_DOMAIN;
+  const domain_search_flags m_search = SEARCH_ALL;
 
   /* The list of CUs from the index entry of the symbol, or NULL if
      not found.  */
@@ -831,100 +831,46 @@ dw2_debug_names_iterator::next ()
 	}
     }
 
-  /* Match dw2_symtab_iter_next, symbol_kind
-     and debug_names::psymbol_tag.  */
-  switch (m_domain)
+  domain_enum domain = UNDEF_DOMAIN;
+  switch (indexval.dwarf_tag)
     {
-    case VAR_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_variable:
-	case DW_TAG_subprogram:
-	/* Some types are also in VAR_DOMAIN.  */
-	case DW_TAG_typedef:
-	case DW_TAG_structure_type:
-	  break;
-	default:
-	  goto again;
-	}
-      break;
-    case STRUCT_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_typedef:
-	case DW_TAG_structure_type:
-	  break;
-	default:
-	  goto again;
-	}
+    case DW_TAG_variable:
+      domain = VAR_DOMAIN;
       break;
-    case LABEL_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case 0:
-	case DW_TAG_variable:
-	  break;
-	default:
-	  goto again;
-	}
-      break;
-    case MODULE_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_module:
-	  break;
-	default:
-	  goto again;
-	}
-      break;
-    default:
+
+    case DW_TAG_subprogram:
+      domain = FUNCTION_DOMAIN;
       break;
-    }
 
-  /* Match dw2_expand_symtabs_matching, symbol_kind and
-     debug_names::psymbol_tag.  */
-  switch (m_search)
-    {
-    case VARIABLES_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_variable:
-	  break;
-	default:
-	  goto again;
-	}
+    case DW_TAG_structure_type:
+    case DW_TAG_union_type:
+    case DW_TAG_enumeration_type:
+      domain = STRUCT_DOMAIN;
       break;
-    case FUNCTIONS_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_subprogram:
-	  break;
-	default:
-	  goto again;
-	}
+
+    case DW_TAG_typedef:
+      domain = TYPE_DOMAIN;
       break;
-    case TYPES_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_typedef:
-	case DW_TAG_structure_type:
-	  break;
-	default:
-	  goto again;
-	}
+
+    case DW_TAG_label:
+      domain = LABEL_DOMAIN;
       break;
-    case MODULES_DOMAIN:
-      switch (indexval.dwarf_tag)
-	{
-	case DW_TAG_module:
-	  break;
-	default:
-	  goto again;
-	}
-    default:
+
+    case DW_TAG_module:
+      domain = MODULE_DOMAIN;
       break;
     }
 
+  if (! (m_domain == domain
+	 || (m_domain == VAR_DOMAIN
+	     && (domain == TYPE_DOMAIN
+		 || domain == FUNCTION_DOMAIN))))
+    goto again;
+
+  domain_search_flags flags = to_search_flags (domain);
+  if ((flags & m_search) == 0)
+    goto again;
+
   return per_cu;
 }
 
@@ -947,7 +893,7 @@ dwarf2_debug_names_index::expand_symtabs_matching
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
    domain_enum domain,
-   enum search_domain kind)
+   domain_search_flags kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 3f10aa748f0..091aa62d61d 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -147,7 +147,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) override;
+     domain_search_flags kind) override;
 };
 
 /* This dumps minimal information about the index.
@@ -176,7 +176,7 @@ dw2_expand_marked_cus
    gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   search_domain kind)
+   domain_search_flags kind)
 {
   offset_type vec_len, vec_idx;
   bool global_seen = false;
@@ -227,27 +227,24 @@ dw2_expand_marked_cus
 		continue;
 	    }
 
-	  switch (kind)
+	  domain_search_flags mask = 0;
+	  switch (symbol_kind)
 	    {
-	    case VARIABLES_DOMAIN:
-	      if (symbol_kind != GDB_INDEX_SYMBOL_KIND_VARIABLE)
-		continue;
-	      break;
-	    case FUNCTIONS_DOMAIN:
-	      if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION)
-		continue;
+	    case GDB_INDEX_SYMBOL_KIND_VARIABLE:
+	      mask = SEARCH_VAR_DOMAIN;
 	      break;
-	    case TYPES_DOMAIN:
-	      if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE)
-		continue;
+	    case GDB_INDEX_SYMBOL_KIND_FUNCTION:
+	      mask = SEARCH_FUNCTION_DOMAIN;
 	      break;
-	    case MODULES_DOMAIN:
-	      if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER)
-		continue;
+	    case GDB_INDEX_SYMBOL_KIND_TYPE:
+	      mask = SEARCH_TYPE_DOMAIN;
 	      break;
-	    default:
+	    case GDB_INDEX_SYMBOL_KIND_OTHER:
+	      mask = SEARCH_MODULE_DOMAIN;
 	      break;
 	    }
+	  if ((kind & mask) == 0)
+	    continue;
 	}
 
       /* Don't crash on bad data.  */
@@ -276,7 +273,7 @@ dwarf2_gdb_index::expand_symtabs_matching
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind)
+     domain_search_flags kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 078edd8c842..292dba3e24e 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1641,7 +1641,7 @@ struct readnow_functions : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) override
+     domain_search_flags kind) override
   {
     return true;
   }
@@ -16734,7 +16734,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) override;
+     domain_search_flags kind) override;
 
   struct compunit_symtab *find_pc_sect_compunit_symtab
     (struct objfile *objfile, struct bound_minimal_symbol msymbol,
@@ -16799,7 +16799,7 @@ cooked_index_functions::expand_symtabs_matching
       gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
       block_search_flags search_flags,
       domain_enum domain,
-      enum search_domain kind)
+      domain_search_flags kind)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 2c54ed55d93..1d8cbc58b97 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -387,13 +387,13 @@ static int symbol_to_sal (struct symtab_and_line *result,
 
 static void add_matching_symbols_to_info (const char *name,
 					  symbol_name_match_type name_match_type,
-					  enum search_domain search_domain,
+					  domain_search_flags domain_search_flags,
 					  struct collect_info *info,
 					  struct program_space *pspace);
 
 static void add_all_symbol_names_from_pspace
     (struct collect_info *info, struct program_space *pspace,
-     const std::vector<const char *> &names, enum search_domain search_domain);
+     const std::vector<const char *> &names, domain_search_flags domain_search_flags);
 
 static std::vector<symtab *>
   collect_symtabs_from_filename (const char *file,
@@ -1155,7 +1155,7 @@ iterate_over_all_matching_symtabs
   (struct linespec_state *state,
    const lookup_name_info &lookup_name,
    const domain_enum name_domain,
-   enum search_domain search_domain,
+   domain_search_flags domain_search_flags,
    struct program_space *search_pspace, bool include_inline,
    gdb::function_view<symbol_found_callback_ftype> callback)
 {
@@ -1174,7 +1174,7 @@ iterate_over_all_matching_symtabs
 					    (SEARCH_GLOBAL_BLOCK
 					     | SEARCH_STATIC_BLOCK),
 					    UNDEF_DOMAIN,
-					    search_domain);
+					    domain_search_flags);
 
 	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
@@ -3331,7 +3331,7 @@ decode_objc (struct linespec_state *self, linespec *ls, const char *arg)
     return {};
 
   add_all_symbol_names_from_pspace (&info, NULL, symbol_names,
-				    FUNCTIONS_DOMAIN);
+				    SEARCH_FUNCTION_DOMAIN);
 
   std::vector<symtab_and_line> values;
   if (!symbols.empty () || !minimal_symbols.empty ())
@@ -3450,10 +3450,10 @@ lookup_prefix_sym (struct linespec_state *state,
       if (elt == nullptr)
 	{
 	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     STRUCT_DOMAIN, ALL_DOMAIN,
+					     STRUCT_DOMAIN, SEARCH_ALL,
 					     NULL, false, collector);
 	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     VAR_DOMAIN, ALL_DOMAIN,
+					     VAR_DOMAIN, SEARCH_ALL,
 					     NULL, false, collector);
 	}
       else
@@ -3531,12 +3531,12 @@ static void
 add_all_symbol_names_from_pspace (struct collect_info *info,
 				  struct program_space *pspace,
 				  const std::vector<const char *> &names,
-				  enum search_domain search_domain)
+				  domain_search_flags domain_search_flags)
 {
   for (const char *iter : names)
     add_matching_symbols_to_info (iter,
 				  symbol_name_match_type::FULL,
-				  search_domain, info, pspace);
+				  domain_search_flags, info, pspace);
 }
 
 static void
@@ -3630,7 +3630,7 @@ find_method (struct linespec_state *self,
 	     iterate over the symbol tables looking for all
 	     matches in this pspace.  */
 	  add_all_symbol_names_from_pspace (&info, pspace, result_names,
-					    FUNCTIONS_DOMAIN);
+					    SEARCH_FUNCTION_DOMAIN);
 
 	  superclass_vec.clear ();
 	  last_result_len = result_names.size ();
@@ -3753,7 +3753,7 @@ symtabs_from_filename (const char *filename,
 void
 symbol_searcher::find_all_symbols (const std::string &name,
 				   const struct language_defn *language,
-				   enum search_domain search_domain,
+				   domain_search_flags domain_search_flags,
 				   std::vector<symtab *> *search_symtabs,
 				   struct program_space *search_pspace)
 {
@@ -3775,7 +3775,7 @@ symbol_searcher::find_all_symbols (const std::string &name,
   info.file_symtabs = search_symtabs;
 
   add_matching_symbols_to_info (name.c_str (), symbol_name_match_type::WILD,
-				search_domain, &info, search_pspace);
+				domain_search_flags, &info, search_pspace);
 }
 
 /* Look up a function symbol named NAME in symtabs FILE_SYMTABS.  Matching
@@ -3801,9 +3801,10 @@ find_function_symbols (struct linespec_state *state,
   find_imps (name, &symbol_names);
   if (!symbol_names.empty ())
     add_all_symbol_names_from_pspace (&info, state->search_pspace,
-				      symbol_names, FUNCTIONS_DOMAIN);
+				      symbol_names, SEARCH_FUNCTION_DOMAIN);
   else
-    add_matching_symbols_to_info (name, name_match_type, FUNCTIONS_DOMAIN,
+    add_matching_symbols_to_info (name, name_match_type,
+				  SEARCH_FUNCTION_DOMAIN,
 				  &info, state->search_pspace);
 }
 
@@ -4322,7 +4323,7 @@ search_minsyms_for_name (struct collect_info *info,
 static void
 add_matching_symbols_to_info (const char *name,
 			      symbol_name_match_type name_match_type,
-			      enum search_domain search_domain,
+			      domain_search_flags domain_search_flags,
 			      struct collect_info *info,
 			      struct program_space *pspace)
 {
@@ -4333,7 +4334,7 @@ add_matching_symbols_to_info (const char *name,
       if (elt == nullptr)
 	{
 	  iterate_over_all_matching_symtabs (info->state, lookup_name,
-					     VAR_DOMAIN, search_domain,
+					     VAR_DOMAIN, domain_search_flags,
 					     pspace, true,
 					     [&] (block_symbol *bsym)
 	    { return info->add_symbol (bsym); });
diff --git a/gdb/mi/mi-symbol-cmds.c b/gdb/mi/mi-symbol-cmds.c
index 758f5974706..37cf2fbcfa2 100644
--- a/gdb/mi/mi-symbol-cmds.c
+++ b/gdb/mi/mi-symbol-cmds.c
@@ -72,7 +72,7 @@ mi_cmd_symbol_list_lines (const char *command, const char *const *argv,
    results.  */
 
 static void
-output_debug_symbol (ui_out *uiout, enum search_domain kind,
+output_debug_symbol (ui_out *uiout, domain_search_flags kind,
 		     struct symbol *sym, int block)
 {
   ui_out_emit_tuple tuple_emitter (uiout, NULL);
@@ -81,7 +81,7 @@ output_debug_symbol (ui_out *uiout, enum search_domain kind,
     uiout->field_unsigned ("line", sym->line ());
   uiout->field_string ("name", sym->print_name ());
 
-  if (kind == FUNCTIONS_DOMAIN || kind == VARIABLES_DOMAIN)
+  if ((kind & (SEARCH_FUNCTION_DOMAIN | SEARCH_VAR_DOMAIN)) != 0)
     {
       string_file tmp_stream;
       type_print (sym->type (), "", &tmp_stream, -1);
@@ -113,7 +113,7 @@ output_nondebug_symbol (ui_out *uiout,
    and then prints the matching [m]symbols in an MI structured format.  */
 
 static void
-mi_symbol_info (enum search_domain kind, const char *name_regexp,
+mi_symbol_info (domain_search_flags kind, const char *name_regexp,
 		const char *type_regexp, bool exclude_minsyms,
 		size_t max_results)
 {
@@ -190,7 +190,7 @@ parse_max_results_option (const char *arg)
    Processes command line options from ARGV and ARGC.  */
 
 static void
-mi_info_functions_or_variables (enum search_domain kind,
+mi_info_functions_or_variables (domain_search_flags kind,
 				const char *const *argv, int argc)
 {
   size_t max_results = SIZE_MAX;
@@ -217,7 +217,7 @@ mi_info_functions_or_variables (enum search_domain kind,
   while (1)
     {
       const char *cmd_string
-	= ((kind == FUNCTIONS_DOMAIN)
+	= ((kind == SEARCH_FUNCTION_DOMAIN)
 	   ? "-symbol-info-functions" : "-symbol-info-variables");
       int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
       if (opt < 0)
@@ -253,7 +253,7 @@ typedef std::vector<module_symbol_search>::const_iterator
 static module_symbol_search_iterator
 output_module_symbols_in_single_module_and_file
 	(struct ui_out *uiout, module_symbol_search_iterator iter,
-	 const module_symbol_search_iterator end, enum search_domain kind)
+	 const module_symbol_search_iterator end, domain_search_flags kind)
 {
   /* The symbol for the module in which the first result resides.  */
   const symbol *first_module_symbol = iter->first.symbol;
@@ -288,7 +288,7 @@ output_module_symbols_in_single_module_and_file
 static module_symbol_search_iterator
 output_module_symbols_in_single_module
 	(struct ui_out *uiout, module_symbol_search_iterator iter,
-	 const module_symbol_search_iterator end, enum search_domain kind)
+	 const module_symbol_search_iterator end, domain_search_flags kind)
 {
   gdb_assert (iter->first.symbol != nullptr);
   gdb_assert (iter->second.symbol != nullptr);
@@ -316,8 +316,8 @@ output_module_symbols_in_single_module
    command line options passed to the MI command.  */
 
 static void
-mi_info_module_functions_or_variables (enum search_domain kind,
-					const char *const *argv, int argc)
+mi_info_module_functions_or_variables (domain_search_flags kind,
+				       const char *const *argv, int argc)
 {
   const char *module_regexp = nullptr;
   const char *regexp = nullptr;
@@ -343,7 +343,7 @@ mi_info_module_functions_or_variables (enum search_domain kind,
   while (1)
     {
       const char *cmd_string
-	= ((kind == FUNCTIONS_DOMAIN)
+	= ((kind == SEARCH_FUNCTION_DOMAIN)
 	   ? "-symbol-info-module-functions"
 	   : "-symbol-info-module-variables");
       int opt = mi_getopt (cmd_string, argc, argv, opts, &oind, &oarg);
@@ -385,7 +385,7 @@ void
 mi_cmd_symbol_info_functions (const char *command, const char *const *argv,
 			      int argc)
 {
-  mi_info_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc);
+  mi_info_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
 }
 
 /* Implement -symbol-info-module-functions command.  */
@@ -394,7 +394,7 @@ void
 mi_cmd_symbol_info_module_functions (const char *command,
 				     const char *const *argv, int argc)
 {
-  mi_info_module_functions_or_variables (FUNCTIONS_DOMAIN, argv, argc);
+  mi_info_module_functions_or_variables (SEARCH_FUNCTION_DOMAIN, argv, argc);
 }
 
 /* Implement -symbol-info-module-variables command.  */
@@ -403,7 +403,7 @@ void
 mi_cmd_symbol_info_module_variables (const char *command,
 				     const char *const *argv, int argc)
 {
-  mi_info_module_functions_or_variables (VARIABLES_DOMAIN, argv, argc);
+  mi_info_module_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
 }
 
 /* Implement -symbol-inf-modules command.  */
@@ -446,7 +446,7 @@ mi_cmd_symbol_info_modules (const char *command, const char *const *argv,
 	}
     }
 
-  mi_symbol_info (MODULES_DOMAIN, regexp, nullptr, true, max_results);
+  mi_symbol_info (SEARCH_MODULE_DOMAIN, regexp, nullptr, true, max_results);
 }
 
 /* Implement -symbol-info-types command.  */
@@ -489,7 +489,8 @@ mi_cmd_symbol_info_types (const char *command, const char *const *argv,
 	}
     }
 
-  mi_symbol_info (TYPES_DOMAIN, regexp, nullptr, true, max_results);
+  mi_symbol_info (SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN, regexp, nullptr,
+		  true, max_results);
 }
 
 /* Implement -symbol-info-variables command.  */
@@ -498,5 +499,5 @@ void
 mi_cmd_symbol_info_variables (const char *command, const char *const *argv,
 			      int argc)
 {
-  mi_info_functions_or_variables (VARIABLES_DOMAIN, argv, argc);
+  mi_info_functions_or_variables (SEARCH_VAR_DOMAIN, argv, argc);
 }
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 65115ce17f0..e576c4b7087 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -592,7 +592,7 @@ struct objfile
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind);
+     domain_search_flags kind);
 
   /* See quick_symbol_functions.  */
   struct compunit_symtab *find_pc_sect_compunit_symtab
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 4a3a872309d..61d7c3bdc71 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -803,7 +803,7 @@ recursively_search_psymtabs
    struct objfile *objfile,
    block_search_flags search_flags,
    domain_enum domain,
-   enum search_domain search,
+   domain_search_flags search,
    const lookup_name_info &lookup_name,
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher)
 {
@@ -876,15 +876,15 @@ recursively_search_psymtabs
 	  if ((domain == UNDEF_DOMAIN
 	       || symbol_matches_domain ((*psym)->ginfo.language (),
 					 (*psym)->domain, domain))
-	      && (search == ALL_DOMAIN
-		  || (search == MODULES_DOMAIN
+	      && (search == SEARCH_ALL
+		  || (search == SEARCH_MODULE_DOMAIN
 		      && (*psym)->domain == MODULE_DOMAIN)
-		  || (search == VARIABLES_DOMAIN
+		  || (search == SEARCH_VAR_DOMAIN
 		      && (*psym)->aclass != LOC_TYPEDEF
 		      && (*psym)->aclass != LOC_BLOCK)
-		  || (search == FUNCTIONS_DOMAIN
+		  || (search == SEARCH_FUNCTION_DOMAIN
 		      && (*psym)->aclass == LOC_BLOCK)
-		  || (search == TYPES_DOMAIN
+		  || (search == SEARCH_TYPE_DOMAIN
 		      && (*psym)->aclass == LOC_TYPEDEF))
 	      && psymbol_name_matches (*psym, lookup_name)
 	      && (sym_matcher == NULL
@@ -914,7 +914,7 @@ psymbol_functions::expand_symtabs_matching
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
    domain_enum domain,
-   enum search_domain search)
+   domain_search_flags search)
 {
   /* Clear the search flags.  */
   for (partial_symtab *ps : partial_symbols (objfile))
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index 2bf423400d1..c4a0d9184f2 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -634,7 +634,7 @@ struct psymbol_functions : public quick_symbol_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) override;
+     domain_search_flags kind) override;
 
   struct compunit_symtab *find_pc_sect_compunit_symtab
     (struct objfile *objfile, struct bound_minimal_symbol msymbol,
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 52a25b632e0..a7d010f6d0c 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -596,7 +596,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
       lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
       expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
 			       SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-			       ALL_DOMAIN);
+			       SEARCH_ALL);
 
       for (objfile *objfile : current_program_space->objfiles ())
 	{
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 1d406392bd3..de3a94dfc9a 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -736,7 +736,7 @@ gdbpy_rbreak (PyObject *self, PyObject *args, PyObject *kw)
       minsyms_p = cmp;
     }
 
-  global_symbol_searcher spec (FUNCTIONS_DOMAIN, regex);
+  global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regex);
   SCOPE_EXIT {
     for (const char *elem : spec.filenames)
       xfree ((void *) elem);
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index 63b2908b8b2..8646ac199bd 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -156,7 +156,7 @@ struct quick_symbol_functions
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
      domain_enum domain,
-     enum search_domain kind) = 0;
+     domain_search_flags kind) = 0;
 
   /* Return the comp unit from OBJFILE that contains PC and
      SECTION.  Return NULL if there is no such compunit.  This
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index b0d2e19295d..38db7777d83 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -223,7 +223,7 @@ objfile::map_symtabs_matching_filename
 					  (SEARCH_GLOBAL_BLOCK
 					   | SEARCH_STATIC_BLOCK),
 					  UNDEF_DOMAIN,
-					  ALL_DOMAIN))
+					  SEARCH_ALL))
 	{
 	  retval = false;
 	  break;
@@ -289,7 +289,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
 					  ? SEARCH_GLOBAL_BLOCK
 					  : SEARCH_STATIC_BLOCK,
 					  domain,
-					  ALL_DOMAIN))
+					  SEARCH_ALL))
 	break;
     }
 
@@ -344,7 +344,7 @@ objfile::expand_symtabs_for_function (const char *func_name)
 				   (SEARCH_GLOBAL_BLOCK
 				    | SEARCH_STATIC_BLOCK),
 				   VAR_DOMAIN,
-				   ALL_DOMAIN);
+				   SEARCH_ALL);
 }
 
 void
@@ -381,7 +381,7 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
 				   (SEARCH_GLOBAL_BLOCK
 				    | SEARCH_STATIC_BLOCK),
 				   UNDEF_DOMAIN,
-				   ALL_DOMAIN);
+				   SEARCH_ALL);
 }
 
 bool
@@ -392,7 +392,7 @@ objfile::expand_symtabs_matching
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
    domain_enum domain,
-   enum search_domain kind)
+   domain_search_flags kind)
 {
   /* This invariant is documented in quick-functions.h.  */
   gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
@@ -404,7 +404,7 @@ objfile::expand_symtabs_matching
 		host_address_to_string (&file_matcher),
 		host_address_to_string (&symbol_matcher),
 		host_address_to_string (&expansion_notify),
-		search_domain_name (kind));
+		domain_name (kind).c_str ());
 
   for (const auto &iter : qf)
     if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 6b9f8055711..065eaf0d518 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3769,7 +3769,7 @@ expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   enum search_domain kind)
+   domain_search_flags kind)
 {
   for (objfile *objfile : current_program_space->objfiles ())
     if (!objfile->expand_symtabs_matching (file_matcher,
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 4cb3c38a5bf..6f8b441b39f 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -352,7 +352,7 @@ bool expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   enum search_domain kind);
+   domain_search_flags kind);
 
 void map_symbol_filenames (gdb::function_view<symbol_filename_ftype> fun,
 			   bool need_fullname);
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 5dfb9fca8f0..519df255047 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -920,7 +920,7 @@ maintenance_expand_symtabs (const char *args, int from_tty)
 	 NULL,
 	 SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
 	 UNDEF_DOMAIN,
-	 ALL_DOMAIN);
+	 SEARCH_ALL);
 }
 \f
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 779e1ff82fe..7c56dbadf8c 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -313,22 +313,6 @@ domain_name (domain_enum e)
     }
 }
 
-/* Return the name of a search_domain .  */
-
-const char *
-search_domain_name (enum search_domain e)
-{
-  switch (e)
-    {
-    case VARIABLES_DOMAIN: return "VARIABLES_DOMAIN";
-    case FUNCTIONS_DOMAIN: return "FUNCTIONS_DOMAIN";
-    case TYPES_DOMAIN: return "TYPES_DOMAIN";
-    case MODULES_DOMAIN: return "MODULES_DOMAIN";
-    case ALL_DOMAIN: return "ALL_DOMAIN";
-    default: gdb_assert_not_reached ("bad search_domain");
-    }
-}
-
 /* See symtab.h.  */
 
 std::string
@@ -4774,7 +4758,7 @@ treg_matches_sym_type_name (const compiled_regex &treg,
 
 bool
 global_symbol_searcher::is_suitable_msymbol
-	(const enum search_domain kind, const minimal_symbol *msymbol)
+	(const domain_search_flags kind, const minimal_symbol *msymbol)
 {
   switch (msymbol->type ())
     {
@@ -4782,12 +4766,12 @@ global_symbol_searcher::is_suitable_msymbol
     case mst_bss:
     case mst_file_data:
     case mst_file_bss:
-      return kind == VARIABLES_DOMAIN;
+      return (kind & SEARCH_VAR_DOMAIN) != 0;
     case mst_text:
     case mst_file_text:
     case mst_solib_trampoline:
     case mst_text_gnu_ifunc:
-      return kind == FUNCTIONS_DOMAIN;
+      return (kind & SEARCH_FUNCTION_DOMAIN) != 0;
     default:
       return false;
     }
@@ -4799,7 +4783,7 @@ bool
 global_symbol_searcher::expand_symtabs
 	(objfile *objfile, const std::optional<compiled_regex> &preg) const
 {
-  enum search_domain kind = m_kind;
+  domain_search_flags kind = m_kind;
   bool found_msymbol = false;
 
   auto do_file_match = [&] (const char *filename, bool basenames)
@@ -4838,7 +4822,7 @@ global_symbol_searcher::expand_symtabs
      all objfiles.  In large programs (1000s of shared libs) searching all
      objfiles is not worth the pain.  */
   if (filenames.empty ()
-      && (kind == VARIABLES_DOMAIN || kind == FUNCTIONS_DOMAIN))
+      && (kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN)) != 0)
     {
       for (minimal_symbol *msymbol : objfile->msymbols ())
 	{
@@ -4858,7 +4842,7 @@ global_symbol_searcher::expand_symtabs
 		     in the process we will add matching symbols or
 		     msymbols to the results list, and that requires that
 		     the symbols tables are expanded.  */
-		  if (kind == FUNCTIONS_DOMAIN
+		  if ((kind & SEARCH_FUNCTION_DOMAIN) != 0
 		      ? (find_pc_compunit_symtab
 			 (msymbol->value_address (objfile)) == NULL)
 		      : (lookup_symbol_in_objfile_from_linkage_name
@@ -4883,7 +4867,7 @@ global_symbol_searcher::add_matching_symbols
 	 const std::optional<compiled_regex> &treg,
 	 std::set<symbol_search> *result_set) const
 {
-  enum search_domain kind = m_kind;
+  domain_search_flags kind = m_kind;
 
   /* Add matching symbols (if not already present).  */
   for (compunit_symtab *cust : objfile->compunits ())
@@ -4916,7 +4900,7 @@ global_symbol_searcher::add_matching_symbols
 		continue;
 
 	      bool matches = false;
-	      if (!matches && kind == VARIABLES_DOMAIN)
+	      if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0)
 		{
 		  if (sym->aclass () != LOC_TYPEDEF
 		      && sym->aclass () != LOC_UNRESOLVED
@@ -4932,7 +4916,7 @@ global_symbol_searcher::add_matching_symbols
 			  || treg_matches_sym_type_name (*treg, sym)))
 		    matches = true;
 		}
-	      if (!matches && kind == FUNCTIONS_DOMAIN)
+	      if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0)
 		{
 		  if (sym->aclass () == LOC_BLOCK
 		      && (!treg.has_value ()
@@ -4940,13 +4924,13 @@ global_symbol_searcher::add_matching_symbols
 							 sym)))
 		    matches = true;
 		}
-	      if (!matches && kind == TYPES_DOMAIN)
+	      if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0)
 		{
 		  if (sym->aclass () == LOC_TYPEDEF
 		      && sym->domain () != MODULE_DOMAIN)
 		    matches = true;
 		}
-	      if (!matches && kind == MODULES_DOMAIN)
+	      if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0)
 		{
 		  if (sym->domain () == MODULE_DOMAIN
 		      && sym->line () != 0)
@@ -4978,7 +4962,7 @@ global_symbol_searcher::add_matching_msymbols
 	(objfile *objfile, const std::optional<compiled_regex> &preg,
 	 std::vector<symbol_search> *results) const
 {
-  enum search_domain kind = m_kind;
+  domain_search_flags kind = m_kind;
 
   for (minimal_symbol *msymbol : objfile->msymbols ())
     {
@@ -4995,7 +4979,7 @@ global_symbol_searcher::add_matching_msymbols
 	    {
 	      /* For functions we can do a quick check of whether the
 		 symbol might be found via find_pc_symtab.  */
-	      if (kind != FUNCTIONS_DOMAIN
+	      if ((kind & SEARCH_FUNCTION_DOMAIN) == 0
 		  || (find_pc_compunit_symtab
 		      (msymbol->value_address (objfile)) == NULL))
 		{
@@ -5025,8 +5009,6 @@ global_symbol_searcher::search () const
   std::optional<compiled_regex> preg;
   std::optional<compiled_regex> treg;
 
-  gdb_assert (m_kind != ALL_DOMAIN);
-
   if (m_symbol_name_regexp != NULL)
     {
       const char *symbol_name_regexp = m_symbol_name_regexp;
@@ -5103,11 +5085,13 @@ global_symbol_searcher::search () const
      user wants to see symbols matching a type regexp, then never give a
      minimal symbol, as we assume that a minimal symbol does not have a
      type.  */
-  if ((found_msymbol || (filenames.empty () && m_kind == VARIABLES_DOMAIN))
+  if ((found_msymbol
+       || (filenames.empty () && (m_kind & SEARCH_VAR_DOMAIN) != 0))
       && !m_exclude_minsyms
       && !treg.has_value ())
     {
-      gdb_assert (m_kind == VARIABLES_DOMAIN || m_kind == FUNCTIONS_DOMAIN);
+      gdb_assert ((m_kind & (SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN))
+		  != 0);
       for (objfile *objfile : current_program_space->objfiles ())
 	if (!add_matching_msymbols (objfile, preg, &result))
 	  break;
@@ -5238,36 +5222,55 @@ print_msymbol_info (struct bound_minimal_symbol msymbol)
 
 static void
 symtab_symbol_info (bool quiet, bool exclude_minsyms,
-		    const char *regexp, enum search_domain kind,
+		    const char *regexp, domain_enum kind,
 		    const char *t_regexp, int from_tty)
 {
-  static const char * const classnames[] =
-    {"variable", "function", "type", "module"};
   const char *last_filename = "";
   int first = 1;
 
-  gdb_assert (kind != ALL_DOMAIN);
-
   if (regexp != nullptr && *regexp == '\0')
     regexp = nullptr;
 
-  global_symbol_searcher spec (kind, regexp);
+  domain_search_flags flags = to_search_flags (kind);
+  if (kind == TYPE_DOMAIN)
+    flags |= SEARCH_STRUCT_DOMAIN;
+
+  global_symbol_searcher spec (flags, regexp);
   spec.set_symbol_type_regexp (t_regexp);
   spec.set_exclude_minsyms (exclude_minsyms);
   std::vector<symbol_search> symbols = spec.search ();
 
   if (!quiet)
     {
+      const char *classname;
+      switch (kind)
+	{
+	case VAR_DOMAIN:
+	  classname = "variable";
+	  break;
+	case FUNCTION_DOMAIN:
+	  classname = "function";
+	  break;
+	case TYPE_DOMAIN:
+	  classname = "type";
+	  break;
+	case MODULE_DOMAIN:
+	  classname = "module";
+	  break;
+	default:
+	  gdb_assert_not_reached ("invalid domain enum");
+	}
+
       if (regexp != NULL)
 	{
 	  if (t_regexp != NULL)
 	    gdb_printf
 	      (_("All %ss matching regular expression \"%s\""
 		 " with type matching regular expression \"%s\":\n"),
-	       classnames[kind], regexp, t_regexp);
+	       classname, regexp, t_regexp);
 	  else
 	    gdb_printf (_("All %ss matching regular expression \"%s\":\n"),
-			classnames[kind], regexp);
+			classname, regexp);
 	}
       else
 	{
@@ -5275,9 +5278,9 @@ symtab_symbol_info (bool quiet, bool exclude_minsyms,
 	    gdb_printf
 	      (_("All defined %ss"
 		 " with type matching regular expression \"%s\" :\n"),
-	       classnames[kind], t_regexp);
+	       classname, t_regexp);
 	  else
-	    gdb_printf (_("All defined %ss:\n"), classnames[kind]);
+	    gdb_printf (_("All defined %ss:\n"), classname);
 	}
     }
 
@@ -5380,7 +5383,7 @@ info_variables_command (const char *args, int from_tty)
     args = nullptr;
 
   symtab_symbol_info
-    (opts.quiet, opts.exclude_minsyms, args, VARIABLES_DOMAIN,
+    (opts.quiet, opts.exclude_minsyms, args, VAR_DOMAIN,
      opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
      from_tty);
 }
@@ -5399,7 +5402,7 @@ info_functions_command (const char *args, int from_tty)
     args = nullptr;
 
   symtab_symbol_info
-    (opts.quiet, opts.exclude_minsyms, args, FUNCTIONS_DOMAIN,
+    (opts.quiet, opts.exclude_minsyms, args, FUNCTION_DOMAIN,
      opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
      from_tty);
 }
@@ -5442,7 +5445,8 @@ info_types_command (const char *args, int from_tty)
     (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
   if (args != nullptr && *args == '\0')
     args = nullptr;
-  symtab_symbol_info (opts.quiet, false, args, TYPES_DOMAIN, NULL, from_tty);
+  symtab_symbol_info (opts.quiet, false, args, TYPE_DOMAIN, nullptr,
+		      from_tty);
 }
 
 /* Command completer for 'info types' command.  */
@@ -5474,7 +5478,7 @@ info_modules_command (const char *args, int from_tty)
     (&args, gdb::option::PROCESS_OPTIONS_UNKNOWN_IS_OPERAND, grp);
   if (args != nullptr && *args == '\0')
     args = nullptr;
-  symtab_symbol_info (opts.quiet, true, args, MODULES_DOMAIN, NULL,
+  symtab_symbol_info (opts.quiet, true, args, MODULE_DOMAIN, nullptr,
 		      from_tty);
 }
 
@@ -5517,7 +5521,7 @@ rbreak_command (const char *regexp, int from_tty)
 	}
     }
 
-  global_symbol_searcher spec (FUNCTIONS_DOMAIN, regexp);
+  global_symbol_searcher spec (SEARCH_FUNCTION_DOMAIN, regexp);
   if (file_name != nullptr)
     spec.filenames.push_back (file_name);
   std::vector<symbol_search> symbols = spec.search ();
@@ -6015,7 +6019,7 @@ default_collect_symbol_completion_matches_break_on
 			       return true;
 			     },
 			   SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-			   ALL_DOMAIN);
+			   SEARCH_ALL);
 
   /* Search upwards from currently selected frame (so that we can
      complete on local vars).  Also catch fields of types defined in
@@ -6714,12 +6718,12 @@ static struct cmd_list_element *info_module_cmdlist = NULL;
 
 std::vector<module_symbol_search>
 search_module_symbols (const char *module_regexp, const char *regexp,
-		       const char *type_regexp, search_domain kind)
+		       const char *type_regexp, domain_search_flags kind)
 {
   std::vector<module_symbol_search> results;
 
   /* Search for all modules matching MODULE_REGEXP.  */
-  global_symbol_searcher spec1 (MODULES_DOMAIN, module_regexp);
+  global_symbol_searcher spec1 (SEARCH_MODULE_DOMAIN, module_regexp);
   spec1.set_exclude_minsyms (true);
   std::vector<symbol_search> modules = spec1.search ();
 
@@ -6765,8 +6769,10 @@ search_module_symbols (const char *module_regexp, const char *regexp,
 static void
 info_module_subcommand (bool quiet, const char *module_regexp,
 			const char *regexp, const char *type_regexp,
-			search_domain kind)
+			domain_search_flags kind)
 {
+  gdb_assert (kind == SEARCH_FUNCTION_DOMAIN || kind == SEARCH_VAR_DOMAIN);
+
   /* Print a header line.  Don't build the header line bit by bit as this
      prevents internationalisation.  */
   if (!quiet)
@@ -6776,12 +6782,12 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 	  if (type_regexp == nullptr)
 	    {
 	      if (regexp == nullptr)
-		gdb_printf ((kind == VARIABLES_DOMAIN
+		gdb_printf ((kind == SEARCH_VAR_DOMAIN
 			     ? _("All variables in all modules:")
 			     : _("All functions in all modules:")));
 	      else
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables matching regular expression"
 			" \"%s\" in all modules:")
 		    : _("All functions matching regular expression"
@@ -6792,7 +6798,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 	    {
 	      if (regexp == nullptr)
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables with type matching regular "
 			"expression \"%s\" in all modules:")
 		    : _("All functions with type matching regular "
@@ -6800,7 +6806,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 		   type_regexp);
 	      else
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables matching regular expression "
 			"\"%s\",\n\twith type matching regular "
 			"expression \"%s\" in all modules:")
@@ -6816,7 +6822,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 	    {
 	      if (regexp == nullptr)
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables in all modules matching regular "
 			"expression \"%s\":")
 		    : _("All functions in all modules matching regular "
@@ -6824,7 +6830,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 		   module_regexp);
 	      else
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables matching regular expression "
 			"\"%s\",\n\tin all modules matching regular "
 			"expression \"%s\":")
@@ -6837,7 +6843,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 	    {
 	      if (regexp == nullptr)
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables with type matching regular "
 			"expression \"%s\"\n\tin all modules matching "
 			"regular expression \"%s\":")
@@ -6847,7 +6853,7 @@ info_module_subcommand (bool quiet, const char *module_regexp,
 		   type_regexp, module_regexp);
 	      else
 		gdb_printf
-		  ((kind == VARIABLES_DOMAIN
+		  ((kind == SEARCH_VAR_DOMAIN
 		    ? _("All variables matching regular expression "
 			"\"%s\",\n\twith type matching regular expression "
 			"\"%s\",\n\tin all modules matching regular "
@@ -6962,7 +6968,7 @@ info_module_functions_command (const char *args, int from_tty)
     (opts.quiet,
      opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args,
      opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
-     FUNCTIONS_DOMAIN);
+     SEARCH_FUNCTION_DOMAIN);
 }
 
 /* Implements the 'info module variables' command.  */
@@ -6981,7 +6987,7 @@ info_module_variables_command (const char *args, int from_tty)
     (opts.quiet,
      opts.module_regexp.empty () ? nullptr : opts.module_regexp.c_str (), args,
      opts.type_regexp.empty () ? nullptr : opts.type_regexp.c_str (),
-     VARIABLES_DOMAIN);
+     SEARCH_VAR_DOMAIN);
 }
 
 /* Command completer for 'info module ...' sub-commands.  */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index c02a58367c6..2e55ad78039 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -947,30 +947,6 @@ 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.  */
-
-enum search_domain
-{
-  /* Everything in VAR_DOMAIN minus FUNCTIONS_DOMAIN and
-     TYPES_DOMAIN.  */
-  VARIABLES_DOMAIN = 0,
-
-  /* All functions -- for some reason not methods, though.  */
-  FUNCTIONS_DOMAIN = 1,
-
-  /* All defined types */
-  TYPES_DOMAIN = 2,
-
-  /* All modules.  */
-  MODULES_DOMAIN = 3,
-
-  /* Any type.  */
-  ALL_DOMAIN = 4
-};
-
-extern const char *search_domain_name (enum search_domain);
-
 /* An address-class says where to find the value of a symbol.  */
 
 enum address_class
@@ -2571,13 +2547,11 @@ class global_symbol_searcher
 public:
 
   /* Constructor.  */
-  global_symbol_searcher (enum search_domain kind,
+  global_symbol_searcher (domain_search_flags kind,
 			  const char *symbol_name_regexp)
     : m_kind (kind),
       m_symbol_name_regexp (symbol_name_regexp)
   {
-    /* The symbol searching is designed to only find one kind of thing.  */
-    gdb_assert (m_kind != ALL_DOMAIN);
   }
 
   /* Set the optional regexp that matches against the symbol type.  */
@@ -2619,7 +2593,7 @@ class global_symbol_searcher
      TYPES_DOMAIN     - Search all type names.
      MODULES_DOMAIN   - Search all Fortran modules.
      ALL_DOMAIN       - Not valid for this function.  */
-  enum search_domain m_kind;
+  domain_search_flags m_kind;
 
   /* Regular expression to match against the symbol name.  */
   const char *m_symbol_name_regexp = nullptr;
@@ -2663,7 +2637,7 @@ class global_symbol_searcher
 			      std::vector<symbol_search> *results) const;
 
   /* Return true if MSYMBOL is of type KIND.  */
-  static bool is_suitable_msymbol (const enum search_domain kind,
+  static bool is_suitable_msymbol (const domain_search_flags kind,
 				   const minimal_symbol *msymbol);
 };
 
@@ -2680,7 +2654,7 @@ typedef std::pair<symbol_search, symbol_search> module_symbol_search;
    within the module.  */
 extern std::vector<module_symbol_search> search_module_symbols
 	(const char *module_regexp, const char *regexp,
-	 const char *type_regexp, search_domain kind);
+	 const char *type_regexp, domain_search_flags kind);
 
 /* Convert a global or static symbol SYM (based on BLOCK, which should be
    either GLOBAL_BLOCK or STATIC_BLOCK) into a string for use in 'info'
@@ -2882,7 +2856,7 @@ class symbol_searcher
      to search all symtabs and program spaces.  */
   void find_all_symbols (const std::string &name,
 			 const struct language_defn *language,
-			 enum search_domain search_domain,
+			 domain_search_flags domain_search_flags,
 			 std::vector<symtab *> *search_symtabs,
 			 struct program_space *search_pspace);
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 14/30] Remove a check of VAR_DOMAIN
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (12 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 13/30] Replace search_domain with domain_search_flags Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 15/30] Introduce "scripting" domains Tom Tromey
                   ` (16 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

completion_list_add_symbol checks that the returned symbol has
VAR_DOMAIN, but also checks that its address class is LOC_BLOCK.  The
domain check is redundant -- only functions can possibly be LOC_BLOCK
-- and leaving this in place will cause a regression when combined
with a later patch in this series.  This patch preemptively removes
the redundant check.
---
 gdb/symtab.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 7c56dbadf8c..76a771b1166 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -5631,7 +5631,6 @@ completion_list_add_symbol (completion_tracker &tracker,
      the msymbol name and removes the msymbol name from the completion
      tracker.  */
   if (sym->language () == language_cplus
-      && sym->domain () == VAR_DOMAIN
       && sym->aclass () == LOC_BLOCK)
     {
       /* The call to canonicalize returns the empty string if the input

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 15/30] Introduce "scripting" domains
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (13 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 14/30] Remove a check of VAR_DOMAIN Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 16/30] Use domain_search_flags in lookup_global_symbol_language Tom Tromey
                   ` (15 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

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.
---
 gdb/symtab.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 gdb/symtab.h | 31 +++++++++++++++++++++++++++++++
 2 files changed, 73 insertions(+)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 76a771b1166..6d24d2fe9ee 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
 {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 2e55ad78039..b12c0541d6f 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -947,6 +947,37 @@ search_flags_matches (domain_search_flags flags, domain_enum domain)
   return (flags & to_search_flags (domain)) != 0;
 }
 
+/* Some helpers for Python and Guile to account for backward
+   compatibility.  Those exposed the domains for lookup as well as
+   checking attributes of a symbol, so special encoding and decoding
+   is needed to continue to support both uses.  Domain constants must
+   remain unchanged, so that comparing a symbol's domain against a
+   constant yields the correct result, so search symbols are
+   distinguished by adding a flag bit.  This way, either sort of
+   constant can be used for lookup.  */
+
+/* The flag bit.  */
+constexpr int SCRIPTING_SEARCH_FLAG = 0x8000;
+static_assert (SCRIPTING_SEARCH_FLAG > SEARCH_ALL);
+
+/* Convert a domain constant to a "scripting domain".  */
+static constexpr inline int
+to_scripting_domain (domain_enum val)
+{
+  return val;
+}
+
+/* Convert a search constant to a "scripting domain".  */
+static constexpr inline int
+to_scripting_domain (domain_search_flags val)
+{
+  return SCRIPTING_SEARCH_FLAG | (int) val;
+}
+
+/* Convert from a "scripting domain" constant back to search flags.
+   Throws an exception if VAL is not one of the allowable values.  */
+extern domain_search_flags from_scripting_domain (int val);
+
 /* An address-class says where to find the value of a symbol.  */
 
 enum address_class

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 16/30] Use domain_search_flags in lookup_global_symbol_language
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (14 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 15/30] Introduce "scripting" domains Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 17/30] Use domain_search_flags in lookup_symbol et al Tom Tromey
                   ` (14 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes quick_symbol_functions::lookup_global_symbol_language to
accept domain_search_flags rather than just a domain_enum, and fixes
up the fallout.

To avoid introducing any regressions, any code passing VAR_DOMAIN now
uses SEARCH_VFT.

That is, no visible changes should result from this patch.  However,
it sets the stage to refine some searches later on.
---
 gdb/ada-exp.y                 | 13 ++++----
 gdb/ada-lang.c                | 71 ++++++++++++++++++++++---------------------
 gdb/ada-lang.h                |  6 ++--
 gdb/dwarf2/cooked-index.h     | 22 --------------
 gdb/dwarf2/read-debug-names.c | 28 ++++++-----------
 gdb/dwarf2/read-gdb-index.c   |  8 ++---
 gdb/dwarf2/read.c             | 54 +++++++++++++++++++++++++++-----
 gdb/dwarf2/read.h             |  2 +-
 gdb/language.h                |  2 +-
 gdb/linespec.c                | 42 ++++++++++++++-----------
 gdb/objfiles.h                |  5 ++-
 gdb/psymtab.c                 | 37 ++++++----------------
 gdb/psymtab.h                 |  3 +-
 gdb/quick-symbol.h            | 10 +++---
 gdb/symfile-debug.c           | 21 ++++++-------
 gdb/symfile.c                 |  5 ++-
 gdb/symmisc.c                 |  1 -
 gdb/symtab.c                  |  7 ++---
 gdb/symtab.h                  |  4 +--
 19 files changed, 164 insertions(+), 177 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 2500bd086c3..1f439b38aea 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1265,7 +1265,7 @@ write_object_renaming (struct parser_state *par_state,
 
   name = obstack_strndup (&temp_parse_space, renamed_entity,
 			  renamed_entity_len);
-  ada_lookup_encoded_symbol (name, orig_left_context, VAR_DOMAIN, &sym_info);
+  ada_lookup_encoded_symbol (name, orig_left_context, SEARCH_VFT, &sym_info);
   if (sym_info.symbol == NULL)
     error (_("Could not find renamed variable: %s"), ada_decode (name).c_str ());
   else if (sym_info.symbol->aclass () == LOC_TYPEDEF)
@@ -1334,7 +1334,7 @@ write_object_renaming (struct parser_state *par_state,
 	    renaming_expr = end;
 
 	    ada_lookup_encoded_symbol (index_name, orig_left_context,
-				       VAR_DOMAIN, &index_sym_info);
+				       SEARCH_VFT, &index_sym_info);
 	    if (index_sym_info.symbol == NULL)
 	      error (_("Could not find %s"), index_name);
 	    else if (index_sym_info.symbol->aclass () == LOC_TYPEDEF)
@@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name)
     }
 
   std::vector<struct block_symbol> syms
-    = ada_lookup_symbol_list (name, context, VAR_DOMAIN);
+    = ada_lookup_symbol_list (name, context, SEARCH_VFT);
 
   if (context == NULL
       && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
@@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name)
 	(char *) alloca (strlen (name) + sizeof ("standard__"));
       strcpy (expanded_name, "standard__");
       strcat (expanded_name, name);
-      sym = ada_lookup_symbol (expanded_name, NULL, VAR_DOMAIN).symbol;
+      sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol;
       if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
 	type = sym->type ();
     }
@@ -1670,7 +1670,8 @@ write_var_or_type (struct parser_state *par_state,
 	  encoded_name[tail_index] = terminator;
 
 	  std::vector<struct block_symbol> syms
-	    = ada_lookup_symbol_list (decoded_name.c_str (), block, VAR_DOMAIN);
+	    = ada_lookup_symbol_list (decoded_name.c_str (), block,
+				      SEARCH_VFT);
 
 	  type_sym = select_possible_type_sym (syms);
 
@@ -1876,7 +1877,7 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
       std::vector<struct block_symbol> syms
 	= ada_lookup_symbol_list (name.ptr,
 				  par_state->expression_context_block,
-				  VAR_DOMAIN);
+				  SEARCH_VFT);
 
       if (syms.size () != 1 || syms[0].symbol->aclass () == LOC_TYPEDEF)
 	pstate->push_new<ada_string_operation> (copy_name (name));
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 4eea4e6609e..a1fac3e8ad3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -98,12 +98,12 @@ static struct value *make_array_descriptor (struct type *, struct value *);
 static void ada_add_block_symbols (std::vector<struct block_symbol> &,
 				   const struct block *,
 				   const lookup_name_info &lookup_name,
-				   domain_enum, struct objfile *);
+				   domain_search_flags, struct objfile *);
 
 static void ada_add_all_symbols (std::vector<struct block_symbol> &,
 				 const struct block *,
 				 const lookup_name_info &lookup_name,
-				 domain_enum, int, int *);
+				 domain_search_flags, int, int *);
 
 static int is_nonfunction (const std::vector<struct block_symbol> &);
 
@@ -176,9 +176,6 @@ static LONGEST pos_atr (struct value *);
 
 static struct value *val_atr (struct type *, LONGEST);
 
-static struct symbol *standard_lookup (const char *, const struct block *,
-				       domain_enum);
-
 static struct value *ada_search_struct_field (const char *, struct value *, int,
 					      struct type *);
 
@@ -335,7 +332,7 @@ struct cache_entry
   /* The name used to perform the lookup.  */
   std::string name;
   /* The namespace used during the lookup.  */
-  domain_enum domain = UNDEF_DOMAIN;
+  domain_search_flags domain = 0;
   /* The symbol returned by the lookup, or NULL if no matching symbol
      was found.  */
   struct symbol *sym = nullptr;
@@ -349,7 +346,7 @@ struct cache_entry
 struct cache_entry_search
 {
   const char *name;
-  domain_enum domain;
+  domain_search_flags domain;
 
   hashval_t hash () const
   {
@@ -3751,7 +3748,7 @@ ada_find_operator_symbol (enum exp_opcode op, bool parse_completion,
     {
       std::vector<struct block_symbol> candidates
 	= ada_lookup_symbol_list (ada_decoded_op_name (op),
-				  NULL, VAR_DOMAIN);
+				  NULL, SEARCH_VFT);
 
       int i = ada_resolve_function (candidates, argvec,
 				    nargs, ada_decoded_op_name (op), NULL,
@@ -3772,7 +3769,7 @@ ada_resolve_funcall (struct symbol *sym, const struct block *block,
 		     innermost_block_tracker *tracker)
 {
   std::vector<struct block_symbol> candidates
-    = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN);
+    = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT);
 
   int i;
   if (candidates.size () == 1)
@@ -3838,7 +3835,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
 		      innermost_block_tracker *tracker)
 {
   std::vector<struct block_symbol> candidates
-    = ada_lookup_symbol_list (sym->linkage_name (), block, VAR_DOMAIN);
+    = ada_lookup_symbol_list (sym->linkage_name (), block, SEARCH_VFT);
 
   if (std::any_of (candidates.begin (),
 		   candidates.end (),
@@ -4708,7 +4705,7 @@ ada_clear_symbol_cache (program_space *pspace)
    SYM.  Same principle for BLOCK if not NULL.  */
 
 static int
-lookup_cached_symbol (const char *name, domain_enum domain,
+lookup_cached_symbol (const char *name, domain_search_flags domain,
 		      struct symbol **sym, const struct block **block)
 {
   htab_t tab = get_ada_pspace_data (current_program_space);
@@ -4731,8 +4728,8 @@ lookup_cached_symbol (const char *name, domain_enum domain,
    in domain DOMAIN, save this result in our symbol cache.  */
 
 static void
-cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
-	      const struct block *block)
+cache_symbol (const char *name, domain_search_flags domain,
+	      struct symbol *sym, const struct block *block)
 {
   /* Symbols for builtin types don't have a block.
      For now don't cache such symbols.  */
@@ -4789,7 +4786,7 @@ name_match_type_from_name (const char *lookup_name)
 
 static struct symbol *
 standard_lookup (const char *name, const struct block *block,
-		 domain_enum domain)
+		 domain_search_flags domain)
 {
   /* Initialize it just to avoid a GCC false warning.  */
   struct block_symbol sym = {};
@@ -5192,7 +5189,7 @@ is_package_name (const char *name)
 
   /* If it is a function that has not been defined at library level,
      then we should be able to look it up in the symbols.  */
-  if (standard_lookup (name, NULL, VAR_DOMAIN) != NULL)
+  if (standard_lookup (name, NULL, SEARCH_VFT) != NULL)
     return 0;
 
   /* Library-level function names start with "_ada_".  See if function
@@ -5205,7 +5202,7 @@ is_package_name (const char *name)
 
   std::string fun_name = string_printf ("_ada_%s", name);
 
-  return (standard_lookup (fun_name.c_str (), NULL, VAR_DOMAIN) == NULL);
+  return (standard_lookup (fun_name.c_str (), NULL, SEARCH_VFT) == NULL);
 }
 
 /* Return nonzero if SYM corresponds to a renaming entity that is
@@ -5365,7 +5362,7 @@ remove_irrelevant_renamings (std::vector<struct block_symbol> *syms,
 static void
 ada_add_local_symbols (std::vector<struct block_symbol> &result,
 		       const lookup_name_info &lookup_name,
-		       const struct block *block, domain_enum domain)
+		       const struct block *block, domain_search_flags domain)
 {
   while (block != NULL)
     {
@@ -5439,7 +5436,7 @@ static int
 ada_add_block_renamings (std::vector<struct block_symbol> &result,
 			 const struct block *block,
 			 const lookup_name_info &lookup_name,
-			 domain_enum domain)
+			 domain_search_flags domain)
 {
   struct using_direct *renaming;
   int defns_mark = result.size ();
@@ -5504,7 +5501,7 @@ ada_lookup_name (const lookup_name_info &lookup_name)
 static void
 map_matching_symbols (struct objfile *objfile,
 		      const lookup_name_info &lookup_name,
-		      domain_enum domain,
+		      domain_search_flags domain,
 		      int global,
 		      match_data &data)
 {
@@ -5514,7 +5511,7 @@ map_matching_symbols (struct objfile *objfile,
 				    global
 				    ? SEARCH_GLOBAL_BLOCK
 				    : SEARCH_STATIC_BLOCK,
-				    domain, SEARCH_ALL);
+				    domain);
 
   const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
   for (compunit_symtab *symtab : objfile->compunits ())
@@ -5535,7 +5532,7 @@ map_matching_symbols (struct objfile *objfile,
 static void
 add_nonlocal_symbols (std::vector<struct block_symbol> &result,
 		      const lookup_name_info &lookup_name,
-		      domain_enum domain, int global)
+		      domain_search_flags domain, int global)
 {
   struct match_data data (&result);
 
@@ -5588,7 +5585,7 @@ static void
 ada_add_all_symbols (std::vector<struct block_symbol> &result,
 		     const struct block *block,
 		     const lookup_name_info &lookup_name,
-		     domain_enum domain,
+		     domain_search_flags domain,
 		     int full_search,
 		     int *made_global_lookup_p)
 {
@@ -5668,7 +5665,7 @@ ada_add_all_symbols (std::vector<struct block_symbol> &result,
 static std::vector<struct block_symbol>
 ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name,
 			       const struct block *block,
-			       domain_enum domain,
+			       domain_search_flags domain,
 			       int full_search)
 {
   int syms_from_global_search;
@@ -5697,7 +5694,7 @@ ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name,
 
 std::vector<struct block_symbol>
 ada_lookup_symbol_list (const char *name, const struct block *block,
-			domain_enum domain)
+			domain_search_flags domain)
 {
   symbol_name_match_type name_match_type = name_match_type_from_name (name);
   lookup_name_info lookup_name (name, name_match_type);
@@ -5714,7 +5711,7 @@ ada_lookup_symbol_list (const char *name, const struct block *block,
 
 void
 ada_lookup_encoded_symbol (const char *name, const struct block *block,
-			   domain_enum domain,
+			   domain_search_flags domain,
 			   struct block_symbol *info)
 {
   /* Since we already have an encoded name, wrap it in '<>' to force a
@@ -5736,7 +5733,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
 
 struct block_symbol
 ada_lookup_symbol (const char *name, const struct block *block0,
-		   domain_enum domain)
+		   domain_search_flags domain)
 {
   std::vector<struct block_symbol> candidates
     = ada_lookup_symbol_list (name, block0, domain);
@@ -6008,7 +6005,7 @@ static void
 ada_add_block_symbols (std::vector<struct block_symbol> &result,
 		       const struct block *block,
 		       const lookup_name_info &lookup_name,
-		       domain_enum domain, struct objfile *objfile)
+		       domain_search_flags domain, struct objfile *objfile)
 {
   /* A matching argument symbol, if any.  */
   struct symbol *arg_sym;
@@ -7441,11 +7438,11 @@ ada_find_any_type_symbol (const char *name)
 {
   struct symbol *sym;
 
-  sym = standard_lookup (name, get_selected_block (NULL), VAR_DOMAIN);
+  sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT);
   if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
     return sym;
 
-  sym = standard_lookup (name, NULL, STRUCT_DOMAIN);
+  sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN);
   return sym;
 }
 
@@ -11323,7 +11320,7 @@ get_var_value (const char *name, const char *err_msg)
   std::vector<struct block_symbol> syms
     = ada_lookup_symbol_list_worker (lookup_name,
 				     get_selected_block (0),
-				     VAR_DOMAIN, 1);
+				     SEARCH_VFT, 1);
 
   if (syms.size () != 1)
     {
@@ -11626,7 +11623,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
      that should be compiled with debugging information.  As a result, we
      expect to find that symbol in the symtabs.  */
 
-  sym = standard_lookup (einfo->catch_exception_sym, NULL, VAR_DOMAIN);
+  sym = standard_lookup (einfo->catch_exception_sym, NULL, SEARCH_VFT);
   if (sym == NULL)
     {
       /* Perhaps we did not find our symbol because the Ada runtime was
@@ -11660,7 +11657,7 @@ ada_has_this_exception_support (const struct exception_support_info *einfo)
     error (_("Symbol \"%s\" is not a function (class = %d)"),
 	   sym->linkage_name (), sym->aclass ());
 
-  sym = standard_lookup (einfo->catch_handlers_sym, NULL, VAR_DOMAIN);
+  sym = standard_lookup (einfo->catch_handlers_sym, NULL, SEARCH_VFT);
   if (sym == NULL)
     {
       struct bound_minimal_symbol msym
@@ -12627,7 +12624,7 @@ ada_exception_sal (enum ada_exception_catchpoint_kind ex)
   /* Then lookup the function on which we will break in order to catch
      the Ada exceptions requested by the user.  */
   sym_name = ada_exception_sym_name (ex);
-  sym = standard_lookup (sym_name, NULL, VAR_DOMAIN);
+  sym = standard_lookup (sym_name, NULL, SEARCH_VFT);
 
   if (sym == NULL)
     throw_error (NOT_FOUND_ERROR, _("Catchpoint symbol not found: %s"),
@@ -13445,7 +13442,7 @@ class ada_language : public language_defn
 
   bool iterate_over_symbols
 	(const struct block *block, const lookup_name_info &name,
-	 domain_enum domain,
+	 domain_search_flags domain,
 	 gdb::function_view<symbol_found_callback_ftype> callback) const override
   {
     std::vector<struct block_symbol> results
@@ -13682,11 +13679,15 @@ class ada_language : public language_defn
   {
     struct block_symbol sym;
 
+    domain_search_flags flags = to_search_flags (domain);
+    if (domain == VAR_DOMAIN)
+      flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
+
     sym = ada_lookup_symbol (name,
 			     (block == nullptr
 			      ? nullptr
 			      : block->static_block ()),
-			     domain);
+			     flags);
     if (sym.symbol != NULL)
       return sym;
 
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index 429931b853d..aefd335ff39 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -230,14 +230,14 @@ extern std::string ada_decode (const char *name, bool wrap = true,
 			       bool wide = true);
 
 extern std::vector<struct block_symbol> ada_lookup_symbol_list
-     (const char *, const struct block *, domain_enum);
+     (const char *, const struct block *, domain_search_flags);
 
 extern struct block_symbol ada_lookup_symbol (const char *,
 					      const struct block *,
-					      domain_enum);
+					      domain_search_flags);
 
 extern void ada_lookup_encoded_symbol
-  (const char *name, const struct block *block, domain_enum domain,
+  (const char *name, const struct block *block, domain_search_flags domain,
    struct block_symbol *symbol_info);
 
 extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *,
diff --git a/gdb/dwarf2/cooked-index.h b/gdb/dwarf2/cooked-index.h
index 8fc54f9b994..458e2b7d01e 100644
--- a/gdb/dwarf2/cooked-index.h
+++ b/gdb/dwarf2/cooked-index.h
@@ -137,28 +137,6 @@ struct cooked_index_entry : public allocate_on_obstack
     return false;
   }
 
-  /* Return true if this entry matches DOMAIN.  */
-  bool matches (domain_enum domain) const
-  {
-    /* Just reject type declarations.  */
-    if ((flags & IS_TYPE_DECLARATION) != 0)
-      return false;
-
-    switch (domain)
-      {
-      case LABEL_DOMAIN:
-	return false;
-
-      case MODULE_DOMAIN:
-	return tag == DW_TAG_module;
-
-      case COMMON_BLOCK_DOMAIN:
-	return tag == DW_TAG_common_block;
-      }
-
-    return true;
-  }
-
   /* Return true if this entry matches KIND.  */
   bool matches (domain_search_flags kind) const;
 
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 91aeb70fac8..0e9b1eb878f 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -91,8 +91,7 @@ struct dwarf2_debug_names_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind) override;
+     domain_search_flags domain) override;
 };
 
 quick_symbol_functions_up
@@ -518,28 +517,27 @@ class dw2_debug_names_iterator
 public:
   dw2_debug_names_iterator (const mapped_debug_names &map,
 			    block_search_flags block_index,
-			    domain_enum domain,
+			    domain_search_flags domain,
 			    const char *name, dwarf2_per_objfile *per_objfile)
-    : m_map (map), m_block_index (block_index), m_domain (domain),
+    : m_map (map), m_block_index (block_index), m_search (domain),
       m_addr (find_vec_in_debug_names (map, name, per_objfile)),
       m_per_objfile (per_objfile)
   {}
 
   dw2_debug_names_iterator (const mapped_debug_names &map,
 			    domain_search_flags search, uint32_t namei,
-			    dwarf2_per_objfile *per_objfile,
-			    domain_enum domain = UNDEF_DOMAIN)
+			    dwarf2_per_objfile *per_objfile)
     : m_map (map),
-      m_domain (domain),
       m_search (search),
       m_addr (find_vec_in_debug_names (map, namei, per_objfile)),
       m_per_objfile (per_objfile)
   {}
 
   dw2_debug_names_iterator (const mapped_debug_names &map,
-			    block_search_flags block_index, domain_enum domain,
+			    block_search_flags block_index,
+			    domain_search_flags domain,
 			    uint32_t namei, dwarf2_per_objfile *per_objfile)
-    : m_map (map), m_block_index (block_index), m_domain (domain),
+    : m_map (map), m_block_index (block_index), m_search (domain),
       m_addr (find_vec_in_debug_names (map, namei, per_objfile)),
       m_per_objfile (per_objfile)
   {}
@@ -563,7 +561,6 @@ class dw2_debug_names_iterator
 				      | SEARCH_STATIC_BLOCK);
 
   /* The kind of symbol we're looking for.  */
-  const domain_enum m_domain = UNDEF_DOMAIN;
   const domain_search_flags m_search = SEARCH_ALL;
 
   /* The list of CUs from the index entry of the symbol, or NULL if
@@ -861,12 +858,6 @@ dw2_debug_names_iterator::next ()
       break;
     }
 
-  if (! (m_domain == domain
-	 || (m_domain == VAR_DOMAIN
-	     && (domain == TYPE_DOMAIN
-		 || domain == FUNCTION_DOMAIN))))
-    goto again;
-
   domain_search_flags flags = to_search_flags (domain);
   if ((flags & m_search) == 0)
     goto again;
@@ -892,8 +883,7 @@ dwarf2_debug_names_index::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   domain_enum domain,
-   domain_search_flags kind)
+   domain_search_flags domain)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
@@ -927,7 +917,7 @@ dwarf2_debug_names_index::expand_symtabs_matching
     {
       /* The name was matched, now expand corresponding CUs that were
 	 marked.  */
-      dw2_debug_names_iterator iter (map, kind, namei, per_objfile, domain);
+      dw2_debug_names_iterator iter (map, domain, namei, per_objfile);
 
       struct dwarf2_per_cu_data *per_cu;
       while ((per_cu = iter.next ()) != NULL)
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index 091aa62d61d..d4741166e61 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -146,8 +146,7 @@ struct dwarf2_gdb_index : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind) override;
+     domain_search_flags domain) override;
 };
 
 /* This dumps minimal information about the index.
@@ -272,8 +271,7 @@ dwarf2_gdb_index::expand_symtabs_matching
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind)
+     domain_search_flags domain)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
@@ -306,7 +304,7 @@ dwarf2_gdb_index::expand_symtabs_matching
 					  [&] (offset_type idx)
     {
       if (!dw2_expand_marked_cus (per_objfile, idx, file_matcher,
-				  expansion_notify, search_flags, kind))
+				  expansion_notify, search_flags, domain))
 	return false;
       return true;
     }, per_objfile);
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 292dba3e24e..877918999b8 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1640,8 +1640,7 @@ struct readnow_functions : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind) override
+     domain_search_flags domain) override
   {
     return true;
   }
@@ -16733,8 +16732,7 @@ struct cooked_index_functions : public dwarf2_base_index_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind) override;
+     domain_search_flags domain) override;
 
   struct compunit_symtab *find_pc_sect_compunit_symtab
     (struct objfile *objfile, struct bound_minimal_symbol msymbol,
@@ -16759,6 +16757,48 @@ struct cooked_index_functions : public dwarf2_base_index_functions
   {
     wait (objfile, false);
   }
+
+  enum language lookup_global_symbol_language (struct objfile *objfile,
+					       const char *name,
+					       domain_search_flags domain,
+					       bool *symbol_found_p) override
+  {
+    *symbol_found_p = false;
+
+    if ((domain & SEARCH_FUNCTION_DOMAIN) == 0)
+      return language_unknown;
+    if (!streq (name, "main"))
+      return language_unknown;
+
+    dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
+    struct dwarf2_per_bfd *per_bfd = per_objfile->per_bfd;
+    if (per_bfd->index_table == nullptr)
+      return language_unknown;
+
+    /* Expansion of large CUs can be slow.  By returning the language of main
+       here for C and C++, we avoid CU expansion during set_initial_language.
+       But by doing a symbol lookup in the cooked index, we are forced to wait
+       for finalization to complete.  See PR symtab/30174 for ideas how to
+       bypass that as well.  */
+    cooked_index *table
+      = (gdb::checked_static_cast<cooked_index *>
+	 (per_bfd->index_table.get ()));
+
+    for (const cooked_index_entry *entry : table->find (name, false))
+      {
+	if (entry->tag != DW_TAG_subprogram)
+	  continue;
+
+	enum language lang = entry->per_cu->lang ();
+	if (!(lang == language_c || lang == language_cplus))
+	  continue;
+
+	*symbol_found_p = true;
+	return lang;
+      }
+
+    return language_unknown;
+  }
 };
 
 dwarf2_per_cu_data *
@@ -16798,8 +16838,7 @@ cooked_index_functions::expand_symtabs_matching
       gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
       gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
       block_search_flags search_flags,
-      domain_enum domain,
-      domain_search_flags kind)
+      domain_search_flags domain)
 {
   dwarf2_per_objfile *per_objfile = get_dwarf2_per_objfile (objfile);
 
@@ -16862,8 +16901,7 @@ cooked_index_functions::expand_symtabs_matching
 
 	  /* See if the symbol matches the type filter.  */
 	  if (!entry->matches (search_flags)
-	      || !entry->matches (domain)
-	      || !entry->matches (kind))
+	      || !entry->matches (domain))
 	    continue;
 
 	  /* We've found the base name of the symbol; now walk its
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 66c6fe3fe87..805a81aad27 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -879,7 +879,7 @@ struct dwarf2_base_index_functions : public quick_symbol_functions
 
   enum language lookup_global_symbol_language (struct objfile *objfile,
 					       const char *name,
-					       domain_enum domain,
+					       domain_search_flags domain,
 					       bool *symbol_found_p) override
   {
     *symbol_found_p = false;
diff --git a/gdb/language.h b/gdb/language.h
index 287faee0cf2..14a1ef6d472 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -369,7 +369,7 @@ struct language_defn
      used as the definition.  */
   virtual bool iterate_over_symbols
 	(const struct block *block, const lookup_name_info &name,
-	 domain_enum domain,
+	 domain_search_flags domain,
 	 gdb::function_view<symbol_found_callback_ftype> callback) const
   {
     return ::iterate_over_symbols (block, name, domain, callback);
diff --git a/gdb/linespec.c b/gdb/linespec.c
index 1d8cbc58b97..b9aca3cc6ce 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -350,7 +350,7 @@ struct linespec_parser
 
 static void iterate_over_file_blocks
   (struct symtab *symtab, const lookup_name_info &name,
-   domain_enum domain,
+   domain_search_flags domain,
    gdb::function_view<symbol_found_callback_ftype> callback);
 
 static void initialize_defaults (struct symtab **default_symtab,
@@ -1154,8 +1154,7 @@ static void
 iterate_over_all_matching_symtabs
   (struct linespec_state *state,
    const lookup_name_info &lookup_name,
-   const domain_enum name_domain,
-   domain_search_flags domain_search_flags,
+   const domain_search_flags domain,
    struct program_space *search_pspace, bool include_inline,
    gdb::function_view<symbol_found_callback_ftype> callback)
 {
@@ -1173,15 +1172,13 @@ iterate_over_all_matching_symtabs
 	  objfile->expand_symtabs_matching (NULL, &lookup_name, NULL, NULL,
 					    (SEARCH_GLOBAL_BLOCK
 					     | SEARCH_STATIC_BLOCK),
-					    UNDEF_DOMAIN,
-					    domain_search_flags);
+					    domain);
 
 	  for (compunit_symtab *cu : objfile->compunits ())
 	    {
 	      struct symtab *symtab = cu->primary_filetab ();
 
-	      iterate_over_file_blocks (symtab, lookup_name, name_domain,
-					callback);
+	      iterate_over_file_blocks (symtab, lookup_name, domain, callback);
 
 	      if (include_inline)
 		{
@@ -1193,7 +1190,7 @@ iterate_over_all_matching_symtabs
 		    {
 		      block = bv->block (i);
 		      state->language->iterate_over_symbols
-			(block, lookup_name, name_domain,
+			(block, lookup_name, domain,
 			 [&] (block_symbol *bsym)
 			 {
 			   /* Restrict calls to CALLBACK to symbols
@@ -1226,7 +1223,8 @@ get_current_search_block (void)
 static void
 iterate_over_file_blocks
   (struct symtab *symtab, const lookup_name_info &name,
-   domain_enum domain, gdb::function_view<symbol_found_callback_ftype> callback)
+   domain_search_flags domain,
+   gdb::function_view<symbol_found_callback_ftype> callback)
 {
   const struct block *block;
 
@@ -3450,10 +3448,10 @@ lookup_prefix_sym (struct linespec_state *state,
       if (elt == nullptr)
 	{
 	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     STRUCT_DOMAIN, SEARCH_ALL,
+					     SEARCH_STRUCT_DOMAIN,
 					     NULL, false, collector);
 	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     VAR_DOMAIN, SEARCH_ALL,
+					     SEARCH_VFT,
 					     NULL, false, collector);
 	}
       else
@@ -3464,8 +3462,12 @@ lookup_prefix_sym (struct linespec_state *state,
 
 	  gdb_assert (!pspace->executing_startup);
 	  set_current_program_space (pspace);
-	  iterate_over_file_blocks (elt, lookup_name, STRUCT_DOMAIN, collector);
-	  iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN, collector);
+	  iterate_over_file_blocks (elt, lookup_name,
+				    SEARCH_STRUCT_DOMAIN,
+				    collector);
+	  iterate_over_file_blocks (elt, lookup_name,
+				    SEARCH_VFT,
+				    collector);
 	}
     }
 
@@ -3799,12 +3801,16 @@ find_function_symbols (struct linespec_state *state,
 
   /* Try NAME as an Objective-C selector.  */
   find_imps (name, &symbol_names);
+
+  domain_search_flags flags = SEARCH_FUNCTION_DOMAIN;
+  if (state->list_mode)
+    flags = SEARCH_VFT;
+
   if (!symbol_names.empty ())
     add_all_symbol_names_from_pspace (&info, state->search_pspace,
-				      symbol_names, SEARCH_FUNCTION_DOMAIN);
+				      symbol_names, flags);
   else
-    add_matching_symbols_to_info (name, name_match_type,
-				  SEARCH_FUNCTION_DOMAIN,
+    add_matching_symbols_to_info (name, name_match_type, flags,
 				  &info, state->search_pspace);
 }
 
@@ -4334,7 +4340,7 @@ add_matching_symbols_to_info (const char *name,
       if (elt == nullptr)
 	{
 	  iterate_over_all_matching_symtabs (info->state, lookup_name,
-					     VAR_DOMAIN, domain_search_flags,
+					     domain_search_flags,
 					     pspace, true,
 					     [&] (block_symbol *bsym)
 	    { return info->add_symbol (bsym); });
@@ -4349,7 +4355,7 @@ add_matching_symbols_to_info (const char *name,
 	  program_space *elt_pspace = elt->compunit ()->objfile ()->pspace;
 	  gdb_assert (!elt_pspace->executing_startup);
 	  set_current_program_space (elt_pspace);
-	  iterate_over_file_blocks (elt, lookup_name, VAR_DOMAIN,
+	  iterate_over_file_blocks (elt, lookup_name, SEARCH_VFT,
 				    [&] (block_symbol *bsym)
 	    { return info->add_symbol (bsym); });
 
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index e576c4b7087..64f2b5ef6be 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -591,8 +591,7 @@ struct objfile
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind);
+     domain_search_flags domain);
 
   /* See quick_symbol_functions.  */
   struct compunit_symtab *find_pc_sect_compunit_symtab
@@ -613,7 +612,7 @@ struct objfile
 
   /* See quick_symbol_functions.  */
   enum language lookup_global_symbol_language (const char *name,
-					       domain_enum domain,
+					       domain_search_flags domain,
 					       bool *symbol_found_p);
 
   /* Return the relocation offset applied to SECTION.  */
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 61d7c3bdc71..eb031d33f0d 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -42,7 +42,7 @@ static struct partial_symbol *lookup_partial_symbol (struct objfile *,
 						     struct partial_symtab *,
 						     const lookup_name_info &,
 						     int,
-						     domain_enum);
+						     domain_search_flags);
 
 static const char *psymtab_to_fullname (struct partial_symtab *ps);
 
@@ -279,7 +279,7 @@ find_pc_sect_psymbol (struct objfile *objfile,
 enum language
 psymbol_functions::lookup_global_symbol_language (struct objfile *objfile,
 						  const char *name,
-						  domain_enum domain,
+						  domain_search_flags domain,
 						  bool *symbol_found_p)
 {
   *symbol_found_p = false;
@@ -325,7 +325,7 @@ static struct partial_symbol *
 lookup_partial_symbol (struct objfile *objfile,
 		       struct partial_symtab *pst,
 		       const lookup_name_info &lookup_name,
-		       int global, domain_enum domain)
+		       int global, domain_search_flags domain)
 {
   struct partial_symbol **start, **psym;
   struct partial_symbol **top, **real_top, **bottom, **center;
@@ -385,8 +385,7 @@ lookup_partial_symbol (struct objfile *objfile,
       while (top <= real_top && symbol_matches_search_name (&(*top)->ginfo,
 							    lookup_name))
 	{
-	  if (symbol_matches_domain ((*top)->ginfo.language (),
-				     (*top)->domain, domain))
+	  if (search_flags_matches (domain, (*top)->domain))
 	    return *top;
 	  top++;
 	}
@@ -399,8 +398,7 @@ lookup_partial_symbol (struct objfile *objfile,
     {
       for (psym = start; psym < start + length; psym++)
 	{
-	  if (symbol_matches_domain ((*psym)->ginfo.language (),
-				     (*psym)->domain, domain)
+	  if (search_flags_matches (domain, (*psym)->domain)
 	      && symbol_matches_search_name (&(*psym)->ginfo, lookup_name))
 	    return *psym;
 	}
@@ -802,8 +800,7 @@ recursively_search_psymtabs
   (struct partial_symtab *ps,
    struct objfile *objfile,
    block_search_flags search_flags,
-   domain_enum domain,
-   domain_search_flags search,
+   domain_search_flags domain,
    const lookup_name_info &lookup_name,
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> sym_matcher)
 {
@@ -825,7 +822,7 @@ recursively_search_psymtabs
 	continue;
 
       r = recursively_search_psymtabs (ps->dependencies[i],
-				       objfile, search_flags, domain, search,
+				       objfile, search_flags, domain,
 				       lookup_name, sym_matcher);
       if (r != 0)
 	{
@@ -873,19 +870,7 @@ recursively_search_psymtabs
 	{
 	  QUIT;
 
-	  if ((domain == UNDEF_DOMAIN
-	       || symbol_matches_domain ((*psym)->ginfo.language (),
-					 (*psym)->domain, domain))
-	      && (search == SEARCH_ALL
-		  || (search == SEARCH_MODULE_DOMAIN
-		      && (*psym)->domain == MODULE_DOMAIN)
-		  || (search == SEARCH_VAR_DOMAIN
-		      && (*psym)->aclass != LOC_TYPEDEF
-		      && (*psym)->aclass != LOC_BLOCK)
-		  || (search == SEARCH_FUNCTION_DOMAIN
-		      && (*psym)->aclass == LOC_BLOCK)
-		  || (search == SEARCH_TYPE_DOMAIN
-		      && (*psym)->aclass == LOC_TYPEDEF))
+	  if (search_flags_matches (domain, (*psym)->domain)
 	      && psymbol_name_matches (*psym, lookup_name)
 	      && (sym_matcher == NULL
 		  || sym_matcher ((*psym)->ginfo.search_name ())))
@@ -913,8 +898,7 @@ psymbol_functions::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   domain_enum domain,
-   domain_search_flags search)
+   domain_search_flags domain)
 {
   /* Clear the search flags.  */
   for (partial_symtab *ps : partial_symbols (objfile))
@@ -956,8 +940,7 @@ psymbol_functions::expand_symtabs_matching
 
       if (lookup_name == nullptr
 	  || recursively_search_psymtabs (ps, objfile, search_flags,
-					  domain, search,
-					  *psym_lookup_name,
+					  domain, *psym_lookup_name,
 					  symbol_matcher))
 	{
 	  compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
diff --git a/gdb/psymtab.h b/gdb/psymtab.h
index c4a0d9184f2..557a7cf4c08 100644
--- a/gdb/psymtab.h
+++ b/gdb/psymtab.h
@@ -617,7 +617,7 @@ struct psymbol_functions : public quick_symbol_functions
 
   enum language lookup_global_symbol_language (struct objfile *objfile,
 					       const char *name,
-					       domain_enum domain,
+					       domain_search_flags domain,
 					       bool *symbol_found_p) override;
 
   void print_stats (struct objfile *objfile, bool print_bcache) override;
@@ -633,7 +633,6 @@ struct psymbol_functions : public quick_symbol_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
      domain_search_flags kind) override;
 
   struct compunit_symtab *find_pc_sect_compunit_symtab
diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h
index 8646ac199bd..676c3ede373 100644
--- a/gdb/quick-symbol.h
+++ b/gdb/quick-symbol.h
@@ -96,14 +96,14 @@ struct quick_symbol_functions
 
   /* Check to see if the global symbol is defined in a "partial" symbol table
      of OBJFILE. NAME is the name of the symbol to look for.  DOMAIN
-     indicates what sort of symbol to search for.
+     indicates what sorts of symbols to search for.
 
      If found, sets *symbol_found_p to true and returns the symbol language.
      defined, or NULL if no such symbol table exists.  */
   virtual enum language lookup_global_symbol_language
        (struct objfile *objfile,
 	const char *name,
-	domain_enum domain,
+	domain_search_flags domain,
 	bool *symbol_found_p) = 0;
 
   /* Print statistics about any indices loaded for OBJFILE.  The
@@ -134,8 +134,7 @@ struct quick_symbol_functions
 
      Otherwise, individual symbols are considered.
 
-     If DOMAIN or KIND do not match, the symbol is skipped.
-     If DOMAIN is UNDEF_DOMAIN, that is treated as a wildcard.
+     If DOMAIN does not match, the symbol is skipped.
 
      If the symbol name does not match LOOKUP_NAME, the symbol is skipped.
 
@@ -155,8 +154,7 @@ struct quick_symbol_functions
      gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
      gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
      block_search_flags search_flags,
-     domain_enum domain,
-     domain_search_flags kind) = 0;
+     domain_search_flags domain) = 0;
 
   /* Return the comp unit from OBJFILE that contains PC and
      SECTION.  Return NULL if there is no such compunit.  This
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 38db7777d83..3f5df13a005 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -222,7 +222,6 @@ objfile::map_symtabs_matching_filename
 					  on_expansion,
 					  (SEARCH_GLOBAL_BLOCK
 					   | SEARCH_STATIC_BLOCK),
-					  UNDEF_DOMAIN,
 					  SEARCH_ALL))
 	{
 	  retval = false;
@@ -278,6 +277,10 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
     return true;
   };
 
+  domain_search_flags flags = to_search_flags (domain);
+  if (domain == VAR_DOMAIN)
+    flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
+
   for (const auto &iter : qf)
     {
       if (!iter->expand_symtabs_matching (this,
@@ -288,8 +291,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
 					  kind == GLOBAL_BLOCK
 					  ? SEARCH_GLOBAL_BLOCK
 					  : SEARCH_STATIC_BLOCK,
-					  domain,
-					  SEARCH_ALL))
+					  flags))
 	break;
     }
 
@@ -343,8 +345,7 @@ objfile::expand_symtabs_for_function (const char *func_name)
 				   nullptr,
 				   (SEARCH_GLOBAL_BLOCK
 				    | SEARCH_STATIC_BLOCK),
-				   VAR_DOMAIN,
-				   SEARCH_ALL);
+				   SEARCH_VFT);
 }
 
 void
@@ -380,7 +381,6 @@ objfile::expand_symtabs_with_fullname (const char *fullname)
 				   nullptr,
 				   (SEARCH_GLOBAL_BLOCK
 				    | SEARCH_STATIC_BLOCK),
-				   UNDEF_DOMAIN,
 				   SEARCH_ALL);
 }
 
@@ -391,8 +391,7 @@ objfile::expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   domain_enum domain,
-   domain_search_flags kind)
+   domain_search_flags domain)
 {
   /* This invariant is documented in quick-functions.h.  */
   gdb_assert (lookup_name != nullptr || symbol_matcher == nullptr);
@@ -404,12 +403,12 @@ objfile::expand_symtabs_matching
 		host_address_to_string (&file_matcher),
 		host_address_to_string (&symbol_matcher),
 		host_address_to_string (&expansion_notify),
-		domain_name (kind).c_str ());
+		domain_name (domain).c_str ());
 
   for (const auto &iter : qf)
     if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name,
 					symbol_matcher, expansion_notify,
-					search_flags, domain, kind))
+					search_flags, domain))
       return false;
   return true;
 }
@@ -504,7 +503,7 @@ objfile::find_compunit_symtab_by_address (CORE_ADDR address)
 
 enum language
 objfile::lookup_global_symbol_language (const char *name,
-					domain_enum domain,
+					domain_search_flags domain,
 					bool *symbol_found_p)
 {
   enum language result = language_unknown;
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 065eaf0d518..17e1a64e77d 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3769,7 +3769,7 @@ expand_symtabs_matching
    gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
    gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
    block_search_flags search_flags,
-   domain_search_flags kind)
+   domain_search_flags domain)
 {
   for (objfile *objfile : current_program_space->objfiles ())
     if (!objfile->expand_symtabs_matching (file_matcher,
@@ -3777,8 +3777,7 @@ expand_symtabs_matching
 					   symbol_matcher,
 					   expansion_notify,
 					   search_flags,
-					   UNDEF_DOMAIN,
-					   kind))
+					   domain))
       return false;
   return true;
 }
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index 519df255047..3659ac687b0 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -919,7 +919,6 @@ maintenance_expand_symtabs (const char *args, int from_tty)
 	 NULL,
 	 NULL,
 	 SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-	 UNDEF_DOMAIN,
 	 SEARCH_ALL);
 }
 \f
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 6d24d2fe9ee..a973052f338 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2864,7 +2864,7 @@ basic_lookup_transparent_type (const char *name)
 bool
 iterate_over_symbols (const struct block *block,
 		      const lookup_name_info &name,
-		      const domain_enum domain,
+		      const domain_search_flags domain,
 		      gdb::function_view<symbol_found_callback_ftype> callback)
 {
   for (struct symbol *sym : block_iterator_range (block, &name))
@@ -2886,7 +2886,7 @@ bool
 iterate_over_symbols_terminated
   (const struct block *block,
    const lookup_name_info &name,
-   const domain_enum domain,
+   const domain_search_flags domain,
    gdb::function_view<symbol_found_callback_ftype> callback)
 {
   if (!iterate_over_symbols (block, name, domain, callback))
@@ -4846,7 +4846,6 @@ global_symbol_searcher::expand_symtabs
      },
      NULL,
      SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK,
-     UNDEF_DOMAIN,
      kind);
 
   /* Here, we search through the minimal symbol tables for functions and
@@ -6502,7 +6501,7 @@ find_main_name (void)
      [&symbol_found_p, pspace] (objfile *obj)
        {
 	 language lang
-	   = obj->lookup_global_symbol_language ("main", VAR_DOMAIN,
+	   = obj->lookup_global_symbol_language ("main", SEARCH_VFT,
 						 &symbol_found_p);
 	 if (symbol_found_p)
 	   {
diff --git a/gdb/symtab.h b/gdb/symtab.h
index b12c0541d6f..69e3c060213 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2804,7 +2804,7 @@ typedef bool (symbol_found_callback_ftype) (struct block_symbol *bsym);
 
 bool iterate_over_symbols (const struct block *block,
 			   const lookup_name_info &name,
-			   const domain_enum domain,
+			   const domain_search_flags domain,
 			   gdb::function_view<symbol_found_callback_ftype> callback);
 
 /* Like iterate_over_symbols, but if all calls to CALLBACK return
@@ -2814,7 +2814,7 @@ bool iterate_over_symbols (const struct block *block,
 bool iterate_over_symbols_terminated
   (const struct block *block,
    const lookup_name_info &name,
-   const domain_enum domain,
+   const domain_search_flags domain,
    gdb::function_view<symbol_found_callback_ftype> callback);
 
 /* Storage type used by demangle_for_lookup.  demangle_for_lookup

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 17/30] Use domain_search_flags in lookup_symbol et al
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (15 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 16/30] Use domain_search_flags in lookup_global_symbol_language Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 18/30] Remove some obsolete Python constants Tom Tromey
                   ` (13 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes lookup_symbol and associated APIs to accept
domain_search_flags rather than a domain_enum.

Note that this introduces some new constants to Python and Guile.  I
chose to break out the documentation patch for this, because the
internals here do not change until a later patch, and it seemed
simpler to patch the docs just once, rather than twice.
---
 gdb/ada-lang.c                      |  10 +--
 gdb/ada-tasks.c                     |  17 +++--
 gdb/alpha-mdebug-tdep.c             |   2 +-
 gdb/ax-gdb.c                        |   5 +-
 gdb/block.c                         |  24 ++++---
 gdb/block.h                         |  15 ++--
 gdb/c-exp.y                         |  19 ++---
 gdb/c-lang.c                        |   2 +-
 gdb/c-valprint.c                    |   2 +-
 gdb/compile/compile-c-symbols.c     |  17 ++---
 gdb/compile/compile-cplus-symbols.c |  13 ++--
 gdb/compile/compile-cplus-types.c   |   8 +--
 gdb/compile/compile-object-load.c   |   6 +-
 gdb/cp-namespace.c                  |  51 ++++++-------
 gdb/cp-support.c                    |   6 +-
 gdb/cp-support.h                    |   8 +--
 gdb/d-exp.y                         |  12 ++--
 gdb/d-lang.c                        |   2 +-
 gdb/d-lang.h                        |   9 +--
 gdb/d-namespace.c                   |  24 +++----
 gdb/dwarf2/ada-imported.c           |   2 +-
 gdb/dwarf2/loc.c                    |   2 +-
 gdb/eval.c                          |   5 +-
 gdb/f-exp.y                         |   8 +--
 gdb/f-lang.c                        |   2 +-
 gdb/f-lang.h                        |   2 +-
 gdb/f-valprint.c                    |   2 +-
 gdb/fbsd-tdep.c                     |   5 +-
 gdb/frame.c                         |   3 +-
 gdb/ft32-tdep.c                     |   3 +-
 gdb/gdbtypes.c                      |  17 +++--
 gdb/gnu-v3-abi.c                    |   2 +-
 gdb/go-exp.y                        |   9 +--
 gdb/guile/scm-frame.c               |   2 +-
 gdb/guile/scm-symbol.c              |  17 +++--
 gdb/infrun.c                        |   2 +-
 gdb/language.c                      |   3 +-
 gdb/language.h                      |   2 +-
 gdb/linespec.c                      |   4 +-
 gdb/m2-exp.y                        |  10 +--
 gdb/mi/mi-cmd-stack.c               |   5 +-
 gdb/moxie-tdep.c                    |   3 +-
 gdb/objc-lang.c                     |   4 +-
 gdb/objfiles.h                      |   2 +-
 gdb/p-exp.y                         |  19 ++---
 gdb/p-valprint.c                    |   2 +-
 gdb/parse.c                         |   3 +-
 gdb/printcmd.c                      |   2 +-
 gdb/psymtab.c                       |   4 +-
 gdb/python/py-frame.c               |   3 +-
 gdb/python/py-objfile.c             |   6 +-
 gdb/python/py-symbol.c              |  22 +++---
 gdb/rust-lang.c                     |   7 +-
 gdb/rust-lang.h                     |   2 +-
 gdb/rust-parse.c                    |   8 +--
 gdb/source.c                        |   5 +-
 gdb/stack.c                         |   4 +-
 gdb/symfile-debug.c                 |  11 ++-
 gdb/symfile.c                       |   4 +-
 gdb/symtab.c                        | 138 +++++++++++++++++-------------------
 gdb/symtab.h                        |  23 +++---
 gdb/valops.c                        |  14 ++--
 gdb/value.c                         |   6 +-
 gdb/xstormy16-tdep.c                |   3 +-
 64 files changed, 342 insertions(+), 312 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a1fac3e8ad3..a15ea7b725e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13675,19 +13675,15 @@ class ada_language : public language_defn
 
   struct block_symbol lookup_symbol_nonlocal
 	(const char *name, const struct block *block,
-	 const domain_enum domain) const override
+	 const domain_search_flags domain) const override
   {
     struct block_symbol sym;
 
-    domain_search_flags flags = to_search_flags (domain);
-    if (domain == VAR_DOMAIN)
-      flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
-
     sym = ada_lookup_symbol (name,
 			     (block == nullptr
 			      ? nullptr
 			      : block->static_block ()),
-			     flags);
+			     domain);
     if (sym.symbol != NULL)
       return sym;
 
@@ -13703,7 +13699,7 @@ class ada_language : public language_defn
        languages, we search the primitive types this late and only after
        having searched the global symbols without success.  */
 
-    if (domain == VAR_DOMAIN)
+    if ((domain & SEARCH_TYPE_DOMAIN) != 0)
       {
 	struct gdbarch *gdbarch;
 
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index e4aacaf4b6a..fd3f5d1ead9 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -520,16 +520,17 @@ ada_get_tcb_types_info (void)
      C-like) lookups to get the first match.  */
 
   struct symbol *atcb_sym =
-    lookup_symbol_in_language (atcb_name, NULL, STRUCT_DOMAIN,
+    lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *common_atcb_sym =
-    lookup_symbol_in_language (common_atcb_name, NULL, STRUCT_DOMAIN,
+    lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *private_data_sym =
-    lookup_symbol_in_language (private_data_name, NULL, STRUCT_DOMAIN,
+    lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *entry_call_record_sym =
-    lookup_symbol_in_language (entry_call_record_name, NULL, STRUCT_DOMAIN,
+    lookup_symbol_in_language (entry_call_record_name, NULL,
+			       SEARCH_STRUCT_DOMAIN,
 			       language_c, NULL).symbol;
 
   if (atcb_sym == NULL || atcb_sym->type () == NULL)
@@ -537,7 +538,7 @@ ada_get_tcb_types_info (void)
       /* In Ravenscar run-time libs, the  ATCB does not have a dynamic
 	 size, so the symbol name differs.  */
       atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL,
-					    STRUCT_DOMAIN, language_c,
+					    SEARCH_STRUCT_DOMAIN, language_c,
 					    NULL).symbol;
 
       if (atcb_sym == NULL || atcb_sym->type () == NULL)
@@ -929,7 +930,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
       data->known_tasks_addr = msym.value_address ();
 
       /* Try to get pointer type and array length from the symtab.  */
-      sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL, VAR_DOMAIN,
+      sym = lookup_symbol_in_language (KNOWN_TASKS_NAME, NULL,
+				       SEARCH_VAR_DOMAIN,
 				       language_c, NULL).symbol;
       if (sym != NULL)
 	{
@@ -975,7 +977,8 @@ ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
       data->known_tasks_addr = msym.value_address ();
       data->known_tasks_length = 1;
 
-      sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL, VAR_DOMAIN,
+      sym = lookup_symbol_in_language (KNOWN_TASKS_LIST, NULL,
+				       SEARCH_VAR_DOMAIN,
 				       language_c, NULL).symbol;
       if (sym != NULL && sym->value_address () != 0)
 	{
diff --git a/gdb/alpha-mdebug-tdep.c b/gdb/alpha-mdebug-tdep.c
index 1ba8e500e32..7691a53148a 100644
--- a/gdb/alpha-mdebug-tdep.c
+++ b/gdb/alpha-mdebug-tdep.c
@@ -106,7 +106,7 @@ find_proc_desc (CORE_ADDR pc)
 	   symbol reading.  */
 	sym = NULL;
       else
-	sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, LABEL_DOMAIN,
+	sym = lookup_symbol (MDEBUG_EFI_SYMBOL_NAME, b, SEARCH_LABEL_DOMAIN,
 			     0).symbol;
     }
 
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index deadbc1bc02..a08a5121527 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1457,7 +1457,8 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value,
   else
     {
       const char *phys_name = type->field (fieldno).loc_physname ();
-      struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol;
+      struct symbol *sym = lookup_symbol (phys_name, 0,
+					  SEARCH_VAR_DOMAIN, 0).symbol;
 
       if (sym)
 	{
@@ -1548,7 +1549,7 @@ gen_maybe_namespace_elt (struct agent_expr *ax, struct axs_value *value,
 
   sym = cp_lookup_symbol_namespace (namespace_name, name,
 				    block_for_pc (ax->scope),
-				    VAR_DOMAIN);
+				    SEARCH_VAR_DOMAIN);
 
   if (sym.symbol == NULL)
     return 0;
diff --git a/gdb/block.c b/gdb/block.c
index 4b9307ea794..0bdd0f915c0 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -630,26 +630,32 @@ block_iterator_next (struct block_iterator *iterator)
 /* See block.h.  */
 
 bool
-best_symbol (struct symbol *a, const domain_enum domain)
+best_symbol (struct symbol *a, const domain_search_flags domain)
 {
-  return (a->domain () == domain
-	  && a->aclass () != LOC_UNRESOLVED);
+  if (a->aclass () == LOC_UNRESOLVED)
+    return false;
+
+  if ((domain & SEARCH_VAR_DOMAIN) != 0)
+    return a->domain () == VAR_DOMAIN;
+
+  return a->matches (domain);
 }
 
 /* See block.h.  */
 
 struct symbol *
-better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
+better_symbol (struct symbol *a, struct symbol *b,
+	       const domain_search_flags domain)
 {
   if (a == NULL)
     return b;
   if (b == NULL)
     return a;
 
-  if (a->domain () == domain && b->domain () != domain)
+  if (a->matches (domain) && !b->matches (domain))
     return a;
 
-  if (b->domain () == domain && a->domain () != domain)
+  if (b->matches (domain) && !a->matches (domain))
     return b;
 
   if (a->aclass () != LOC_UNRESOLVED && b->aclass () == LOC_UNRESOLVED)
@@ -675,7 +681,7 @@ better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
 struct symbol *
 block_lookup_symbol (const struct block *block, const char *name,
 		     symbol_name_match_type match_type,
-		     const domain_enum domain)
+		     const domain_search_flags domain)
 {
   lookup_name_info lookup_name (name, match_type);
 
@@ -730,7 +736,7 @@ block_lookup_symbol (const struct block *block, const char *name,
 
 struct symbol *
 block_lookup_symbol_primary (const struct block *block, const char *name,
-			     const domain_enum domain)
+			     const domain_search_flags domain)
 {
   struct symbol *sym, *other;
   struct mdict_iterator mdict_iter;
@@ -792,7 +798,7 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
 
 struct symbol *
 block_find_symbol (const struct block *block, const lookup_name_info &name,
-		   const domain_enum domain, struct symbol **stub)
+		   const domain_search_flags domain, struct symbol **stub)
 {
   /* Verify BLOCK is STATIC_BLOCK or GLOBAL_BLOCK.  */
   gdb_assert (block->superblock () == NULL
diff --git a/gdb/block.h b/gdb/block.h
index 5c56518bfce..0c121941f05 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -554,28 +554,29 @@ typedef iterator_range<block_iterator_wrapper> block_iterator_range;
 
 /* Return true if symbol A is the best match possible for DOMAIN.  */
 
-extern bool best_symbol (struct symbol *a, const domain_enum domain);
+extern bool best_symbol (struct symbol *a, const domain_search_flags domain);
 
 /* Return symbol B if it is a better match than symbol A for DOMAIN.
    Otherwise return A.  */
 
 extern struct symbol *better_symbol (struct symbol *a, struct symbol *b,
-				     const domain_enum domain);
+				     const domain_search_flags domain);
 
 /* Search BLOCK for symbol NAME in DOMAIN.  */
 
 extern struct symbol *block_lookup_symbol (const struct block *block,
 					   const char *name,
 					   symbol_name_match_type match_type,
-					   const domain_enum domain);
+					   const domain_search_flags domain);
 
 /* Search BLOCK for symbol NAME in DOMAIN but only in primary symbol table of
    BLOCK.  BLOCK must be STATIC_BLOCK or GLOBAL_BLOCK.  Function is useful if
    one iterates all global/static blocks of an objfile.  */
 
-extern struct symbol *block_lookup_symbol_primary (const struct block *block,
-						   const char *name,
-						   const domain_enum domain);
+extern struct symbol *block_lookup_symbol_primary
+     (const struct block *block,
+      const char *name,
+      const domain_search_flags domain);
 
 /* Find symbol NAME in BLOCK and in DOMAIN.  This will return a
    matching symbol whose type is not a "opaque", see TYPE_IS_OPAQUE.
@@ -584,7 +585,7 @@ extern struct symbol *block_lookup_symbol_primary (const struct block *block,
 
 extern struct symbol *block_find_symbol (const struct block *block,
 					 const lookup_name_info &name,
-					 const domain_enum domain,
+					 const domain_search_flags domain,
 					 struct symbol **stub);
 
 /* Given a vector of pairs, allocate and build an obstack allocated
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 8c0d86f68b5..fb85914805c 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1087,9 +1087,10 @@ block	:	block COLONCOLON name
 			  std::string copy = copy_name ($3);
 			  struct symbol *tem
 			    = lookup_symbol (copy.c_str (), $1,
-					     VAR_DOMAIN, NULL).symbol;
+					     SEARCH_FUNCTION_DOMAIN,
+					     nullptr).symbol;
 
-			  if (!tem || tem->aclass () != LOC_BLOCK)
+			  if (tem == nullptr)
 			    error (_("No function \"%s\" in specified context."),
 				   copy.c_str ());
 			  $$ = tem->value_block (); }
@@ -1113,7 +1114,7 @@ variable:	block COLONCOLON name
 			  std::string copy = copy_name ($3);
 			  struct block_symbol sym
 			    = lookup_symbol (copy.c_str (), $1,
-					     VAR_DOMAIN, NULL);
+					     SEARCH_VFT, NULL);
 
 			  if (sym.symbol == 0)
 			    error (_("No symbol \"%s\" in specified context."),
@@ -1168,7 +1169,7 @@ variable:	qualified_name
 			  struct block_symbol sym
 			    = lookup_symbol (name.c_str (),
 					     (const struct block *) NULL,
-					     VAR_DOMAIN, NULL);
+					     SEARCH_VFT, NULL);
 			  pstate->push_symbol (name.c_str (), sym);
 			}
 	;
@@ -1833,7 +1834,7 @@ name_not_typename :	NAME
 			  $$.sym
 			    = lookup_symbol ($1.ptr,
 					     pstate->expression_context_block,
-					     VAR_DOMAIN,
+					     SEARCH_VFT,
 					     &is_a_field_of_this);
 			  $$.is_a_field_of_this
 			    = is_a_field_of_this.type != NULL;
@@ -2969,7 +2970,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name)
 
 	    if (lookup_symbol (copy.c_str (),
 			       pstate->expression_context_block,
-			       VAR_DOMAIN,
+			       SEARCH_VFT,
 			       (par_state->language ()->la_language
 				== language_cplus ? &is_a_field_of_this
 				: NULL)).symbol
@@ -3037,7 +3038,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
      we can refer to it unconditionally below.  */
   memset (&is_a_field_of_this, 0, sizeof (is_a_field_of_this));
 
-  bsym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN,
+  bsym = lookup_symbol (copy.c_str (), block, SEARCH_VFT,
 			par_state->language ()->name_of_this ()
 			? &is_a_field_of_this : NULL);
 
@@ -3060,7 +3061,7 @@ classify_name (struct parser_state *par_state, const struct block *block,
 	{
 	  struct field_of_this_result inner_is_a_field_of_this;
 
-	  bsym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN,
+	  bsym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN,
 				&inner_is_a_field_of_this);
 	  if (bsym.symbol != NULL)
 	    {
@@ -3167,7 +3168,7 @@ classify_inner_name (struct parser_state *par_state,
   std::string copy = copy_name (yylval.ssym.stoken);
   /* N.B. We assume the symbol can only be in VAR_DOMAIN.  */
   yylval.ssym.sym = cp_lookup_nested_symbol (type, copy.c_str (), block,
-					     VAR_DOMAIN);
+					     SEARCH_VFT);
 
   /* If no symbol was found, search for a matching base class named
      COPY.  This will allow users to enter qualified names of class members
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 2dfbd05c52f..ce711c4b4f6 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -1014,7 +1014,7 @@ class cplus_language : public language_defn
 
   struct block_symbol lookup_symbol_nonlocal
 	(const char *name, const struct block *block,
-	 const domain_enum domain) const override
+	 const domain_search_flags domain) const override
   {
     return cp_lookup_symbol_nonlocal (this, name, block, domain);
   }
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 1731f0302a8..8911a169604 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -205,7 +205,7 @@ print_unpacked_pointer (struct type *type, struct type *elttype,
 	    {
 	      const char *search_name = msymbol.minsym->search_name ();
 	      wsym = lookup_symbol_search_name (search_name, NULL,
-						VAR_DOMAIN).symbol;
+						SEARCH_VAR_DOMAIN).symbol;
 	    }
 
 	  if (wsym)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index f55438d9ccb..a8f4ca16225 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -210,7 +210,7 @@ convert_one_symbol (compile_c_instance *context,
 
 static void
 convert_symbol_sym (compile_c_instance *context, const char *identifier,
-		    struct block_symbol sym, domain_enum domain)
+		    struct block_symbol sym, domain_search_flags domain)
 {
   int is_local_symbol;
 
@@ -325,19 +325,19 @@ gcc_convert_symbol (void *datum,
 {
   compile_c_instance *context
     = static_cast<compile_c_instance *> (datum);
-  domain_enum domain;
+  domain_search_flags domain;
   int found = 0;
 
   switch (request)
     {
     case GCC_C_ORACLE_SYMBOL:
-      domain = VAR_DOMAIN;
+      domain = SEARCH_VFT;
       break;
     case GCC_C_ORACLE_TAG:
-      domain = STRUCT_DOMAIN;
+      domain = SEARCH_STRUCT_DOMAIN;
       break;
     case GCC_C_ORACLE_LABEL:
-      domain = LABEL_DOMAIN;
+      domain = SEARCH_LABEL_DOMAIN;
       break;
     default:
       gdb_assert_not_reached ("Unrecognized oracle request.");
@@ -355,7 +355,7 @@ gcc_convert_symbol (void *datum,
 	  convert_symbol_sym (context, identifier, sym, domain);
 	  found = 1;
 	}
-      else if (domain == VAR_DOMAIN)
+      else if (request == GCC_C_ORACLE_SYMBOL)
 	{
 	  struct bound_minimal_symbol bmsym;
 
@@ -398,8 +398,9 @@ gcc_symbol_address (void *datum, struct gcc_c_context *gcc_context,
       struct symbol *sym;
 
       /* We only need global functions here.  */
-      sym = lookup_symbol (identifier, NULL, VAR_DOMAIN, NULL).symbol;
-      if (sym != NULL && sym->aclass () == LOC_BLOCK)
+      sym = lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN,
+			   nullptr).symbol;
+      if (sym != nullptr)
 	{
 	  if (compile_debug)
 	    gdb_printf (gdb_stdlog,
diff --git a/gdb/compile/compile-cplus-symbols.c b/gdb/compile/compile-cplus-symbols.c
index dbdabe94e1e..9d8e801ba3a 100644
--- a/gdb/compile/compile-cplus-symbols.c
+++ b/gdb/compile/compile-cplus-symbols.c
@@ -227,7 +227,7 @@ convert_one_symbol (compile_cplus_instance *instance,
 static void
 convert_symbol_sym (compile_cplus_instance *instance,
 		    const char *identifier, struct block_symbol sym,
-		    domain_enum domain)
+		    domain_search_flags domain)
 {
   /* If we found a symbol and it is not in the  static or global
      scope, then we should first convert any static or global scope
@@ -355,12 +355,12 @@ gcc_cplus_convert_symbol (void *datum,
 	 This will find variables in the current scope.  */
 
       struct block_symbol sym
-	= lookup_symbol (identifier, instance->block (), VAR_DOMAIN, nullptr);
+	= lookup_symbol (identifier, instance->block (), SEARCH_VFT, nullptr);
 
       if (sym.symbol != nullptr)
 	{
 	  found = true;
-	  convert_symbol_sym (instance, identifier, sym, VAR_DOMAIN);
+	  convert_symbol_sym (instance, identifier, sym, SEARCH_VFT);
 	}
 
       /* Then use linespec.c's multi-symbol search.  This should find
@@ -378,7 +378,7 @@ gcc_cplus_convert_symbol (void *datum,
 	    {
 	      found = true;
 	      convert_symbol_sym (instance, identifier, it,
-				  it.symbol->domain ());
+				  to_search_flags (it.symbol->domain ()));
 	    }
 	}
 
@@ -437,9 +437,10 @@ gcc_cplus_symbol_address (void *datum, struct gcc_cp_context *gcc_context,
   try
     {
       struct symbol *sym
-	= lookup_symbol (identifier, nullptr, VAR_DOMAIN, nullptr).symbol;
+	= lookup_symbol (identifier, nullptr, SEARCH_FUNCTION_DOMAIN,
+			 nullptr).symbol;
 
-      if (sym != nullptr && sym->aclass () == LOC_BLOCK)
+      if (sym != nullptr)
 	{
 	  if (compile_debug)
 	    gdb_printf (gdb_stdlog,
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 90ce3f15e14..c8a25515359 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -154,7 +154,7 @@ type_name_to_scope (const char *type_name, const struct block *block)
 
       /* Look up the resulting name.  */
       struct block_symbol bsymbol
-	= lookup_symbol (lookup_name.c_str (), block, VAR_DOMAIN, nullptr);
+	= lookup_symbol (lookup_name.c_str (), block, SEARCH_VFT, nullptr);
 
       if (bsymbol.symbol != nullptr)
 	{
@@ -384,7 +384,7 @@ compile_cplus_instance::new_scope (const char *type_name, struct type *type)
 	  scope_component comp
 	    = {
 		decl_name (type->name ()).get (),
-		lookup_symbol (type->name (), block (), VAR_DOMAIN, nullptr)
+		lookup_symbol (type->name (), block (), SEARCH_VFT, nullptr)
 	      };
 	  scope.push_back (comp);
 	}
@@ -617,7 +617,7 @@ compile_cplus_convert_struct_or_union_members
 		const char *physname = type->field (i).loc_physname ();
 		struct block_symbol sym
 		  = lookup_symbol (physname, instance->block (),
-				   VAR_DOMAIN, nullptr);
+				   SEARCH_VFT, nullptr);
 
 		if (sym.symbol == nullptr)
 		  {
@@ -729,7 +729,7 @@ compile_cplus_convert_struct_or_union_methods (compile_cplus_instance *instance,
 	  gcc_type method_type;
 	  struct block_symbol sym
 	    = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (methods, j),
-			     instance->block (), VAR_DOMAIN, nullptr);
+			     instance->block (), SEARCH_VFT, nullptr);
 
 	  if (sym.symbol == nullptr)
 	    {
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index b2cc3a1a042..e26f0f46048 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -437,7 +437,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
       gdb_val_sym = block_lookup_symbol (block,
 					 COMPILE_I_EXPR_VAL,
 					 symbol_name_match_type::SEARCH_NAME,
-					 VAR_DOMAIN);
+					 SEARCH_VFT);
       if (gdb_val_sym == NULL)
 	continue;
 
@@ -463,7 +463,7 @@ get_out_value_type (struct symbol *func_sym, struct objfile *objfile,
 
   gdb_ptr_type_sym = block_lookup_symbol (block, COMPILE_I_EXPR_PTR_TYPE,
 					  symbol_name_match_type::SEARCH_NAME,
-					  VAR_DOMAIN);
+					  SEARCH_VFT);
   if (gdb_ptr_type_sym == NULL)
     error (_("No \"%s\" symbol found"), COMPILE_I_EXPR_PTR_TYPE);
   gdb_ptr_type = gdb_ptr_type_sym->type ();
@@ -652,7 +652,7 @@ compile_object_load (const compile_file_names &file_names,
   func_sym = lookup_global_symbol_from_objfile (objfile,
 						GLOBAL_BLOCK,
 						GCC_FE_WRAPPER_FUNCTION,
-						VAR_DOMAIN).symbol;
+						SEARCH_VFT).symbol;
   if (func_sym == NULL)
     error (_("Cannot find function \"%s\" in compiled module \"%s\"."),
 	   GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile));
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index a573b1410d3..593340af350 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -42,7 +42,7 @@ static struct block_symbol
 			     const char *nested_name,
 			     const char *concatenated_name,
 			     const struct block *block,
-			     const domain_enum domain,
+			     const domain_search_flags domain,
 			     int basic_lookup, int is_in_anonymous);
 
 static struct type *cp_lookup_transparent_type_loop (const char *name,
@@ -129,7 +129,7 @@ cp_is_in_anonymous (const char *symbol_name)
 
 static struct block_symbol
 cp_basic_lookup_symbol (const char *name, const struct block *block,
-			const domain_enum domain, int is_in_anonymous)
+			const domain_search_flags domain, int is_in_anonymous)
 {
   struct block_symbol sym;
 
@@ -172,7 +172,7 @@ cp_basic_lookup_symbol (const char *name, const struct block *block,
 static struct block_symbol
 cp_lookup_bare_symbol (const struct language_defn *langdef,
 		       const char *name, const struct block *block,
-		       const domain_enum domain, int search)
+		       const domain_search_flags domain, int search)
 {
   struct block_symbol sym;
 
@@ -192,7 +192,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
      shared libraries we could search all of them only to find out the
      builtin type isn't defined in any of them.  This is common for types
      like "void".  */
-  if (langdef != NULL && domain == VAR_DOMAIN)
+  if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0)
     {
       struct gdbarch *gdbarch;
 
@@ -251,7 +251,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
 static struct block_symbol
 cp_search_static_and_baseclasses (const char *name,
 				  const struct block *block,
-				  const domain_enum domain,
+				  const domain_search_flags domain,
 				  unsigned int prefix_len,
 				  int is_in_anonymous)
 {
@@ -273,9 +273,9 @@ cp_search_static_and_baseclasses (const char *name,
      symbol_matches_domain (which should be replaced with something
      else, but it's what we have today).  */
   block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (),
-							  block, VAR_DOMAIN);
+							  block, SEARCH_VFT);
   if (scope_sym.symbol == NULL)
-    scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN);
+    scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT);
   if (scope_sym.symbol == NULL)
     return {};
 
@@ -285,9 +285,9 @@ cp_search_static_and_baseclasses (const char *name,
      static variable.  E.g., "print 'function()::static_var'".  */
   if ((scope_type->code () == TYPE_CODE_FUNC
        || scope_type->code () == TYPE_CODE_METHOD)
-      && domain == VAR_DOMAIN)
+      && (domain & SEARCH_VAR_DOMAIN) != 0)
     return lookup_symbol (nested, scope_sym.symbol->value_block (),
-			  VAR_DOMAIN, NULL);
+			  domain, NULL);
 
   /* Look for a symbol named NESTED in this class/namespace.
      The caller is assumed to have already have done a basic lookup of NAME.
@@ -308,7 +308,7 @@ cp_search_static_and_baseclasses (const char *name,
 static struct block_symbol
 cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
 			       const struct block *block,
-			       const domain_enum domain, int search)
+			       const domain_search_flags domain, int search)
 {
   char *concatenated_name = NULL;
   int is_in_anonymous;
@@ -382,7 +382,7 @@ static void
 cp_lookup_symbol_via_imports (const char *scope,
 			      const char *name,
 			      const struct block *block,
-			      const domain_enum domain,
+			      const domain_search_flags domain,
 			      const int search_scope_first,
 			      const int declaration_only,
 			      const int search_parents,
@@ -503,7 +503,7 @@ static struct block_symbol
 cp_lookup_symbol_via_imports (const char *scope,
 			      const char *name,
 			      const struct block *block,
-			      const domain_enum domain,
+			      const domain_search_flags domain,
 			      const int declaration_only,
 			      const int search_parents)
 {
@@ -560,13 +560,14 @@ struct block_symbol
 cp_lookup_symbol_imports_or_template (const char *scope,
 				      const char *name,
 				      const struct block *block,
-				      const domain_enum domain)
+				      const domain_search_flags domain)
 {
   struct symbol *function = block->function ();
 
   symbol_lookup_debug_printf
     ("cp_lookup_symbol_imports_or_template (%s, %s, %s, %s)",
-     scope, name, host_address_to_string (block), domain_name (domain));
+     scope, name, host_address_to_string (block),
+     domain_name (domain).c_str ());
 
   if (function != NULL && function->language () == language_cplus)
     {
@@ -646,7 +647,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
 static struct block_symbol
 cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
 				  const struct block *block,
-				  const domain_enum domain)
+				  const domain_search_flags domain)
 {
   struct block_symbol sym;
 
@@ -671,13 +672,13 @@ struct block_symbol
 cp_lookup_symbol_namespace (const char *scope,
 			    const char *name,
 			    const struct block *block,
-			    const domain_enum domain)
+			    const domain_search_flags domain)
 {
   struct block_symbol sym;
 
   symbol_lookup_debug_printf ("cp_lookup_symbol_namespace (%s, %s, %s, %s)",
 			      scope, name, host_address_to_string (block),
-			      domain_name (domain));
+			      domain_name (domain).c_str ());
 
   /* First, try to find the symbol in the given namespace.  */
   sym = cp_lookup_symbol_in_namespace (scope, name, block, domain, 1);
@@ -711,7 +712,7 @@ static struct block_symbol
 lookup_namespace_scope (const struct language_defn *langdef,
 			const char *name,
 			const struct block *block,
-			const domain_enum domain,
+			const domain_search_flags domain,
 			const char *scope,
 			int scope_len)
 {
@@ -768,14 +769,15 @@ struct block_symbol
 cp_lookup_symbol_nonlocal (const struct language_defn *langdef,
 			   const char *name,
 			   const struct block *block,
-			   const domain_enum domain)
+			   const domain_search_flags domain)
 {
   struct block_symbol sym;
   const char *scope = block == nullptr ? "" : block->scope ();
 
   symbol_lookup_debug_printf
     ("cp_lookup_symbol_non_local (%s, %s (scope %s), %s)",
-     name, host_address_to_string (block), scope, domain_name (domain));
+     name, host_address_to_string (block), scope,
+     domain_name (domain).c_str ());
 
   /* First, try to find the symbol in the given namespace, and all
      containing namespaces.  */
@@ -826,7 +828,8 @@ cp_find_type_baseclass_by_name (struct type *parent_type, const char *name)
 
 static struct block_symbol
 find_symbol_in_baseclass (struct type *parent_type, const char *name,
-			  const struct block *block, const domain_enum domain,
+			  const struct block *block,
+			  const domain_search_flags domain,
 			  int is_in_anonymous)
 {
   int i;
@@ -869,7 +872,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
 			   const char *nested_name,
 			   const char *concatenated_name,
 			   const struct block *block,
-			   const domain_enum domain,
+			   const domain_search_flags domain,
 			   int basic_lookup, int is_in_anonymous)
 {
   struct block_symbol sym;
@@ -933,7 +936,7 @@ struct block_symbol
 cp_lookup_nested_symbol (struct type *parent_type,
 			 const char *nested_name,
 			 const struct block *block,
-			 const domain_enum domain)
+			 const domain_search_flags domain)
 {
   /* type_name_or_error provides better error reporting using the
      original type.  */
@@ -948,7 +951,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
       symbol_lookup_debug_printf ("cp_lookup_nested_symbol (%s, %s, %s, %s)",
 				  type_name != NULL ? type_name : "unnamed",
 				  nested_name, host_address_to_string (block),
-				  domain_name (domain));
+				  domain_name (domain).c_str ());
     }
 
   switch (parent_type->code ())
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 3ce2f131b25..9a59d7632a1 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -151,7 +151,7 @@ inspect_type (struct demangle_parse_info *info,
 
   try
     {
-      sym = lookup_symbol (name, 0, VAR_DOMAIN, 0).symbol;
+      sym = lookup_symbol (name, 0, SEARCH_VFT, 0).symbol;
     }
   catch (const gdb_exception &except)
     {
@@ -505,7 +505,7 @@ replace_typedefs (struct demangle_parse_info *info,
 	      try
 		{
 		  sym = lookup_symbol (local_name.get (), 0,
-				       VAR_DOMAIN, 0).symbol;
+				       SEARCH_VFT, 0).symbol;
 		}
 	      catch (const gdb_exception &except)
 		{
@@ -1500,7 +1500,7 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
 
   /* Use VAR_DOMAIN here as NAME may be a typedef.  PR 18141, 18417.
      Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN.  */
-  rtti_sym = lookup_symbol (name, block, VAR_DOMAIN, NULL).symbol;
+  rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol;
 
   if (rtti_sym == NULL)
     {
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index a50b111bab8..f95b6f0f0e2 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -141,25 +141,25 @@ extern struct block_symbol cp_lookup_symbol_nonlocal
      (const struct language_defn *langdef,
       const char *name,
       const struct block *block,
-      const domain_enum domain);
+      const domain_search_flags domain);
 
 extern struct block_symbol
   cp_lookup_symbol_namespace (const char *the_namespace,
 			      const char *name,
 			      const struct block *block,
-			      const domain_enum domain);
+			      const domain_search_flags domain);
 
 extern struct block_symbol cp_lookup_symbol_imports_or_template
      (const char *scope,
       const char *name,
       const struct block *block,
-      const domain_enum domain);
+      const domain_search_flags domain);
 
 extern struct block_symbol
   cp_lookup_nested_symbol (struct type *parent_type,
 			   const char *nested_name,
 			   const struct block *block,
-			   const domain_enum domain);
+			   const domain_search_flags domain);
 
 struct type *cp_lookup_transparent_type (const char *name);
 
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 6f7beae0dac..620d900709c 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -444,7 +444,7 @@ PrimaryExpression:
 		  /* Handle VAR, which could be local or global.  */
 		  sym = lookup_symbol (copy.c_str (),
 				       pstate->expression_context_block,
-				       VAR_DOMAIN, &is_a_field_of_this);
+				       SEARCH_VFT, &is_a_field_of_this);
 		  if (sym.symbol && sym.symbol->aclass () != LOC_TYPEDEF)
 		    {
 		      if (symbol_read_needs_frame (sym.symbol))
@@ -493,7 +493,7 @@ PrimaryExpression:
 			      sym =
 				lookup_symbol (name.c_str (),
 					       (const struct block *) NULL,
-					       VAR_DOMAIN, NULL);
+					       SEARCH_VFT, NULL);
 			      pstate->push_symbol (name.c_str (), sym);
 			    }
 			  else
@@ -1337,7 +1337,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
 
   std::string copy = copy_name (yylval.sval);
 
-  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
   if (sym.symbol && sym.symbol->aclass () == LOC_TYPEDEF)
     {
       yylval.tsym.type = sym.symbol->type ();
@@ -1346,9 +1346,11 @@ classify_name (struct parser_state *par_state, const struct block *block)
   else if (sym.symbol == NULL)
     {
       /* Look-up first for a module name, then a type.  */
-      sym = lookup_symbol (copy.c_str (), block, MODULE_DOMAIN, NULL);
+      sym = lookup_symbol (copy.c_str (), block, SEARCH_MODULE_DOMAIN,
+			   nullptr);
       if (sym.symbol == NULL)
-	sym = lookup_symbol (copy.c_str (), block, STRUCT_DOMAIN, NULL);
+	sym = lookup_symbol (copy.c_str (), block, SEARCH_STRUCT_DOMAIN,
+			     nullptr);
 
       if (sym.symbol != NULL)
 	{
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 5b0307d44ac..6af57062ef9 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -171,7 +171,7 @@ class d_language : public language_defn
 
   struct block_symbol lookup_symbol_nonlocal
 	(const char *name, const struct block *block,
-	 const domain_enum domain) const override
+	 const domain_search_flags domain) const override
   {
     return d_lookup_symbol_nonlocal (this, name, block, domain);
   }
diff --git a/gdb/d-lang.h b/gdb/d-lang.h
index 1747ad90f24..ecf194d8155 100644
--- a/gdb/d-lang.h
+++ b/gdb/d-lang.h
@@ -69,10 +69,11 @@ extern const struct builtin_d_type *builtin_d_type (struct gdbarch *);
 
 /* Defined in d-namespace.c  */
 
-extern struct block_symbol d_lookup_symbol_nonlocal (const struct language_defn *,
-						     const char *,
-						     const struct block *,
-						     const domain_enum);
+extern struct block_symbol d_lookup_symbol_nonlocal
+     (const struct language_defn *,
+      const char *,
+      const struct block *,
+      const domain_search_flags);
 
 extern struct block_symbol d_lookup_nested_symbol (struct type *, const char *,
 						   const struct block *);
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index c110cbda057..3f8f7d8c24e 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -78,7 +78,7 @@ d_entire_prefix_len (const char *name)
 static struct block_symbol
 d_lookup_symbol (const struct language_defn *langdef,
 		 const char *name, const struct block *block,
-		 const domain_enum domain, int search)
+		 const domain_search_flags domain, int search)
 {
   struct block_symbol sym;
 
@@ -88,7 +88,7 @@ d_lookup_symbol (const struct language_defn *langdef,
 
   /* If we didn't find a definition for a builtin type in the static block,
      such as "ucent" which is a specialist type, search for it now.  */
-  if (langdef != NULL && domain == VAR_DOMAIN)
+  if (langdef != nullptr && (domain & SEARCH_TYPE_DOMAIN) != 0)
     {
       struct gdbarch *gdbarch;
 
@@ -166,7 +166,7 @@ d_lookup_symbol (const struct language_defn *langdef,
 static struct block_symbol
 d_lookup_symbol_in_module (const char *module, const char *name,
 			   const struct block *block,
-			   const domain_enum domain, int search)
+			   const domain_search_flags domain, int search)
 {
   char *concatenated_name = NULL;
 
@@ -198,7 +198,7 @@ d_lookup_symbol_in_module (const char *module, const char *name,
 static struct block_symbol
 lookup_module_scope (const struct language_defn *langdef,
 		     const char *name, const struct block *block,
-		     const domain_enum domain, const char *scope,
+		     const domain_search_flags domain, const char *scope,
 		     int scope_len)
 {
   char *module;
@@ -261,7 +261,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
 
       /* Search this particular base class.  */
       sym = d_lookup_symbol_in_module (base_name, name, block,
-				       VAR_DOMAIN, 0);
+				       SEARCH_VFT, 0);
       if (sym.symbol != NULL)
 	break;
 
@@ -270,14 +270,14 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
 	 what we want is possibly there.  */
       std::string concatenated_name = std::string (base_name) + "." + name;
       sym = lookup_symbol_in_static_block (concatenated_name.c_str (), block,
-					   VAR_DOMAIN);
+					   SEARCH_VFT);
       if (sym.symbol != NULL)
 	break;
 
       /* Nope.  We now have to search all static blocks in all objfiles,
 	 even if block != NULL, because there's no guarantees as to which
 	 symtab the symbol we want is in.  */
-      sym = lookup_static_symbol (concatenated_name.c_str (), VAR_DOMAIN);
+      sym = lookup_static_symbol (concatenated_name.c_str (), SEARCH_VFT);
       if (sym.symbol != NULL)
 	break;
 
@@ -320,7 +320,7 @@ d_lookup_nested_symbol (struct type *parent_type,
 	  const char *parent_name = type_name_or_error (saved_parent_type);
 	  struct block_symbol sym
 	    = d_lookup_symbol_in_module (parent_name, nested_name,
-					 block, VAR_DOMAIN, 0);
+					 block, SEARCH_VFT, 0);
 	  char *concatenated_name;
 
 	  if (sym.symbol != NULL)
@@ -337,7 +337,7 @@ d_lookup_nested_symbol (struct type *parent_type,
 	  xsnprintf (concatenated_name, size, "%s.%s",
 		     parent_name, nested_name);
 
-	  sym = lookup_static_symbol (concatenated_name, VAR_DOMAIN);
+	  sym = lookup_static_symbol (concatenated_name, SEARCH_VFT);
 	  if (sym.symbol != NULL)
 	    return sym;
 
@@ -361,7 +361,7 @@ d_lookup_nested_symbol (struct type *parent_type,
 static struct block_symbol
 d_lookup_symbol_imports (const char *scope, const char *name,
 			 const struct block *block,
-			 const domain_enum domain)
+			 const domain_search_flags domain)
 {
   struct using_direct *current;
   struct block_symbol sym;
@@ -473,7 +473,7 @@ d_lookup_symbol_imports (const char *scope, const char *name,
 static struct block_symbol
 d_lookup_symbol_module (const char *scope, const char *name,
 			const struct block *block,
-			const domain_enum domain)
+			const domain_search_flags domain)
 {
   struct block_symbol sym;
 
@@ -509,7 +509,7 @@ struct block_symbol
 d_lookup_symbol_nonlocal (const struct language_defn *langdef,
 			  const char *name,
 			  const struct block *block,
-			  const domain_enum domain)
+			  const domain_search_flags domain)
 {
   struct block_symbol sym;
   const char *scope = block == nullptr ? "" : block->scope ();
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 7654c05742e..21f81bbcdea 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym)
 {
   const char *name = get_imported_name (sym);
   block_symbol real_symbol = lookup_global_symbol (name, nullptr,
-						   VAR_DOMAIN);
+						   SEARCH_VFT);
   if (real_symbol.symbol == nullptr)
     error (_("could not find alias '%s' for function '%s'"),
 	   name, sym->print_name ());
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 062bd12909f..f832507341a 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -625,7 +625,7 @@ func_get_frame_base_dwarf_block (struct symbol *framefunc, CORE_ADDR pc,
 value *
 compute_var_value (const char *name)
 {
-  struct block_symbol sym = lookup_symbol (name, nullptr, VAR_DOMAIN,
+  struct block_symbol sym = lookup_symbol (name, nullptr, SEARCH_VAR_DOMAIN,
 					   nullptr);
   if (sym.symbol != nullptr)
     return value_of_variable (sym.symbol, sym.block);
diff --git a/gdb/eval.c b/gdb/eval.c
index 495effe2d03..b25b10f342a 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -730,7 +730,7 @@ scope_operation::evaluate_funcall (struct type *expect_type,
       function = cp_lookup_symbol_namespace (type->name (),
 					     name.c_str (),
 					     get_selected_block (0),
-					     VAR_DOMAIN).symbol;
+					     SEARCH_FUNCTION_DOMAIN).symbol;
       if (function == NULL)
 	error (_("No symbol \"%s\" in namespace \"%s\"."),
 	       name.c_str (), type->name ());
@@ -1105,7 +1105,8 @@ eval_op_func_static_var (struct type *expect_type, struct expression *exp,
 {
   CORE_ADDR addr = func->address ();
   const block *blk = block_for_pc (addr);
-  struct block_symbol sym = lookup_symbol (var, blk, VAR_DOMAIN, NULL);
+  struct block_symbol sym = lookup_symbol (var, blk, SEARCH_VAR_DOMAIN,
+					   nullptr);
   if (sym.symbol == NULL)
     error (_("No symbol \"%s\" in specified context."), var);
   return evaluate_var_value (noside, sym.block, sym.symbol);
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 7e45069c67e..faa53ba9dd0 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1640,11 +1640,11 @@ yylex (void)
   {
     std::string tmp = copy_name (yylval.sval);
     struct block_symbol result;
-    const domain_enum lookup_domains[] =
+    const domain_search_flags lookup_domains[] =
     {
-      STRUCT_DOMAIN,
-      VAR_DOMAIN,
-      MODULE_DOMAIN
+      SEARCH_STRUCT_DOMAIN,
+      SEARCH_VFT,
+      SEARCH_MODULE_DOMAIN
     };
     int hextype;
 
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index c35c73a0eb7..d573c4f2fbb 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -1715,7 +1715,7 @@ f_language::search_name_hash (const char *name) const
 struct block_symbol
 f_language::lookup_symbol_nonlocal (const char *name,
 				    const struct block *block,
-				    const domain_enum domain) const
+				    const domain_search_flags domain) const
 {
   return cp_lookup_symbol_nonlocal (this, name, block, domain);
 }
diff --git a/gdb/f-lang.h b/gdb/f-lang.h
index 3126146c607..c2034258513 100644
--- a/gdb/f-lang.h
+++ b/gdb/f-lang.h
@@ -142,7 +142,7 @@ class f_language : public language_defn
 
   struct block_symbol lookup_symbol_nonlocal
 	(const char *name, const struct block *block,
-	 const domain_enum domain) const override;
+	 const domain_search_flags domain) const override;
 
   /* See language.h.  */
 
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index f15ae7e8fb6..19bcd746208 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -552,7 +552,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream,
 		     value field before printing its value.  */
 		  struct block_symbol sym
 		    = lookup_symbol (field_name, get_selected_block (nullptr),
-				     VAR_DOMAIN, nullptr);
+				     SEARCH_VFT, nullptr);
 		  if (sym.symbol == nullptr)
 		    error (_("failed to find symbol for name list component %s"),
 			   field_name);
diff --git a/gdb/fbsd-tdep.c b/gdb/fbsd-tdep.c
index 5bcd5a744f1..d8fae0786f8 100644
--- a/gdb/fbsd-tdep.c
+++ b/gdb/fbsd-tdep.c
@@ -1960,8 +1960,9 @@ fbsd_fetch_rtld_offsets (struct gdbarch *gdbarch, struct fbsd_pspace_data *data)
     {
       /* Fetch offsets from debug symbols in rtld.  */
       struct symbol *obj_entry_sym
-	= lookup_symbol_in_language ("Struct_Obj_Entry", NULL, STRUCT_DOMAIN,
-				     language_c, NULL).symbol;
+	= lookup_symbol_in_language ("Struct_Obj_Entry", nullptr,
+				     SEARCH_STRUCT_DOMAIN,
+				     language_c, nullptr).symbol;
       if (obj_entry_sym == NULL)
 	error (_("Unable to find Struct_Obj_Entry symbol"));
       data->off_linkmap = lookup_struct_elt (obj_entry_sym->type (),
diff --git a/gdb/frame.c b/gdb/frame.c
index d95d63eb0f6..03f3c50cb8d 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2559,7 +2559,8 @@ inside_main_func (frame_info_ptr this_frame)
       /* In some language (for example Fortran) there will be no minimal
 	 symbol with the name of the main function.  In this case we should
 	 search the full symbols to see if we can find a match.  */
-      struct block_symbol bs = lookup_symbol (name, NULL, VAR_DOMAIN, 0);
+      struct block_symbol bs = lookup_symbol (name, nullptr,
+					      SEARCH_VFT, nullptr);
 
       /* We might have found some unrelated symbol.  For example, the
 	 Rust compiler can emit both a subprogram and a namespace with
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 9484f9e843f..069d40f56fb 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -297,7 +297,8 @@ ft32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  plg_end = ft32_analyze_prologue (func_addr,
 					   func_end, &cache, gdbarch);
 	  /* Found a function.  */
-	  sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
+	  sym = lookup_symbol (func_name, nullptr, SEARCH_FUNCTION_DOMAIN,
+			       nullptr).symbol;
 	  /* Don't use line number debug info for assembly source files.  */
 	  if ((sym != NULL) && sym->language () != language_asm)
 	    {
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 1dc68a99104..f4eff650799 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1655,7 +1655,7 @@ lookup_typename (const struct language_defn *language,
 {
   struct symbol *sym;
 
-  sym = lookup_symbol_in_language (name, block, VAR_DOMAIN,
+  sym = lookup_symbol_in_language (name, block, SEARCH_VFT,
 				   language->la_language, NULL).symbol;
   if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
     {
@@ -1699,7 +1699,7 @@ lookup_struct (const char *name, const struct block *block)
 {
   struct symbol *sym;
 
-  sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
+  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
 
   if (sym == NULL)
     {
@@ -1722,7 +1722,7 @@ lookup_union (const char *name, const struct block *block)
   struct symbol *sym;
   struct type *t;
 
-  sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
+  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
 
   if (sym == NULL)
     error (_("No union type named %s."), name);
@@ -1745,7 +1745,7 @@ lookup_enum (const char *name, const struct block *block)
 {
   struct symbol *sym;
 
-  sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
+  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
   if (sym == NULL)
     {
       error (_("No enum type named %s."), name);
@@ -1772,7 +1772,8 @@ lookup_template_type (const char *name, struct type *type,
   nam += type->name ();
   nam += " >"; /* FIXME, extra space still introduced in gcc?  */
 
-  symbol *sym = lookup_symbol (nam.c_str (), block, VAR_DOMAIN, 0).symbol;
+  symbol *sym = lookup_symbol (nam.c_str (), block,
+			       SEARCH_STRUCT_DOMAIN, 0).symbol;
 
   if (sym == NULL)
     {
@@ -2994,7 +2995,8 @@ check_typedef (struct type *type)
 	      stub_noname_complaint ();
 	      return make_qualified_type (type, instance_flags, NULL);
 	    }
-	  sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
+	  sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
+			       nullptr).symbol;
 	  if (sym)
 	    type->set_target_type (sym->type ());
 	  else					/* TYPE_CODE_UNDEF */
@@ -3084,7 +3086,8 @@ check_typedef (struct type *type)
 	  stub_noname_complaint ();
 	  return make_qualified_type (type, instance_flags, NULL);
 	}
-      sym = lookup_symbol (name, 0, STRUCT_DOMAIN, 0).symbol;
+      sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
+			   nullptr).symbol;
       if (sym)
 	{
 	  /* Same as above for opaque types, we can replace the stub
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index de6d21ae2c3..faefe925943 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -1079,7 +1079,7 @@ gnuv3_get_typeid_type (struct gdbarch *gdbarch)
   struct symbol *typeinfo;
   struct type *typeinfo_type;
 
-  typeinfo = lookup_symbol ("std::type_info", NULL, STRUCT_DOMAIN,
+  typeinfo = lookup_symbol ("std::type_info", NULL, SEARCH_STRUCT_DOMAIN,
 			    NULL).symbol;
   if (typeinfo == NULL)
     {
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 0b17ea42ff3..a3afbbb8514 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1293,7 +1293,8 @@ package_name_p (const char *name, const struct block *block)
   struct symbol *sym;
   struct field_of_this_result is_a_field_of_this;
 
-  sym = lookup_symbol (name, block, STRUCT_DOMAIN, &is_a_field_of_this).symbol;
+  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN,
+		       &is_a_field_of_this).symbol;
 
   if (sym
       && sym->aclass () == LOC_TYPEDEF
@@ -1335,7 +1336,7 @@ classify_packaged_name (const struct block *block)
 
   std::string copy = copy_name (yylval.sval);
 
-  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
 
   if (sym.symbol)
     {
@@ -1378,7 +1379,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
 
   /* TODO: What about other types?  */
 
-  sym = lookup_symbol (copy.c_str (), block, VAR_DOMAIN, &is_a_field_of_this);
+  sym = lookup_symbol (copy.c_str (), block, SEARCH_VFT, &is_a_field_of_this);
 
   if (sym.symbol)
     {
@@ -1403,7 +1404,7 @@ classify_name (struct parser_state *par_state, const struct block *block)
 			       strlen (current_package_name.get ()),
 			       copy.c_str (), copy.size ());
 
-	sym = lookup_symbol (sval.ptr, block, VAR_DOMAIN,
+	sym = lookup_symbol (sval.ptr, block, SEARCH_VFT,
 			     &is_a_field_of_this);
 	if (sym.symbol)
 	  {
diff --git a/gdb/guile/scm-frame.c b/gdb/guile/scm-frame.c
index 60bacdd7320..b133e8de11d 100644
--- a/gdb/guile/scm-frame.c
+++ b/gdb/guile/scm-frame.c
@@ -937,7 +937,7 @@ gdbscm_frame_read_var (SCM self, SCM symbol_scm, SCM rest)
 
 	    if (block == NULL)
 	      block = get_frame_block (frame_info_ptr (frame), NULL);
-	    lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN,
+	    lookup_sym = lookup_symbol (var_name.get (), block, SEARCH_VFT,
 					NULL);
 	    var = lookup_sym.symbol;
 	    block = lookup_sym.block;
diff --git a/gdb/guile/scm-symbol.c b/gdb/guile/scm-symbol.c
index bf5fe24f23d..7061ff58872 100644
--- a/gdb/guile/scm-symbol.c
+++ b/gdb/guile/scm-symbol.c
@@ -617,7 +617,8 @@ gdbscm_lookup_symbol (SCM name_scm, SCM rest)
   gdbscm_gdb_exception except {};
   try
     {
-      symbol = lookup_symbol (name, block, (domain_enum) domain,
+      domain_search_flags flags = from_scripting_domain (domain);
+      symbol = lookup_symbol (name, block, flags,
 			      &is_a_field_of_this).symbol;
     }
   catch (const gdb_exception &ex)
@@ -654,7 +655,8 @@ gdbscm_lookup_global_symbol (SCM name_scm, SCM rest)
 
   try
     {
-      symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol;
+      domain_search_flags flags = from_scripting_domain (domain);
+      symbol = lookup_global_symbol (name, NULL, flags).symbol;
     }
   catch (const gdb_exception &ex)
     {
@@ -696,14 +698,15 @@ static const scheme_integer_constant symbol_integer_constants[] =
 #undef X
 
 #define DOMAIN(X) \
-  { "SYMBOL_" #X "_DOMAIN", X ## _DOMAIN },
+  { "SYMBOL_" #X "_DOMAIN", to_scripting_domain (X ## _DOMAIN) },	\
+  { "SEARCH_" #X "_DOMAIN", to_scripting_domain (SEARCH_ ## X ## _DOMAIN) },
 #include "sym-domains.def"
 #undef DOMAIN
 
-  /* These were never correct.  */
-  { "SYMBOL_VARIABLES_DOMAIN", VAR_DOMAIN },
-  { "SYMBOL_FUNCTIONS_DOMAIN", VAR_DOMAIN },
-  { "SYMBOL_TYPES_DOMAIN", VAR_DOMAIN },
+  /* Historical.  */
+  { "SYMBOL_VARIABLES_DOMAIN", to_scripting_domain (SEARCH_VAR_DOMAIN) },
+  { "SYMBOL_FUNCTIONS_DOMAIN", to_scripting_domain (SEARCH_FUNCTION_DOMAIN) },
+  { "SYMBOL_TYPES_DOMAIN", to_scripting_domain (SEARCH_TYPE_DOMAIN) },
 
   END_INTEGER_CONSTANTS
 };
diff --git a/gdb/infrun.c b/gdb/infrun.c
index 3f0f69be098..87939579111 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -8799,7 +8799,7 @@ insert_exception_resume_breakpoint (struct thread_info *tp,
       struct breakpoint *bp;
 
       vsym = lookup_symbol_search_name (sym->search_name (),
-					b, VAR_DOMAIN);
+					b, SEARCH_VAR_DOMAIN);
       value = read_var_value (vsym.symbol, vsym.block, frame);
       /* If the value was optimized out, revert to the old behavior.  */
       if (! value->optimized_out ())
diff --git a/gdb/language.c b/gdb/language.c
index 038559a34bf..d6f6831c190 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -944,7 +944,8 @@ language_arch_info::bool_type () const
     {
       struct symbol *sym;
 
-      sym = lookup_symbol (m_bool_type_name, NULL, VAR_DOMAIN, NULL).symbol;
+      sym = lookup_symbol (m_bool_type_name, nullptr, SEARCH_TYPE_DOMAIN,
+			   nullptr).symbol;
       if (sym != nullptr)
 	{
 	  struct type *type = sym->type ();
diff --git a/gdb/language.h b/gdb/language.h
index 14a1ef6d472..5bef965c2c8 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -513,7 +513,7 @@ struct language_defn
   virtual struct block_symbol lookup_symbol_nonlocal
 	(const char *name,
 	 const struct block *block,
-	 const domain_enum domain) const;
+	 const domain_search_flags domain) const;
 
   /* Return an expression that can be used for a location
      watchpoint.  TYPE is a pointer type that points to the memory
diff --git a/gdb/linespec.c b/gdb/linespec.c
index b9aca3cc6ce..4e43bf28a67 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3923,7 +3923,7 @@ find_label_symbols_in_block (const struct block *block,
 
       for (struct symbol *sym : block_iterator_range (block))
 	{
-	  if (sym->matches (LABEL_DOMAIN)
+	  if (sym->domain () == LABEL_DOMAIN
 	      && cmp (sym->search_name (), name, name_len) == 0)
 	    {
 	      result->push_back ({sym, block});
@@ -3934,7 +3934,7 @@ find_label_symbols_in_block (const struct block *block,
   else
     {
       struct block_symbol label_sym
-	= lookup_symbol (name, block, LABEL_DOMAIN, 0);
+	= lookup_symbol (name, block, SEARCH_LABEL_DOMAIN, 0);
 
       if (label_sym.symbol != NULL)
 	{
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 67252ef5684..ce5a399477d 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -494,7 +494,7 @@ fblock	:	BLOCKNAME
 			{ struct symbol *sym
 			    = lookup_symbol (copy_name ($1).c_str (),
 					     pstate->expression_context_block,
-					     VAR_DOMAIN, 0).symbol;
+					     SEARCH_VFT, 0).symbol;
 			  $$ = sym;}
 	;
 			     
@@ -503,7 +503,7 @@ fblock	:	BLOCKNAME
 fblock	:	block COLONCOLON BLOCKNAME
 			{ struct symbol *tem
 			    = lookup_symbol (copy_name ($3).c_str (), $1,
-					     VAR_DOMAIN, 0).symbol;
+					     SEARCH_VFT, 0).symbol;
 			  if (!tem || tem->aclass () != LOC_BLOCK)
 			    error (_("No function \"%s\" in specified context."),
 				   copy_name ($3).c_str ());
@@ -528,7 +528,7 @@ variable:	DOLLAR_VARIABLE
 variable:	block COLONCOLON NAME
 			{ struct block_symbol sym
 			    = lookup_symbol (copy_name ($3).c_str (), $1,
-					     VAR_DOMAIN, 0);
+					     SEARCH_VFT, 0);
 
 			  if (sym.symbol == 0)
 			    error (_("No symbol \"%s\" in specified context."),
@@ -549,7 +549,7 @@ variable:	NAME
 			  sym
 			    = lookup_symbol (name.c_str (),
 					     pstate->expression_context_block,
-					     VAR_DOMAIN,
+					     SEARCH_VFT,
 					     &is_a_field_of_this);
 
 			  pstate->push_symbol (name.c_str (), sym);
@@ -927,7 +927,7 @@ yylex (void)
     if (lookup_symtab (tmp.c_str ()))
       return BLOCKNAME;
     sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
-			 VAR_DOMAIN, 0).symbol;
+			 SEARCH_VFT, 0).symbol;
     if (sym && sym->aclass () == LOC_BLOCK)
       return BLOCKNAME;
     if (lookup_typename (pstate->language (),
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 3cd9e097458..d80739b1f39 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -636,8 +636,9 @@ list_args_or_locals (const frame_print_options &fp_opts,
 	      struct frame_arg arg, entryarg;
 
 	      if (sym->is_argument ())
-		sym2 = lookup_symbol_search_name (sym->search_name (),
-						  block, VAR_DOMAIN).symbol;
+		sym2 = (lookup_symbol_search_name
+			(sym->search_name (),
+			 block, SEARCH_VAR_DOMAIN).symbol);
 	      else
 		sym2 = sym;
 	      gdb_assert (sym2 != NULL);
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 223cf09a561..4a80355ada5 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -226,7 +226,8 @@ moxie_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	  plg_end = moxie_analyze_prologue (func_addr, 
 					    func_end, &cache, gdbarch);
 	  /* Found a function.  */
-	  sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
+	  sym = lookup_symbol (func_name, nullptr,
+			       SEARCH_FUNCTION_DOMAIN, nullptr).symbol;
 	  /* Don't use line number debug info for assembly source
 	     files.  */
 	  if (sym && sym->language () != language_asm)
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 10eb73a95cb..2424e1e8530 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -87,7 +87,7 @@ lookup_struct_typedef (const char *name, const struct block *block, int noerr)
 {
   struct symbol *sym;
 
-  sym = lookup_symbol (name, block, STRUCT_DOMAIN, 0).symbol;
+  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, 0).symbol;
 
   if (sym == NULL)
     {
@@ -1129,7 +1129,7 @@ find_imps (const char *method, std::vector<const char *> *symbol_names)
      add the selector itself as a symbol, if it exists.  */
   if (selector_case && !symbol_names->empty ())
     {
-      struct symbol *sym = lookup_symbol (selector, NULL, VAR_DOMAIN,
+      struct symbol *sym = lookup_symbol (selector, NULL, SEARCH_VFT,
 					  0).symbol;
 
       if (sym != NULL) 
diff --git a/gdb/objfiles.h b/gdb/objfiles.h
index 64f2b5ef6be..98e2355f7a9 100644
--- a/gdb/objfiles.h
+++ b/gdb/objfiles.h
@@ -562,7 +562,7 @@ struct objfile
      contains !TYPE_OPAQUE symbol prefer its compunit.  If it contains
      only TYPE_OPAQUE symbol(s), return at least that compunit.  */
   struct compunit_symtab *lookup_symbol (block_enum kind, const char *name,
-					 domain_enum domain);
+					 domain_search_flags domain);
 
   /* See quick_symbol_functions.  */
   void print_stats (bool print_bcache);
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 2b5eb6f3026..ea7eb8c8d7e 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -629,9 +629,10 @@ block	:	block COLONCOLON name
 			  std::string copy = copy_name ($3);
 			  struct symbol *tem
 			    = lookup_symbol (copy.c_str (), $1,
-					     VAR_DOMAIN, NULL).symbol;
+					     SEARCH_FUNCTION_DOMAIN,
+					     nullptr).symbol;
 
-			  if (!tem || tem->aclass () != LOC_BLOCK)
+			  if (tem == nullptr)
 			    error (_("No function \"%s\" in specified context."),
 				   copy.c_str ());
 			  $$ = tem->value_block (); }
@@ -642,7 +643,7 @@ variable:	block COLONCOLON name
 
 			  std::string copy = copy_name ($3);
 			  sym = lookup_symbol (copy.c_str (), $1,
-					       VAR_DOMAIN, NULL);
+					       SEARCH_VFT, NULL);
 			  if (sym.symbol == 0)
 			    error (_("No symbol \"%s\" in specified context."),
 				   copy.c_str ());
@@ -672,7 +673,7 @@ variable:	qualified_name
 
 			  struct block_symbol sym
 			    = lookup_symbol (name.c_str (), nullptr,
-					     VAR_DOMAIN, nullptr);
+					     SEARCH_VFT, nullptr);
 			  pstate->push_symbol (name.c_str (), sym);
 			}
 	;
@@ -1400,7 +1401,7 @@ yylex (void)
 	  static const char this_name[] = "this";
 
 	  if (lookup_symbol (this_name, pstate->expression_context_block,
-			     VAR_DOMAIN, NULL).symbol)
+			     SEARCH_VFT, NULL).symbol)
 	    {
 	      free (uptokstart);
 	      return THIS;
@@ -1440,7 +1441,7 @@ yylex (void)
       sym = NULL;
     else
       sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
-			   VAR_DOMAIN, &is_a_field_of_this).symbol;
+			   SEARCH_VFT, &is_a_field_of_this).symbol;
     /* second chance uppercased (as Free Pascal does).  */
     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
       {
@@ -1456,7 +1457,7 @@ yylex (void)
 	 sym = NULL;
        else
 	 sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
-			      VAR_DOMAIN, &is_a_field_of_this).symbol;
+			      SEARCH_VFT, &is_a_field_of_this).symbol;
       }
     /* Third chance Capitalized (as GPC does).  */
     if (!sym && is_a_field_of_this.type == NULL && !is_a_field)
@@ -1479,7 +1480,7 @@ yylex (void)
 	 sym = NULL;
        else
 	 sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
-			      VAR_DOMAIN, &is_a_field_of_this).symbol;
+			      SEARCH_VFT, &is_a_field_of_this).symbol;
       }
 
     if (is_a_field || (is_a_field_of_this.type != NULL))
@@ -1576,7 +1577,7 @@ yylex (void)
 		      cur_sym
 			= lookup_symbol (ncopy,
 					 pstate->expression_context_block,
-					 VAR_DOMAIN, NULL).symbol;
+					 SEARCH_VFT, NULL).symbol;
 		      if (cur_sym)
 			{
 			  if (cur_sym->aclass () == LOC_TYPEDEF)
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 076ee08ab6e..2372cdf83eb 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -253,7 +253,7 @@ pascal_language::value_print_inner (struct value *val,
 		{
 		  const char *search_name = msymbol.minsym->search_name ();
 		  wsym = lookup_symbol_search_name (search_name, NULL,
-						    VAR_DOMAIN).symbol;
+						    SEARCH_VFT).symbol;
 		}
 
 	      if (wsym)
diff --git a/gdb/parse.c b/gdb/parse.c
index 9209e3d8fa2..4b0eeaf5330 100644
--- a/gdb/parse.c
+++ b/gdb/parse.c
@@ -225,7 +225,8 @@ parser_state::push_dollar (struct stoken str)
   /* On some systems, such as HP-UX and hppa-linux, certain system routines
      have names beginning with $ or $$.  Check for those, first.  */
 
-  sym = lookup_symbol (copy.c_str (), NULL, VAR_DOMAIN, NULL);
+  sym = lookup_symbol (copy.c_str (), nullptr,
+		       SEARCH_VAR_DOMAIN | SEARCH_FUNCTION_DOMAIN, nullptr);
   if (sym.symbol)
     {
       push_new<expr::var_value_operation> (sym);
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 7a638ab8b89..813b5e642ef 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -1582,7 +1582,7 @@ info_address_command (const char *exp, int from_tty)
   if (exp == 0)
     error (_("Argument required."));
 
-  sym = lookup_symbol (exp, get_selected_block (&context_pc), VAR_DOMAIN,
+  sym = lookup_symbol (exp, get_selected_block (&context_pc), SEARCH_VFT,
 		       &is_a_field_of_this).symbol;
   if (sym == NULL)
     {
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index eb031d33f0d..cb7a397afb1 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1507,7 +1507,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 
 		  sym = block_lookup_symbol (b, psym->ginfo.search_name (),
 					     symbol_name_match_type::SEARCH_NAME,
-					     psym->domain);
+					     to_search_flags (psym->domain));
 		  if (!sym)
 		    {
 		      gdb_printf ("Static symbol `");
@@ -1522,7 +1522,7 @@ maintenance_check_psymtabs (const char *ignore, int from_tty)
 		{
 		  sym = block_lookup_symbol (b, psym->ginfo.search_name (),
 					     symbol_name_match_type::SEARCH_NAME,
-					     psym->domain);
+					     to_search_flags (psym->domain));
 		  if (!sym)
 		    {
 		      gdb_printf ("Global symbol `");
diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c
index 95f15e00436..a1061fc0d72 100644
--- a/gdb/python/py-frame.c
+++ b/gdb/python/py-frame.c
@@ -532,7 +532,8 @@ frapy_read_var (PyObject *self, PyObject *args, PyObject *kw)
 
 	  if (!block)
 	    block = get_frame_block (frame, NULL);
-	  lookup_sym = lookup_symbol (var_name.get (), block, VAR_DOMAIN, NULL);
+	  lookup_sym = lookup_symbol (var_name.get (), block,
+				      SEARCH_VFT, nullptr);
 	  var = lookup_sym.symbol;
 	  block = lookup_sym.block;
 	}
diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c
index a3e55ffa3eb..ffdb7be4a9a 100644
--- a/gdb/python/py-objfile.c
+++ b/gdb/python/py-objfile.c
@@ -479,8 +479,9 @@ objfpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
+      domain_search_flags flags = from_scripting_domain (domain);
       struct symbol *sym = lookup_global_symbol_from_objfile
-	(obj->objfile, GLOBAL_BLOCK, symbol_name, (domain_enum) domain).symbol;
+	(obj->objfile, GLOBAL_BLOCK, symbol_name, flags).symbol;
       if (sym == nullptr)
 	Py_RETURN_NONE;
 
@@ -513,8 +514,9 @@ objfpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
+      domain_search_flags flags = from_scripting_domain (domain);
       struct symbol *sym = lookup_global_symbol_from_objfile
-	(obj->objfile, STATIC_BLOCK, symbol_name, (domain_enum) domain).symbol;
+	(obj->objfile, STATIC_BLOCK, symbol_name, flags).symbol;
       if (sym == nullptr)
 	Py_RETURN_NONE;
 
diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index a7d010f6d0c..2fb68377bad 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -432,8 +432,8 @@ gdbpy_lookup_symbol (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
-      symbol = lookup_symbol (name, block, (domain_enum) domain,
-			      &is_a_field_of_this).symbol;
+      domain_search_flags flags = from_scripting_domain (domain);
+      symbol = lookup_symbol (name, block, flags, &is_a_field_of_this).symbol;
     }
   catch (const gdb_exception &except)
     {
@@ -481,7 +481,8 @@ gdbpy_lookup_global_symbol (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
-      symbol = lookup_global_symbol (name, NULL, (domain_enum) domain).symbol;
+      domain_search_flags flags = from_scripting_domain (domain);
+      symbol = lookup_global_symbol (name, NULL, flags).symbol;
     }
   catch (const gdb_exception &except)
     {
@@ -542,13 +543,14 @@ gdbpy_lookup_static_symbol (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
+      domain_search_flags flags = from_scripting_domain (domain);
+
       if (block != nullptr)
 	symbol
-	  = lookup_symbol_in_static_block (name, block,
-					   (domain_enum) domain).symbol;
+	  = lookup_symbol_in_static_block (name, block, flags).symbol;
 
       if (symbol == nullptr)
-	symbol = lookup_static_symbol (name, (domain_enum) domain).symbol;
+	symbol = lookup_static_symbol (name, flags).symbol;
     }
   catch (const gdb_exception &except)
     {
@@ -592,6 +594,8 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
 
   try
     {
+      domain_search_flags flags = from_scripting_domain (domain);
+
       /* Expand any symtabs that contain potentially matching symbols.  */
       lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
       expand_symtabs_matching (NULL, lookup_name, NULL, NULL,
@@ -613,7 +617,7 @@ gdbpy_lookup_static_symbols (PyObject *self, PyObject *args, PyObject *kw)
 	      if (block != nullptr)
 		{
 		  symbol *symbol = lookup_symbol_in_static_block
-		    (name, block, (domain_enum) domain).symbol;
+		    (name, block, flags).symbol;
 
 		  if (symbol != nullptr)
 		    {
@@ -675,7 +679,9 @@ gdbpy_initialize_symbols (void)
 
 #define DOMAIN(X)							\
   if (PyModule_AddIntConstant (gdb_module, "SYMBOL_" #X "_DOMAIN",	\
-			       X ## _DOMAIN) < 0)			\
+			       to_scripting_domain (X ## _DOMAIN)) < 0	\
+      || PyModule_AddIntConstant (gdb_module, "SEARCH_" #X "_DOMAIN",	\
+				  to_scripting_domain (SEARCH_ ## X ## _DOMAIN)) < 0) \
     return -1;
 #include "sym-domains.def"
 #undef DOMAIN
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index ff1769c7296..11c7f13417d 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1563,7 +1563,8 @@ rust_structop::evaluate_funcall (struct type *expect_type,
 
   const struct block *block = get_selected_block (0);
   struct block_symbol sym = lookup_symbol (name.c_str (), block,
-					   VAR_DOMAIN, NULL);
+					   SEARCH_VFT,
+					   nullptr);
   if (sym.symbol == NULL)
     error (_("Could not find function named '%s'"), name.c_str ());
 
@@ -1699,7 +1700,7 @@ rust_language::is_string_type_p (struct type *type) const
 struct block_symbol
 rust_language::lookup_symbol_nonlocal
      (const char *name, const struct block *block,
-      const domain_enum domain) const
+      const domain_search_flags domain) const
 {
   struct block_symbol result = {};
 
@@ -1707,7 +1708,7 @@ rust_language::lookup_symbol_nonlocal
   symbol_lookup_debug_printf
     ("rust_lookup_symbol_non_local (%s, %s (scope %s), %s)",
      name, host_address_to_string (block), scope,
-     domain_name (domain));
+     domain_name (domain).c_str ());
 
   /* Look up bare names in the block's scope.  */
   std::string scopedname;
diff --git a/gdb/rust-lang.h b/gdb/rust-lang.h
index d2270e66b4a..e76a63ee037 100644
--- a/gdb/rust-lang.h
+++ b/gdb/rust-lang.h
@@ -151,7 +151,7 @@ class rust_language : public language_defn
 
   struct block_symbol lookup_symbol_nonlocal
 	(const char *name, const struct block *block,
-	 const domain_enum domain) const override;
+	 const domain_search_flags domain) const override;
 
   /* See language.h.  */
 
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index 277a0793ea9..af1b76f738a 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -308,7 +308,7 @@ struct rust_parser
   void update_innermost_block (struct block_symbol sym);
   struct block_symbol lookup_symbol (const char *name,
 				     const struct block *block,
-				     const domain_enum domain);
+				     const domain_search_flags domain);
   struct type *rust_lookup_type (const char *name);
 
   /* Clear some state.  This is only used for testing.  */
@@ -431,7 +431,7 @@ munge_name_and_block (const char **name, const struct block **block)
 
 struct block_symbol
 rust_parser::lookup_symbol (const char *name, const struct block *block,
-			    const domain_enum domain)
+			    const domain_search_flags domain)
 {
   struct block_symbol result;
 
@@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name)
   const struct block *block = pstate->expression_context_block;
   munge_name_and_block (&name, &block);
 
-  result = ::lookup_symbol (name, block, STRUCT_DOMAIN, NULL);
+  result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL);
   if (result.symbol != NULL)
     {
       update_innermost_block (result);
@@ -1221,7 +1221,7 @@ rust_parser::name_to_operation (const std::string &name)
 {
   struct block_symbol sym = lookup_symbol (name.c_str (),
 					   pstate->expression_context_block,
-					   VAR_DOMAIN);
+					   SEARCH_VFT);
   if (sym.symbol != nullptr && sym.symbol->aclass () != LOC_TYPEDEF)
     return make_operation<var_value_operation> (sym);
 
diff --git a/gdb/source.c b/gdb/source.c
index 2c3bf91923b..2c465a1251f 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -316,8 +316,9 @@ select_source_symtab ()
 
   /* Make the default place to list be the function `main'
      if one exists.  */
-  block_symbol bsym = lookup_symbol (main_name (), 0, VAR_DOMAIN, 0);
-  if (bsym.symbol != nullptr && bsym.symbol->aclass () == LOC_BLOCK)
+  block_symbol bsym = lookup_symbol (main_name (), nullptr,
+				     SEARCH_FUNCTION_DOMAIN, nullptr);
+  if (bsym.symbol != nullptr)
     {
       symtab_and_line sal = find_function_start_sal (bsym.symbol, true);
       if (sal.symtab == NULL)
diff --git a/gdb/stack.c b/gdb/stack.c
index 2de3e361c61..fac0279472e 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -818,7 +818,7 @@ print_frame_args (const frame_print_options &fp_opts,
 	      struct symbol *nsym;
 
 	      nsym = lookup_symbol_search_name (sym->search_name (),
-						b, VAR_DOMAIN).symbol;
+						b, SEARCH_VAR_DOMAIN).symbol;
 	      gdb_assert (nsym != NULL);
 	      if (nsym->aclass () == LOC_REGISTER
 		  && !nsym->is_argument ())
@@ -2472,7 +2472,7 @@ iterate_over_block_arg_vars (const struct block *b,
 
 	  struct symbol *sym2
 	    = lookup_symbol_search_name (sym->search_name (),
-					 b, VAR_DOMAIN).symbol;
+					 b, SEARCH_VAR_DOMAIN).symbol;
 	  cb (sym->print_name (), sym2);
 	}
     }
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 3f5df13a005..30b02531b9c 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -240,7 +240,8 @@ objfile::map_symtabs_matching_filename
 }
 
 struct compunit_symtab *
-objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
+objfile::lookup_symbol (block_enum kind, const char *name,
+			domain_search_flags domain)
 {
   struct compunit_symtab *retval = nullptr;
 
@@ -248,7 +249,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
     gdb_printf (gdb_stdlog,
 		"qf->lookup_symbol (%s, %d, \"%s\", %s)\n",
 		objfile_debug_name (this), kind, name,
-		domain_name (domain));
+		domain_name (domain).c_str ());
 
   lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
 
@@ -277,10 +278,6 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
     return true;
   };
 
-  domain_search_flags flags = to_search_flags (domain);
-  if (domain == VAR_DOMAIN)
-    flags |= SEARCH_TYPE_DOMAIN | SEARCH_FUNCTION_DOMAIN;
-
   for (const auto &iter : qf)
     {
       if (!iter->expand_symtabs_matching (this,
@@ -291,7 +288,7 @@ objfile::lookup_symbol (block_enum kind, const char *name, domain_enum domain)
 					  kind == GLOBAL_BLOCK
 					  ? SEARCH_GLOBAL_BLOCK
 					  : SEARCH_STATIC_BLOCK,
-					  flags))
+					  domain))
 	break;
     }
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 17e1a64e77d..9d5ce7f6ad2 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1697,8 +1697,8 @@ set_initial_language_callback ()
     {
       const char *name = main_name ();
       struct symbol *sym
-	= lookup_symbol_in_language (name, NULL, VAR_DOMAIN, default_lang,
-				     NULL).symbol;
+	= lookup_symbol_in_language (name, nullptr, SEARCH_FUNCTION_DOMAIN,
+				     default_lang, nullptr).symbol;
 
       if (sym != NULL)
 	lang = sym->language ();
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a973052f338..5735786ac44 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -85,7 +85,7 @@ static struct block_symbol
   lookup_symbol_aux (const char *name,
 		     symbol_name_match_type match_type,
 		     const struct block *block,
-		     const domain_enum domain,
+		     const domain_search_flags domain,
 		     enum language language,
 		     struct field_of_this_result *);
 
@@ -93,13 +93,14 @@ static
 struct block_symbol lookup_local_symbol (const char *name,
 					 symbol_name_match_type match_type,
 					 const struct block *block,
-					 const domain_enum domain,
+					 const domain_search_flags domain,
 					 enum language language);
 
 static struct block_symbol
   lookup_symbol_in_objfile (struct objfile *objfile,
 			    enum block_enum block_index,
-			    const char *name, const domain_enum domain);
+			    const char *name,
+			    const domain_search_flags domain);
 
 static void set_main_name (program_space *pspace, const char *name,
 			   language lang);
@@ -171,14 +172,14 @@ struct symbol_cache_slot
      lookup was saved in the cache, but cache space is pretty cheap.  */
   const struct objfile *objfile_context;
 
+  /* The domain that was searched for initially.  This must exactly
+     match.  */
+  domain_search_flags domain;
+
   union
   {
     struct block_symbol found;
-    struct
-    {
-      char *name;
-      domain_enum domain;
-    } not_found;
+    char *name;
   } value;
 };
 
@@ -188,7 +189,7 @@ static void
 symbol_cache_clear_slot (struct symbol_cache_slot *slot)
 {
   if (slot->state == SYMBOL_SLOT_NOT_FOUND)
-    xfree (slot->value.not_found.name);
+    xfree (slot->value.name);
   slot->state = SYMBOL_SLOT_UNUSED;
 }
 
@@ -1243,19 +1244,14 @@ matching_obj_sections (struct obj_section *obj_first,
 
 static unsigned int
 hash_symbol_entry (const struct objfile *objfile_context,
-		   const char *name, domain_enum domain)
+		   const char *name, domain_search_flags domain)
 {
   unsigned int hash = (uintptr_t) objfile_context;
 
   if (name != NULL)
     hash += htab_hash_string (name);
 
-  /* Because of symbol_matches_domain we need VAR_DOMAIN and STRUCT_DOMAIN
-     to map to the same slot.  */
-  if (domain == STRUCT_DOMAIN)
-    hash += VAR_DOMAIN * 7;
-  else
-    hash += domain * 7;
+  hash += domain * 7;
 
   return hash;
 }
@@ -1265,10 +1261,9 @@ hash_symbol_entry (const struct objfile *objfile_context,
 static int
 eq_symbol_entry (const struct symbol_cache_slot *slot,
 		 const struct objfile *objfile_context,
-		 const char *name, domain_enum domain)
+		 const char *name, domain_search_flags domain)
 {
   const char *slot_name;
-  domain_enum slot_domain;
 
   if (slot->state == SYMBOL_SLOT_UNUSED)
     return 0;
@@ -1276,16 +1271,11 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
   if (slot->objfile_context != objfile_context)
     return 0;
 
+  domain_search_flags slot_domain = slot->domain;
   if (slot->state == SYMBOL_SLOT_NOT_FOUND)
-    {
-      slot_name = slot->value.not_found.name;
-      slot_domain = slot->value.not_found.domain;
-    }
+    slot_name = slot->value.name;
   else
-    {
-      slot_name = slot->value.found.symbol->search_name ();
-      slot_domain = slot->value.found.symbol->domain ();
-    }
+    slot_name = slot->value.found.symbol->search_name ();
 
   /* NULL names match.  */
   if (slot_name == NULL && name == NULL)
@@ -1301,18 +1291,18 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
 	 the first time through.  If the slot records a found symbol,
 	 then this means using the symbol name comparison function of
 	 the symbol's language with symbol->search_name ().  See
-	 dictionary.c.  It also means using symbol_matches_domain for
-	 found symbols.  See block.c.
+	 dictionary.c.
 
 	 If the slot records a not-found symbol, then require a precise match.
 	 We could still be lax with whitespace like strcmp_iw though.  */
 
+      if (slot_domain != domain)
+	return 0;
+
       if (slot->state == SYMBOL_SLOT_NOT_FOUND)
 	{
 	  if (strcmp (slot_name, name) != 0)
 	    return 0;
-	  if (slot_domain != domain)
-	    return 0;
 	}
       else
 	{
@@ -1321,9 +1311,6 @@ eq_symbol_entry (const struct symbol_cache_slot *slot,
 
 	  if (!symbol_matches_search_name (sym, lookup_name))
 	    return 0;
-
-	  if (!symbol_matches_domain (sym->language (), slot_domain, domain))
-	    return 0;
 	}
     }
   else
@@ -1443,7 +1430,7 @@ set_symbol_cache_size_handler (const char *args, int from_tty,
 static struct block_symbol
 symbol_cache_lookup (struct symbol_cache *cache,
 		     struct objfile *objfile_context, enum block_enum block,
-		     const char *name, domain_enum domain,
+		     const char *name, domain_search_flags domain,
 		     struct block_symbol_cache **bsc_ptr,
 		     struct symbol_cache_slot **slot_ptr)
 {
@@ -1474,7 +1461,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
 				  block == GLOBAL_BLOCK ? "Global" : "Static",
 				  slot->state == SYMBOL_SLOT_NOT_FOUND
 				  ? " (not found)" : "", name,
-				  domain_name (domain));
+				  domain_name (domain).c_str ());
       ++bsc->hits;
       if (slot->state == SYMBOL_SLOT_NOT_FOUND)
 	return SYMBOL_LOOKUP_FAILED;
@@ -1485,7 +1472,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
 
   symbol_lookup_debug_printf ("%s block symbol cache miss for %s, %s",
 			      block == GLOBAL_BLOCK ? "Global" : "Static",
-			      name, domain_name (domain));
+			      name, domain_name (domain).c_str ());
   ++bsc->misses;
   return {};
 }
@@ -1500,7 +1487,8 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc,
 			 struct symbol_cache_slot *slot,
 			 struct objfile *objfile_context,
 			 struct symbol *symbol,
-			 const struct block *block)
+			 const struct block *block,
+			 domain_search_flags domain)
 {
   if (bsc == NULL)
     return;
@@ -1513,6 +1501,7 @@ symbol_cache_mark_found (struct block_symbol_cache *bsc,
   slot->objfile_context = objfile_context;
   slot->value.found.symbol = symbol;
   slot->value.found.block = block;
+  slot->domain = domain;
 }
 
 /* Mark symbol NAME, DOMAIN as not found in SLOT.
@@ -1523,7 +1512,7 @@ static void
 symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
 			     struct symbol_cache_slot *slot,
 			     struct objfile *objfile_context,
-			     const char *name, domain_enum domain)
+			     const char *name, domain_search_flags domain)
 {
   if (bsc == NULL)
     return;
@@ -1534,8 +1523,8 @@ symbol_cache_mark_not_found (struct block_symbol_cache *bsc,
     }
   slot->state = SYMBOL_SLOT_NOT_FOUND;
   slot->objfile_context = objfile_context;
-  slot->value.not_found.name = xstrdup (name);
-  slot->value.not_found.domain = domain;
+  slot->value.name = xstrdup (name);
+  slot->domain = domain;
 }
 
 /* Flush the symbol cache of PSPACE.  */
@@ -1620,8 +1609,8 @@ symbol_cache_dump (const struct symbol_cache *cache)
 	    case SYMBOL_SLOT_NOT_FOUND:
 	      gdb_printf ("  [%4u] = %s, %s %s (not found)\n", i,
 			  host_address_to_string (slot->objfile_context),
-			  slot->value.not_found.name,
-			  domain_name (slot->value.not_found.domain));
+			  slot->value.name,
+			  domain_name (slot->domain).c_str ());
 	      break;
 	    case SYMBOL_SLOT_FOUND:
 	      {
@@ -1984,7 +1973,8 @@ search_name_hash (enum language language, const char *search_name)
 
 struct block_symbol
 lookup_symbol_in_language (const char *name, const struct block *block,
-			   const domain_enum domain, enum language lang,
+			   const domain_search_flags domain,
+			   enum language lang,
 			   struct field_of_this_result *is_a_field_of_this)
 {
   SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
@@ -2002,7 +1992,7 @@ lookup_symbol_in_language (const char *name, const struct block *block,
 
 struct block_symbol
 lookup_symbol (const char *name, const struct block *block,
-	       domain_enum domain,
+	       domain_search_flags domain,
 	       struct field_of_this_result *is_a_field_of_this)
 {
   return lookup_symbol_in_language (name, block, domain,
@@ -2014,7 +2004,7 @@ lookup_symbol (const char *name, const struct block *block,
 
 struct block_symbol
 lookup_symbol_search_name (const char *search_name, const struct block *block,
-			   domain_enum domain)
+			   domain_search_flags domain)
 {
   return lookup_symbol_aux (search_name, symbol_name_match_type::SEARCH_NAME,
 			    block, domain, language_asm, NULL);
@@ -2039,7 +2029,7 @@ lookup_language_this (const struct language_defn *lang,
 
       sym = block_lookup_symbol (block, lang->name_of_this (),
 				 symbol_name_match_type::SEARCH_NAME,
-				 VAR_DOMAIN);
+				 SEARCH_VFT);
       if (sym != NULL)
 	{
 	  symbol_lookup_debug_printf_v
@@ -2108,7 +2098,7 @@ check_field (struct type *type, const char *name,
 static struct block_symbol
 lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
 		   const struct block *block,
-		   const domain_enum domain, enum language language,
+		   const domain_search_flags domain, enum language language,
 		   struct field_of_this_result *is_a_field_of_this)
 {
   SYMBOL_LOOKUP_SCOPED_DEBUG_ENTER_EXIT;
@@ -2127,7 +2117,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
 	 objfile != NULL ? objfile_debug_name (objfile) : "NULL");
       symbol_lookup_debug_printf
 	("domain name = \"%s\", language = \"%s\")",
-	 domain_name (domain), language_str (language));
+	 domain_name (domain).c_str (), language_str (language));
     }
 
   /* Make sure we do something sensible with is_a_field_of_this, since
@@ -2157,7 +2147,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
   /* Don't do this check if we are searching for a struct.  It will
      not be found by check_field, but will be found by other
      means.  */
-  if (is_a_field_of_this != NULL && domain != STRUCT_DOMAIN)
+  if (is_a_field_of_this != NULL && (domain & SEARCH_STRUCT_DOMAIN) == 0)
     {
       result = lookup_language_this (langdef, block);
 
@@ -2213,7 +2203,7 @@ static struct block_symbol
 lookup_local_symbol (const char *name,
 		     symbol_name_match_type match_type,
 		     const struct block *block,
-		     const domain_enum domain,
+		     const domain_search_flags domain,
 		     enum language language)
 {
   if (block == nullptr)
@@ -2258,7 +2248,7 @@ lookup_local_symbol (const char *name,
 struct symbol *
 lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 			const struct block *block,
-			const domain_enum domain)
+			const domain_search_flags domain)
 {
   struct symbol *sym;
 
@@ -2271,7 +2261,7 @@ lookup_symbol_in_block (const char *name, symbol_name_match_type match_type,
 	("lookup_symbol_in_block (%s, %s (objfile %s), %s)",
 	 name, host_address_to_string (block),
 	 objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
-	 domain_name (domain));
+	 domain_name (domain).c_str ());
     }
 
   sym = block_lookup_symbol (block, name, match_type, domain);
@@ -2292,7 +2282,7 @@ struct block_symbol
 lookup_global_symbol_from_objfile (struct objfile *main_objfile,
 				   enum block_enum block_index,
 				   const char *name,
-				   const domain_enum domain)
+				   const domain_search_flags domain)
 {
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
@@ -2316,7 +2306,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
 static struct block_symbol
 lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
 				  enum block_enum block_index, const char *name,
-				  const domain_enum domain)
+				  const domain_search_flags domain)
 {
   gdb_assert (block_index == GLOBAL_BLOCK || block_index == STATIC_BLOCK);
 
@@ -2324,7 +2314,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
     ("lookup_symbol_in_objfile_symtabs (%s, %s, %s, %s)",
      objfile_debug_name (objfile),
      block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
-     name, domain_name (domain));
+     name, domain_name (domain).c_str ());
 
   struct block_symbol other;
   other.symbol = NULL;
@@ -2383,7 +2373,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile,
 static struct block_symbol
 lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
 					    const char *linkage_name,
-					    domain_enum domain)
+					    domain_search_flags domain)
 {
   enum language lang = current_language->la_language;
   struct objfile *main_objfile;
@@ -2435,7 +2425,7 @@ Internal: %s symbol `%s' found in %s psymtab but not in symtab.\n\
 static struct block_symbol
 lookup_symbol_via_quick_fns (struct objfile *objfile,
 			     enum block_enum block_index, const char *name,
-			     const domain_enum domain)
+			     const domain_search_flags domain)
 {
   struct compunit_symtab *cust;
   const struct blockvector *bv;
@@ -2446,7 +2436,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
     ("lookup_symbol_via_quick_fns (%s, %s, %s, %s)",
      objfile_debug_name (objfile),
      block_index == GLOBAL_BLOCK ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
-     name, domain_name (domain));
+     name, domain_name (domain).c_str ());
 
   cust = objfile->lookup_symbol (block_index, name, domain);
   if (cust == NULL)
@@ -2477,7 +2467,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile,
 struct block_symbol
 language_defn::lookup_symbol_nonlocal (const char *name,
 				       const struct block *block,
-				       const domain_enum domain) const
+				       const domain_search_flags domain) const
 {
   struct block_symbol result;
 
@@ -2495,7 +2485,7 @@ language_defn::lookup_symbol_nonlocal (const char *name,
      shared libraries we could search all of them only to find out the
      builtin type isn't defined in any of them.  This is common for types
      like "void".  */
-  if (domain == VAR_DOMAIN)
+  if ((domain & SEARCH_TYPE_DOMAIN) != 0)
     {
       struct gdbarch *gdbarch;
 
@@ -2518,7 +2508,7 @@ language_defn::lookup_symbol_nonlocal (const char *name,
 struct block_symbol
 lookup_symbol_in_static_block (const char *name,
 			       const struct block *block,
-			       const domain_enum domain)
+			       const domain_search_flags domain)
 {
   if (block == nullptr)
     return {};
@@ -2538,7 +2528,7 @@ lookup_symbol_in_static_block (const char *name,
 	("lookup_symbol_in_static_block (%s, %s (objfile %s), %s)",
 	 name, host_address_to_string (block),
 	 objfile != nullptr ? objfile_debug_name (objfile) : "NULL",
-	 domain_name (domain));
+	 domain_name (domain).c_str ());
     }
 
   sym = lookup_symbol_in_block (name,
@@ -2557,7 +2547,7 @@ lookup_symbol_in_static_block (const char *name,
 
 static struct block_symbol
 lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
-			  const char *name, const domain_enum domain)
+			  const char *name, const domain_search_flags domain)
 {
   struct block_symbol result;
 
@@ -2567,7 +2557,7 @@ lookup_symbol_in_objfile (struct objfile *objfile, enum block_enum block_index,
 			      objfile_debug_name (objfile),
 			      block_index == GLOBAL_BLOCK
 			      ? "GLOBAL_BLOCK" : "STATIC_BLOCK",
-			      name, domain_name (domain));
+			      name, domain_name (domain).c_str ());
 
   result = lookup_symbol_in_objfile_symtabs (objfile, block_index,
 					     name, domain);
@@ -2598,7 +2588,7 @@ static struct block_symbol
 lookup_global_or_static_symbol (const char *name,
 				enum block_enum block_index,
 				struct objfile *objfile,
-				const domain_enum domain)
+				const domain_search_flags domain)
 {
   struct symbol_cache *cache = get_symbol_cache (current_program_space);
   struct block_symbol result;
@@ -2632,7 +2622,8 @@ lookup_global_or_static_symbol (const char *name,
        objfile);
 
   if (result.symbol != NULL)
-    symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block);
+    symbol_cache_mark_found (bsc, slot, objfile, result.symbol, result.block,
+			     domain);
   else
     symbol_cache_mark_not_found (bsc, slot, objfile, name, domain);
 
@@ -2642,7 +2633,7 @@ lookup_global_or_static_symbol (const char *name,
 /* See symtab.h.  */
 
 struct block_symbol
-lookup_static_symbol (const char *name, const domain_enum domain)
+lookup_static_symbol (const char *name, const domain_search_flags domain)
 {
   return lookup_global_or_static_symbol (name, STATIC_BLOCK, nullptr, domain);
 }
@@ -2652,7 +2643,7 @@ lookup_static_symbol (const char *name, const domain_enum domain)
 struct block_symbol
 lookup_global_symbol (const char *name,
 		      const struct block *block,
-		      const domain_enum domain)
+		      const domain_search_flags domain)
 {
   /* If a block was passed in, we want to search the corresponding
      global block first.  This yields "more expected" behavior, and is
@@ -2761,7 +2752,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   const struct block *block;
   struct symbol *sym;
 
-  cust = objfile->lookup_symbol (block_index, name, STRUCT_DOMAIN);
+  cust = objfile->lookup_symbol (block_index, name, SEARCH_STRUCT_DOMAIN);
   if (cust == NULL)
     return NULL;
 
@@ -2769,7 +2760,7 @@ basic_lookup_transparent_type_quick (struct objfile *objfile,
   block = bv->block (block_index);
 
   lookup_name_info lookup_name (name, symbol_name_match_type::FULL);
-  sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr);
+  sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN, nullptr);
   if (sym == nullptr)
     error_in_psymtab_expansion (block_index, name, cust);
   gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -2794,7 +2785,8 @@ basic_lookup_transparent_type_1 (struct objfile *objfile,
     {
       bv = cust->blockvector ();
       block = bv->block (block_index);
-      sym = block_find_symbol (block, lookup_name, STRUCT_DOMAIN, nullptr);
+      sym = block_find_symbol (block, lookup_name, SEARCH_STRUCT_DOMAIN,
+			       nullptr);
       if (sym != nullptr)
 	{
 	  gdb_assert (!TYPE_IS_OPAQUE (sym->type ()));
@@ -4888,7 +4880,7 @@ global_symbol_searcher::expand_symtabs
 			 (msymbol->value_address (objfile)) == NULL)
 		      : (lookup_symbol_in_objfile_from_linkage_name
 			 (objfile, msymbol->linkage_name (),
-			  VAR_DOMAIN)
+			  SEARCH_VFT)
 			 .symbol == NULL))
 		    found_msymbol = true;
 		}
@@ -5026,7 +5018,7 @@ global_symbol_searcher::add_matching_msymbols
 		{
 		  if (lookup_symbol_in_objfile_from_linkage_name
 		      (objfile, msymbol->linkage_name (),
-		       VAR_DOMAIN).symbol == NULL)
+		       SEARCH_VFT).symbol == NULL)
 		    {
 		      /* Matching msymbol, add it to the results list.  */
 		      if (results->size () < m_max_search_results)
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 69e3c060213..340ad170ece 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -2099,7 +2099,7 @@ struct field_of_this_result
 extern struct block_symbol
   lookup_symbol_in_language (const char *,
 			     const struct block *,
-			     const domain_enum,
+			     const domain_search_flags,
 			     enum language,
 			     struct field_of_this_result *);
 
@@ -2107,7 +2107,7 @@ extern struct block_symbol
 
 extern struct block_symbol lookup_symbol (const char *,
 					  const struct block *,
-					  const domain_enum,
+					  const domain_search_flags,
 					  struct field_of_this_result *);
 
 /* Find the definition for a specified symbol search name in domain
@@ -2119,9 +2119,10 @@ extern struct block_symbol lookup_symbol (const char *,
    pointer, or NULL if no symbol is found.  The symbol's section is
    fixed up if necessary.  */
 
-extern struct block_symbol lookup_symbol_search_name (const char *search_name,
-						      const struct block *block,
-						      domain_enum domain);
+extern struct block_symbol lookup_symbol_search_name
+     (const char *search_name,
+      const struct block *block,
+      domain_search_flags domain);
 
 /* Some helper functions for languages that need to write their own
    lookup_symbol_nonlocal functions.  */
@@ -2133,13 +2134,13 @@ extern struct block_symbol lookup_symbol_search_name (const char *search_name,
 extern struct block_symbol
   lookup_symbol_in_static_block (const char *name,
 				 const struct block *block,
-				 const domain_enum domain);
+				 const domain_search_flags domain);
 
 /* Search all static file-level symbols for NAME from DOMAIN.
    Upon success fixes up the symbol's section if necessary.  */
 
-extern struct block_symbol lookup_static_symbol (const char *name,
-						 const domain_enum domain);
+extern struct block_symbol lookup_static_symbol
+     (const char *name, const domain_search_flags domain);
 
 /* Lookup a symbol in all files' global blocks.
 
@@ -2155,7 +2156,7 @@ extern struct block_symbol lookup_static_symbol (const char *name,
 extern struct block_symbol
   lookup_global_symbol (const char *name,
 			const struct block *block,
-			const domain_enum domain);
+			const domain_search_flags domain);
 
 /* Lookup a symbol in block BLOCK.
    Upon success fixes up the symbol's section if necessary.  */
@@ -2164,7 +2165,7 @@ extern struct symbol *
   lookup_symbol_in_block (const char *name,
 			  symbol_name_match_type match_type,
 			  const struct block *block,
-			  const domain_enum domain);
+			  const domain_search_flags domain);
 
 /* Look up the `this' symbol for LANG in BLOCK.  Return the symbol if
    found, or NULL if not found.  */
@@ -2711,7 +2712,7 @@ extern struct block_symbol
   lookup_global_symbol_from_objfile (struct objfile *main_objfile,
 				     enum block_enum block_index,
 				     const char *name,
-				     const domain_enum domain);
+				     const domain_search_flags domain);
 
 /* Return 1 if the supplied producer string matches the ARM RealView
    compiler (armcc).  */
diff --git a/gdb/valops.c b/gdb/valops.c
index 93e2dfedad0..e2694f0c32b 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -118,15 +118,9 @@ find_function_in_inferior (const char *name, struct objfile **objf_p)
 {
   struct block_symbol sym;
 
-  sym = lookup_symbol (name, 0, VAR_DOMAIN, 0);
+  sym = lookup_symbol (name, nullptr, SEARCH_TYPE_DOMAIN, nullptr);
   if (sym.symbol != NULL)
     {
-      if (sym.symbol->aclass () != LOC_BLOCK)
-	{
-	  error (_("\"%s\" exists in this program but is not a function."),
-		 name);
-	}
-
       if (objf_p)
 	*objf_p = sym.symbol->objfile ();
 
@@ -3708,7 +3702,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 	    {
 	      struct symbol *s = 
 		lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
-			       0, VAR_DOMAIN, 0).symbol;
+			       0, SEARCH_FUNCTION_DOMAIN, 0).symbol;
 
 	      if (s == NULL)
 		return NULL;
@@ -3739,7 +3733,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 	    {
 	      struct symbol *s = 
 		lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
-			       0, VAR_DOMAIN, 0).symbol;
+			       0, SEARCH_FUNCTION_DOMAIN, 0).symbol;
 
 	      if (s == NULL)
 		return NULL;
@@ -3819,7 +3813,7 @@ value_maybe_namespace_elt (const struct type *curtype,
   struct value *result;
 
   sym = cp_lookup_symbol_namespace (namespace_name, name,
-				    get_selected_block (0), VAR_DOMAIN);
+				    get_selected_block (0), SEARCH_VFT);
 
   if (sym.symbol == NULL)
     return NULL;
diff --git a/gdb/value.c b/gdb/value.c
index 4ec9babcce8..ccaef9fd80f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2922,7 +2922,8 @@ value_static_field (struct type *type, int fieldno)
     {
       const char *phys_name = type->field (fieldno).loc_physname ();
       /* type->field (fieldno).name (); */
-      struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
+      struct block_symbol sym = lookup_symbol (phys_name, nullptr,
+					       SEARCH_VAR_DOMAIN, nullptr);
 
       if (sym.symbol == NULL)
 	{
@@ -3113,7 +3114,8 @@ value_fn_field (struct value **arg1p, struct fn_field *f,
   struct symbol *sym;
   struct bound_minimal_symbol msym;
 
-  sym = lookup_symbol (physname, 0, VAR_DOMAIN, 0).symbol;
+  sym = lookup_symbol (physname, nullptr, SEARCH_FUNCTION_DOMAIN,
+		       nullptr).symbol;
   if (sym == nullptr)
     {
       msym = lookup_bound_minimal_symbol (physname);
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index 71339c502d2..b19c9491fd0 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -423,7 +423,8 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
 	return plg_end;
 
       /* Found a function.  */
-      sym = lookup_symbol (func_name, NULL, VAR_DOMAIN, NULL).symbol;
+      sym = lookup_symbol (func_name, NULL, SEARCH_FUNCTION_DOMAIN,
+			   nullptr).symbol;
       /* Don't use line number debug info for assembly source files.  */
       if (sym && sym->language () != language_asm)
 	{

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 18/30] Remove some obsolete Python constants
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (16 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 17/30] Use domain_search_flags in lookup_symbol et al Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 19/30] Remove old symbol_matches_domain Tom Tromey
                   ` (12 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

The Python code has exported some constants, but they are no longer
documented, and were never useful.  This patch removes them.
---
 gdb/python/py-symbol.c | 14 --------------
 1 file changed, 14 deletions(-)

diff --git a/gdb/python/py-symbol.c b/gdb/python/py-symbol.c
index 2fb68377bad..db8df891b29 100644
--- a/gdb/python/py-symbol.c
+++ b/gdb/python/py-symbol.c
@@ -686,20 +686,6 @@ gdbpy_initialize_symbols (void)
 #include "sym-domains.def"
 #undef DOMAIN
 
-  /* These remain defined for compatibility, but as they were never
-     correct, they are no longer documented.  Eventually we can remove
-     them.  These exist because at one time, enum search_domain and
-     enum domain_enum_tag were combined -- but different values were
-     used differently.  Here we try to give them values that will make
-     sense if they are passed to gdb.lookup_symbol.  */
-  if (PyModule_AddIntConstant (gdb_module, "SYMBOL_VARIABLES_DOMAIN",
-			       VAR_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_FUNCTIONS_DOMAIN",
-				  VAR_DOMAIN) < 0
-      || PyModule_AddIntConstant (gdb_module, "SYMBOL_TYPES_DOMAIN",
-				  VAR_DOMAIN) < 0)
-    return -1;
-
   return gdb_pymodule_addobject (gdb_module, "Symbol",
 				 (PyObject *) &symbol_object_type);
 }

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 19/30] Remove old symbol_matches_domain
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (17 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 18/30] Remove some obsolete Python constants Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 20/30] Use the new symbol domains Tom Tromey
                   ` (11 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

Nothing calls the variant of symbol_matches_domain that accepts a
domain_enum for searching, so this patch removes it and the
corresponding symbol::matches.
---
 gdb/symtab.c | 20 --------------------
 gdb/symtab.h | 11 -----------
 2 files changed, 31 deletions(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 5735786ac44..b8588355921 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2676,26 +2676,6 @@ lookup_global_symbol (const char *name,
     return bs;
 }
 
-bool
-symbol_matches_domain (enum language symbol_language,
-		       domain_enum symbol_domain,
-		       domain_enum domain)
-{
-  /* For C++ "struct foo { ... }" also defines a typedef for "foo".
-     Similarly, any Ada type declaration implicitly defines a typedef.  */
-  if (symbol_language == language_cplus
-      || symbol_language == language_d
-      || symbol_language == language_ada
-      || symbol_language == language_rust)
-    {
-      if ((domain == VAR_DOMAIN || domain == STRUCT_DOMAIN)
-	  && symbol_domain == STRUCT_DOMAIN)
-	return true;
-    }
-  /* For all other languages, strict match is required.  */
-  return (symbol_domain == domain);
-}
-
 /* See symtab.h.  */
 
 bool
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 340ad170ece..8624006746d 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1242,10 +1242,6 @@ enum symbol_subclass_kind
 
 extern gdb::array_view<const struct symbol_impl> symbol_impls;
 
-bool symbol_matches_domain (enum language symbol_language,
-			    domain_enum symbol_domain,
-			    domain_enum domain);
-
 /* This structure is space critical.  See space comments at the top.  */
 
 struct symbol : public general_symbol_info, public allocate_on_obstack
@@ -1292,13 +1288,6 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     return this->impl ().aclass;
   }
 
-  /* Call symbol_matches_domain on this symbol, using the symbol's
-     domain.  */
-  bool matches (domain_enum d) const
-  {
-    return symbol_matches_domain (language (), domain (), d);
-  }
-
   /* Return true if this symbol's domain matches FLAGS.  */
   bool matches (domain_search_flags flags) const;
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 20/30] Use the new symbol domains
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (18 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 19/30] Remove old symbol_matches_domain Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 21/30] Simplify some symbol searches in Ada code Tom Tromey
                   ` (10 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This patch changes the DWARF reader to use the new symbol domains.  It
also adjusts many bits of associated code to adapt to this change.
The cooked index and the .debug_names index now share some code here
-- the long term goal here is to bring these two pieces of code into
sync, since really they do more or less the same job, just with
slightly differing inputs.

The non-DWARF readers are updated on a best-effort basis.  This is
somewhat simpler since most of them only support C and C++.  I have no
way to test a few of these.

I went back and forth a few times on how to handle the "tag"
situation.  The basic problem is that C has a special namespace for
tags, which is separate from the type namespace.  Other languages
don't do this.  So, the question is, should a DW_TAG_structure_type
end up in the tag domain, or the type domain, or should it be
language-dependent?

I settled on making it language-dependent using a thought experiment.
Suppose there was a Rust compiler that only emitted nameless
DW_TAG_structure_type objects, and specified all structure type names
using DW_TAG_typedef.  This DWARF would be correct, in that it
faithfully represents the source language -- but would not work with a
purely struct-domain implementation in gdb.  Therefore gdb would be
wrong.

Now, this approach is a little tricky for C++, which uses tags but
also enters a typedef for them.  I notice that some other readers --
like stabsread -- actually emit a typedef symbol as well.  And, I
think this is a reasonable approach.  It uses more memory, but it
makes the internals simpler.  However, DWARF never did this for
whatever reason, and so in the interest of keeping the series slightly
shorter, I've left some C++-specific hacks in place here.

Note that this patch includes language_minimal as a language that uses
tags.  I did this to avoid regressing gdb.dwarf2/debug-names-tu.exp,
which doesn't specify the language for a type unit.  Arguably this
test case is wrong.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30164
---
 gdb/ada-tasks.c                          |  10 +--
 gdb/coffread.c                           |   5 +-
 gdb/ctfread.c                            |   2 +-
 gdb/dwarf2/cooked-index.c                |  26 +-------
 gdb/dwarf2/index-write.c                 |   7 +--
 gdb/dwarf2/read-debug-names.c            |  40 +++---------
 gdb/dwarf2/read-gdb-index.c              |   2 +-
 gdb/dwarf2/read.c                        |  31 +++++++--
 gdb/dwarf2/tag.h                         |  79 +++++++++++++++++++++++
 gdb/gdbtypes.c                           |  24 ++++---
 gdb/go-exp.y                             |   2 +-
 gdb/jit.c                                |   2 +-
 gdb/language.c                           |   2 +-
 gdb/mdebugread.c                         |   4 +-
 gdb/rust-parse.c                         |   2 +-
 gdb/stabsread.c                          |   8 +--
 gdb/sym-domains.def                      |   4 +-
 gdb/symtab.c                             | 104 ++++++++++---------------------
 gdb/testsuite/gdb.ada/info_auto_lang.exp |   4 +-
 gdb/testsuite/gdb.ada/ptype-o.exp        |   2 +-
 gdb/testsuite/gdb.fortran/info-types.exp |   2 +-
 gdb/xcoffread.c                          |   9 +--
 22 files changed, 197 insertions(+), 174 deletions(-)

diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index fd3f5d1ead9..8ae94dcdbab 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -520,17 +520,17 @@ ada_get_tcb_types_info (void)
      C-like) lookups to get the first match.  */
 
   struct symbol *atcb_sym =
-    lookup_symbol_in_language (atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
+    lookup_symbol_in_language (atcb_name, NULL, SEARCH_TYPE_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *common_atcb_sym =
-    lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_STRUCT_DOMAIN,
+    lookup_symbol_in_language (common_atcb_name, NULL, SEARCH_TYPE_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *private_data_sym =
-    lookup_symbol_in_language (private_data_name, NULL, SEARCH_STRUCT_DOMAIN,
+    lookup_symbol_in_language (private_data_name, NULL, SEARCH_TYPE_DOMAIN,
 			       language_c, NULL).symbol;
   const struct symbol *entry_call_record_sym =
     lookup_symbol_in_language (entry_call_record_name, NULL,
-			       SEARCH_STRUCT_DOMAIN,
+			       SEARCH_TYPE_DOMAIN,
 			       language_c, NULL).symbol;
 
   if (atcb_sym == NULL || atcb_sym->type () == NULL)
@@ -538,7 +538,7 @@ ada_get_tcb_types_info (void)
       /* In Ravenscar run-time libs, the  ATCB does not have a dynamic
 	 size, so the symbol name differs.  */
       atcb_sym = lookup_symbol_in_language (atcb_name_fixed, NULL,
-					    SEARCH_STRUCT_DOMAIN, language_c,
+					    SEARCH_TYPE_DOMAIN, language_c,
 					    NULL).symbol;
 
       if (atcb_sym == NULL || atcb_sym->type () == NULL)
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 30a38035c52..abb1c1880d6 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -1473,7 +1473,7 @@ patch_opaque_types (struct symtab *s)
 	 but search the whole chain, as there may be several syms
 	 from different files with the same name.  */
       if (real_sym->aclass () == LOC_TYPEDEF
-	  && real_sym->domain () == VAR_DOMAIN
+	  && real_sym->domain () == TYPE_DOMAIN
 	  && real_sym->type ()->code () == TYPE_CODE_PTR
 	  && real_sym->type ()->target_type ()->length () != 0)
 	{
@@ -1544,6 +1544,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
   if (ISFCN (cs->c_type))
     {
+      sym->set_domain (FUNCTION_DOMAIN);
       sym->set_value_longest
 	(sym->value_longest () + objfile->text_section_offset ());
       sym->set_type
@@ -1626,7 +1627,7 @@ process_coff_symbol (struct coff_symbol *cs,
 
 	case C_TPDEF:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  sym->set_domain (VAR_DOMAIN);
+	  sym->set_domain (TYPE_DOMAIN);
 
 	  /* If type has no name, give it one.  */
 	  if (sym->type ()->name () == 0)
diff --git a/gdb/ctfread.c b/gdb/ctfread.c
index 50bac18232e..cbb8c3f2b8a 100644
--- a/gdb/ctfread.c
+++ b/gdb/ctfread.c
@@ -505,7 +505,7 @@ new_symbol (struct ctf_context *ccp, struct type *type, ctf_id_t tid)
 	  case CTF_K_INTEGER:
 	  case CTF_K_FLOAT:
 	    sym->set_aclass_index (LOC_TYPEDEF);
-	    sym->set_domain (VAR_DOMAIN);
+	    sym->set_domain (TYPE_DOMAIN);
 	    break;
 	  case CTF_K_POINTER:
 	    break;
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 2430dbd40f4..3800c3aa800 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -206,31 +206,7 @@ cooked_index_entry::matches (domain_search_flags kind) const
   if ((flags & IS_TYPE_DECLARATION) != 0)
     return false;
 
-  if ((kind & SEARCH_VAR_DOMAIN) != 0
-      && (tag == DW_TAG_variable
-	  || tag == DW_TAG_constant
-	  || tag == DW_TAG_enumerator))
-    return true;
-
-  if ((kind & SEARCH_STRUCT_DOMAIN) != 0
-      && (tag == DW_TAG_structure_type
-	  || tag == DW_TAG_class_type
-	  || tag == DW_TAG_union_type
-	  || tag == DW_TAG_enumeration_type))
-    return true;
-
-  if ((kind & SEARCH_MODULE_DOMAIN) != 0 && tag == DW_TAG_module)
-    return true;
-
-  if ((kind & SEARCH_TYPE_DOMAIN) != 0 && tag_is_type (tag))
-    return true;
-
-  if ((kind & SEARCH_FUNCTION_DOMAIN) != 0
-      && (tag == DW_TAG_subprogram
-	  || tag == DW_TAG_entry_point))
-    return true;
-
-  return false;
+  return tag_matches_domain (tag, kind, per_cu->lang ());
 }
 
 /* See cooked-index.h.  */
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index 081046d4237..15356c72cb2 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -1314,11 +1314,10 @@ write_cooked_index (cooked_index *table,
 	       || entry->tag == DW_TAG_constant
 	       || entry->tag == DW_TAG_enumerator)
 	kind = GDB_INDEX_SYMBOL_KIND_VARIABLE;
-      else if (entry->tag == DW_TAG_module
-	       || entry->tag == DW_TAG_common_block)
-	kind = GDB_INDEX_SYMBOL_KIND_OTHER;
-      else
+      else if (tag_is_type (entry->tag))
 	kind = GDB_INDEX_SYMBOL_KIND_TYPE;
+      else
+	kind = GDB_INDEX_SYMBOL_KIND_OTHER;
 
       symtab->add_index_entry (name, (entry->flags & IS_STATIC) != 0,
 			       kind, it->second);
diff --git a/gdb/dwarf2/read-debug-names.c b/gdb/dwarf2/read-debug-names.c
index 0e9b1eb878f..d7709bb91cb 100644
--- a/gdb/dwarf2/read-debug-names.c
+++ b/gdb/dwarf2/read-debug-names.c
@@ -20,6 +20,7 @@
 #include "defs.h"
 #include "read-debug-names.h"
 #include "dwarf2/aranges.h"
+#include "dwarf2/tag.h"
 
 #include "complaints.h"
 #include "cp-support.h"
@@ -828,38 +829,13 @@ dw2_debug_names_iterator::next ()
 	}
     }
 
-  domain_enum domain = UNDEF_DOMAIN;
-  switch (indexval.dwarf_tag)
-    {
-    case DW_TAG_variable:
-      domain = VAR_DOMAIN;
-      break;
-
-    case DW_TAG_subprogram:
-      domain = FUNCTION_DOMAIN;
-      break;
-
-    case DW_TAG_structure_type:
-    case DW_TAG_union_type:
-    case DW_TAG_enumeration_type:
-      domain = STRUCT_DOMAIN;
-      break;
-
-    case DW_TAG_typedef:
-      domain = TYPE_DOMAIN;
-      break;
-
-    case DW_TAG_label:
-      domain = LABEL_DOMAIN;
-      break;
-
-    case DW_TAG_module:
-      domain = MODULE_DOMAIN;
-      break;
-    }
-
-  domain_search_flags flags = to_search_flags (domain);
-  if ((flags & m_search) == 0)
+  /* We have to use language_cplus here, first because the CU's
+     language isn't set yet, and then second because C++ is the main
+     special case, and so this choice will match a superset of other
+     languages.  This hack can go away once the .debug_names writer is
+     fixed to be more corrects.  */
+  if (!tag_matches_domain ((dwarf_tag) indexval.dwarf_tag, m_search,
+			   language_cplus))
     goto again;
 
   return per_cu;
diff --git a/gdb/dwarf2/read-gdb-index.c b/gdb/dwarf2/read-gdb-index.c
index d4741166e61..bf4f828b007 100644
--- a/gdb/dwarf2/read-gdb-index.c
+++ b/gdb/dwarf2/read-gdb-index.c
@@ -236,7 +236,7 @@ dw2_expand_marked_cus
 	      mask = SEARCH_FUNCTION_DOMAIN;
 	      break;
 	    case GDB_INDEX_SYMBOL_KIND_TYPE:
-	      mask = SEARCH_TYPE_DOMAIN;
+	      mask = SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN;
 	      break;
 	    case GDB_INDEX_SYMBOL_KIND_OTHER:
 	      mask = SEARCH_MODULE_DOMAIN;
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 877918999b8..24459a0d166 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -5780,9 +5780,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       sym = new (&objfile->objfile_obstack) symbol;
       sym->set_language (language_go, &objfile->objfile_obstack);
       sym->compute_and_set_names (saved_package_name, false, objfile->per_bfd);
-      /* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
-	 e.g., "main" finds the "main" module and not C's main().  */
-      sym->set_domain (STRUCT_DOMAIN);
+      sym->set_domain (TYPE_DOMAIN);
       sym->set_aclass_index (LOC_TYPEDEF);
       sym->set_type (type);
 
@@ -19052,7 +19050,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 
       /* Default assumptions.
 	 Use the passed type or decode it from the die.  */
-      sym->set_domain (VAR_DOMAIN);
+      sym->set_domain (UNDEF_DOMAIN);
       sym->set_aclass_index (LOC_OPTIMIZED_OUT);
       if (type != NULL)
 	sym->set_type (type);
@@ -19104,6 +19102,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_entry_point:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
+	  sym->set_domain (FUNCTION_DOMAIN);
 	  sym->set_aclass_index (LOC_BLOCK);
 	  /* DW_TAG_entry_point provides an additional entry_point to an
 	     existing sub_program.  Therefore, we inherit the "external"
@@ -19118,6 +19117,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_subprogram:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
+	  sym->set_domain (FUNCTION_DOMAIN);
 	  sym->set_aclass_index (LOC_BLOCK);
 	  attr2 = dwarf2_attr (die, DW_AT_external, cu);
 	  if ((attr2 != nullptr && attr2->as_boolean ())
@@ -19162,6 +19162,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_inlined_subroutine:
 	  /* SYMBOL_BLOCK_VALUE (sym) will be filled in later by
 	     finish_block.  */
+	  sym->set_domain (FUNCTION_DOMAIN);
 	  sym->set_aclass_index (LOC_BLOCK);
 	  sym->set_is_inlined (1);
 	  list_to_add = cu->list_in_scope;
@@ -19172,6 +19173,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_constant:
 	case DW_TAG_variable:
 	case DW_TAG_member:
+	  sym->set_domain (VAR_DOMAIN);
 	  /* Compilation with minimal debug info may result in
 	     variables with missing type entries.  Change the
 	     misleading `void' type to something sensible.  */
@@ -19320,6 +19322,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	       when we do not have enough information to show inlined frames;
 	       pretend it's a local variable in that case so that the user can
 	       still see it.  */
+	    sym->set_domain (VAR_DOMAIN);
 	    struct context_stack *curr
 	      = cu->get_builder ()->get_current_context_stack ();
 	    if (curr != nullptr && curr->name != nullptr)
@@ -19358,11 +19361,25 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	      sym->set_aclass_index (LOC_STATIC);
 	      sym->set_domain (VAR_DOMAIN);
 	    }
-	  else
+	  else if (cu->lang () == language_c
+		   || cu->lang () == language_cplus
+		   || cu->lang () == language_objc
+		   || cu->lang () == language_opencl
+		   || cu->lang () == language_minimal)
 	    {
+	      /* These languages have a tag namespace.  Note that
+		 there's a special hack for C++ in the matching code,
+		 so we don't need to enter a separate typedef for the
+		 tag.  */
 	      sym->set_aclass_index (LOC_TYPEDEF);
 	      sym->set_domain (STRUCT_DOMAIN);
 	    }
+	  else
+	    {
+	      /* Other languages don't have a tag namespace.  */
+	      sym->set_aclass_index (LOC_TYPEDEF);
+	      sym->set_domain (TYPE_DOMAIN);
+	    }
 
 	  /* NOTE: carlton/2003-11-10: C++ class symbols shouldn't
 	     really ever be static objects: otherwise, if you try
@@ -19406,10 +19423,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	case DW_TAG_subrange_type:
 	case DW_TAG_generic_subrange:
 	  sym->set_aclass_index (LOC_TYPEDEF);
-	  sym->set_domain (VAR_DOMAIN);
+	  sym->set_domain (TYPE_DOMAIN);
 	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_enumerator:
+	  sym->set_domain (VAR_DOMAIN);
 	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
 	  if (attr != nullptr)
 	    {
@@ -19427,6 +19445,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
 	  break;
 	case DW_TAG_imported_declaration:
 	case DW_TAG_namespace:
+	  sym->set_domain (TYPE_DOMAIN);
 	  sym->set_aclass_index (LOC_TYPEDEF);
 	  list_to_add = cu->get_builder ()->get_global_symbols ();
 	  break;
diff --git a/gdb/dwarf2/tag.h b/gdb/dwarf2/tag.h
index 2fae4cced78..2ceae5393b5 100644
--- a/gdb/dwarf2/tag.h
+++ b/gdb/dwarf2/tag.h
@@ -21,6 +21,7 @@
 #define GDB_DWARF2_TAG_H
 
 #include "dwarf2.h"
+#include "symtab.h"
 
 /* Return true if TAG represents a type, false otherwise.  */
 
@@ -64,4 +65,82 @@ tag_is_type (dwarf_tag tag)
     }
 }
 
+/* Return true if the given DWARF tag matches the specified search
+   domain flags.  LANG may affect the result, due to the "C++ tag
+   hack".  */
+
+static inline bool
+tag_matches_domain (dwarf_tag tag, domain_search_flags search, language lang)
+{
+  domain_search_flags flags = 0;
+  switch (tag)
+    {
+    case DW_TAG_variable:
+    case DW_TAG_enumerator:
+    case DW_TAG_constant:
+      flags = SEARCH_VAR_DOMAIN;
+      break;
+
+    case DW_TAG_subprogram:
+    case DW_TAG_entry_point:
+      flags = SEARCH_FUNCTION_DOMAIN;
+      break;
+
+    case DW_TAG_structure_type:
+    case DW_TAG_class_type:
+    case DW_TAG_union_type:
+    case DW_TAG_enumeration_type:
+      {
+	if (lang == language_c
+	    || lang == language_objc
+	    || lang == language_opencl
+	    || lang == language_minimal)
+	  flags = SEARCH_STRUCT_DOMAIN;
+	else if (lang == language_cplus)
+	  flags = SEARCH_STRUCT_DOMAIN | SEARCH_TYPE_DOMAIN;
+	else
+	  flags = SEARCH_TYPE_DOMAIN;
+      }
+      break;
+
+    case DW_TAG_padding:
+    case DW_TAG_array_type:
+    case DW_TAG_pointer_type:
+    case DW_TAG_reference_type:
+    case DW_TAG_string_type:
+    case DW_TAG_subroutine_type:
+    case DW_TAG_ptr_to_member_type:
+    case DW_TAG_set_type:
+    case DW_TAG_subrange_type:
+    case DW_TAG_base_type:
+    case DW_TAG_const_type:
+    case DW_TAG_packed_type:
+    case DW_TAG_template_type_param:
+    case DW_TAG_volatile_type:
+    case DW_TAG_restrict_type:
+    case DW_TAG_interface_type:
+    case DW_TAG_namespace:
+    case DW_TAG_unspecified_type:
+    case DW_TAG_shared_type:
+    case DW_TAG_rvalue_reference_type:
+    case DW_TAG_coarray_type:
+    case DW_TAG_dynamic_type:
+    case DW_TAG_atomic_type:
+    case DW_TAG_immutable_type:
+    case DW_TAG_typedef:
+      flags = SEARCH_TYPE_DOMAIN;
+      break;
+
+    case DW_TAG_label:
+      flags = SEARCH_LABEL_DOMAIN;
+      break;
+
+    case DW_TAG_module:
+      flags = SEARCH_MODULE_DOMAIN;
+      break;
+    }
+
+  return (flags & search) != 0;
+}
+
 #endif /* GDB_DWARF2_TAG_H */
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index f4eff650799..970a9e4a4a5 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2988,15 +2988,19 @@ check_typedef (struct type *type)
 	    return make_qualified_type (type, instance_flags, NULL);
 
 	  name = type->name ();
-	  /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or
-	     VAR_DOMAIN as appropriate?  */
 	  if (name == NULL)
 	    {
 	      stub_noname_complaint ();
 	      return make_qualified_type (type, instance_flags, NULL);
 	    }
-	  sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
-			       nullptr).symbol;
+	  domain_search_flag flag
+	    = ((type->language () == language_c
+		|| type->language () == language_objc
+		|| type->language () == language_opencl
+		|| type->language () == language_minimal)
+	       ? SEARCH_STRUCT_DOMAIN
+	       : SEARCH_TYPE_DOMAIN);
+	  sym = lookup_symbol (name, nullptr, flag, nullptr).symbol;
 	  if (sym)
 	    type->set_target_type (sym->type ());
 	  else					/* TYPE_CODE_UNDEF */
@@ -3077,8 +3081,6 @@ check_typedef (struct type *type)
   else if (type->is_stub () && !currently_reading_symtab)
     {
       const char *name = type->name ();
-      /* FIXME: shouldn't we look in STRUCT_DOMAIN and/or VAR_DOMAIN
-	 as appropriate?  */
       struct symbol *sym;
 
       if (name == NULL)
@@ -3086,8 +3088,14 @@ check_typedef (struct type *type)
 	  stub_noname_complaint ();
 	  return make_qualified_type (type, instance_flags, NULL);
 	}
-      sym = lookup_symbol (name, nullptr, SEARCH_STRUCT_DOMAIN,
-			   nullptr).symbol;
+      domain_search_flag flag
+	= ((type->language () == language_c
+	    || type->language () == language_objc
+	    || type->language () == language_opencl
+	    || type->language () == language_minimal)
+	   ? SEARCH_STRUCT_DOMAIN
+	   : SEARCH_TYPE_DOMAIN);
+      sym = lookup_symbol (name, nullptr, flag, nullptr).symbol;
       if (sym)
 	{
 	  /* Same as above for opaque types, we can replace the stub
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index a3afbbb8514..2e56e4bff61 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1293,7 +1293,7 @@ package_name_p (const char *name, const struct block *block)
   struct symbol *sym;
   struct field_of_this_result is_a_field_of_this;
 
-  sym = lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN,
+  sym = lookup_symbol (name, block, SEARCH_TYPE_DOMAIN,
 		       &is_a_field_of_this).symbol;
 
   if (sym
diff --git a/gdb/jit.c b/gdb/jit.c
index 7960d32acd1..f1dbf39f73f 100644
--- a/gdb/jit.c
+++ b/gdb/jit.c
@@ -581,7 +581,7 @@ finalize_symtab (struct gdb_symtab *stab, struct objfile *objfile)
       new_block->set_end (gdb_block_iter.end);
 
       /* The name.  */
-      block_name->set_domain (VAR_DOMAIN);
+      block_name->set_domain (FUNCTION_DOMAIN);
       block_name->set_aclass_index (LOC_BLOCK);
       block_name->set_symtab (filetab);
       block_name->set_type (lookup_function_type (block_type));
diff --git a/gdb/language.c b/gdb/language.c
index d6f6831c190..c5bbc319963 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -974,7 +974,7 @@ language_arch_info::type_and_symbol::alloc_type_symbol
   symbol->set_is_objfile_owned (0);
   symbol->set_section_index (0);
   symbol->set_type (type);
-  symbol->set_domain (VAR_DOMAIN);
+  symbol->set_domain (TYPE_DOMAIN);
   symbol->set_aclass_index (LOC_TYPEDEF);
   return symbol;
 }
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 13c9401d171..4748b0cd7aa 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -753,7 +753,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
 	  break;
 	}
       s = new_symbol (name);
-      s->set_domain (VAR_DOMAIN);
+      s->set_domain (FUNCTION_DOMAIN);
       s->set_aclass_index (LOC_BLOCK);
       s->set_section_index (section_index);
       /* Type of the return value.  */
@@ -1297,7 +1297,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend,
       if (has_opaque_xref (cur_fdr, sh))
 	break;
       s = new_symbol (name);
-      s->set_domain (VAR_DOMAIN);
+      s->set_domain (TYPE_DOMAIN);
       s->set_aclass_index (LOC_TYPEDEF);
       s->set_value_block (top_stack->cur_block);
       s->set_type (t);
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index af1b76f738a..66263b91bdc 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -454,7 +454,7 @@ rust_parser::rust_lookup_type (const char *name)
   const struct block *block = pstate->expression_context_block;
   munge_name_and_block (&name, &block);
 
-  result = ::lookup_symbol (name, block, SEARCH_STRUCT_DOMAIN, NULL);
+  result = ::lookup_symbol (name, block, SEARCH_TYPE_DOMAIN, nullptr);
   if (result.symbol != NULL)
     {
       update_innermost_block (result);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 071290fbe12..025cb2120d1 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -940,7 +940,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* A static function definition.  */
       sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_BLOCK);
-      sym->set_domain (VAR_DOMAIN);
+      sym->set_domain (FUNCTION_DOMAIN);
       add_symbol_to_list (sym, get_file_symbols ());
       /* fall into process_function_types.  */
 
@@ -1011,7 +1011,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       /* A global function definition.  */
       sym->set_type (read_type (&p, objfile));
       sym->set_aclass_index (LOC_BLOCK);
-      sym->set_domain (VAR_DOMAIN);
+      sym->set_domain (FUNCTION_DOMAIN);
       add_symbol_to_list (sym, get_global_symbols ());
       goto process_function_types;
 
@@ -1209,7 +1209,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 
       sym->set_aclass_index (LOC_TYPEDEF);
       sym->set_value_longest (valu);
-      sym->set_domain (VAR_DOMAIN);
+      sym->set_domain (TYPE_DOMAIN);
       /* C++ vagaries: we may have a type which is derived from
 	 a base type which did not have its name defined when the
 	 derived class was output.  We fill in the derived class's
@@ -1328,7 +1328,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
 	  *typedef_sym = *sym;
 	  typedef_sym->set_aclass_index (LOC_TYPEDEF);
 	  typedef_sym->set_value_longest (valu);
-	  typedef_sym->set_domain (VAR_DOMAIN);
+	  typedef_sym->set_domain (TYPE_DOMAIN);
 	  if (sym->type ()->name () == 0)
 	    sym->type ()->set_name
 	      (obconcat (&objfile->objfile_obstack, sym->linkage_name (),
diff --git a/gdb/sym-domains.def b/gdb/sym-domains.def
index cea25a5f5b3..7545631063b 100644
--- a/gdb/sym-domains.def
+++ b/gdb/sym-domains.def
@@ -47,7 +47,9 @@ DOMAIN (LABEL)
 DOMAIN (COMMON_BLOCK)
 
 /* TYPE_DOMAIN is for types and typedefs.  Note that tags are not
-   found here, see STRUCT_DOMAIN above.  */
+   found here, see STRUCT_DOMAIN above.  If a language does not have a
+   tag namespace, then all types (including structures, etc) are
+   here.  */
 
 DOMAIN (TYPE)
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index b8588355921..30b12d6f4eb 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2681,32 +2681,10 @@ lookup_global_symbol (const char *name,
 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;
+  /* C++ has a typedef for every tag, and the types are in the struct
+     domain.  */
+  if (language () == language_cplus && (flags & SEARCH_TYPE_DOMAIN) != 0)
+    flags |= SEARCH_STRUCT_DOMAIN;
 
   return search_flags_matches (flags, m_domain);
 }
@@ -4908,59 +4886,42 @@ global_symbol_searcher::add_matching_symbols
 					 filenames, false))))
 		continue;
 
+	      if (!sym->matches (kind))
+		continue;
+
 	      if (preg.has_value () && !preg->exec (sym->natural_name (), 0,
 						    nullptr, 0) == 0)
 		continue;
 
-	      bool matches = false;
-	      if (!matches && (kind & SEARCH_VAR_DOMAIN) != 0)
+	      if (((sym->domain () == VAR_DOMAIN
+		    || sym->domain () == FUNCTION_DOMAIN)
+		   && treg.has_value ()
+		   && !treg_matches_sym_type_name (*treg, sym)))
+		continue;
+
+	      if ((kind & SEARCH_VAR_DOMAIN) != 0)
 		{
-		  if (sym->aclass () != LOC_TYPEDEF
-		      && sym->aclass () != LOC_UNRESOLVED
-		      && sym->aclass () != LOC_BLOCK
+		  if (sym->aclass () == LOC_UNRESOLVED
 		      /* LOC_CONST can be used for more than
 			 just enums, e.g., c++ static const
 			 members.  We only want to skip enums
 			 here.  */
-		      && !(sym->aclass () == LOC_CONST
-			   && (sym->type ()->code ()
-			       == TYPE_CODE_ENUM))
-		      && (!treg.has_value ()
-			  || treg_matches_sym_type_name (*treg, sym)))
-		    matches = true;
-		}
-	      if (!matches && (kind & SEARCH_FUNCTION_DOMAIN) != 0)
-		{
-		  if (sym->aclass () == LOC_BLOCK
-		      && (!treg.has_value ()
-			  || treg_matches_sym_type_name (*treg,
-							 sym)))
-		    matches = true;
-		}
-	      if (!matches && (kind & SEARCH_TYPE_DOMAIN) != 0)
-		{
-		  if (sym->aclass () == LOC_TYPEDEF
-		      && sym->domain () != MODULE_DOMAIN)
-		    matches = true;
-		}
-	      if (!matches && (kind & SEARCH_MODULE_DOMAIN) != 0)
-		{
-		  if (sym->domain () == MODULE_DOMAIN
-		      && sym->line () != 0)
-		    matches = true;
+		      || (sym->aclass () == LOC_CONST
+			  && (sym->type ()->code () == TYPE_CODE_ENUM)))
+		    continue;
 		}
-	      if (matches)
+	      if (sym->domain () == MODULE_DOMAIN && sym->line () == 0)
+		continue;
+
+	      if (result_set->size () < m_max_search_results)
 		{
-		  if (result_set->size () < m_max_search_results)
-		    {
-		      /* Match, insert if not already in the results.  */
-		      symbol_search ss (block, sym);
-		      if (result_set->find (ss) == result_set->end ())
-			result_set->insert (ss);
-		    }
-		  else
-		    return false;
+		  /* Match, insert if not already in the results.  */
+		  symbol_search ss (block, sym);
+		  if (result_set->find (ss) == result_set->end ())
+		    result_set->insert (ss);
 		}
+	      else
+		return false;
 	    }
 	}
     }
@@ -5123,12 +5084,12 @@ symbol_to_info_string (struct symbol *sym, int block)
   gdb_assert (block == GLOBAL_BLOCK || block == STATIC_BLOCK);
 
   if (block == STATIC_BLOCK
-      && sym->domain () == VAR_DOMAIN
-      && sym->aclass () != LOC_TYPEDEF)
+      && (sym->domain () == VAR_DOMAIN
+	  || sym->domain () == FUNCTION_DOMAIN))
     str += "static ";
 
   /* Typedef that is not a C++ class.  */
-  if (sym->domain () == VAR_DOMAIN && sym->aclass () == LOC_TYPEDEF)
+  if (sym->domain () == TYPE_DOMAIN)
     {
       string_file tmp_stream;
 
@@ -5147,7 +5108,8 @@ symbol_to_info_string (struct symbol *sym, int block)
       str += tmp_stream.string ();
     }
   /* variable, func, or typedef-that-is-c++-class.  */
-  else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN)
+  else if (sym->domain () == VAR_DOMAIN || sym->domain () == STRUCT_DOMAIN
+	   || sym->domain () == FUNCTION_DOMAIN)
     {
       string_file tmp_stream;
 
diff --git a/gdb/testsuite/gdb.ada/info_auto_lang.exp b/gdb/testsuite/gdb.ada/info_auto_lang.exp
index dc92659670b..cb2a5a7a172 100644
--- a/gdb/testsuite/gdb.ada/info_auto_lang.exp
+++ b/gdb/testsuite/gdb.ada/info_auto_lang.exp
@@ -65,8 +65,8 @@ set type_in_c(ada_syntax) [multi_line \
 			      "${decimal}:	record" \
 			      "    some_component_in_c: int;" \
 			      "end record" ]
-set type_in_ada(c_syntax) "${decimal}:	struct global_pack__some_type_in_ada;"
-set type_in_ada(ada_syntax)  "${decimal}:	global_pack.some_type_in_ada;"
+set type_in_ada(c_syntax) "${decimal}:	struct global_pack__some_type_in_ada"
+set type_in_ada(ada_syntax)  "${decimal}:	global_pack.some_type_in_ada"
 
 set var_in_c(c_syntax)     "${decimal}:	some_type_in_c some_struct_in_c;"
 set var_in_c(ada_syntax)   "${decimal}:	some_struct_in_c: some_type_in_c;"
diff --git a/gdb/testsuite/gdb.ada/ptype-o.exp b/gdb/testsuite/gdb.ada/ptype-o.exp
index 1a2817da6bc..f7782199d58 100644
--- a/gdb/testsuite/gdb.ada/ptype-o.exp
+++ b/gdb/testsuite/gdb.ada/ptype-o.exp
@@ -43,5 +43,5 @@ foreach_with_prefix scenario {all minimal} {
 	# crash.
 	set exp ".*"
     }
-    gdb_test "ptype/o struct prog__rec" $exp
+    gdb_test "ptype/o prog__rec" $exp
 }
diff --git a/gdb/testsuite/gdb.fortran/info-types.exp b/gdb/testsuite/gdb.fortran/info-types.exp
index ab1d8947729..52ce7ace89d 100644
--- a/gdb/testsuite/gdb.fortran/info-types.exp
+++ b/gdb/testsuite/gdb.fortran/info-types.exp
@@ -44,7 +44,7 @@ GDBInfoSymbols::check_header "All defined types:"
 GDBInfoSymbols::check_optional_entry "${srcfile}" "" "${character1}"
 GDBInfoSymbols::check_entry "${srcfile}" "" "${integer4}"
 GDBInfoSymbols::check_entry "${srcfile}" "" "${logical4}"
-GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1;"
+GDBInfoSymbols::check_entry "${srcfile}" "$decimal" "Type m1t1"
 GDBInfoSymbols::check_entry "${srcfile}" "" "${real4}"
 
 # The emission of the 'Type s1' at global scope is actually not expected.  The
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index d161ad34c2f..589208cda68 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -1491,6 +1491,7 @@ process_xcoff_symbol (struct xcoff_symbol *cs, struct objfile *objfile)
       sym->set_linkage_name (SYMNAME_ALLOC (name, symname_alloced));
       sym->set_type (builtin_type (objfile)->nodebug_text_symbol);
 
+      sym->set_domain (FUNCTION_DOMAIN);
       sym->set_aclass_index (LOC_BLOCK);
       sym2 = new (&objfile->objfile_obstack) symbol (*sym);
 
@@ -2546,7 +2547,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 			/* Also a typedef with the same name.  */
 			pst->add_psymbol (std::string_view (namestring,
 							    p - namestring),
-					  true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+					  true, TYPE_DOMAIN, LOC_TYPEDEF, -1,
 					  psymbol_placement::STATIC,
 					  unrelocated_addr (0),
 					  psymtab_language,
@@ -2561,7 +2562,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		  {
 		    pst->add_psymbol (std::string_view (namestring,
 							p - namestring),
-				      true, VAR_DOMAIN, LOC_TYPEDEF, -1,
+				      true, TYPE_DOMAIN, LOC_TYPEDEF, -1,
 				      psymbol_placement::STATIC,
 				      unrelocated_addr (0),
 				      psymtab_language,
@@ -2661,7 +2662,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 		  }
 		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
-				  true, VAR_DOMAIN, LOC_BLOCK,
+				  true, FUNCTION_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::STATIC,
 				  unrelocated_addr (symbol.n_value),
@@ -2688,7 +2689,7 @@ scan_xcoff_symtab (minimal_symbol_reader &reader,
 
 		pst->add_psymbol (std::string_view (namestring,
 						    p - namestring),
-				  true, VAR_DOMAIN, LOC_BLOCK,
+				  true, FUNCTION_DOMAIN, LOC_BLOCK,
 				  SECT_OFF_TEXT (objfile),
 				  psymbol_placement::GLOBAL,
 				  unrelocated_addr (symbol.n_value),

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 21/30] Simplify some symbol searches in Ada code
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (19 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 20/30] Use the new symbol domains Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 22/30] Simplify some symbol searches in linespec.c Tom Tromey
                   ` (9 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes some of the Ada code to simplify symbol searches.  For
example, if a function is being looked for, the search is narrowed to
use SEARCH_FUNCTION_DOMAIN rather than SEARCH_VFT.  In one spot, a
search of the "struct" domain is removed, because Ada does not have a
tag domain.
---
 gdb/ada-exp.y             |  4 ++--
 gdb/ada-lang.c            | 10 ++--------
 gdb/dwarf2/ada-imported.c |  2 +-
 3 files changed, 5 insertions(+), 11 deletions(-)

diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 1f439b38aea..ab936ae4733 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1404,7 +1404,7 @@ block_lookup (const struct block *context, const char *raw_name)
     }
 
   std::vector<struct block_symbol> syms
-    = ada_lookup_symbol_list (name, context, SEARCH_VFT);
+    = ada_lookup_symbol_list (name, context, SEARCH_FUNCTION_DOMAIN);
 
   if (context == NULL
       && (syms.empty () || syms[0].symbol->aclass () != LOC_BLOCK))
@@ -1483,7 +1483,7 @@ find_primitive_type (struct parser_state *par_state, const char *name)
 	(char *) alloca (strlen (name) + sizeof ("standard__"));
       strcpy (expanded_name, "standard__");
       strcat (expanded_name, name);
-      sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_VFT).symbol;
+      sym = ada_lookup_symbol (expanded_name, NULL, SEARCH_TYPE_DOMAIN).symbol;
       if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
 	type = sym->type ();
     }
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index a15ea7b725e..f1d01ec7aa3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7436,14 +7436,8 @@ field_alignment (struct type *type, int f)
 static struct symbol *
 ada_find_any_type_symbol (const char *name)
 {
-  struct symbol *sym;
-
-  sym = standard_lookup (name, get_selected_block (NULL), SEARCH_VFT);
-  if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
-    return sym;
-
-  sym = standard_lookup (name, NULL, SEARCH_STRUCT_DOMAIN);
-  return sym;
+  return standard_lookup (name, get_selected_block (nullptr),
+			  SEARCH_TYPE_DOMAIN);
 }
 
 /* Find a type named NAME.  Ignores ambiguity.  This routine will look
diff --git a/gdb/dwarf2/ada-imported.c b/gdb/dwarf2/ada-imported.c
index 21f81bbcdea..1a0bc1d528e 100644
--- a/gdb/dwarf2/ada-imported.c
+++ b/gdb/dwarf2/ada-imported.c
@@ -103,7 +103,7 @@ ada_alias_get_block_value (const struct symbol *sym)
 {
   const char *name = get_imported_name (sym);
   block_symbol real_symbol = lookup_global_symbol (name, nullptr,
-						   SEARCH_VFT);
+						   SEARCH_FUNCTION_DOMAIN);
   if (real_symbol.symbol == nullptr)
     error (_("could not find alias '%s' for function '%s'"),
 	   name, sym->print_name ());

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 22/30] Simplify some symbol searches in linespec.c
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (20 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 21/30] Simplify some symbol searches in Ada code Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 23/30] Only search for "main" as a function Tom Tromey
                   ` (8 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This simplifies some symbol searches in linespec.c.  In particular,
two separate searches here can now be combined into one, due to the
new use of flags.

Arguably the STRUCT_DOMAIN searches should perhaps not even be done.
Only C really has these, and C doesn't have member functions.
However, it seems relatively harmless -- and clearly compatible -- to
leave this in.
---
 gdb/linespec.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index 4e43bf28a67..b5bbd8c433c 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -3446,14 +3446,9 @@ lookup_prefix_sym (struct linespec_state *state,
   for (const auto &elt : file_symtabs)
     {
       if (elt == nullptr)
-	{
-	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     SEARCH_STRUCT_DOMAIN,
-					     NULL, false, collector);
-	  iterate_over_all_matching_symtabs (state, lookup_name,
-					     SEARCH_VFT,
-					     NULL, false, collector);
-	}
+	iterate_over_all_matching_symtabs (state, lookup_name,
+					   SEARCH_STRUCT_DOMAIN | SEARCH_VFT,
+					   NULL, false, collector);
       else
 	{
 	  /* Program spaces that are executing startup should have
@@ -3463,10 +3458,7 @@ lookup_prefix_sym (struct linespec_state *state,
 	  gdb_assert (!pspace->executing_startup);
 	  set_current_program_space (pspace);
 	  iterate_over_file_blocks (elt, lookup_name,
-				    SEARCH_STRUCT_DOMAIN,
-				    collector);
-	  iterate_over_file_blocks (elt, lookup_name,
-				    SEARCH_VFT,
+				    SEARCH_STRUCT_DOMAIN | SEARCH_VFT,
 				    collector);
 	}
     }

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 23/30] Only search for "main" as a function
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (21 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 22/30] Simplify some symbol searches in linespec.c Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 24/30] Only look for functions in expand_symtabs_for_function Tom Tromey
                   ` (7 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes find_main_name to restrict its search to the function
domain.
---
 gdb/symtab.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 30b12d6f4eb..517e843244b 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -6435,7 +6435,8 @@ find_main_name (void)
      [&symbol_found_p, pspace] (objfile *obj)
        {
 	 language lang
-	   = obj->lookup_global_symbol_language ("main", SEARCH_VFT,
+	   = obj->lookup_global_symbol_language ("main",
+						 SEARCH_FUNCTION_DOMAIN,
 						 &symbol_found_p);
 	 if (symbol_found_p)
 	   {

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 24/30] Only look for functions in expand_symtabs_for_function
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (22 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 23/30] Only search for "main" as a function Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 25/30] Use a function-domain search in inside_main_func Tom Tromey
                   ` (6 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes expand_symtabs_for_function to only look in the function
domain.
---
 gdb/symfile-debug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 30b02531b9c..96cdfeeb7ed 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -342,7 +342,7 @@ objfile::expand_symtabs_for_function (const char *func_name)
 				   nullptr,
 				   (SEARCH_GLOBAL_BLOCK
 				    | SEARCH_STATIC_BLOCK),
-				   SEARCH_VFT);
+				   SEARCH_FUNCTION_DOMAIN);
 }
 
 void

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 25/30] Use a function-domain search in inside_main_func
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (23 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 24/30] Only look for functions in expand_symtabs_for_function Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 26/30] Only search types in cp_lookup_rtti_type Tom Tromey
                   ` (5 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes inside_main_func to search only for functions.
---
 gdb/frame.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/gdb/frame.c b/gdb/frame.c
index 03f3c50cb8d..7d586eef244 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -2560,13 +2560,9 @@ inside_main_func (frame_info_ptr this_frame)
 	 symbol with the name of the main function.  In this case we should
 	 search the full symbols to see if we can find a match.  */
       struct block_symbol bs = lookup_symbol (name, nullptr,
-					      SEARCH_VFT, nullptr);
+					      SEARCH_FUNCTION_DOMAIN, nullptr);
 
-      /* We might have found some unrelated symbol.  For example, the
-	 Rust compiler can emit both a subprogram and a namespace with
-	 the same name in the same scope; and due to how gdb's symbol
-	 tables currently work, we can't request the one we'd
-	 prefer.  */
+      /* This lookup should always yield a block-valued symbol.  */
       if (bs.symbol != nullptr && bs.symbol->aclass () == LOC_BLOCK)
 	{
 	  const struct block *block = bs.symbol->value_block ();

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 26/30] Only search types in cp_lookup_rtti_type
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (24 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 25/30] Use a function-domain search in inside_main_func Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 27/30] Only search types in lookup_typename Tom Tromey
                   ` (4 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes cp_lookup_rtti_type to only search for types -- not
functions or variables.  Due to the symbol-matching hack, this could
just use SEARCH_TYPE_DOMAIN, but I think it's better to be clear; also
I hold on to some hope that perhaps the hack can someday be removed.
---
 gdb/cp-support.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 9a59d7632a1..6b7c2f5a062 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1498,9 +1498,9 @@ cp_lookup_rtti_type (const char *name, const struct block *block)
   struct symbol * rtti_sym;
   struct type * rtti_type;
 
-  /* Use VAR_DOMAIN here as NAME may be a typedef.  PR 18141, 18417.
-     Classes "live" in both STRUCT_DOMAIN and VAR_DOMAIN.  */
-  rtti_sym = lookup_symbol (name, block, SEARCH_VFT, NULL).symbol;
+  rtti_sym = lookup_symbol (name, block,
+			    SEARCH_TYPE_DOMAIN | SEARCH_STRUCT_DOMAIN,
+			    nullptr).symbol;
 
   if (rtti_sym == NULL)
     {

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 27/30] Only search types in lookup_typename
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (25 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 26/30] Only search types in cp_lookup_rtti_type Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 28/30] Only search for functions in rust_structop::evaluate_funcall Tom Tromey
                   ` (3 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes lookup_typename to only look for types.  The check for
LOC_TYPEDEF can now also be removed, because only types will appear in
TYPE_DOMAIN.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24870
---
 gdb/gdbtypes.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 970a9e4a4a5..a48c4c8abf2 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1655,9 +1655,9 @@ lookup_typename (const struct language_defn *language,
 {
   struct symbol *sym;
 
-  sym = lookup_symbol_in_language (name, block, SEARCH_VFT,
+  sym = lookup_symbol_in_language (name, block, SEARCH_TYPE_DOMAIN,
 				   language->la_language, NULL).symbol;
-  if (sym != NULL && sym->aclass () == LOC_TYPEDEF)
+  if (sym != nullptr)
     {
       struct type *type = sym->type ();
       /* Ensure the length of TYPE is valid.  */

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 28/30] Only search for functions in rust_structop::evaluate_funcall
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (26 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 27/30] Only search types in lookup_typename Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 29/30] Refine search in cp_search_static_and_baseclasses Tom Tromey
                   ` (2 subsequent siblings)
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes rust_structop::evaluate_funcall to only search for
functions.
---
 gdb/rust-lang.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 11c7f13417d..e0b5a887a23 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -1563,7 +1563,7 @@ rust_structop::evaluate_funcall (struct type *expect_type,
 
   const struct block *block = get_selected_block (0);
   struct block_symbol sym = lookup_symbol (name.c_str (), block,
-					   SEARCH_VFT,
+					   SEARCH_FUNCTION_DOMAIN,
 					   nullptr);
   if (sym.symbol == NULL)
     error (_("Could not find function named '%s'"), name.c_str ());

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 29/30] Refine search in cp_search_static_and_baseclasses
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (27 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 28/30] Only search for functions in rust_structop::evaluate_funcall Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-18 20:32 ` [PATCH v2 30/30] Document new Python and Guile constants Tom Tromey
  2024-01-28 23:42 ` [PATCH v2 00/30] Restructure symbol domains Tom Tromey
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches

This changes cp_search_static_and_baseclasses to only search for
types, functions, and modules.  The latter two cases were discovered
by regression testing.  I found it somewhat surprising the Fortran
name lookup ends up in this code, but did not attempt to change this.
---
 gdb/cp-namespace.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 593340af350..41ab52de54a 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -268,14 +268,19 @@ cp_search_static_and_baseclasses (const char *name,
   const char *nested = name + prefix_len + 2;
 
   /* Lookup the scope symbol.  If none is found, there is nothing more
-     that can be done.  SCOPE could be a namespace, so always look in
-     VAR_DOMAIN.  This works for classes too because of
-     symbol_matches_domain (which should be replaced with something
-     else, but it's what we have today).  */
-  block_symbol scope_sym = lookup_symbol_in_static_block (scope.c_str (),
-							  block, SEARCH_VFT);
+     that can be done.  SCOPE could be a namespace, a class, or even a
+     function.  This code is also used by Fortran, so modules are
+     included in the search as well.  */
+  block_symbol scope_sym
+    = lookup_symbol_in_static_block (scope.c_str (), block,
+				     SEARCH_TYPE_DOMAIN
+				     | SEARCH_FUNCTION_DOMAIN
+				     | SEARCH_MODULE_DOMAIN);
   if (scope_sym.symbol == NULL)
-    scope_sym = lookup_global_symbol (scope.c_str (), block, SEARCH_VFT);
+    scope_sym = lookup_global_symbol (scope.c_str (), block,
+				      SEARCH_TYPE_DOMAIN
+				      | SEARCH_FUNCTION_DOMAIN
+				      | SEARCH_MODULE_DOMAIN);
   if (scope_sym.symbol == NULL)
     return {};
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH v2 30/30] Document new Python and Guile constants
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (28 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 29/30] Refine search in cp_search_static_and_baseclasses Tom Tromey
@ 2024-01-18 20:32 ` Tom Tromey
  2024-01-28 23:42 ` [PATCH v2 00/30] Restructure symbol domains Tom Tromey
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-18 20:32 UTC (permalink / raw)
  To: gdb-patches; +Cc: Eli Zaretskii

This documents the new Python and Guile constants introduced earlier
in this series.

Reviewed-By: Eli Zaretskii <eliz@gnu.org>
---
 gdb/NEWS            | 12 ++++++++++++
 gdb/doc/guile.texi  | 13 +++++++++++++
 gdb/doc/python.texi | 30 +++++++++++++++++++++++++++---
 3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/gdb/NEWS b/gdb/NEWS
index bab300e36b8..2638b3e0d9c 100644
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -108,6 +108,11 @@ show remote thread-options-packet
      object, these will be stored in the object's new
      InferiorThread.__dict__ attribute.
 
+  ** New constants gdb.SYMBOL_TYPE_DOMAIN, gdb.SYMBOL_FUNCTION_DOMAIN,
+     and gdb.SEARCH_*_DOMAIN corresponding to all the existing symbol
+     domains.  Symbol lookup can now search in multiple domains at
+     once, and can also narrowly search for just a type or function.
+
 * Debugger Adapter Protocol changes
 
   ** GDB now emits the "process" event.
@@ -121,6 +126,13 @@ show remote thread-options-packet
   ** The "set debug dap-log-file" command is now documented.  This
      command was available in GDB 14 but not documented.
 
+* Guile API
+
+  ** New constants SYMBOL_TYPE_DOMAIN, SYMBOL_FUNCTION_DOMAIN, and
+     SEARCH_*_DOMAIN corresponding to all the existing symbol domains.
+     Symbol lookup can now search in multiple domains at once, and can
+     also narrowly search for just a type or function.
+
 * New remote packets
 
 New stop reason: clone
diff --git a/gdb/doc/guile.texi b/gdb/doc/guile.texi
index 271b672fdc6..483a96fb592 100644
--- a/gdb/doc/guile.texi
+++ b/gdb/doc/guile.texi
@@ -2802,6 +2802,14 @@ in the symbol information or in @value{GDBN}'s handling of symbols.
 This domain contains variables, function names, typedef names and enum
 type values.
 
+@item SYMBOL_FUNCTION_DOMAIN
+This domain contains functions.
+
+@item SYMBOL_TYPE_DOMAIN
+This domain contains types.  In a C-like language, types using a tag
+will not appear here; in other languages, all types are in this
+domain.
+
 @item SYMBOL_STRUCT_DOMAIN
 This domain holds struct, union and enum type names.
 
@@ -2822,6 +2830,11 @@ This domain contains all types.
 The available address class categories in @code{<gdb:symbol>} are represented
 as constants in the @code{gdb} module:
 
+When searching for a symbol, the desired domain constant can be passed
+verbatim to the lookup function.  For more complex searches, there is
+a corresponding set of constants using a @samp{SEARCH_} prefix.  These
+may be or'd together to form a search constant.
+
 @vtable @code
 @item SYMBOL_LOC_UNDEF
 If this is returned by address class, it indicates an error either in
diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi
index 71431878dd3..906775c5711 100644
--- a/gdb/doc/python.texi
+++ b/gdb/doc/python.texi
@@ -6214,12 +6214,22 @@ in the symbol information or in @value{GDBN}'s handling of symbols.
 
 @vindex SYMBOL_VAR_DOMAIN
 @item gdb.SYMBOL_VAR_DOMAIN
-This domain contains variables, function names, typedef names and enum
-type values.
+This domain contains variables.
+
+@vindex SYMBOL_FUNCTION_DOMAIN
+@item gdb.SYMBOL_FUNCTION_DOMAIN
+This domain contains functions.
+
+@vindex SYMBOL_TYPE_DOMAIN
+@item gdb.SYMBOL_TYPE_DOMAIN
+This domain contains types.  In a C-like language, types using a tag
+will not appear here; in other languages, all types are in this
+domain.
 
 @vindex SYMBOL_STRUCT_DOMAIN
 @item gdb.SYMBOL_STRUCT_DOMAIN
-This domain holds struct, union and enum type names.
+This domain holds struct, union and enum tag names.  This domain is
+only used for C-like languages.
 
 @vindex SYMBOL_LABEL_DOMAIN
 @item gdb.SYMBOL_LABEL_DOMAIN
@@ -6234,6 +6244,20 @@ This domain contains names of Fortran module types.
 This domain contains names of Fortran common blocks.
 @end vtable
 
+When searching for a symbol, the desired domain constant can be passed
+verbatim to the lookup function.  For example:
+@smallexample
+symbol = gdb.lookup_symbol ("name", domain=gdb.SYMBOL_VAR_DOMAIN)
+@end smallexample
+
+For more complex searches, there is a corresponding set of constants
+using a @samp{SEARCH_} prefix.  These may be or'd together to form a
+search constant, e.g.:
+@smallexample
+symbol = gdb.lookup_symbol ("name",
+                            domain=gdb.SEARCH_VAR_DOMAIN | gdb.SEARCH_TYPE_DOMAIN)
+@end smallexample
+
 The available address class categories in @code{gdb.Symbol} are represented
 as constants in the @code{gdb} module:
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 00/30] Restructure symbol domains
  2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
                   ` (29 preceding siblings ...)
  2024-01-18 20:32 ` [PATCH v2 30/30] Document new Python and Guile constants Tom Tromey
@ 2024-01-28 23:42 ` Tom Tromey
  30 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-28 23:42 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

>>>>> "Tom" == Tom Tromey <tom@tromey.com> writes:

Tom> v2 note: I was planning to check this in, but re-testing showed some
Tom> regressions.  I've fixed them here, basically DW_TAG_entry_point
Tom> caused some problems necessitating a fix in one patch, and a new patch
Tom> to fix a latent bug.  I plan to check this in relatively soon.

I re-regression tested this and now I am checking it in.
I'll file a follow-up bug about the double symbol idea for C++.

Tom

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 10/30] Use a .def file for domain_enum
  2024-01-18 20:32 ` [PATCH v2 10/30] Use a .def file for domain_enum Tom Tromey
@ 2024-01-29 17:57   ` Lancelot SIX
  2024-01-29 18:20     ` Tom Tromey
  0 siblings, 1 reply; 34+ messages in thread
From: Lancelot SIX @ 2024-01-29 17:57 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches

On Thu, Jan 18, 2024 at 01:32:08PM -0700, Tom Tromey wrote:
> Future patches will change and reuse the names from domain_enum.  This
> patch makes this less error-prone by having a single point to define
> these names, using the typical gdb ".def" file.
> ---
>  gdb/guile/scm-symbol.c | 18 ++++++++++--------
>  gdb/python/py-symbol.c | 21 ++++++++-------------
>  gdb/sym-domains.def    | 47 +++++++++++++++++++++++++++++++++++++++++++++++
>  gdb/symtab.c           | 10 ++++------
>  gdb/symtab.h           | 31 +++----------------------------
>  5 files changed, 72 insertions(+), 55 deletions(-)

Hi Tom,

FYI, starting this patch I have a CI box running centos-7 which fails
with:

    In file included from ../../gdb/tui/tui-source.c:25:
    ../../gdb/symtab.h:897: error: "DOMAIN" redefined [-Werror]
      897 | #define DOMAIN(X) X ## _DOMAIN,
          | 
    In file included from /opt/rh/devtoolset-9/root/usr/include/c++/9/cmath:45,
                     from /opt/rh/devtoolset-9/root/usr/include/c++/9/math.h:36,
                     from ../gnulib/import/math.h:41,
                     from ../../gdb/tui/tui-source.c:23:
    /usr/include/math.h:332: note: this is the location of the previous definition
      332 | # define DOMAIN  1
          | 

The DOMAIN macro used to call the .def conflicts with the one from
/usr/include/math.h (glibc-1.17, so yeah, quite old).

A fix can be to use DOMAIN_ (or SYM_DOMAIN any better name) in
sym-domains.def.  Do you have a preferred name?

Best,
Lancelot.

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH v2 10/30] Use a .def file for domain_enum
  2024-01-29 17:57   ` Lancelot SIX
@ 2024-01-29 18:20     ` Tom Tromey
  0 siblings, 0 replies; 34+ messages in thread
From: Tom Tromey @ 2024-01-29 18:20 UTC (permalink / raw)
  To: Lancelot SIX; +Cc: Tom Tromey, gdb-patches

>>>>> "Lancelot" == Lancelot SIX <lsix@lancelotsix.com> writes:

Lancelot> A fix can be to use DOMAIN_ (or SYM_DOMAIN any better name) in
Lancelot> sym-domains.def.  Do you have a preferred name?

SYM_DOMAIN would be fine by me.  If you'd prefer, I can do it.
If not, thank you.

Tom

^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2024-01-29 18:20 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-18 20:31 [PATCH v2 00/30] Restructure symbol domains Tom Tromey
2024-01-18 20:31 ` [PATCH v2 01/30] Fix bug in cooked index scanner Tom Tromey
2024-01-18 20:32 ` [PATCH v2 02/30] Small cleanup in DWARF reader Tom Tromey
2024-01-18 20:32 ` [PATCH v2 03/30] Fix latent bug in DW_TAG_entry_point handling Tom Tromey
2024-01-18 20:32 ` [PATCH v2 04/30] Make nsalias.exp more reliable Tom Tromey
2024-01-18 20:32 ` [PATCH v2 05/30] Fix latent bug in mdebugread.c Tom Tromey
2024-01-18 20:32 ` [PATCH v2 06/30] Give names to unspecified types Tom Tromey
2024-01-18 20:32 ` [PATCH v2 07/30] Remove NR_DOMAINS Tom Tromey
2024-01-18 20:32 ` [PATCH v2 08/30] Simplify symbol_to_info_string Tom Tromey
2024-01-18 20:32 ` [PATCH v2 09/30] Split up a big 'if' in symtab.c Tom Tromey
2024-01-18 20:32 ` [PATCH v2 10/30] Use a .def file for domain_enum Tom Tromey
2024-01-29 17:57   ` Lancelot SIX
2024-01-29 18:20     ` Tom Tromey
2024-01-18 20:32 ` [PATCH v2 11/30] Add two new symbol domains Tom Tromey
2024-01-18 20:32 ` [PATCH v2 12/30] Add domain_search_flags Tom Tromey
2024-01-18 20:32 ` [PATCH v2 13/30] Replace search_domain with domain_search_flags Tom Tromey
2024-01-18 20:32 ` [PATCH v2 14/30] Remove a check of VAR_DOMAIN Tom Tromey
2024-01-18 20:32 ` [PATCH v2 15/30] Introduce "scripting" domains Tom Tromey
2024-01-18 20:32 ` [PATCH v2 16/30] Use domain_search_flags in lookup_global_symbol_language Tom Tromey
2024-01-18 20:32 ` [PATCH v2 17/30] Use domain_search_flags in lookup_symbol et al Tom Tromey
2024-01-18 20:32 ` [PATCH v2 18/30] Remove some obsolete Python constants Tom Tromey
2024-01-18 20:32 ` [PATCH v2 19/30] Remove old symbol_matches_domain Tom Tromey
2024-01-18 20:32 ` [PATCH v2 20/30] Use the new symbol domains Tom Tromey
2024-01-18 20:32 ` [PATCH v2 21/30] Simplify some symbol searches in Ada code Tom Tromey
2024-01-18 20:32 ` [PATCH v2 22/30] Simplify some symbol searches in linespec.c Tom Tromey
2024-01-18 20:32 ` [PATCH v2 23/30] Only search for "main" as a function Tom Tromey
2024-01-18 20:32 ` [PATCH v2 24/30] Only look for functions in expand_symtabs_for_function Tom Tromey
2024-01-18 20:32 ` [PATCH v2 25/30] Use a function-domain search in inside_main_func Tom Tromey
2024-01-18 20:32 ` [PATCH v2 26/30] Only search types in cp_lookup_rtti_type Tom Tromey
2024-01-18 20:32 ` [PATCH v2 27/30] Only search types in lookup_typename Tom Tromey
2024-01-18 20:32 ` [PATCH v2 28/30] Only search for functions in rust_structop::evaluate_funcall Tom Tromey
2024-01-18 20:32 ` [PATCH v2 29/30] Refine search in cp_search_static_and_baseclasses Tom Tromey
2024-01-18 20:32 ` [PATCH v2 30/30] Document new Python and Guile constants Tom Tromey
2024-01-28 23:42 ` [PATCH v2 00/30] Restructure symbol domains Tom Tromey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).