mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-01-06 12:09:26 +08:00
70bc38f513
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.
34 lines
1.0 KiB
Plaintext
34 lines
1.0 KiB
Plaintext
# Copyright 2020 Free Software Foundation, Inc.
|
|
|
|
# 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 <http://www.gnu.org/licenses/>. */
|
|
|
|
standard_testfile decl-before-def-decl.c decl-before-def-def.c
|
|
set sources [list $srcfile $srcfile2]
|
|
|
|
if {[prepare_for_testing "failed to prepare" $testfile $sources]} {
|
|
return -1
|
|
}
|
|
|
|
# This is required due to PR25764.
|
|
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\}}
|