diff options
author | Tom de Vries <tdevries@suse.de> | 2020-04-23 15:42:47 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2020-04-23 15:42:47 +0200 |
commit | 70bc38f51381698804566504e25d197e8e731d2d (patch) | |
tree | 7c31c334dd730929ad993f55d6b97d152402e0c8 /gdb/testsuite | |
parent | de82891ce5b6d2c8109f512cd0732325f4cd0557 (diff) | |
download | gdb-70bc38f51381698804566504e25d197e8e731d2d.zip gdb-70bc38f51381698804566504e25d197e8e731d2d.tar.gz gdb-70bc38f51381698804566504e25d197e8e731d2d.tar.bz2 |
[gdb/symtab] Prefer def over decl (inter-CU case, with context)
This is a follow-up patch on "[PATCH][gdb/symtab] Prefer def over decl
(inter-CU case)" (
https://sourceware.org/pipermail/gdb-patches/2020-April/167489.html ).
Consider the test-case from that patch. It contains a decl and def of var a
in different CUs, and tests whether var a can be printed using the def, even
if the decl is found first.
However, the test-case does this in a contextless environment, so if we add to
the test-case like this to set the context to the CU containing main:
...
gdb_test "p a" { = \{1, 2\}}
+
+if ![runto_main] then {
+ fail "can't run to main"
+ return 0
+}
+
+gdb_test "p a" { = \{1, 2\}}
...
then the second test fails, because the decl is found in the context.
Fix this by preferring defs over decls in lookup_global_symbol.
Build and reg-tested on x86_64-linux.
gdb/ChangeLog:
2020-04-23 Tom de Vries <tdevries@suse.de>
* symtab.c (lookup_global_symbol): Prefer def over decl.
gdb/testsuite/ChangeLog:
2020-04-23 Tom de Vries <tdevries@suse.de>
* gdb.base/decl-before-def.exp: Run to main and print a again.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gdb/testsuite/gdb.base/decl-before-def.exp | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index e37aca2..10683db 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,5 +1,9 @@ 2020-04-23 Tom de Vries <tdevries@suse.de> + * gdb.base/decl-before-def.exp: Run to main and print a again. + +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. diff --git a/gdb/testsuite/gdb.base/decl-before-def.exp b/gdb/testsuite/gdb.base/decl-before-def.exp index feb2084..0af3bdf 100644 --- a/gdb/testsuite/gdb.base/decl-before-def.exp +++ b/gdb/testsuite/gdb.base/decl-before-def.exp @@ -24,3 +24,10 @@ if {[prepare_for_testing "failed to prepare" $testfile $sources]} { gdb_test "maint expand-symtabs" gdb_test "p a" { = \{1, 2\}} + +if ![runto_main] then { + fail "can't run to main" + return 0 +} + +gdb_test "p a" { = \{1, 2\}} |