aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-03-31 12:17:27 +0200
committerTom de Vries <tdevries@suse.de>2020-03-31 12:17:27 +0200
commit16b0db75af6b4b4d434aa84c74d58b7290e04143 (patch)
treebd982707c9f86e8686e64e7e5a19bc096462b559
parent89b599df37111317b9bc6fab541eb94c8b0bea35 (diff)
downloadfsf-binutils-gdb-16b0db75af6b4b4d434aa84c74d58b7290e04143.zip
fsf-binutils-gdb-16b0db75af6b4b4d434aa84c74d58b7290e04143.tar.gz
fsf-binutils-gdb-16b0db75af6b4b4d434aa84c74d58b7290e04143.tar.bz2
[gdb/testsuite] Fix c-linkage-name.exp with -flto
When running test-case gdb.base/c-linkage-name.exp with target board unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects, I run into: ... PASS: gdb.base/c-linkage-name.exp: maint info psymtab: c-linkage-name-2.c: no FAIL: gdb.base/c-linkage-name.exp: print symada__cS before partial symtab \ expansion ... The test-case tries to print a symbol before and after symtab expansion. And it tries to ensure (since commit 13c3a74afb) that the symtab containing the symbol is not yet expanded when doing the 'before' print, by placing the symbol in a different CU (c-linkage-name-2.c) from the one containing main (c-linkage-name.c), such that when we load the exec and expand the symtab containing main, the symtab containing the symbol isn't. The generated debug info for the test-case when using mentioned target board however is structured like this: ... <0><d2>: Abbrev Number: 1 (DW_TAG_compile_unit) <d8> DW_AT_name : <artificial> <1><f4>: Abbrev Number: 2 (DW_TAG_imported_unit) <f5> DW_AT_import : <0x16b> [Abbrev Number: 1] <1><f9>: Abbrev Number: 2 (DW_TAG_imported_unit) <fa> DW_AT_import : <0x19c> [Abbrev Number: 1] <1><fe>: Abbrev Number: 3 (DW_TAG_subprogram) <ff> DW_AT_abstract_origin: <0x17d> <1><115>: Abbrev Number: 4 (DW_TAG_variable) <116> DW_AT_abstract_origin: <0x1ce> <0><16b>: Abbrev Number: 1 (DW_TAG_compile_unit) <171> DW_AT_name : c-linkage-name.c <1><17d>: Abbrev Number: 2 (DW_TAG_subprogram) <17e> DW_AT_name : main <0><19c>: Abbrev Number: 1 (DW_TAG_compile_unit) <1a2> DW_AT_name : c-linkage-name-2.c <1><1ce>: Abbrev Number: 5 (DW_TAG_variable) <1cf> DW_AT_name : mundane <1d6> DW_AT_linkage_name: symada__cS ... So, the CU named <artificial> contains both the concrete main and the concrete symbol, which explains the FAIL. The first test should fail, but passes for two reasons. First of all, due to PR symtab/25700, we have two regular partial symtabs c-linkage-name-2.c instead of one, and one of them is expanded, the other one not: ... { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38d6f60) readin yes { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38d6fe0) readin no ... And then there's the include symtab, which is also not expanded: ... { psymtab c-linkage-name-2.c ((struct partial_symtab *) 0x38143e0) readin no ... Fix the FAIL by explicitly setting the language before load, changing the language setting from auto/c to manual/c, such that the symtab containing main is no longer expanded. And make the symtab expansion testing more robust by using the output of "maint info symtabs" instead of "maint info psymtabs". Tested on x86_64-linux, using native and target boards cc-with-gdb-index.exp, cc-with-debug-names.exp, readnow.exp and unix/-flto/-O0/-flto-partition=none/-ffat-lto-objects. gdb/testsuite/ChangeLog: 2020-03-31 Tom de Vries <tdevries@suse.de> * gdb.base/c-linkage-name.exp: Fix test-case comment. Set language to c. Use "maint info symtabs" to check symtab expansion.
-rw-r--r--gdb/testsuite/ChangeLog5
-rw-r--r--gdb/testsuite/gdb.base/c-linkage-name.exp20
2 files changed, 18 insertions, 7 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 9d879fb..bb31bcd 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2020-03-31 Tom de Vries <tdevries@suse.de>
+
+ * gdb.base/c-linkage-name.exp: Fix test-case comment. Set language to
+ c. Use "maint info symtabs" to check symtab expansion.
+
2020-03-30 Tom de Vries <tdevries@suse.de>
* gdb.base/c-linkage-name.exp: Use readnow call to mark a test
diff --git a/gdb/testsuite/gdb.base/c-linkage-name.exp b/gdb/testsuite/gdb.base/c-linkage-name.exp
index 9a472a7..8afd8ce 100644
--- a/gdb/testsuite/gdb.base/c-linkage-name.exp
+++ b/gdb/testsuite/gdb.base/c-linkage-name.exp
@@ -14,8 +14,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This file is part of the gdb testsuite. It is intended to test that
-# gdb can correctly print arrays with indexes for each element of the
-# array.
+# gdb can correctly print an ada symbol with linkage name before and after
+# symtab expansion.
standard_testfile c-linkage-name.c c-linkage-name-2.c
@@ -25,13 +25,19 @@ if { [gdb_compile "${sources}" "${binfile}" executable {debug}] != "" } {
return -1
}
-clean_restart ${binfile}
+clean_restart
+gdb_test_no_output "set language c"
+gdb_load ${binfile}
set readnow [readnow]
-# Verify that partial symtab expansion has not taken place for
-# c-linkage-name-2.c.
+set test "verify no symtab expansion"
+if { $readnow } {
+ unsupported $test
+} else {
+ # Verify that symtab expansion has not taken place.
-verify_psymtab_expanded c-linkage-name-2.c no
+ gdb_test_no_output "maint info symtabs" $test
+}
set test "print symada__cS before partial symtab expansion"
if { $readnow } {
@@ -54,7 +60,7 @@ gdb_test "break do_something_other_cu" \
# Verify that partial symtab expansion has taken place for
# c-linkage-name-2.c.
-verify_psymtab_expanded c-linkage-name-2.c yes
+gdb_test "maint info symtabs" "\{ symtab \[^\r\n\]*c-linkage-name-2.c.*"
# Flush the symbol cache to prevent the lookup to return the same as before.