aboutsummaryrefslogtreecommitdiff
path: root/gdb/block.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-04-23 15:42:47 +0200
committerTom de Vries <tdevries@suse.de>2020-04-23 15:42:47 +0200
commitde82891ce5b6d2c8109f512cd0732325f4cd0557 (patch)
treefc6456d024f830a8cd7d5303c8dd00ad3c1bbf23 /gdb/block.c
parentecc6c6066b5cdd4663413e0bd6ef8deea1a8c889 (diff)
downloadbinutils-de82891ce5b6d2c8109f512cd0732325f4cd0557.zip
binutils-de82891ce5b6d2c8109f512cd0732325f4cd0557.tar.gz
binutils-de82891ce5b6d2c8109f512cd0732325f4cd0557.tar.bz2
[gdb/symtab] Prefer def over decl (inter-CU case)
When running test-case gdb.threads/tls.exp with target board -readnow, we have: ... (gdb) print a_thread_local^M Cannot find thread-local storage for process 0, executable file tls/tls:^M Cannot find thread-local variables on this target^M (gdb) FAIL: gdb.threads/tls.exp: print a_thread_local ... while with native we have: ... (gdb) print a_thread_local^M Cannot read `a_thread_local' without registers^M (gdb) PASS: gdb.threads/tls.exp: print a_thread_local ... The difference in behaviour can be explained as follows. Without -readnow, we have two a_thread_locals, the def and the decl, each in a different CU: ... $ gdb -batch outputs/gdb.threads/tls/tls \ -ex "maint expand-symtabs" \ -ex "print a_thread_local" \ -ex "maint print symbols" \ | grep "a_thread_local;" Cannot read `a_thread_local' without registers int a_thread_local; computed at runtime int a_thread_local; unresolved ... and with -readnow, we have the opposite order: ... $ gdb -readnow -batch outputs/gdb.threads/tls/tls \ -ex "maint expand-symtabs" \ -ex "print a_thread_local" \ -ex "maint print symbols" \ | grep "a_thread_local;" Cannot find thread-local storage for process 0, executable file tls/tls: Cannot find thread-local variables on this target int a_thread_local; unresolved int a_thread_local; computed at runtime ... Fix the FAIL by preferring the def over the decl (something we already do intra-CU since the fix for PR24971, commit 93e55f0a03 "[gdb/symtab] Prefer var def over decl"). Build and reg-tested on x86_64-linux. gdb/ChangeLog: 2020-04-23 Tom de Vries <tdevries@suse.de> PR symtab/25807 * block.c (best_symbol, better_symbol): Promote to external. * block.h (best_symbol, better_symbol): Declare. * symtab.c (lookup_symbol_in_objfile_symtabs): Prefer def over decl. gdb/testsuite/ChangeLog: 2020-04-23 Tom de Vries <tdevries@suse.de> * gdb.base/decl-before-def-decl.c: New test. * gdb.base/decl-before-def-def.c: New test. * gdb.base/decl-before-def.exp: New file.
Diffstat (limited to 'gdb/block.c')
-rw-r--r--gdb/block.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gdb/block.c b/gdb/block.c
index 9b58243..597d6d5 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -657,19 +657,18 @@ block_iter_match_next (const lookup_name_info &name,
return block_iter_match_step (iterator, name, 0);
}
-/* Return true if symbol A is the best match possible for DOMAIN. */
+/* See block.h. */
-static bool
+bool
best_symbol (struct symbol *a, const domain_enum domain)
{
return (SYMBOL_DOMAIN (a) == domain
&& SYMBOL_CLASS (a) != LOC_UNRESOLVED);
}
-/* Return symbol B if it is a better match than symbol A for DOMAIN.
- Otherwise return A. */
+/* See block.h. */
-static struct symbol *
+struct symbol *
better_symbol (struct symbol *a, struct symbol *b, const domain_enum domain)
{
if (a == NULL)