From patchwork Tue Nov 21 03:53:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 80416 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 8A6B03858412 for ; Tue, 21 Nov 2023 03:56:04 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 693653858C53 for ; Tue, 21 Nov 2023 03:53:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 693653858C53 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 693653858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538808; cv=none; b=RvptdQOSZ3R7dAmVqkGCeVR5eekR26yXHAS+93bXCQMFqy8vdIfjOL8GLNSz0ZcnHJ6XnQ7sbY761dhTVAXg2lfFeoW69V3N6ba8q5beyaMgmrIvV0U3O3PI0a6v+qtIE9xQ3maR3ySftE+BXxp5+KwdeGIA0RKPgj4jaC4nLUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700538808; c=relaxed/simple; bh=EP5PIpRCAev095xtlZLGnARFoEJf8GLOTDAY1j7xQNA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=JqsbPD0hcr6NrFPhn/G4nuwsKGGM41dzBkWR4Ib217Zsskz9EEBR/UaLCWrS1YKq7g10Dx64015cMqnDsD22AW3i+tGbHUtzeNNmgGXQejMwcwzJdEle5nG+JCRXVjFIbxKEOFp9VW/fqeRamHnbkSKZ+FynECP2EeekXtzk/7I= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5009a.ext.cloudfilter.net ([10.0.29.176]) by cmsmtp with ESMTPS id 5ATqrmyTsWcCI5HpBrZVLU; Tue, 21 Nov 2023 03:53:21 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id 5HpArzUJL97pz5HpArri8s; Tue, 21 Nov 2023 03:53:20 +0000 X-Authority-Analysis: v=2.4 cv=ULDOoQTy c=1 sm=1 tr=0 ts=655c29b0 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=OWjo9vPv0XrRhIrVQ50Ab3nP57M=:19 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IkcTkHD0fZMA:10 a=BNY50KLci1gA:10 a=Qbun_eYptAEA:10 a=G8phxFYgWPlDxzhUtmMA: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=DBt46Dic+b742P8Le1ayYzUwMp3A5Cz4viauvlAyrqY=; b=mHeVQ8Q5lEG7k7eZrwLprzE4RE NWBBX5lte849Wcj6yjjpqLq2CHpr4rKZopITBcWDLemz4sVE/uzu4yYRfZNVbVEX1XmABAAm7+lJt xu8ZMrmJrxJVasfmEImrHDOt+; Received: from 97-122-77-73.hlrn.qwest.net ([97.122.77.73]:47856 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 1r5HpA-0040be-08 for gdb-patches@sourceware.org; Mon, 20 Nov 2023 20:53:20 -0700 From: Tom Tromey Date: Mon, 20 Nov 2023 20:53:43 -0700 Subject: [PATCH 12/29] Replace search_domain with domain_search_flags MIME-Version: 1.0 Message-Id: <20231120-submit-domain-hacks-2-v1-12-29650d01b198@tromey.com> References: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@tromey.com> In-Reply-To: <20231120-submit-domain-hacks-2-v1-0-29650d01b198@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.77.73 X-Source-L: No X-Exim-ID: 1r5HpA-0040be-08 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-77-73.hlrn.qwest.net ([192.168.0.21]) [97.122.77.73]:47856 X-Source-Auth: tom+tromey.com X-Email-Count: 13 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfOb9uK3zo2Mcmpa2RibUfFlUl1ktWY/ch5CGsIZA6OI+ZkZJnT94kcnaFql/Bzp1jpEhhU746rhfDHPh6BFg0T7jOeWkNN8Y0nIBsr7t+hN1adRYrIWK k5SgVAAFUUlyINwl+nKqhKLxIZb4mOqfafVGt9eO/Jg/oAgSzYO4SYNE6246Ls5a6Njw0qyhzby+JORkjzak5LVQM749OOGXoU8= X-Spam-Status: No, score=-3023.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, 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 | 4 +- gdb/compile/compile-cplus-symbols.c | 2 +- gdb/dwarf2/cooked-index.c | 34 ++++++++++ gdb/dwarf2/cooked-index.h | 23 +------ 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, 218 insertions(+), 280 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9bb649e901d..eac688cd632 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13057,7 +13057,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. */ @@ -13602,7 +13602,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 1edbf8f64b5..4a52427a072 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 58ea541a5c9..e451e324424 100644 --- a/gdb/dwarf2/cooked-index.c +++ b/gdb/dwarf2/cooked-index.c @@ -181,6 +181,40 @@ 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) + 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 5aacb321c91..b3d5b5cd6f6 100644 --- a/gdb/dwarf2/cooked-index.h +++ b/gdb/dwarf2/cooked-index.h @@ -128,28 +128,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; - 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 c1b62b38f93..743cee6c46d 100644 --- a/gdb/dwarf2/read-debug-names.c +++ b/gdb/dwarf2/read-debug-names.c @@ -99,7 +99,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 @@ -544,7 +544,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), @@ -582,7 +582,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. */ @@ -850,100 +850,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; } @@ -1005,7 +951,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 e789e9c2654..eeb52203ef9 100644 --- a/gdb/dwarf2/read-gdb-index.c +++ b/gdb/dwarf2/read-gdb-index.c @@ -154,7 +154,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. @@ -366,7 +366,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; @@ -417,27 +417,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; + case GDB_INDEX_SYMBOL_KIND_VARIABLE: + mask = SEARCH_VAR_DOMAIN; break; - case FUNCTIONS_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_FUNCTION) - continue; + case GDB_INDEX_SYMBOL_KIND_FUNCTION: + mask = SEARCH_FUNCTION_DOMAIN; break; - case TYPES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_TYPE) - continue; + case GDB_INDEX_SYMBOL_KIND_TYPE: + mask = SEARCH_TYPE_DOMAIN; break; - case MODULES_DOMAIN: - if (symbol_kind != GDB_INDEX_SYMBOL_KIND_OTHER) - continue; - break; - default: + case GDB_INDEX_SYMBOL_KIND_OTHER: + mask = SEARCH_MODULE_DOMAIN; break; } + if ((kind & mask) == 0) + continue; } /* Don't crash on bad data. */ @@ -466,7 +463,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 aa44d19b517..866c00e75a2 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -1652,7 +1652,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; } @@ -16590,7 +16590,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; bool can_lazily_read_symbols () override { @@ -16725,7 +16725,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 fa733d880e3..7aabedf239d 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 ()) { @@ -3323,7 +3323,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 ()) @@ -3442,10 +3442,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 @@ -3523,12 +3523,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 @@ -3622,7 +3622,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 (); @@ -3745,7 +3745,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) { @@ -3767,7 +3767,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 @@ -3793,9 +3793,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); } @@ -4310,7 +4311,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) { @@ -4321,7 +4322,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 7492d007fba..c1b00e13f88 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 ec9d354e4a7..0da44a38c7f 100644 --- a/gdb/objfiles.h +++ b/gdb/objfiles.h @@ -598,7 +598,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 41ecf31424b..dc960b661ea 100644 --- a/gdb/psymtab.c +++ b/gdb/psymtab.c @@ -908,7 +908,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) { @@ -981,15 +981,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 @@ -1019,7 +1019,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 41337d0db89..43e6244fd6e 100644 --- a/gdb/psymtab.h +++ b/gdb/psymtab.h @@ -641,7 +641,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 ceea4b7e241..863e8caf4ce 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 7e48165db21..9f5f012d77d 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -760,7 +760,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 a7fea2ccb49..1eac8f25035 100644 --- a/gdb/quick-symbol.h +++ b/gdb/quick-symbol.h @@ -183,7 +183,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 85c43719dee..8fbacef9d30 100644 --- a/gdb/symfile-debug.c +++ b/gdb/symfile-debug.c @@ -227,7 +227,7 @@ objfile::map_symtabs_matching_filename (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN)) + SEARCH_ALL)) { retval = false; break; @@ -293,7 +293,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; } @@ -348,7 +348,7 @@ objfile::expand_symtabs_for_function (const char *func_name) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), VAR_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } void @@ -385,7 +385,7 @@ objfile::expand_symtabs_with_fullname (const char *fullname) (SEARCH_GLOBAL_BLOCK | SEARCH_STATIC_BLOCK), UNDEF_DOMAIN, - ALL_DOMAIN); + SEARCH_ALL); } void @@ -414,7 +414,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); @@ -426,7 +426,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_require_partial_symbols ()) if (!iter->expand_symtabs_matching (this, file_matcher, lookup_name, diff --git a/gdb/symfile.c b/gdb/symfile.c index bbac6ad9df1..b21ba73c69d 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -3763,7 +3763,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 bb61a779314..b3577fdb44c 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 c1a6ab5cd7d..8f620bb7ebe 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 3c66cca1cab..e5e168c20e9 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -312,22 +312,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 @@ -4677,7 +4661,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 ()) { @@ -4685,12 +4669,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; } @@ -4702,7 +4686,7 @@ bool global_symbol_searcher::expand_symtabs (objfile *objfile, const gdb::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) @@ -4741,7 +4725,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 ()) { @@ -4761,7 +4745,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 @@ -4786,7 +4770,7 @@ global_symbol_searcher::add_matching_symbols const gdb::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 ()) @@ -4819,7 +4803,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 @@ -4835,7 +4819,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 () @@ -4843,13 +4827,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) @@ -4881,7 +4865,7 @@ global_symbol_searcher::add_matching_msymbols (objfile *objfile, const gdb::optional &preg, std::vector *results) const { - enum search_domain kind = m_kind; + domain_search_flags kind = m_kind; for (minimal_symbol *msymbol : objfile->msymbols ()) { @@ -4898,7 +4882,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)) { @@ -4928,8 +4912,6 @@ global_symbol_searcher::search () const gdb::optional preg; gdb::optional treg; - gdb_assert (m_kind != ALL_DOMAIN); - if (m_symbol_name_regexp != NULL) { const char *symbol_name_regexp = m_symbol_name_regexp; @@ -5006,11 +4988,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; @@ -5141,36 +5125,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 { @@ -5178,9 +5181,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); } } @@ -5283,7 +5286,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); } @@ -5302,7 +5305,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); } @@ -5345,7 +5348,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. */ @@ -5377,7 +5381,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); } @@ -5420,7 +5424,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 (); @@ -5918,7 +5922,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 @@ -6615,12 +6619,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 (); @@ -6666,8 +6670,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) @@ -6677,12 +6683,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" @@ -6693,7 +6699,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 " @@ -6701,7 +6707,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:") @@ -6717,7 +6723,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 " @@ -6725,7 +6731,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\":") @@ -6738,7 +6744,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\":") @@ -6748,7 +6754,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 " @@ -6863,7 +6869,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. */ @@ -6882,7 +6888,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 0328a2024ad..d9caeb70856 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -941,30 +941,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 @@ -2546,13 +2522,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. */ @@ -2594,7 +2568,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; @@ -2638,7 +2612,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); }; @@ -2655,7 +2629,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' @@ -2857,7 +2831,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);