]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.dwarf2
authorTom de Vries <tdevries@suse.de>
Wed, 3 Sep 2025 15:38:09 +0000 (17:38 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 3 Sep 2025 15:38:09 +0000 (17:38 +0200)
Fix clean_restart <absolute filename> in the test-cases in gdb.dwarf2.

Tested on x86_64-linux using gcc-14.

Tested these test-cases on x86_64-linux with target board unix/-m32:
- gdb.dwarf2/valop.exp
- gdb.dwarf2/callframecfa.exp
- gdb.dwarf2/implptr.exp
- gdb.dwarf2/watch-notconst.exp
- gdb.dwarf2/pieces.exp
- gdb.dwarf2/pieces-optimized-out.exp

Tested these test-cases on x86_64-linux with target board fission-dwp:
- gdb.dwarf2/dwp-symlink.exp
- gdb.dwarf2/dwp-sepdebug.exp

Tested test-case gdb.dwarf2/gdb-index-tilde.exp on x86_64-linux by disabling a
too strict home directory check, see PR testsuite/33364.

25 files changed:
gdb/testsuite/gdb.dwarf2/dw2-aranges.exp
gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp
gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp
gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp
gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp
gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp
gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp
gdb/testsuite/gdb.dwarf2/fission-base.exp
gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp
gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp
gdb/testsuite/gdb.dwarf2/fission-loclists.exp
gdb/testsuite/gdb.dwarf2/fission-mix.exp
gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp
gdb/testsuite/gdb.dwarf2/fission-reread.exp
gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp
gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp
gdb/testsuite/gdb.dwarf2/gdb-add-index.exp
gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp
gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp
gdb/testsuite/gdb.dwarf2/gdb-index.exp
gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp
gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp

index 8d941bada547d29c07c0e26d2188c8532db0b781..0dd59bb044b3277f1fe0dd9fdc8b519d0d04f78c 100644 (file)
@@ -32,7 +32,8 @@ Dwarf::assemble $asm_file {
     }
 }
 
