aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.h
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-04-14 15:08:42 +0200
committerTom de Vries <tdevries@suse.de>2020-04-14 15:08:42 +0200
commitc1a66c0629d3b62075a73793f1a7e7393e23e7e2 (patch)
treee4f476e5deaa1c9c4075e46b153a3834e9f27bc9 /gdb/symfile.h
parent10ca4b042d15cd0727300cf3f5a9f11ac8d6abff (diff)
downloadbinutils-c1a66c0629d3b62075a73793f1a7e7393e23e7e2.zip
binutils-c1a66c0629d3b62075a73793f1a7e7393e23e7e2.tar.gz
binutils-c1a66c0629d3b62075a73793f1a7e7393e23e7e2.tar.bz2
[gdb] Expand symbolless symtabs using maint expand-symtabs
Consider this test-case, consisting of header file hello.h: ... inline static const char* foo (void) { return "foo"; } ... and source file hello.c: ... int main (void) { printf ("hello: %s\n", foo ()); return 0; } ... compiled with -g: ... $ gcc hello.c -g ... When trying to expand the partial symtab for hello.h: ... $ gdb -batch \ -iex "set language c" \ a.out \ -ex "maint expand-symtabs hello.h" \ -ex "maint info psymtabs" ... we in fact find that the partial symtab for hello.h (and corresponding includer partial symtab hello.c) have not been expanded: ... { psymtab hello.h ((struct partial_symtab *) 0x27cf070) readin no ... { psymtab hello.c ((struct partial_symtab *) 0x2cf09e0) readin no ... This is due to the recursively_search_psymtabs call in psym_expand_symtabs_matching: ... if (recursively_search_psymtabs (ps, objfile, domain, lookup_name, symbol_matcher)) ... which always returns false for symbolless partial symtabs. The same problem occurs with CUs where the dwarf is generated by gas --gdwarf-2 for a foo.S: if we read such a test-case with -readnow, we'll have a symbolless symtab for foo.S. But if we read the test-case with partial symtabs, and expand those using "maint expand-symtabs", the foo.S psymtab remains unexpanded. Fix this by passing a NULL symbol_matcher and lookup_name to expand_symtabs_matching in maintenance_expand_symtabs, and skipping the call to recursively_search_psymtabs if symbol_matcher == NULL and lookup_name == NULL. Build and tested on x86_64-linux, with native. In addition, tested test-case with target boards cc-with-gdb-index.exp, cc-with-debug-names.exp and readnow.exp. gdb/ChangeLog: 2020-04-14 Tom de Vries <tdevries@suse.de> PR symtab/25720 * symmisc.c (maintenance_expand_symtabs): Call expand_symtabs_matching with NULL symbol_matcher and lookup_name. * psymtab.c (psym_expand_symtabs_matching): Handle NULL symbol_matcher and lookup_name. * dwarf2/read.c (dw2_expand_symtabs_matching) (dw2_debug_names_expand_symtabs_matching): Same. * symfile.h (struct quick_symbol_functions::expand_symtabs_matching): Make lookup_name a pointer. Update comment. * symtab.c (global_symbol_searcher::expand_symtabs): Handle lookup_name being a pointer. * symfile.c (expand_symtabs_matching): Same. * symfile-debug.c (debug_qf_expand_symtabs_matching): Same. * linespec.c (iterate_over_all_matching_symtabs): Same. gdb/testsuite/ChangeLog: 2020-04-14 Tom de Vries <tdevries@suse.de> PR symtab/25720 * gdb.base/maint-expand-symbols-header-file.c: New test. * gdb.base/maint-expand-symbols-header-file.exp: New file. * gdb.base/maint-expand-symbols-header-file.h: New test.
Diffstat (limited to 'gdb/symfile.h')
-rw-r--r--gdb/symfile.h13
1 files changed, 8 insertions, 5 deletions
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 84fa283..5ada6c3 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -253,11 +253,14 @@ struct quick_symbol_functions
names (the passed file name is already only the lbasename'd
part).
- Otherwise, if KIND does not match, this symbol is skipped.
+ If the file is not skipped, and SYMBOL_MATCHER and LOOKUP_NAME are NULL,
+ the symbol table is expanded.
- If even KIND matches, SYMBOL_MATCHER is called for each symbol
- defined in the file. The symbol "search" name is passed to
- SYMBOL_MATCHER.
+ 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.
@@ -265,7 +268,7 @@ struct quick_symbol_functions
void (*expand_symtabs_matching)
(struct objfile *objfile,
gdb::function_view<expand_symtabs_file_matcher_ftype> file_matcher,
- const lookup_name_info &lookup_name,
+ const lookup_name_info *lookup_name,
gdb::function_view<expand_symtabs_symbol_matcher_ftype> symbol_matcher,
gdb::function_view<expand_symtabs_exp_notify_ftype> expansion_notify,
enum search_domain kind);