From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.210]) by sourceware.org (Postfix) with ESMTPS id 36E4138708D5 for ; Sun, 28 Feb 2021 20:38:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 36E4138708D5 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm11.websitewelcome.com (cm11.websitewelcome.com [100.42.49.5]) by gateway33.websitewelcome.com (Postfix) with ESMTP id CC3EA3AB21E3 for ; Sun, 28 Feb 2021 14:38:09 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id GSpNlZqUzABzoGSpNlmdUn; Sun, 28 Feb 2021 14:38:09 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: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=mQrcpZ423eU0ORZoD28RRHR8XQG1K1/LzGggogFLUGw=; b=s6U0zFgaRr0TjBJfTiO4Pxa9Im DyfudWyIXMFKwJQKNQehEtEUtQaBFoe1KPBKPvIWTk0OqcWwJUwRibz1BvBIDi99dXHjQNq5PYuF9 s0v2eY37sJ0TOixG6SVY8Yi8K; Received: from 97-122-70-152.hlrn.qwest.net ([97.122.70.152]:36730 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lGSpN-000Xf8-72 for gdb-patches@sourceware.org; Sun, 28 Feb 2021 13:38:09 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 06/26] Move quick_symbol_functions to a new header Date: Sun, 28 Feb 2021 13:37:43 -0700 Message-Id: <20210228203803.1693413-7-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210228203803.1693413-1-tom@tromey.com> References: <20210228203803.1693413-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.70.152 X-Source-L: No X-Exim-ID: 1lGSpN-000Xf8-72 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-70-152.hlrn.qwest.net (localhost.localdomain) [97.122.70.152]:36730 X-Source-Auth: tom+tromey.com X-Email-Count: 7 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_SHORT, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L5, SPF_HELO_PASS, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Feb 2021 20:38:13 -0000 This introduces a new header, quick-symbol.h, and moves quick_symbol_functions and related typedefs into it. gdb/ChangeLog 2021-02-28 Tom Tromey * symfile.h (symbol_compare_ftype, symbol_filename_ftype) (expand_symtabs_file_matcher_ftype) (expand_symtabs_symbol_matcher_ftype) (expand_symtabs_exp_notify_ftype, struct quick_symbol_functions): Move to quick-symbol.h. * quick-symbol.h: New file. --- gdb/ChangeLog | 9 ++ gdb/quick-symbol.h | 228 +++++++++++++++++++++++++++++++++++++++++++++ gdb/symfile.h | 206 +--------------------------------------- 3 files changed, 238 insertions(+), 205 deletions(-) create mode 100644 gdb/quick-symbol.h diff --git a/gdb/quick-symbol.h b/gdb/quick-symbol.h new file mode 100644 index 00000000000..fa5f5012211 --- /dev/null +++ b/gdb/quick-symbol.h @@ -0,0 +1,228 @@ +/* "Quick" symbol functions + + Copyright (C) 2021 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#ifndef GDB_QUICK_SYMBOL_H +#define GDB_QUICK_SYMBOL_H + +/* Comparison function for symbol look ups. */ + +typedef int (symbol_compare_ftype) (const char *string1, + const char *string2); + +/* Callback for quick_symbol_functions->map_symbol_filenames. */ + +typedef void (symbol_filename_ftype) (const char *filename, + const char *fullname, void *data); + +/* Callback for quick_symbol_functions->expand_symtabs_matching + to match a file name. */ + +typedef bool (expand_symtabs_file_matcher_ftype) (const char *filename, + bool basenames); + +/* Callback for quick_symbol_functions->expand_symtabs_matching + to match a symbol name. */ + +typedef bool (expand_symtabs_symbol_matcher_ftype) (const char *name); + +/* Callback for quick_symbol_functions->expand_symtabs_matching + to be called after a symtab has been expanded. */ + +typedef void (expand_symtabs_exp_notify_ftype) (compunit_symtab *symtab); + +/* The "quick" symbol functions exist so that symbol readers can + avoiding an initial read of all the symbols. For example, symbol + readers might choose to use the "partial symbol table" utilities, + which is one implementation of the quick symbol functions. + + The quick symbol functions are generally opaque: the underlying + representation is hidden from the caller. + + In general, these functions should only look at whatever special + index the symbol reader creates -- looking through the symbol + tables themselves is handled by generic code. If a function is + defined as returning a "symbol table", this means that the function + should only return a newly-created symbol table; it should not + examine pre-existing ones. + + The exact list of functions here was determined in an ad hoc way + based on gdb's history. */ + +struct quick_symbol_functions +{ + /* Return true if this objfile has any "partial" symbols + available. */ + bool (*has_symbols) (struct objfile *objfile); + + /* Return the symbol table for the "last" file appearing in + OBJFILE. */ + struct symtab *(*find_last_source_symtab) (struct objfile *objfile); + + /* Forget all cached full file names for OBJFILE. */ + void (*forget_cached_source_info) (struct objfile *objfile); + + /* Expand and iterate over each "partial" symbol table in OBJFILE + where the source file is named NAME. + + If NAME is not absolute, a match after a '/' in the symbol table's + file name will also work, REAL_PATH is NULL then. If NAME is + absolute then REAL_PATH is non-NULL absolute file name as resolved + via gdb_realpath from NAME. + + If a match is found, the "partial" symbol table is expanded. + Then, this calls iterate_over_some_symtabs (or equivalent) over + all newly-created symbol tables, passing CALLBACK to it. + The result of this call is returned. */ + bool (*map_symtabs_matching_filename) + (struct objfile *objfile, const char *name, const char *real_path, + gdb::function_view callback); + + /* Check to see if the symbol is defined in a "partial" symbol table + of OBJFILE. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, + depending on whether we want to search global symbols or static + symbols. NAME is the name of the symbol to look for. DOMAIN + indicates what sort of symbol to search for. + + Returns the newly-expanded compunit in which the symbol is + defined, or NULL if no such symbol table exists. If OBJFILE + contains !TYPE_OPAQUE symbol prefer its compunit. If it contains + only TYPE_OPAQUE symbol(s), return at least that compunit. */ + struct compunit_symtab *(*lookup_symbol) (struct objfile *objfile, + block_enum block_index, + const char *name, + domain_enum domain); + + /* Check to see if the global symbol is defined in a "partial" symbol table + of OBJFILE. NAME is the name of the symbol to look for. DOMAIN + indicates what sort of symbol to search for. + + If found, sets *symbol_found_p to true and returns the symbol language. + defined, or NULL if no such symbol table exists. */ + enum language (*lookup_global_symbol_language) (struct objfile *objfile, + const char *name, + domain_enum domain, + bool *symbol_found_p); + + /* Print statistics about any indices loaded for OBJFILE. The + statistics should be printed to gdb_stdout. This is used for + "maint print statistics". */ + void (*print_stats) (struct objfile *objfile); + + /* Dump any indices loaded for OBJFILE. The dump should go to + gdb_stdout. This is used for "maint print objfiles". */ + void (*dump) (struct objfile *objfile); + + /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that + the corresponding symbol tables are loaded. */ + void (*expand_symtabs_for_function) (struct objfile *objfile, + const char *func_name); + + /* Read all symbol tables associated with OBJFILE. */ + void (*expand_all_symtabs) (struct objfile *objfile); + + /* Read all symbol tables associated with OBJFILE which have + symtab_to_fullname equal to FULLNAME. + This is for the purposes of examining code only, e.g., expand_line_sal. + The routine may ignore debug info that is known to not be useful with + code, e.g., DW_TAG_type_unit for dwarf debug info. */ + void (*expand_symtabs_with_fullname) (struct objfile *objfile, + const char *fullname); + + /* Find global or static symbols in all tables that are in DOMAIN + and for which MATCH (symbol name, NAME) == 0, passing each to + CALLBACK, reading in partial symbol tables as needed. Look + through global symbols if GLOBAL and otherwise static symbols. + Passes NAME and NAMESPACE to CALLBACK with each symbol + found. After each block is processed, passes NULL to CALLBACK. + MATCH must be weaker than strcmp_iw_ordered in the sense that + strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE, + if non-null, must be an ordering relation compatible with + strcmp_iw_ordered in the sense that + strcmp_iw_ordered(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0 + and + strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0 + (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0). + CALLBACK returns true to indicate that the scan should continue, or + false to indicate that the scan should be terminated. */ + + void (*map_matching_symbols) + (struct objfile *, + const lookup_name_info &lookup_name, + domain_enum domain, + int global, + gdb::function_view callback, + symbol_compare_ftype *ordered_compare); + + /* Expand all symbol tables in OBJFILE matching some criteria. + + FILE_MATCHER is called for each file in OBJFILE. The file name + is passed to it. If the matcher returns false, the file is + skipped. If FILE_MATCHER is NULL the file is not skipped. If + BASENAMES is true the matcher should consider only file base + names (the passed file name is already only the lbasename'd + part). + + If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL, + the symbol table is expanded. + + Otherwise, individual symbols are considered. + + If KIND does not match, the symbol is skipped. + + If the symbol name does not match LOOKUP_NAME, the symbol is skipped. + + If SYMBOL_MATCHER returns false, then the symbol is skipped. + + Otherwise, the symbol's symbol table is expanded. */ + void (*expand_symtabs_matching) + (struct objfile *objfile, + gdb::function_view file_matcher, + const lookup_name_info *lookup_name, + gdb::function_view symbol_matcher, + gdb::function_view expansion_notify, + enum search_domain kind); + + /* Return the comp unit from OBJFILE that contains PC and + SECTION. Return NULL if there is no such compunit. This + should return the compunit that contains a symbol whose + address exactly matches PC, or, if there is no exact match, the + compunit that contains a symbol whose address is closest to + PC. */ + struct compunit_symtab *(*find_pc_sect_compunit_symtab) + (struct objfile *objfile, struct bound_minimal_symbol msymbol, + CORE_ADDR pc, struct obj_section *section, int warn_if_readin); + + /* Return the comp unit from OBJFILE that contains a symbol at + ADDRESS. Return NULL if there is no such comp unit. Unlike + find_pc_sect_compunit_symtab, any sort of symbol (not just text + symbols) can be considered, and only exact address matches are + considered. This pointer may be NULL. */ + struct compunit_symtab *(*find_compunit_symtab_by_address) + (struct objfile *objfile, CORE_ADDR address); + + /* Call a callback for every file defined in OBJFILE whose symtab is + not already read in. FUN is the callback. It is passed the file's + FILENAME, the file's FULLNAME (if need_fullname is non-zero), and + the DATA passed to this function. */ + void (*map_symbol_filenames) (struct objfile *objfile, + symbol_filename_ftype *fun, void *data, + int need_fullname); +}; + +#endif /* GDB_QUICK_SYMBOL_H */ diff --git a/gdb/symfile.h b/gdb/symfile.h index facffeab810..7e64db74b8d 100644 --- a/gdb/symfile.h +++ b/gdb/symfile.h @@ -28,6 +28,7 @@ #include "gdb_bfd.h" #include "gdbsupport/function-view.h" #include "target-section.h" +#include "quick-symbol.h" /* Opaque declarations. */ struct target_section; @@ -41,11 +42,6 @@ struct agent_expr; struct axs_value; class probe; -/* Comparison function for symbol look ups. */ - -typedef int (symbol_compare_ftype) (const char *string1, - const char *string2); - struct other_sections { other_sections (CORE_ADDR addr_, std::string &&name_, int sectindex_) @@ -107,206 +103,6 @@ struct symfile_segment_data using symfile_segment_data_up = std::unique_ptr; -/* Callback for quick_symbol_functions->map_symbol_filenames. */ - -typedef void (symbol_filename_ftype) (const char *filename, - const char *fullname, void *data); - -/* Callback for quick_symbol_functions->expand_symtabs_matching - to match a file name. */ - -typedef bool (expand_symtabs_file_matcher_ftype) (const char *filename, - bool basenames); - -/* Callback for quick_symbol_functions->expand_symtabs_matching - to match a symbol name. */ - -typedef bool (expand_symtabs_symbol_matcher_ftype) (const char *name); - -/* Callback for quick_symbol_functions->expand_symtabs_matching - to be called after a symtab has been expanded. */ - -typedef void (expand_symtabs_exp_notify_ftype) (compunit_symtab *symtab); - -/* The "quick" symbol functions exist so that symbol readers can - avoiding an initial read of all the symbols. For example, symbol - readers might choose to use the "partial symbol table" utilities, - which is one implementation of the quick symbol functions. - - The quick symbol functions are generally opaque: the underlying - representation is hidden from the caller. - - In general, these functions should only look at whatever special - index the symbol reader creates -- looking through the symbol - tables themselves is handled by generic code. If a function is - defined as returning a "symbol table", this means that the function - should only return a newly-created symbol table; it should not - examine pre-existing ones. - - The exact list of functions here was determined in an ad hoc way - based on gdb's history. */ - -struct quick_symbol_functions -{ - /* Return true if this objfile has any "partial" symbols - available. */ - bool (*has_symbols) (struct objfile *objfile); - - /* Return the symbol table for the "last" file appearing in - OBJFILE. */ - struct symtab *(*find_last_source_symtab) (struct objfile *objfile); - - /* Forget all cached full file names for OBJFILE. */ - void (*forget_cached_source_info) (struct objfile *objfile); - - /* Expand and iterate over each "partial" symbol table in OBJFILE - where the source file is named NAME. - - If NAME is not absolute, a match after a '/' in the symbol table's - file name will also work, REAL_PATH is NULL then. If NAME is - absolute then REAL_PATH is non-NULL absolute file name as resolved - via gdb_realpath from NAME. - - If a match is found, the "partial" symbol table is expanded. - Then, this calls iterate_over_some_symtabs (or equivalent) over - all newly-created symbol tables, passing CALLBACK to it. - The result of this call is returned. */ - bool (*map_symtabs_matching_filename) - (struct objfile *objfile, const char *name, const char *real_path, - gdb::function_view callback); - - /* Check to see if the symbol is defined in a "partial" symbol table - of OBJFILE. BLOCK_INDEX should be either GLOBAL_BLOCK or STATIC_BLOCK, - depending on whether we want to search global symbols or static - symbols. NAME is the name of the symbol to look for. DOMAIN - indicates what sort of symbol to search for. - - Returns the newly-expanded compunit in which the symbol is - defined, or NULL if no such symbol table exists. If OBJFILE - contains !TYPE_OPAQUE symbol prefer its compunit. If it contains - only TYPE_OPAQUE symbol(s), return at least that compunit. */ - struct compunit_symtab *(*lookup_symbol) (struct objfile *objfile, - block_enum block_index, - const char *name, - domain_enum domain); - - /* Check to see if the global symbol is defined in a "partial" symbol table - of OBJFILE. NAME is the name of the symbol to look for. DOMAIN - indicates what sort of symbol to search for. - - If found, sets *symbol_found_p to true and returns the symbol language. - defined, or NULL if no such symbol table exists. */ - enum language (*lookup_global_symbol_language) (struct objfile *objfile, - const char *name, - domain_enum domain, - bool *symbol_found_p); - - /* Print statistics about any indices loaded for OBJFILE. The - statistics should be printed to gdb_stdout. This is used for - "maint print statistics". */ - void (*print_stats) (struct objfile *objfile); - - /* Dump any indices loaded for OBJFILE. The dump should go to - gdb_stdout. This is used for "maint print objfiles". */ - void (*dump) (struct objfile *objfile); - - /* Find all the symbols in OBJFILE named FUNC_NAME, and ensure that - the corresponding symbol tables are loaded. */ - void (*expand_symtabs_for_function) (struct objfile *objfile, - const char *func_name); - - /* Read all symbol tables associated with OBJFILE. */ - void (*expand_all_symtabs) (struct objfile *objfile); - - /* Read all symbol tables associated with OBJFILE which have - symtab_to_fullname equal to FULLNAME. - This is for the purposes of examining code only, e.g., expand_line_sal. - The routine may ignore debug info that is known to not be useful with - code, e.g., DW_TAG_type_unit for dwarf debug info. */ - void (*expand_symtabs_with_fullname) (struct objfile *objfile, - const char *fullname); - - /* Find global or static symbols in all tables that are in DOMAIN - and for which MATCH (symbol name, NAME) == 0, passing each to - CALLBACK, reading in partial symbol tables as needed. Look - through global symbols if GLOBAL and otherwise static symbols. - Passes NAME and NAMESPACE to CALLBACK with each symbol - found. After each block is processed, passes NULL to CALLBACK. - MATCH must be weaker than strcmp_iw_ordered in the sense that - strcmp_iw_ordered(x,y) == 0 --> MATCH(x,y) == 0. ORDERED_COMPARE, - if non-null, must be an ordering relation compatible with - strcmp_iw_ordered in the sense that - strcmp_iw_ordered(x,y) == 0 --> ORDERED_COMPARE(x,y) == 0 - and - strcmp_iw_ordered(x,y) <= 0 --> ORDERED_COMPARE(x,y) <= 0 - (allowing strcmp_iw_ordered(x,y) < 0 while ORDERED_COMPARE(x, y) == 0). - CALLBACK returns true to indicate that the scan should continue, or - false to indicate that the scan should be terminated. */ - - void (*map_matching_symbols) - (struct objfile *, - const lookup_name_info &lookup_name, - domain_enum domain, - int global, - gdb::function_view callback, - symbol_compare_ftype *ordered_compare); - - /* Expand all symbol tables in OBJFILE matching some criteria. - - FILE_MATCHER is called for each file in OBJFILE. The file name - is passed to it. If the matcher returns false, the file is - skipped. If FILE_MATCHER is NULL the file is not skipped. If - BASENAMES is true the matcher should consider only file base - names (the passed file name is already only the lbasename'd - part). - - If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL, - the symbol table is expanded. - - Otherwise, individual symbols are considered. - - If KIND does not match, the symbol is skipped. - - If the symbol name does not match LOOKUP_NAME, the symbol is skipped. - - If SYMBOL_MATCHER returns false, then the symbol is skipped. - - Otherwise, the symbol's symbol table is expanded. */ - void (*expand_symtabs_matching) - (struct objfile *objfile, - gdb::function_view file_matcher, - const lookup_name_info *lookup_name, - gdb::function_view symbol_matcher, - gdb::function_view expansion_notify, - enum search_domain kind); - - /* Return the comp unit from OBJFILE that contains PC and - SECTION. Return NULL if there is no such compunit. This - should return the compunit that contains a symbol whose - address exactly matches PC, or, if there is no exact match, the - compunit that contains a symbol whose address is closest to - PC. */ - struct compunit_symtab *(*find_pc_sect_compunit_symtab) - (struct objfile *objfile, struct bound_minimal_symbol msymbol, - CORE_ADDR pc, struct obj_section *section, int warn_if_readin); - - /* Return the comp unit from OBJFILE that contains a symbol at - ADDRESS. Return NULL if there is no such comp unit. Unlike - find_pc_sect_compunit_symtab, any sort of symbol (not just text - symbols) can be considered, and only exact address matches are - considered. This pointer may be NULL. */ - struct compunit_symtab *(*find_compunit_symtab_by_address) - (struct objfile *objfile, CORE_ADDR address); - - /* Call a callback for every file defined in OBJFILE whose symtab is - not already read in. FUN is the callback. It is passed the file's - FILENAME, the file's FULLNAME (if need_fullname is non-zero), and - the DATA passed to this function. */ - void (*map_symbol_filenames) (struct objfile *objfile, - symbol_filename_ftype *fun, void *data, - int need_fullname); -}; - /* Structure of functions used for probe support. If one of these functions is provided, all must be. */ -- 2.26.2