From: Thiago Jung Bauermann Date: Wed, 29 Apr 2026 23:04:15 +0000 (-0300) Subject: GDB: testsuite: Python: Don't return value from top-level (manual) X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd3440a5ae4e02ef494e8c53fc6b4ec61b911294;p=thirdparty%2Fbinutils-gdb.git GDB: testsuite: Python: Don't return value from top-level (manual) This patch manually changes "return -1" and "return 0" statements that weren't caught by the sed command. These return statements fall into one of these criteria: - misaligned line, which is then fixed by this patch; - return at top level but inside block such as save_vars, with_test_prefix, foreach, gdb_test_multiple. In a couple of cases the whole if block was in a single line: if { condition } { return -1 } In those cases the formatting was changed to the multi-line style we tend to use. Approved-By: Tom Tromey --- diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp index 6630143f037..7a1025841f4 100644 --- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp +++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } # First, use 'maint print reggroups' to get a list of all register diff --git a/gdb/testsuite/gdb.python/py-arch-reg-names.exp b/gdb/testsuite/gdb.python/py-arch-reg-names.exp index 7bbb171e13e..6807098fbda 100644 --- a/gdb/testsuite/gdb.python/py-arch-reg-names.exp +++ b/gdb/testsuite/gdb.python/py-arch-reg-names.exp @@ -24,7 +24,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } # First, use 'info registers' to get a list of register names. diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp index a2ac6ad4bfa..b1dd81a0583 100644 --- a/gdb/testsuite/gdb.python/py-arch.exp +++ b/gdb/testsuite/gdb.python/py-arch.exp @@ -21,7 +21,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } # Test python/15461. Invalid architectures should not trigger an diff --git a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp index 7a92ff0fac7..bd0d1c4b11e 100644 --- a/gdb/testsuite/gdb.python/py-auto-load-chaining.exp +++ b/gdb/testsuite/gdb.python/py-auto-load-chaining.exp @@ -29,13 +29,13 @@ set f2_o [standard_output_file ${gdb_test_file_name}-f2.o] # Now build the object files. if {[gdb_compile "${srcdir}/${subdir}/${srcfile2}" ${f1_o} object {}] != ""} { - untested "failed to compile object file f1.o" - return -1 + untested "failed to compile object file f1.o" + return } if {[gdb_compile "${srcdir}/${subdir}/${srcfile3}" ${f2_o} object {}] != ""} { - untested "failed to compile object file f2.o" - return -1 + untested "failed to compile object file f2.o" + return } # Copy the two Python scripts to where the tests are being run. @@ -50,7 +50,7 @@ if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { } if {![runto_main]} { - return -1 + return } set safe_path [standard_output_file ""] diff --git a/gdb/testsuite/gdb.python/py-disasm.exp.tcl b/gdb/testsuite/gdb.python/py-disasm.exp.tcl index e4391fa59ce..6382005eee5 100644 --- a/gdb/testsuite/gdb.python/py-disasm.exp.tcl +++ b/gdb/testsuite/gdb.python/py-disasm.exp.tcl @@ -30,7 +30,7 @@ if { $kind == "obj" } { if { [gdb_compile "$srcdir/$subdir/$srcfile" $binfile object \ "debug"] != "" } { untested "failed to compile object file $testfile" - return -1 + return } clean_restart $testfile @@ -38,12 +38,12 @@ if { $kind == "obj" } { } else { if { [prepare_for_testing "failed to prepare" $testfile $srcfile] } { - return -1 + return } if { ![runto_main] } { fail "can't run to main" - return 0 + return } } diff --git a/gdb/testsuite/gdb.python/py-events.exp b/gdb/testsuite/gdb.python/py-events.exp index 1177dd54e48..16a290c31c2 100644 --- a/gdb/testsuite/gdb.python/py-events.exp +++ b/gdb/testsuite/gdb.python/py-events.exp @@ -315,7 +315,7 @@ with_test_prefix "gdb exiting: error" { if {![runto_main]} { fail "cannot run to main." - return 0 + return } gdb_test_no_output "source ${pyfile}" "load python file" diff --git a/gdb/testsuite/gdb.python/py-explore-cc.exp b/gdb/testsuite/gdb.python/py-explore-cc.exp index 772886b931f..70b1beeada0 100644 --- a/gdb/testsuite/gdb.python/py-explore-cc.exp +++ b/gdb/testsuite/gdb.python/py-explore-cc.exp @@ -37,7 +37,7 @@ i = .*\ c = .*" if {![runto_main]} { - return -1 + return } gdb_breakpoint [gdb_get_line_number "Break here."] diff --git a/gdb/testsuite/gdb.python/py-explore.exp b/gdb/testsuite/gdb.python/py-explore.exp index 276148da8f1..debe3031535 100644 --- a/gdb/testsuite/gdb.python/py-explore.exp +++ b/gdb/testsuite/gdb.python/py-explore.exp @@ -76,7 +76,7 @@ proc scalar_value { value_name value } { set SS_fields [field_values {a = 10} {d = 100[.].*}] if {![runto_main]} { - return -1 + return } gdb_breakpoint [gdb_get_line_number "Break here."] diff --git a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp index 043416c724c..960a44f412a 100644 --- a/gdb/testsuite/gdb.python/py-finish-breakpoint.exp +++ b/gdb/testsuite/gdb.python/py-finish-breakpoint.exp @@ -46,7 +46,7 @@ with_test_prefix "normal conditions" { gdb_load_shlib ${lib_sl} if {![runto_main]} { - return 0 + return } set python_file [gdb_remote_download host \ @@ -98,7 +98,7 @@ with_test_prefix "return to inlined function" { "import python scripts" if {![runto_main]} { - return 0 + return } gdb_breakpoint "increase_2" @@ -124,7 +124,7 @@ with_test_prefix "no debug symbol" { set cond_line [gdb_get_line_number "Condition Break."] if {![runto_main]} { - return 0 + return } gdb_test "print do_nothing" "no debug info.*" "ensure that shared lib has no debug info" @@ -179,7 +179,7 @@ with_test_prefix "finish in dummy frame" { if {![runto_main]} { - return 0 + return } gdb_test "break ${cond_line} if test_1(i,8)" "Breakpoint .* at .*" \ @@ -206,7 +206,7 @@ with_test_prefix "finish in normal frame" { "import python scripts" if {![runto_main]} { - return 0 + return } gdb_test "break ${cond_line} if test(i,8)" \ @@ -235,7 +235,7 @@ with_test_prefix "explicit inferior function call" { "import python scripts" if {![runto_main]} { - return 0 + return } # return address in dummy frame @@ -262,7 +262,7 @@ with_test_prefix "explicit inferior function call" { with_test_prefix "inferior exit" { if {![runto "test_exec_exit"]} { - return 0 + return } gdb_test_no_output "set var self_exec = 0" "switch to exit() test" @@ -276,7 +276,7 @@ with_test_prefix "inferior exit" { with_test_prefix "inferior exec" { if {![runto "test_exec_exit"]} { - return 0 + return } gdb_test "python SimpleFinishBreakpoint(gdb.newest_frame())" "SimpleFinishBreakpoint init" "set FinishBP after the exec" diff --git a/gdb/testsuite/gdb.python/py-format-address.exp b/gdb/testsuite/gdb.python/py-format-address.exp index dda012234b7..9f32686dfd3 100644 --- a/gdb/testsuite/gdb.python/py-format-address.exp +++ b/gdb/testsuite/gdb.python/py-format-address.exp @@ -23,7 +23,7 @@ foreach func_name { foo bar } { [list debug \ nopie \ additional_flags=-DFUNCTION_NAME=${func_name}]] == -1} { - return -1 + return } } @@ -35,7 +35,7 @@ set binary_bar [standard_output_file $testfile_bar] clean_restart $testfile_foo if {![runto_main]} { - return -1 + return } # Check the gdb.format_address method when using the default values diff --git a/gdb/testsuite/gdb.python/py-framefilter-addr.exp b/gdb/testsuite/gdb.python/py-framefilter-addr.exp index 3c0436ce197..1c85a8afcb3 100644 --- a/gdb/testsuite/gdb.python/py-framefilter-addr.exp +++ b/gdb/testsuite/gdb.python/py-framefilter-addr.exp @@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } # Run to our test breakpoint. diff --git a/gdb/testsuite/gdb.python/py-label-symbol-value.exp b/gdb/testsuite/gdb.python/py-label-symbol-value.exp index c97ae72ec58..bd3f9ee689e 100644 --- a/gdb/testsuite/gdb.python/py-label-symbol-value.exp +++ b/gdb/testsuite/gdb.python/py-label-symbol-value.exp @@ -25,7 +25,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } # Use Python to print the value of the 'some_label' symbol. diff --git a/gdb/testsuite/gdb.python/py-linetable-empty.exp b/gdb/testsuite/gdb.python/py-linetable-empty.exp index 651fe9b6dbf..3244d88a936 100644 --- a/gdb/testsuite/gdb.python/py-linetable-empty.exp +++ b/gdb/testsuite/gdb.python/py-linetable-empty.exp @@ -43,7 +43,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} \ } if {![runto_main]} { - return -1 + return } gdb_test "python print(gdb.selected_frame().function().symtab.fullname())" \ diff --git a/gdb/testsuite/gdb.python/py-pp-registration.exp b/gdb/testsuite/gdb.python/py-pp-registration.exp index 3d974b2120b..ab84a0f7f90 100644 --- a/gdb/testsuite/gdb.python/py-pp-registration.exp +++ b/gdb/testsuite/gdb.python/py-pp-registration.exp @@ -64,7 +64,7 @@ proc test_printers { s_prefix } { with_test_prefix "verbose off" { if {![prepare_test]} { - return -1 + return } gdb_test_no_output "set verbose off" @@ -79,7 +79,7 @@ with_test_prefix "verbose off" { with_test_prefix "verbose on" { if {![prepare_test]} { - return -1 + return } gdb_test_no_output "set verbose on" @@ -96,7 +96,7 @@ with_test_prefix "verbose on" { with_test_prefix "replace" { if {![prepare_test]} { - return -1 + return } gdb_test_no_output "py gdb.printing.register_pretty_printer(gdb, lookup_function_lookup_test)" diff --git a/gdb/testsuite/gdb.python/py-prompt.exp b/gdb/testsuite/gdb.python/py-prompt.exp index cc149ae6230..96ea5284344 100644 --- a/gdb/testsuite/gdb.python/py-prompt.exp +++ b/gdb/testsuite/gdb.python/py-prompt.exp @@ -70,7 +70,7 @@ save_vars { INTERNAL_GDBFLAGS GDBFLAGS } { } if {![can_spawn_for_attach]} { - return 0 + return } set test_spawn_id [spawn_wait_for_attach $binfile] diff --git a/gdb/testsuite/gdb.python/py-read-memory-leak.exp b/gdb/testsuite/gdb.python/py-read-memory-leak.exp index 58343126e67..1a361c99053 100644 --- a/gdb/testsuite/gdb.python/py-read-memory-leak.exp +++ b/gdb/testsuite/gdb.python/py-read-memory-leak.exp @@ -27,7 +27,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } { } if {![runto_main]} { - return -1 + return } gdb_py_run_memory_leak_test ${srcdir}/${subdir}/${testfile}.py \ diff --git a/gdb/testsuite/gdb.python/py-record-btrace.exp b/gdb/testsuite/gdb.python/py-record-btrace.exp index 4e324e71fc0..d5a647ebc59 100644 --- a/gdb/testsuite/gdb.python/py-record-btrace.exp +++ b/gdb/testsuite/gdb.python/py-record-btrace.exp @@ -23,7 +23,9 @@ load_lib gdb-python.exp standard_testfile -if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 } +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { + return +} if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.python/py-record-full.exp b/gdb/testsuite/gdb.python/py-record-full.exp index 95640770e9a..37bf07a64bf 100644 --- a/gdb/testsuite/gdb.python/py-record-full.exp +++ b/gdb/testsuite/gdb.python/py-record-full.exp @@ -23,7 +23,9 @@ load_lib gdb-python.exp standard_testfile -if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { return -1 } +if {[prepare_for_testing "failed to prepare" $testfile $srcfile]} { + return +} if {![runto_main]} { return diff --git a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp index 576fd5a85d3..5e2b769cf71 100644 --- a/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp +++ b/gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp @@ -27,7 +27,7 @@ if {[prepare_for_testing $testfile.exp $testfile $srcfile \ } if {![runto_main]} { - return -1 + return } gdb_breakpoint [gdb_get_line_number "Break here."] diff --git a/gdb/testsuite/gdb.python/py-value-cc.exp b/gdb/testsuite/gdb.python/py-value-cc.exp index 1d65d617e30..fa0cd066978 100644 --- a/gdb/testsuite/gdb.python/py-value-cc.exp +++ b/gdb/testsuite/gdb.python/py-value-cc.exp @@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { } if {![runto_main]} { - return -1 + return } gdb_breakpoint [gdb_get_line_number "Break here."] diff --git a/gdb/testsuite/gdb.python/py-value.exp b/gdb/testsuite/gdb.python/py-value.exp index 4337928ddef..ba3b1376ff5 100644 --- a/gdb/testsuite/gdb.python/py-value.exp +++ b/gdb/testsuite/gdb.python/py-value.exp @@ -840,7 +840,7 @@ test_subscript_regression "${binfile}" "c" if {[allow_cplus_tests]} { if { [build_inferior "${binfile}-cxx" "c++"] < 0 } { - return -1 + return } with_test_prefix "c++" { test_subscript_regression "${binfile}-cxx" "c++" diff --git a/gdb/testsuite/gdb.python/py-xmethods.exp b/gdb/testsuite/gdb.python/py-xmethods.exp index 52f0a759709..b8a8b46c1db 100644 --- a/gdb/testsuite/gdb.python/py-xmethods.exp +++ b/gdb/testsuite/gdb.python/py-xmethods.exp @@ -27,7 +27,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug c++}]} { } if {![runto_main]} { - return -1 + return } set xmethods_script [gdb_remote_download host \ diff --git a/gdb/testsuite/gdb.python/python.exp b/gdb/testsuite/gdb.python/python.exp index 7d3cd299bc8..27dbc555a17 100644 --- a/gdb/testsuite/gdb.python/python.exp +++ b/gdb/testsuite/gdb.python/python.exp @@ -48,7 +48,7 @@ gdb_test_multiple "python print (23)" "verify python support" { "print (23)" "" \ "end" "not supported.*" - return -1 + return } -re "$gdb_prompt $" {} }