From: Tom de Vries Date: Wed, 3 Sep 2025 09:53:08 +0000 (+0200) Subject: [gdb/testsuite] Fix clean_restart in gdb.python X-Git-Tag: gdb-17-branchpoint~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c1e9f1454faaa0b66a2b32e17201f4613b9bc0c4;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix clean_restart in gdb.python Fix clean_restart in the test-cases in gdb.python. Tested on x86_64-linux. --- diff --git a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp index dd6cb595a8d..17b8afe8a13 100644 --- a/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp +++ b/gdb/testsuite/gdb.python/pretty-print-call-by-hand.exp @@ -39,7 +39,7 @@ proc start_test { breakpoint_comment } { # Start with a fresh gdb. # This is important because the test can crash GDB. - clean_restart ${binfile} + clean_restart ${::testfile} if {![runto_main]} { untested "couldn't run to breakpoint" diff --git a/gdb/testsuite/gdb.python/py-disasm.exp.tcl b/gdb/testsuite/gdb.python/py-disasm.exp.tcl index c5099bac22c..5f4574702e7 100644 --- a/gdb/testsuite/gdb.python/py-disasm.exp.tcl +++ b/gdb/testsuite/gdb.python/py-disasm.exp.tcl @@ -24,14 +24,16 @@ standard_testfile py-disasm.c if { $kind == "obj" } { - set obj [standard_output_file ${gdb_test_file_name}.o] + set testfile $testfile.o + set binfile [standard_output_file $testfile] - if { [gdb_compile "$srcdir/$subdir/$srcfile" $obj object "debug"] != "" } { - untested "failed to compile object file [file tail $obj]" + if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile object \ + "debug"] != "" } { + untested "failed to compile object file $testfile" return -1 } - clean_restart $obj + clean_restart $testfile } else { diff --git a/gdb/testsuite/gdb.python/py-exec-file.exp b/gdb/testsuite/gdb.python/py-exec-file.exp index b3418a59115..139ce8324f3 100644 --- a/gdb/testsuite/gdb.python/py-exec-file.exp +++ b/gdb/testsuite/gdb.python/py-exec-file.exp @@ -19,8 +19,10 @@ load_lib gdb-python.exp standard_testfile -set binfile1 ${binfile}-a -set binfile2 ${binfile}-b +set testfile1 $testfile-a +set binfile1 [standard_output_file $testfile1] +set testfile2 $testfile-b +set binfile2 [standard_output_file $testfile2] if {[build_executable "failed to prepare first executable" \ $binfile1 $srcfile]} { @@ -176,7 +178,7 @@ with_test_prefix "using 'symbol-file' command" { # Check the executable_changed event when the executable changes on disk. with_test_prefix "exec changes on disk" { - clean_restart $binfile1 + clean_restart $::testfile1 setup_exec_change_handler diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp index 173297c80ee..dd35627b573 100644 --- a/gdb/testsuite/gdb.python/py-format-address.exp +++ b/gdb/testsuite/gdb.python/py-format-address.exp @@ -27,10 +27,12 @@ foreach func_name { foo bar } { } } -set binary_foo [standard_output_file "${testfile}-foo"] -set binary_bar [standard_output_file "${testfile}-bar"] +set testfile_foo $testfile-foo +set testfile_bar $testfile-bar +set binary_foo [standard_output_file $testfile_foo] +set binary_bar [standard_output_file $testfile_bar] -clean_restart $binary_foo +clean_restart $testfile_foo if ![runto_main] { return -1 diff --git a/gdb/testsuite/gdb.python/py-format-string.exp b/gdb/testsuite/gdb.python/py-format-string.exp index 2463185aab4..8f38c182bc3 100644 --- a/gdb/testsuite/gdb.python/py-format-string.exp +++ b/gdb/testsuite/gdb.python/py-format-string.exp @@ -47,7 +47,8 @@ proc build_inferior {exefile lang} { proc prepare_gdb {exefile} { global srcdir subdir srcfile testfile hex - clean_restart $exefile + clean_restart + gdb_load $exefile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.python/py-framefilter-mi.exp b/gdb/testsuite/gdb.python/py-framefilter-mi.exp index de042364595..03e5f90580c 100644 --- a/gdb/testsuite/gdb.python/py-framefilter-mi.exp +++ b/gdb/testsuite/gdb.python/py-framefilter-mi.exp @@ -28,7 +28,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return -1 } -if {[mi_clean_restart $binfile]} { +if {[mi_clean_restart $::testfile]} { return } diff --git a/gdb/testsuite/gdb.python/py-mi-objfile.exp b/gdb/testsuite/gdb.python/py-mi-objfile.exp index 58ecbc5519a..39bac2b8fc9 100644 --- a/gdb/testsuite/gdb.python/py-mi-objfile.exp +++ b/gdb/testsuite/gdb.python/py-mi-objfile.exp @@ -33,7 +33,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb # gdb will find it. set remote_python_file [gdb_remote_download host ${srcdir}/${subdir}/${pyfile}] -if {[mi_clean_restart $binfile]} { +if {[mi_clean_restart $::testfile]} { return } diff --git a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp index 07cd40fe53e..7a9124b4ca3 100644 --- a/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp +++ b/gdb/testsuite/gdb.python/py-mi-var-info-path-expression.exp @@ -29,7 +29,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != "" } return -1 } -mi_clean_restart $binfile +mi_clean_restart $::testfile set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] mi_gdb_test "source ${pyfile}" \ diff --git a/gdb/testsuite/gdb.python/py-mi.exp b/gdb/testsuite/gdb.python/py-mi.exp index 7f1dffc74b3..28d63c1c2c7 100644 --- a/gdb/testsuite/gdb.python/py-mi.exp +++ b/gdb/testsuite/gdb.python/py-mi.exp @@ -26,7 +26,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {deb return -1 } -if {[mi_clean_restart $binfile]} { +if {[mi_clean_restart $::testfile]} { return } @@ -345,7 +345,7 @@ if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}-cxx" \ return -1 } -if {[mi_clean_restart ${binfile}-cxx]} { +if {[mi_clean_restart ${::testfile}-cxx]} { return } diff --git a/gdb/testsuite/gdb.python/py-missing-objfile.exp b/gdb/testsuite/gdb.python/py-missing-objfile.exp index 29bc555d88f..ce4dc76b71e 100644 --- a/gdb/testsuite/gdb.python/py-missing-objfile.exp +++ b/gdb/testsuite/gdb.python/py-missing-objfile.exp @@ -134,7 +134,7 @@ proc clean_restart_load_python {} { # For sanity, lets check that we can load the specify the executable # and then load the core-file the easy way. with_test_prefix "initial sanity check" { - clean_restart $binfile + clean_restart $::testfile load_core_file check_loaded_debug true true } diff --git a/gdb/testsuite/gdb.python/py-objfile.exp b/gdb/testsuite/gdb.python/py-objfile.exp index 8d1102896fa..befdb9116ec 100644 --- a/gdb/testsuite/gdb.python/py-objfile.exp +++ b/gdb/testsuite/gdb.python/py-objfile.exp @@ -163,7 +163,8 @@ if ![ishost *-*-mingw*] { remote_exec host "rm -f ${symlink_binary}" remote_exec host "ln -sf ${testfile} ${symlink_binary}" if [remote_file host exists "${symlink_binary}"] { - clean_restart "${symlink_binary}" + clean_restart + gdb_load "${symlink_binary}" gdb_test "python print (gdb.lookup_objfile (\"${symlink_binary}\").filename)" \ "${testfile}" "gdb.lookup_objfile of symlinked binary" } diff --git a/gdb/testsuite/gdb.python/py-prettyprint.exp b/gdb/testsuite/gdb.python/py-prettyprint.exp index 0b5ca9ae342..c342d453a9a 100644 --- a/gdb/testsuite/gdb.python/py-prettyprint.exp +++ b/gdb/testsuite/gdb.python/py-prettyprint.exp @@ -36,7 +36,8 @@ proc run_lang_tests {exefile lang} { set nl "\[\r\n\]+" # Start with a fresh gdb. - clean_restart $exefile + clean_restart + gdb_load $exefile if {![runto_main]} { return @@ -192,7 +193,7 @@ with_test_prefix c++ { # Run various other tests. -clean_restart $binfile +clean_restart $::testfile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.python/py-source-styling.exp b/gdb/testsuite/gdb.python/py-source-styling.exp index 308053c480a..5d7935629a5 100644 --- a/gdb/testsuite/gdb.python/py-source-styling.exp +++ b/gdb/testsuite/gdb.python/py-source-styling.exp @@ -62,7 +62,7 @@ proc check_source_listing_styling { cmd expect_styled { testname "" } } { # highlighting when GNU source highlight is not available (or is # disabled, as is done in this test). proc test_pygments_styling {} { - clean_restart $::binfile + clean_restart $::testfile # Remote host boards disable styling via GDB's command line. Turn # it back on now. @@ -91,7 +91,7 @@ proc test_pygments_styling {} { # string, then set the correct host encoding, and try again. This # time the conversion should succeed. proc test_gdb_execute_non_utf8_source {} { - clean_restart $::binfile + clean_restart $::testfile # The default host charset is utf-8, the source code contains a # non-utf-8 character, so this will fail. @@ -117,7 +117,7 @@ proc test_gdb_execute_non_utf8_source {} { # output to be returned via a string, and in other cases we ask for # the output to be sent straight to stdout. proc_with_prefix test_source_cache_style_tracking {} { - clean_restart $::binfile + clean_restart $::testfile # Remote host boards disable styling via GDB's command line. Turn # it back on now. diff --git a/gdb/testsuite/gdb.python/py-symbol.exp b/gdb/testsuite/gdb.python/py-symbol.exp index dfc435e7a3d..2029c286599 100644 --- a/gdb/testsuite/gdb.python/py-symbol.exp +++ b/gdb/testsuite/gdb.python/py-symbol.exp @@ -44,7 +44,7 @@ if {!$readnow_p} { } # Restart so we don't have expanded symtabs after the previous test. -clean_restart ${binfile} +clean_restart ${::testfile} # Test looking up a global symbol before we runto_main as this is the # point where we don't have a current frame, and we don't want to @@ -214,8 +214,10 @@ gdb_test "python print (t\[0\].symtab)" "${py_symbol_c}" "get symtab" # C++ tests # Recompile binary. lappend opts c++ -if {[prepare_for_testing "failed to prepare" "${binfile}-cxx" \ - [list $srcfile $srcfile2] $opts]} { +set testfile $testfile-cxx +set binfile [standard_output_file $testfile] +if { [prepare_for_testing "failed to prepare" $testfile \ + [list $srcfile $srcfile2] $opts] } { return -1 } @@ -251,7 +253,7 @@ gdb_test "python print (cplusfunc.addr_class == gdb.SYMBOL_LOC_BLOCK)" "True" "t # Test is_valid when the objfile is unloaded. This must be the last # test as it unloads the object file in GDB. # Start with a fresh gdb. -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.python/py-thrhandle.exp b/gdb/testsuite/gdb.python/py-thrhandle.exp index 343bf4b46c3..a9590443dca 100644 --- a/gdb/testsuite/gdb.python/py-thrhandle.exp +++ b/gdb/testsuite/gdb.python/py-thrhandle.exp @@ -29,7 +29,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} runto_main diff --git a/gdb/testsuite/gdb.python/py-type.exp b/gdb/testsuite/gdb.python/py-type.exp index 0bc4556c653..5472482717d 100644 --- a/gdb/testsuite/gdb.python/py-type.exp +++ b/gdb/testsuite/gdb.python/py-type.exp @@ -34,7 +34,8 @@ proc build_inferior {exefile lang} { # Restart GDB. proc restart_gdb {exefile} { - clean_restart $exefile + clean_restart + gdb_load $exefile if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 93985a99a0c..4857937836a 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -431,7 +431,8 @@ proc test_value_after_death {} { proc test_subscript_regression {exefile lang} { # Start with a fresh gdb. - clean_restart ${exefile} + clean_restart + gdb_load $exefile if {![runto_main]} { return @@ -768,7 +769,7 @@ if { [build_inferior "${binfile}" "c"] < 0 } { } # Start with a fresh gdb. -clean_restart ${binfile} +clean_restart ${::testfile} test_history_count test_value_creation diff --git a/gdb/testsuite/gdb.python/py-varobj.exp b/gdb/testsuite/gdb.python/py-varobj.exp index 7fb45f93bd4..cf6a6620773 100644 --- a/gdb/testsuite/gdb.python/py-varobj.exp +++ b/gdb/testsuite/gdb.python/py-varobj.exp @@ -25,7 +25,7 @@ if {[gdb_compile "$srcdir/$subdir/$srcfile" $binfile executable {debug}] != ""} return -1 } -mi_clean_restart $binfile +mi_clean_restart $::testfile set pyfile [gdb_remote_download host ${srcdir}/${subdir}/${testfile}.py] mi_gdb_test "source ${pyfile}" \