From: Tom de Vries Date: Wed, 3 Sep 2025 15:38:09 +0000 (+0200) Subject: [gdb/testsuite] Fix clean_restart in gdb.dwarf2 X-Git-Tag: gdb-17-branchpoint~54 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1eac6d15fd2b73b26bbc68356ac3c4db5dafdcfd;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix clean_restart in gdb.dwarf2 Fix clean_restart 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. --- diff --git a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp index 8d941bada54..0dd59bb044b 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-aranges.exp @@ -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 } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp index fa9d000b5d1..ed03c279275 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-bad-elf.exp @@ -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] { diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp index 49091f718bc..ff91d637023 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt-2.exp @@ -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 { diff --git a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp index 65d9559f07d..d3049637a71 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-is-stmt.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp b/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp index a8fa524de79..00929690a47 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-multiple-debug-info.exp @@ -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 .*" diff --git a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp index 486a4e87a20..870c8c15a4c 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp @@ -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 } diff --git a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp index 23d8c26f6ad..070865b9396 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-prologue-end.exp @@ -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] { diff --git a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp index f021f4245c7..c6234d56201 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-var-zero-addr.exp @@ -34,7 +34,7 @@ test save_vars { GDBFLAGS } { set GDBFLAGS "$GDBFLAGS --readnow" - clean_restart ${binfile} + clean_restart ${::testfile} } with_test_prefix "readnow" { diff --git a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp index 221bf7b5830..1d2068887b3 100644 --- a/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp +++ b/gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp @@ -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] } { diff --git a/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp b/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp index 44d58a8b3eb..f84f0f38402 100644 --- a/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp +++ b/gdb/testsuite/gdb.dwarf2/entry-value-typedef.exp @@ -31,7 +31,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" executable {c++}] != ""} return } -clean_restart $binfile +clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.dwarf2/fission-base.exp b/gdb/testsuite/gdb.dwarf2/fission-base.exp index 4d18ea0d234..9f70f305466 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-base.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-base.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp index 4f5867c28b5..7072b7e7e3a 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-dw-form-strx.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp index 5be2e8e2123..aa5471821c5 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-loclists-pie.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp index 95c1faced1e..59cd10b5bf5 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-loclists.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-loclists.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/fission-mix.exp b/gdb/testsuite/gdb.dwarf2/fission-mix.exp index e4741c38d34..e6a430c1eba 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-mix.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-mix.exp @@ -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 .*" diff --git a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp index 44e72d60aa8..78f279839a7 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-multi-cu.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/fission-reread.exp b/gdb/testsuite/gdb.dwarf2/fission-reread.exp index 682174784a3..238afb142ce 100644 --- a/gdb/testsuite/gdb.dwarf2/fission-reread.exp +++ b/gdb/testsuite/gdb.dwarf2/fission-reread.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp index ef7cf92a1a3..6857a08af5c 100644 --- a/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp +++ b/gdb/testsuite/gdb.dwarf2/frame-inlined-in-outer-frame.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp b/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp index cd05925bc16..9233637841d 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-add-index-symlink.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp index 3285d1cb961..0fbd3a27006 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-add-index.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp index c0d5225ae76..a8c5c391efb 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-tilde.exp @@ -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 diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp index d6f5e48bf71..effa12759c7 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-index-types-dwarf5.exp @@ -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] diff --git a/gdb/testsuite/gdb.dwarf2/gdb-index.exp b/gdb/testsuite/gdb.dwarf2/gdb-index.exp index ebeb62bb832..f7c3337897d 100644 --- a/gdb/testsuite/gdb.dwarf2/gdb-index.exp +++ b/gdb/testsuite/gdb.dwarf2/gdb-index.exp @@ -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" diff --git a/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp b/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp index c4bacb159c4..cdcb8108fd1 100644 --- a/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp +++ b/gdb/testsuite/gdb.dwarf2/imported-unit-runto-main.exp @@ -77,6 +77,6 @@ if { [ensure_gdb_index $binfile] == -1 } { return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} runto main diff --git a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp index ea871d67147..76656802083 100644 --- a/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp +++ b/gdb/testsuite/gdb.dwarf2/locexpr-data-member-location.exp @@ -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.