[gdb/testsuite] Fix gdb.base/gold-gdb-index.exp
authorTom de Vries <tdevries@suse.de>
Wed, 14 Jul 2021 09:46:50 +0000 (11:46 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 14 Jul 2021 09:46:50 +0000 (11:46 +0200)
When running test-case gdb.base/gold-gdb-index.exp on openSUSE Tumbleweed,
I run into:
...
FAIL: gdb.base/gold-gdb-index.exp: maint info symtabs
...

This is due to a dummy .gdb_index:
...
Contents of the .gdb_index section:

Version 7

CU table:

TU table:

Address table:

Symbol table:
...

The dummy .gdb_index is ignored when loading the symbols, and instead partial
symbols are used.  Consequently, we get the same result as if we'd removed
-Wl,--gdb-index from the compilation.

Presumably, gold fails to generate a proper .gdb_index because it lacks
DWARF5 support.

Anyway, without a proper .gdb_index we can't test the gdb behaviour we're
trying to excercise.  Fix this by detecting whether we actually used a
.gdb_index for symbol loading.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-07-14  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (have_index): New proc.
* gdb.base/gold-gdb-index.exp: Use have_index.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/gold-gdb-index.exp
gdb/testsuite/lib/gdb.exp

index 7222534045de6de1e77be6f8df36cf9aa5c758f7..16df96bbeb01bdcdd5501e70ca8c21a55683ef8a 100644 (file)
@@ -1,3 +1,8 @@
+2021-07-14  Tom de Vries  <tdevries@suse.de>
+
+       * lib/gdb.exp (have_index): New proc.
+       * gdb.base/gold-gdb-index.exp: Use have_index.
+
 2021-07-13  Pedro Alves  <pedro@palves.net>
 
        PR gdb/28080
index 2a6da322dfd92a8076db00b78df854d66728fcc3..1af756ac0ec14d85feec9c3e19bcbfd1eb1152f7 100644 (file)
@@ -28,7 +28,7 @@ if {[prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
     return -1
 }
 
-if { [readnow] } {
+if { [have_index $binfile] != "gdb_index" } {
     return -1
 }
 
index 38f40fdddb5d8c67b5b685b0c19dd9cfd32441ba..001d18851d929147dedc80609c479e8c2373ad4f 100644 (file)
@@ -7645,6 +7645,34 @@ proc readnow { args } {
     return $readnow_p
 }
 
+# Return index name if symbols were read in using an index.
+# Otherwise, return "".
+
+proc have_index { objfile } {
+
+    set res ""
+    set cmd "maint print objfiles $objfile"
+    gdb_test_multiple $cmd "" -lbl {
+       -re "\r\n.gdb_index: faked for \"readnow\"" {
+           set res ""
+           exp_continue
+       }
+       -re "\r\n.gdb_index:" {
+           set res "gdb_index"
+           exp_continue
+       }
+       -re "\r\n.debug_names:" {
+           set res "debug_names"
+           exp_continue
+       }
+       -re -wrap "" {
+           # We don't care about any other input.
+       }
+    }
+
+    return $res
+}
+
 # Return 1 if partial symbols are available.  Otherwise, return 0.
 
 proc psymtabs_p {  } {
This page took 0.045139 seconds and 4 git commands to generate.