[PATCH] [gdb/testsuite] Simplify gdb.dwarf2/forward-spec.exp

Tom de Vries tdevries@suse.de
Wed Sep 11 08:17:27 GMT 2024


Test-case gdb.dwarf2/forward-spec.exp contains a non-trivial gdb_test_multiple
to parse this cooked_index_entry:
...
    [5] ((cooked_index_entry *) 0x7f01f0004040)^M
    name:       v^M
    canonical:  v^M
    qualified:  ns::v^M
    DWARF tag:  DW_TAG_variable^M
    flags:      0x2 [IS_STATIC]^M
    DIE offset: 0xcb^M
    parent:     ((cooked_index_entry *) 0x7f01f00040a0) [ns]^M
...
which allows us to verify that the entry has a parent.

After commit 8f258a6c979 ("[gdb/symtab] Dump qualified name of
cooked_index_entry") that's no longer necessary.

Simplify this by checking for ns::v instead.

While we're at it, also fix the test-case for target boards readnow,
cc-with-gdb-index and cc-with-debug-names.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.dwarf2/forward-spec.exp | 40 +++++++----------------
 1 file changed, 12 insertions(+), 28 deletions(-)

diff --git a/gdb/testsuite/gdb.dwarf2/forward-spec.exp b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
index b045c02a6a2..18d9c5a1bd7 100644
--- a/gdb/testsuite/gdb.dwarf2/forward-spec.exp
+++ b/gdb/testsuite/gdb.dwarf2/forward-spec.exp
@@ -16,6 +16,8 @@
 # Check that the DWARF reader works with a a DW_AT_specification that
 # refers to a later DIE.
 
+require !readnow
+
 load_lib dwarf.exp
 
 # This test can only be run on targets which support DWARF-2 and use gas.
@@ -72,31 +74,13 @@ if {[prepare_for_testing "failed to prepare" ${testfile} \
     return -1
 }
 
-set in_v 0
-gdb_test_multiple "maint print objfiles" "v has a parent" {
-    -re "^ *\\\[\[0-9\]\\\] *\\(\\(cooked_index_entry\[^\r\n\]*" {
-	set in_v 0
-	exp_continue
-    }
-    -re "^ *name: *v\[\r\n\]*" {
-	set in_v 1
-	exp_continue
-    }
-    -re "^ *parent: *\\(\\(cooked_index_entry \\*\\) (0|$hex)\\)" {
-	if {$in_v} {
-	    if {$expect_out(1,string) == "0"} {
-		fail $gdb_test_name
-	    } else {
-		pass $gdb_test_name
-	    }
-	    set in_v 0
-	}
-	exp_continue
-    }
-    -re "^\[^\r\n\]*\[\r\n\]+" {
-	exp_continue
-    }
-    -re "$gdb_prompt " {
-	# Done.
-    }
-}
+require {string equal [have_index $binfile] ""}
+
+set re_ws "\[ \t\]"
+
+gdb_test "maint print objfiles" \
+    [multi_line \
+	 "" \
+	 "$re_ws+qualified:$re_ws+ns::v" \
+	 ".*"] \
+    "v has a parent"

base-commit: 8e98b4aa43deebf76f4bff2eaac0165ce6eb4c1b
-- 
2.35.3



More information about the Gdb-patches mailing list