From patchwork Thu Jan 18 20:32:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 84376 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EF4038582B4 for ; Thu, 18 Jan 2024 20:34:55 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 8A5E6385840C for ; Thu, 18 Jan 2024 20:32:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A5E6385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8A5E6385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; cv=none; b=pFwkqW8iSWMa3PVTT9ItA1EqQ4077K87tt7oYEDixUvsZoxxyZR7MiXLcpGzQFymHT1lhLLNGFgqIh0eE96977NDSg9UmNf+JkabDqGNpfIfNs7nkz3bPDOpsZNsDAN/WuWgj2ueHN1PGA0dhRnzbufhXw0WhbOdMQ5KSvspwqk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705609942; c=relaxed/simple; bh=/7rl5GpIaogvwdDJ1vJsDbzXreKacDYhsfh9rHTeMPI=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=cluGpxydFQbokc8DpKLJOtZcdA0FH+pnbYP0Xe1jrMSzYC8vdgU8RH4KsW2oB0VmKzQ3vbSvjuda9j/pDEXQ2jc7ZlfF/R9Q8I7BwoVKYxpr6NxTBdgI5NRv77h/+BhqwHhwtMCWT0Pc8jmJesQ9VU7BH0VTL0qa6rRewYZk/T0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-6003a.ext.cloudfilter.net ([10.0.30.151]) by cmsmtp with ESMTPS id QWCrrCWPyCF6GQZ3brrcy0; Thu, 18 Jan 2024 20:32:11 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id QZ3arhTautzh2QZ3brbVKh; Thu, 18 Jan 2024 20:32:11 +0000 X-Authority-Analysis: v=2.4 cv=Ra6Dtnhv c=1 sm=1 tr=0 ts=65a98acb a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=dEuoMetlWLkA:10 a=Qbun_eYptAEA:10 a=635ygisoJLhA9rX-spYA:9 a=QEXdDO2ut3YA:10 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=oU7wIbbZqL92l4POqMbQzxeXbwzfEkd3Gh+VCQJGkjU=; b=OpalyiiC7QHTHbZkVCM7D3oFjy rlRUhyM48O1bIH9g2dzQSIWNoi8NMXkuyqsRo8WQhOp6PxAsSQzVfck5mK8ZjELHiN+tPBJNT/usC 3ab9t478tsWal/KPu5oGREZlw; Received: from 97-122-68-157.hlrn.qwest.net ([97.122.68.157]:50746 helo=[192.168.0.21]) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1rQZ3a-002DCj-1U for gdb-patches@sourceware.org; Thu, 18 Jan 2024 13:32:10 -0700 From: Tom Tromey Date: Thu, 18 Jan 2024 13:32:11 -0700 Subject: [PATCH v2 13/30] Replace search_domain with domain_search_flags MIME-Version: 1.0 Message-Id: <20240118-submit-domain-hacks-2-v2-13-aecab29fa104@tromey.com> References: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> In-Reply-To: <20240118-submit-domain-hacks-2-v2-0-aecab29fa104@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.12.4 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.68.157 X-Source-L: No X-Exim-ID: 1rQZ3a-002DCj-1U X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-68-157.hlrn.qwest.net ([192.168.0.21]) [97.122.68.157]:50746 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfEjlZR+Jm9LvamJUt+ZKpDzeczcNUyW73QKNWqhvJEcpreZqVnz3F3qyJm+XBgS5/DMI6rG/J1wn7r0kM6pAzyKAp8JXHEHAyCWkTrfQy+QpH1mmEXXZ gm69mU3jm342QbIayi8YsKal9Bt1K2DFyRpQjAGwPJsAm2w3abAh1GnuPp7n+URoHu7nL2llBdcHxMWm/8TR/+/GSsKODUKfos0= X-Spam-Status: No, score=-3022.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org 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 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 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 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 file_matcher, gdb::function_view 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 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 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 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 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 &names, enum search_domain search_domain); + const std::vector &names, domain_search_flags domain_search_flags); static std::vector 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 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 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 &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 *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::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 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 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 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 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 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 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 symbol_matcher, gdb::function_view 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 symbol_matcher, gdb::function_view expansion_notify, block_search_flags search_flags, - enum search_domain kind); + domain_search_flags kind); void map_symbol_filenames (gdb::function_view 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); } 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 &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 &treg, std::set *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 &preg, std::vector *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 preg; std::optional 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 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 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 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 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 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 *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 module_symbol_search; within the module. */ extern std::vector 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 *search_symtabs, struct program_space *search_pspace);