]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
GDB: testsuite: Python: Don't return value from top-level (manual)
authorThiago Jung Bauermann <thiago.bauermann@linaro.org>
Wed, 29 Apr 2026 23:04:15 +0000 (20:04 -0300)
committerThiago Jung Bauermann <thiago.bauermann@linaro.org>
Fri, 8 May 2026 21:55:59 +0000 (18:55 -0300)
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 <tom@tromey.com>
23 files changed:
gdb/testsuite/gdb.python/py-arch-reg-groups.exp
gdb/testsuite/gdb.python/py-arch-reg-names.exp
gdb/testsuite/gdb.python/py-arch.exp
gdb/testsuite/gdb.python/py-auto-load-chaining.exp
gdb/testsuite/gdb.python/py-disasm.exp.tcl
gdb/testsuite/gdb.python/py-events.exp
gdb/testsuite/gdb.python/py-explore-cc.exp
gdb/testsuite/gdb.python/py-explore.exp
gdb/testsuite/gdb.python/py-finish-breakpoint.exp
gdb/testsuite/gdb.python/py-format-address.exp
gdb/testsuite/gdb.python/py-framefilter-addr.exp
gdb/testsuite/gdb.python/py-label-symbol-value.exp
gdb/testsuite/gdb.python/py-linetable-empty.exp
gdb/testsuite/gdb.python/py-pp-registration.exp
gdb/testsuite/gdb.python/py-prompt.exp
gdb/testsuite/gdb.python/py-read-memory-leak.exp
gdb/testsuite/gdb.python/py-record-btrace.exp
gdb/testsuite/gdb.python/py-record-full.exp
gdb/testsuite/gdb.python/py-rvalue-ref-value-cc.exp
gdb/testsuite/gdb.python/py-value-cc.exp
gdb/testsuite/gdb.python/py-value.exp
gdb/testsuite/gdb.python/py-xmethods.exp
gdb/testsuite/gdb.python/python.exp

index 6630143f03737f0b881ca888ad30f65fd5e125fc..7a1025841f46984b63f2b312d67d37f06d0678a2 100644 (file)
@@ -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
index 7bbb171e13e11084b94e91322052591ca4b7cc70..6807098fbda881133cd3bb4085f6108a62dee3af 100644 (file)
@@ -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.
index a2ac6ad4bfa177e6c7065e1c64add2ca88e4fd86..b1dd81a0583922afe7d7b690f1b9959e988b8e1c 100644 (file)
@@ -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
index 7a92ff0fac719962d6b7bc7ff39013ea856d98d9..bd0d1c4b11ef5adc6d9c1ae217ea05327eeec2aa 100644 (file)
@@ -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 ""]
index e4391fa59ced996087bdfbee65cf822a1fa76d00..6382005eee52b6884f58daf5f6ee6c3e2ad33421 100644 (file)
@@ -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
     }
 
 }
index 1177dd54e4823d7573e84c2e2b84a3fcfe8ff717..16a290c31c29349344388512b38234dd28b63164 100644 (file)
@@ -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"
index 772886b931f9fe7420d099bb115cee628f633bdf..70b1beeada0ab3333b44b28a3fb6d8372d858316 100644 (file)
@@ -37,7 +37,7 @@ i = <Enter 1 to explore this field of type 'int'>.*\
 c = <Enter 2 to explore this field of type 'char'>.*"
 
 if {![runto_main]} {
-   return -1
+    return
 }
 
 gdb_breakpoint [gdb_get_line_number "Break here."]
index 276148da8f102fc222e192a37b2898b476b56432..debe30315356974c85184f1e9d132640f7c44749 100644 (file)
@@ -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."]
index 043416c724ccb496f4e710f16f3c437c26ae64fb..960a44f412a606f6d4005ac40fb17619e44c7772 100644 (file)
@@ -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"
index dda012234b77f4b6d5e4220aeb3bbf2ffb015be1..9f32686dfd3d6a92734334a86c4caeeb63e3d020 100644 (file)
@@ -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
index 3c0436ce1972d71cc3e45cb16b117d6742878637..1c85a8afcb3696b8ea95b599771b96ffd38bca07 100644 (file)
@@ -28,7 +28,7 @@ if { [prepare_for_testing "failed to prepare" ${testfile} ${srcfile}] } {
 }
 
 if {![runto_main]} {
-   return -1
+    return
 }
 
 # Run to our test breakpoint.
index c97ae72ec58dc91a8f5a6d4983402414247cdac4..bd3f9ee689e97dfddad24ffd1c0181548549085c 100644 (file)
@@ -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.
index 651fe9b6dbf3961d7432842341838e3195cfb998..3244d88a93678605bc3d90dd6d16e93579d1c72e 100644 (file)
@@ -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())" \
index 3d974b2120b6044c671a59dce95a7ce81720831b..ab84a0f7f9059d2f8da6b77163e6532d19cc60c5 100644 (file)
@@ -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)"
index cc149ae6230335051cd20eac0cb6fc1a82f72f9a..96ea528434421f132cd610a3927dfd6130bdfb12 100644 (file)
@@ -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]
index 58343126e67cdc812d9a866db8f94b8d9dc25750..1a361c9905332518a1e001220f42376424811adc 100644 (file)
@@ -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 \
index 4e324e71fc092c425bbec0914984a3b50a7023c4..d5a647ebc59a496ded3f18fa13a4533d22bff9c5 100644 (file)
@@ -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
index 95640770e9a5c1a5ce0f912d29dbb0019e6c3ed3..37bf07a64bfd04d05bda26be8f5259df24b6e025 100644 (file)
@@ -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
index 576fd5a85d3d1099bc88bb9e765bc7bfa8702ec6..5e2b769cf71f8a53f9a690d6a8c2137bdc933c8e 100644 (file)
@@ -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."]
index 1d65d617e30db88dfac8d49b95e94db99332cf5a..fa0cd066978bf8d4d501d6b16f62565080e9555e 100644 (file)
@@ -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."]
index 4337928ddef49f6833f7066710f2b69276eb371e..ba3b1376ff5a842d198cdb3323b3b219e963cad5 100644 (file)
@@ -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++"
index 52f0a7597093ca84eb1a818c3dca57e09a6c2c20..b8a8b46c1db3e45a0b1825d6ee6a50f72f2dffb9 100644 (file)
@@ -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 \
index 7d3cd299bc8cf04cd017f59bbb46fad474079be5..27dbc555a17be6cd4c3ee43452f52f8346771e86 100644 (file)
@@ -48,7 +48,7 @@ gdb_test_multiple "python print (23)" "verify python support" {
          "print (23)" "" \
          "end" "not supported.*"
 
-      return -1
+      return
     }
     -re "$gdb_prompt $"        {}
 }