-if { [prepare_for_testing "failed to prepare" $binfile  [list $asm_file $srcfile ]] } {
+if { [prepare_for_testing "failed to prepare" $testfile \
+         [list $asm_file $srcfile ]] } {
     return -1
 }
 
index fa9d000b5d10a8f74ba4e8e9b83dc8a857a719c9..ed03c279275dc52d6271a5272a9df936bb43eb41 100644 (file)
@@ -170,7 +170,7 @@ if { [build_executable ${testfile}.exp ${testfile} \
 proc run_test { goto_main } {
     global binfile decimal hex
 
-    clean_restart ${binfile}
+    clean_restart ${::testfile}
 
     if { $goto_main } {
        if ![runto_main] {
index 49091f718bcd364dfb7211d2d99a879142fb5e16..ff91d637023485f44c585fa8196b4ce42fa6ce2a 100644 (file)
@@ -179,7 +179,7 @@ foreach entry $locs {
 # through.  This is checking that the is-stmt marked lines are
 # displayed differently (without addresses) to addresses that are
 # mid-way through a line, or not marked as is-stmt.
-clean_restart $binfile
+clean_restart $::testfile
 runto_main
 
 foreach entry $locs {
index 65d9559f07dfdd6f63d483a80fc8b996497c9b38..d3049637a7168a5ea8a9495ec0bcf703fff3b9e8 100644 (file)
@@ -116,7 +116,7 @@ gdb_test "step" "/\\* main end \\*/" \
 
 # Restart the test.  This time, stop at a location we know is marked
 # as a statement.
-clean_restart ${binfile}
+clean_restart ${::testfile}
 runto_main
 
 gdb_breakpoint "*line_label_3"
@@ -129,7 +129,7 @@ gdb_test "step" "/\\* main end \\*/" \
 
 # Restart the test, this time, step through line by line, ensure we
 # only stop at the places where is-stmt is true.
-clean_restart ${binfile}
+clean_restart ${::testfile}
 runto_main
 
 # Get the values of the labels where we expect to stop.
@@ -161,7 +161,7 @@ with_test_prefix "step to line_label_5" {
 
 # Now restart the test, and place a breakpoint by line number.  GDB
 # should select the location that is marked as is-stmt.
-clean_restart ${binfile}
+clean_restart ${::testfile}
 runto_main
 set linum [gdb_get_line_number "main, set var to 0"]
 gdb_breakpoint "$srcfile:$linum"
@@ -171,7 +171,7 @@ gdb_assert { $ll3 == $pc } "check initial \$pc"
 
 # Restart the test again, this time we will test stepping by
 # instruction.
-clean_restart ${binfile}
+clean_restart ${::testfile}
 runto_main
 
 # We will be at line_label_1 at this point - we already tested this
index a8fa524de795448651ede8f10f228afbfabe4eca..00929690a4739290866d833d54764e6addbda057 100644 (file)
@@ -31,6 +31,6 @@ if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" object \
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 gdb_test "ptype a" "type = class sp1::A .*"
index 486a4e87a20bc46c1dcca10c6204445799cc65b8..870c8c15a4cd17609b2a169b4cd270a89da4d702 100644 (file)
@@ -134,7 +134,7 @@ set re_address_class "@\[^\r\n\]+"
 proc do_console_test {} {
     global binfile
 
-    clean_restart $binfile
+    clean_restart $::testfile
 
     with_test_prefix "console" {
        gdb_test_no_output "set print object on"
@@ -173,7 +173,7 @@ proc do_mi_test {} {
     global binfile
     
     with_test_prefix "mi" {
-       if {[mi_clean_restart $binfile]} {
+       if {[mi_clean_restart $::testfile]} {
            return
        }
        
index 23d8c26f6ad62684db27920d1cea87ba55ebdd78..070865b939669e61e8605e037fa4ccdbe5b0fd33 100644 (file)
@@ -91,7 +91,7 @@ set prologue_end_line [gdb_get_line_number "main assign o"]
 gdb_test "frame" ".*main \\\(\\\) at \[^\r\n\]*:$prologue_end_line\r\n.*"
 
 with_test_prefix "ignore-prologue-end" {
-    clean_restart $binfile
+    clean_restart $::testfile
     gdb_test_no_output "maintenance set ignore-prologue-end-flag on"
 
     if ![runto_main] {
index f021f4245c761a8f87481a77283635367f13f5a0..c6234d5620172cdb3ab7bad6942e90114b2f7a49 100644 (file)
@@ -34,7 +34,7 @@ test
 
 save_vars { GDBFLAGS } {
     set GDBFLAGS "$GDBFLAGS --readnow"
-    clean_restart ${binfile}
+    clean_restart ${::testfile}
 }
 
 with_test_prefix "readnow" {
index 221bf7b58305fb492071646539456e4abc448b1e..1d2068887b384e815c1c9efe77e82a318d3bc80b 100644 (file)
@@ -26,7 +26,8 @@ standard_testfile .c -shlib.c -dw.S
 # Test for presence of complaint, with the lib relocated.
 
 proc_with_prefix test_relocated { exec_path lib_path complaint_re readnow_p } {
-    clean_restart $exec_path
+    clean_restart
+    gdb_load $exec_path
     gdb_load_shlib $lib_path
 
     if { ![runto_main] } {
index 44d58a8b3ebbc607cd5a82635344e855cf16073b..f84f0f38402a90185e8ebcf51f92fbfc20aa2794 100644 (file)
@@ -31,7 +31,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" executable {c++}] != ""}
     return
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if {![runto_main]} {
     return
index 4d18ea0d234a005160834bfdfb887f32b8e56cb3..9f70f305466abe55dc37d5efe0e7ea22dc15fb52 100644 (file)
@@ -35,7 +35,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if ![runto_main] {
     return -1
index 4f5867c28b5935c0ae784f3672d69ff9dbf899cb..7072b7e7e3a063ae26a2df4351838b6d00de8e77 100644 (file)
@@ -83,6 +83,6 @@ if { [is_remote host] } {
     gdb_remote_download host $dwo_file
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 gdb_test "ptype global_var" "type = int"
index 5be2e8e2123191884e2395deee7cc567a0cf1cbf..aa5471821c5b797c0af7b6ad5d811dc8341d72f3 100644 (file)
@@ -40,7 +40,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" \
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if ![runto_main] {
     return -1
index 95c1faced1e3e0f78215603707eacd5ec82a83f6..59cd10b5bf527b26518ecccc11bd8b651b7d780c 100644 (file)
@@ -35,7 +35,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if ![runto_main] {
     return -1
index e4741c38d34c8e47eda4e5f9cff2b447f0864ec5..e6a430c1eba0463222f481a3bc141336f6119bb8 100644 (file)
@@ -35,7 +35,7 @@ if {[gdb_compile "$objfile $objfile2" $binfile executable {debug}] != "" } {
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 gdb_test "break -q main" "Breakpoint .*"
 
index 44e72d60aa8d86ae0b37f980a09bbe941fa91137..78f279839a7d3bf1b65cf793014e0506245d860e 100644 (file)
@@ -203,7 +203,7 @@ if [build_executable_and_dwo_files "$testfile.exp" "${binfile}" {nodebug} \
     return -1
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if ![runto_main] {
     return -1
index 682174784a35a0d2f245182cd502baae14366afe..238afb142ce00c0e035a35350f7a6e7ff15f136d 100644 (file)
@@ -62,7 +62,7 @@ pass "$testfile - unload"
 remote_file target delete $dwo
 save_vars { GDBFLAGS } {
     append GDBFLAGS " -iex \"maint set dwarf synchronous on\""
-    clean_restart $binfile
+    clean_restart $::testfile
 }
 set output_dir [standard_output_file ""]
 set cmd "save gdb-index"
index ef7cf92a1a3eb4ede6cc59a8e581f406492ca101..6857a08af5cd16e7e3920a9d401f598736d56ac9 100644 (file)
@@ -106,7 +106,7 @@ if { [build_executable ${testfile}.exp ${testfile} "$srcfile $dwarf_asm" \
     return
 }
 
-clean_restart $binfile
+clean_restart $::testfile
 
 if { [gdb_starti_cmd] != 0 } {
     fail "failed to run to first instruction"
index cd05925bc166d6385e57f17415a322620f5124ab..9233637841d69a8ffd40ea2ed0114ad8e32d16f0 100644 (file)
@@ -56,7 +56,8 @@ if { [ensure_gdb_index $symlink] == -1 } {
 # Ok, we have a copy of $binfile with an index.
 # Restart gdb and verify the index was used.
 
-clean_restart $symlink
+clean_restart
+gdb_load $symlink
 gdb_test "mt print objfiles ${testfile}" \
     "(gdb_index|debug_names).*" \
     "index used"
index 3285d1cb961cda1c9e692345a06c0bf4dddd26ef..0fbd3a27006efad2e9872dd284d30959579ac00d 100644 (file)
@@ -33,7 +33,7 @@ if { [ensure_gdb_index $binfile] == -1 } {
 # Ok, we have a copy of $binfile with an index.
 # Restart gdb and verify the index was used.
 
-clean_restart ${binfile}
+clean_restart ${::testfile}
 gdb_test "mt print objfiles ${testfile}" \
     "(gdb_index|debug_names).*" \
     "index used"
index c0d5225ae760e9c67535e937eec98e0e93dacf1c..a8c5c391efba5e7656aeee50b7930cc13f344134 100644 (file)
@@ -47,7 +47,7 @@ if { [prepare_for_testing "failed to prepare" "${testfile}" ${srcfile}] } {
 }
 
 # Start GDB and load in the executable.
-clean_restart ${binfile}
+clean_restart ${::testfile}
 
 # If the executable was built with an index, or lacks the debug
 # information required to create an index, then we'll not be able to
index d6f5e48bf71735a034019cfbebdaafa99c4a1db5..effa12759c76a1bb9f3041ead1ba184d4c0e0d7d 100644 (file)
@@ -29,7 +29,7 @@ if { [ensure_gdb_index $binfile] != 1 } {
     return -1
 }
 
-clean_restart ${binfile}
+clean_restart ${::testfile}
 
 # Verify that .gdb_index section is not ignored.
 set index [have_index $binfile]
index ebeb62bb8326ad0bb22cab5dea6bcb44ead272e4..f7c3337897da9f2d92595543c1f67eac319e3729 100644 (file)
@@ -98,20 +98,24 @@ set test "check if index present"
 set filter "gdb_index|debug_names|Psymtabs|Cooked"
 set cmd "pipe mt print objfiles ${testfile} | grep -E \"$filter\""
 set cmd_re [string_to_regexp $cmd]
+set testfile_with_index bla
 gdb_test_multiple $cmd $test {
     -re ^$cmd_re {
        exp_continue
     }
     -re "gdb_index.*${gdb_prompt} $" {
-       set binfile_with_index $binfile
+       set testfile_with_index $testfile
+       set binfile_with_index [standard_output_file $testfile_with_index]
        set host_binfile_with_index [gdb_remote_download host $binfile]
     }
     -re "debug_names.*${gdb_prompt} $" {
-       set binfile_with_index $binfile
+       set testfile_with_index $testfile
+       set binfile_with_index [standard_output_file $testfile_with_index]
        set host_binfile_with_index [gdb_remote_download host $binfile]
     }
     -re "(Psymtabs|Cooked).*${gdb_prompt} $" {
        lassign [local_add_gdb_index $binfile] binfile_with_index host_binfile_with_index
+       set testfile_with_index [file tail $binfile_with_index]
        if { ${binfile_with_index} == "" } {
            return -1
        }
@@ -124,7 +128,7 @@ gdb_test_multiple $cmd $test {
 # Ok, we have a copy of $binfile with an index.
 # Restart gdb and verify the index was used.
 
-clean_restart ${binfile_with_index}
+clean_restart $testfile_with_index
 gdb_test "mt print objfiles ${testfile}" \
     "(gdb_index|debug_names).*" \
     "index used"
index c4bacb159c478ae59f25bb32a09ceb9e7893f17e..cdcb8108fd10384087e65901ffcb56674ba07897 100644 (file)
@@ -77,6 +77,6 @@ if { [ensure_gdb_index $binfile] == -1 } {
     return -1
 }
 
-clean_restart ${binfile}
+clean_restart ${::testfile}
 
 runto main
index ea871d671472c80094a485da7554343c3982f5cf..766568020838a5f7d89eeed0c8d1a44022aa0b12 100644 (file)
@@ -330,7 +330,7 @@ if {[gdb_compile_shlib [list $libsrc $asm_file] $lib_so \
 ### Second GDB session.
 
 with_test_prefix "second session" {
-    clean_restart $binfile
+    clean_restart $::testfile
 
     # Again, do whatever is necessary to make sure that the shared library is
     # loaded for remote targets.