[gdb/testsuite] Fix clean_restart <absolute filename> in gdb.base, part 2

Manually fix the test-cases found by:
...
$ find gdb/testsuite/gdb.base -name *.exp* \
  | xargs grep -l 'clean_restart[^;]*binfile'
$ find gdb/testsuite/gdb.base -name *.exp* \
  | xargs grep -l 'prepare_for_testing.*bin'
...
except for gdb.base/foll-vfork.exp and gdb.base/solib-overlap.exp.

Tested on x86_64-linux.
This commit is contained in:
Tom de Vries
2025-09-05 15:36:23 +02:00
parent 202beb3fee
commit 2e61486fce
31 changed files with 69 additions and 42 deletions

View File

@@ -52,7 +52,8 @@ proc prepare_test {has_cfi} {
return false
}
clean_restart "$binfile-${extension}"
clean_restart
gdb_load $binfile-$extension
if ![runto callback] then {
fail "has_cfi=$has_cfi: Can't run to callback"

View File

@@ -26,7 +26,7 @@
standard_testfile
if { [prepare_for_testing "failed to prepare" ${binfile} "${srcfile}" \
if { [prepare_for_testing "failed to prepare" $testfile $srcfile \
{debug c++}] == -1 } {
return
}

View File

@@ -44,7 +44,8 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {d
# on the first instruction of function "main" ("*main"), then
# run to that breakpoint.
clean_restart ${binfile1}
clean_restart
gdb_load $binfile1
with_test_prefix "${testfile1}" {

View File

@@ -161,7 +161,7 @@ foreach_with_prefix pie { "nopie" "pie" } {
set binfile [standard_output_file $testfile-$pie]
if {[prepare_for_testing "failed to prepare" $binfile $srcfile $opts]} {
if {[prepare_for_testing "failed to prepare" $testfile-$pie $srcfile $opts]} {
continue
}

View File

@@ -46,7 +46,7 @@ proc start_scalars_test { type } {
set testfile "call-sc-${type}"
set binfile [standard_output_file ${testfile}]
if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return -1
}

View File

@@ -17,7 +17,7 @@
standard_testfile
if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}

View File

@@ -17,7 +17,7 @@
standard_testfile
if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}

View File

@@ -517,7 +517,7 @@ foreach testspec $specs {
# These tests don't rely on the debug format.
with_test_prefix nodebug {
if { [prepare_for_testing "failed to prepare" $binfile $srcfile {nodebug}] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile {nodebug}] } {
return 0
}

View File

@@ -22,7 +22,7 @@
standard_testfile
if {[prepare_for_testing "failed to prepare" ${binfile} ${srcfile}]} {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return
}

View File

@@ -68,7 +68,8 @@ proc do_exec_tests { execer_lang execee_lang } {
}
# Now we can start running the tests.
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
if {![runto_main]} {
@@ -93,7 +94,8 @@ proc do_exec_tests { execer_lang execee_lang } {
return
}
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -182,7 +184,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -250,7 +253,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -317,7 +321,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
#
@@ -378,7 +383,8 @@ proc do_exec_tests { execer_lang execee_lang } {
# Explicitly kill this program, or a subsequent rerun actually runs
# the exec'd program, not the original program...
clean_restart $execer_binfile
clean_restart
gdb_load $execer_binfile
# Start the program running, and stop at main.
#

View File

@@ -38,7 +38,8 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] {
set perm [file attributes ${binfile} -permissions]
file attributes ${stripped_binfile} -permissions $perm
clean_restart ${stripped_binfile}
clean_restart
gdb_load $stripped_binfile
# The binary is stripped of debug info, but not minsyms.
if ![runto break_here] {

View File

@@ -42,7 +42,8 @@ if [run_on_host "strip" "$strip_program" "-g -o ${stripped_binfile} $binfile"] {
set perm [file attributes ${binfile} -permissions]
file attributes ${stripped_binfile} -permissions $perm
clean_restart ${stripped_binfile}
clean_restart
gdb_load $stripped_binfile
# The binary is stripped of debug info, but not minsyms.
if ![runto break_here] {

View File

@@ -90,13 +90,15 @@ foreach_with_prefix flag { "" "-dwarf-5" } {
}
# Add the index section to the executable.
clean_restart ${binfile}.${extension}
clean_restart
gdb_load $binfile.$extension
gdb_assert {[ensure_gdb_index ${binfile}.${extension} ${flag}] == 1} \
"add index to executable"
# Reload the executable (which now has an index), and try to
# generate and index from it. This will fail.
clean_restart ${binfile}.${extension}
clean_restart
gdb_load $binfile.$extension
gdb_test "save gdb-index ${flag} $already_indexed_dir" \
"Error while writing index for `[string_to_regexp $binfile.$extension]': Cannot use an index to create the index" \
"try to generate an index from a binary with an index"

View File

@@ -96,7 +96,8 @@ proc_with_prefix set-break {resolver_attr resolver_debug final_debug} {
set suffix [make_binsuffix $resolver_attr $resolver_debug $final_debug]
set lib_so [standard_output_file ${libfile}-$suffix.so]
clean_restart $binfile-$suffix
clean_restart
gdb_load $binfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {
@@ -223,7 +224,8 @@ proc misc_tests {resolver_attr resolver_debug final_debug} {
# Start with a fresh gdb.
clean_restart $binfile-$suffix
clean_restart
gdb_load $binfile-$suffix
gdb_load_shlib ${lib_so}
if {![runto_main]} {

View File

@@ -35,7 +35,8 @@ standard_testfile
proc do_test { threads non-stop } {
save_vars { ::GDBFLAGS } {
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
clean_restart $::binfile-$threads
clean_restart
gdb_load $::binfile-$threads
}
gdb_test "info program" \

View File

@@ -46,7 +46,8 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } {
return
}
clean_restart $::main_binfile
clean_restart
gdb_load $::main_binfile
if { ![runto_main] } {
return
}

View File

@@ -54,7 +54,8 @@ if { [compile_jit_main ${main_srcfile} ${main_binfile} {}] != 0 } {
# that the callers can continue execution until there.
proc do_setup { detach-on-fork follow-fork-mode } {
clean_restart ${::main_binfile}
clean_restart
gdb_load $::main_binfile
gdb_test_no_output "set detach-on-fork ${detach-on-fork}"
gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}"

View File

@@ -73,7 +73,8 @@ proc one_jit_test {solib_binfiles_target match_str} {
global main_loader_binfile main_loader_srcfile
global main_solib_binfile main_solib_binfile_target main_solib_srcfile
clean_restart $main_loader_binfile
clean_restart
gdb_load $main_loader_binfile
gdb_locate_shlib $main_solib_binfile
# This is just to help debugging when things fail

View File

@@ -48,7 +48,8 @@ proc clean_reattach {} {
gdb_test_no_output "set var wait_for_gdb = 1"
gdb_test "detach" "Detaching from .*"
clean_restart ${main_binfile}
clean_restart
gdb_load $main_binfile
if { ![gdb_attach $testpid \
-pattern "main.*at .*$::main_basename.c:.*"] } {
@@ -84,7 +85,8 @@ proc one_jit_test {jit_solibs_target match_str reattach} {
global test_verbose
global main_binfile main_srcfile
clean_restart ${main_binfile}
clean_restart
gdb_load $main_binfile
# This is just to help debugging when things fail
if {$test_verbose > 0} {

View File

@@ -106,7 +106,8 @@ proc jit_test_reread {standalone change_addr} {
clean_restart
gdb_load $binfile
} else {
clean_restart $binfile_dl
clean_restart
gdb_load $binfile_dl
}
runto_main
@@ -176,7 +177,8 @@ foreach standalone {1 0} {
# see JIT breakpoints defined for both.
with_test_prefix "two JITers" {
clean_restart $binfile_dl2
clean_restart
gdb_load $binfile_dl2
if {![runto_main]} {
return -1

View File

@@ -53,7 +53,8 @@ proc test { src name } {
return
}
clean_restart [host_file_normalize $binfile]
clean_restart
gdb_load [host_file_normalize $binfile]
if { ![runto_main] } {
return

View File

@@ -30,7 +30,7 @@ proc compile_and_run_tests { lang } {
lappend flags "additional_flags=-std=c++11"
}
if { [prepare_for_testing "failed to prepare" "${binfile}" "${srcfile}" "${flags}"] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return 0
}

View File

@@ -26,7 +26,7 @@ if { [build_executable "failed to build" $testfile $srcfile { debug }] == -1 } {
save_vars { GDBFLAGS } {
append GDBFLAGS " --readnever"
if { [clean_restart ${binfile}] == -1 } {
if { [clean_restart $testfile] == -1 } {
return -1
}
}

View File

@@ -114,7 +114,8 @@ if { [gdb_compile ${srcfile_main} ${binfile_main} executable $main_flags] != ""
return -1
}
clean_restart ${binfile_main}
clean_restart
gdb_load $binfile_main
if {![runto_main]} {
return 0

View File

@@ -309,7 +309,8 @@ with_test_prefix "step using -fi + -fu" {
with_test_prefix "skip delete completion" {
global binfile
clean_restart "${binfile}"
clean_restart
gdb_load $binfile
if ![runto_main] {
return
}

View File

@@ -56,7 +56,7 @@ proc start_structs_test { types } {
}
set binfile [standard_output_file ${testfile}]
if { [prepare_for_testing "failed to prepare" $binfile $srcfile $flags] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile $flags] } {
return -1
}

View File

@@ -15,7 +15,7 @@
standard_testfile .c
if { [prepare_for_testing "failed to prepare" $binfile $srcfile {debug}] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] } {
return -1
}

View File

@@ -77,7 +77,7 @@ proc run_style_tests { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
clean_restart_and_disable "restart 1" ${binfile}
clean_restart_and_disable "restart 1" $::testfile
set readnow [readnow]
@@ -358,7 +358,7 @@ proc test_disable_disassembler_styling { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
clean_restart_and_disable "restart 3" $::binfile
clean_restart_and_disable "restart 3" $::testfile
set styled_hex [limited_style $::hex address]
set main [limited_style main function]
@@ -473,7 +473,7 @@ proc test_disassembler_error_handling { } {
# Restart GDB with the correct TERM variable setting, this
# means that GDB will enable styling.
clean_restart_and_disable "restart 4" $::binfile
clean_restart_and_disable "restart 4" $::testfile
# Disable use of libopcodes for styling. As this function is
# only called when Python Pygments module is available, we

View File

@@ -61,7 +61,8 @@ if {[gdb_compile_shlib $libsrc $lib_so {debug}] != ""} {
return
}
if {[prepare_for_testing "failed to prepare" $binfile "$srcfile $srcfile2" $exec_opts]} {
if { [prepare_for_testing "failed to prepare" $testfile "$srcfile $srcfile2" \
$exec_opts] } {
return
}

View File

@@ -27,7 +27,7 @@ standard_testfile .c
# Compile binary
# and start with a fresh gdb
if { [prepare_for_testing "failed to prepare" ${binfile} ${srcfile}] } {
if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } {
return -1
}

View File

@@ -106,7 +106,8 @@ proc do_tests {force_internal_tls {do_kfail_tls_access 0}} {
set objcopy [gdb_find_objcopy]
set cmd "$objcopy --strip-debug ${::binfile} $binfile_stripped"
if ![catch "exec $cmd" cmd_output] {
clean_restart $binfile_stripped
clean_restart
gdb_load $binfile_stripped
if ![runto_main] {
return
}