]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Exit left-over gdb in gdb.mi/mi-break.exp
authorTom de Vries <tdevries@suse.de>
Mon, 24 Feb 2025 20:44:15 +0000 (21:44 +0100)
committerTom de Vries <tdevries@suse.de>
Mon, 24 Feb 2025 20:44:15 +0000 (21:44 +0100)
After test-case gdb.mi/mi-break.exp, a gdb instance is left running.

The test-case starts two instances using mi_clean_restart, one using
separate-mi-tty.

For each instance, gdb_exit is called once, from two different locations:
- mi_clean_restart, and
- gdb_finish.

But this doesn't seem to be effective for the separate-mi-tty case.

Fix this by calling gdb_mi_exit at the end of proc test_break.

Likewise in a few more more test-case.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR testsuite/32709
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32709

gdb/testsuite/gdb.mi/mi-break.exp
gdb/testsuite/gdb.mi/mi-multi-commands.exp
gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp
gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp
gdb/testsuite/gdb.mi/mi-watch.exp
gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp
gdb/testsuite/gdb.mi/new-ui-mi-sync.exp
gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp
gdb/testsuite/gdb.mi/user-selected-context-sync.exp

index 86e7b57260ab2e14473fde6433ecaf16564e1ad4..aa8603f4ef0a31ea73ffdb5f1470ed04f1fe7076 100644 (file)
@@ -417,6 +417,10 @@ proc test_break {mi_mode} {
     test_explicit_breakpoints
 
     test_forced_conditions
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
 
 foreach_mi_ui_mode mi-mode {
index 028e187366a6b64438396b5532ab0aeacb87ab58..ce4379c8636bc66ac50159016190c8105261e093 100644 (file)
@@ -123,6 +123,10 @@ proc run_test { args } {
            break
        }
     }
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
 
 foreach_with_prefix args { "" "separate-mi-tty" } {
index 08c7218221794999162366d40d598201b54fbef1..261ab7d0369f5a0b776991e0a4a67eedee1ba0e1 100644 (file)
@@ -36,8 +36,6 @@ if { [build_executable "failed to prepare" $testfile $srcfile \
 }
 
 foreach_mi_ui_mode mode {
-    mi_gdb_exit
-
     if {$mode eq "separate"} {
        set start_ops "separate-mi-tty"
     } else {
@@ -279,4 +277,8 @@ foreach_mi_ui_mode mode {
        "set do_spin variable in inferior, inferior should now finish"
     mi_expect_stop "breakpoint-hit" "breakpt" ".*" ".*" "$::decimal" \
        {"" "disp=\"keep\""} "stop in breakpt at the end of the test"
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
index 715e0f7e8047be5ad4de9f2d1d361dc3cf60d9f5..6026e7b4727a04fddc3fc165379060ad0a7338a3 100644 (file)
@@ -33,17 +33,7 @@ proc make_loc {num} {
     return [mi_make_breakpoint_loc -thread "1" -number "$::decimal\\.$num"]
 }
 
-foreach_mi_ui_mode mode {
-
-    if {$mode == "separate"} {
-       set start_ops "separate-mi-tty"
-    } else {
-       set start_ops ""
-    }
-
-    if {[mi_clean_restart $binfile $start_ops]} {
-       return -1
-    }
+proc do_test { mode } {
 
     # Ensure we get an error when placing a b/p for thread 1 at a point
     # where thread 1 doesn't exist.
@@ -55,7 +45,7 @@ foreach_mi_ui_mode mode {
     # would succeed, and then 'info breakpoint' on the CLI would
     # trigger an assertion.
     if {$mode eq "separate"} {
-       with_spawn_id $gdb_main_spawn_id {
+       with_spawn_id $::gdb_main_spawn_id {
            gdb_test "info breakpoints" "No breakpoints, watchpoints, tracepoints, or catchpoints\\." \
                "check CLI 'info breakpoints' when there are no breakpoints"
        }
@@ -83,9 +73,34 @@ foreach_mi_ui_mode mode {
 
     # Check that 'info breakpoints' on the CLI succeeds.
     if {$mode eq "separate"} {
-       with_spawn_id $gdb_main_spawn_id {
+       with_spawn_id $::gdb_main_spawn_id {
            gdb_test "info breakpoints" ".*" \
                "check CLI 'info breakpoints' when there are some breakpoints"
        }
     }
+
+    return 1
+}
+
+foreach_mi_ui_mode mode {
+
+    if {$mode == "separate"} {
+       set start_ops "separate-mi-tty"
+    } else {
+       set start_ops ""
+    }
+
+    if {[mi_clean_restart $binfile $start_ops]} {
+       break
+    }
+
+    set res [do_test $mode]
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
+
+    if { $res == -1 } {
+       break
+    }
 }
index a5a442eb13ebcccdfdab70895894610f47a96f28..cf97d416535bc77a1954ec8b174b70d4c5af12d5 100644 (file)
@@ -173,6 +173,10 @@ proc test_watchpoint_all {mi_mode type} {
     #test_rwatch_creation_and_listing
     #test_awatch_creation_and_listing
     test_watchpoint_triggering
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
 
 # Run the tests twice, once using software watchpoints, and another
index 938e6deec05e643939622b219c918e47fac81caa..9e5298808142df4317473c044abd56176d3ed13e 100644 (file)
@@ -45,8 +45,6 @@ proc make_bp_loc { num } {
 }
 
 foreach_mi_ui_mode mode {
-    mi_gdb_exit
-
     if {$mode eq "separate"} {
        set start_ops "separate-mi-tty"
     } else {
@@ -109,4 +107,8 @@ foreach_mi_ui_mode mode {
                 "=breakpoint-deleted,id=\"$bpnum\"" \
                 "\\^done"]
     }
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
index 28a42dcb665e54178ece1b42189c65f1b6f4e013..bf1365e18adf462e0b30b0194df0ff4d73de64c2 100644 (file)
@@ -40,27 +40,22 @@ proc do_test {sync_command} {
     global gdb_spawn_id gdb_main_spawn_id mi_spawn_id inferior_spawn_id
     global gdb_prompt mi_gdb_prompt
 
-    if {[mi_clean_restart $binfile "separate-mi-tty"] != 0} {
-       fail "could not start gdb"
-       return
-    }
-
     # Start a synchronous run/continue on the MI UI.
     set test "send synchronous execution command"
     if {$sync_command == "run"} {
        if {[mi_run_cmd] >= 0} {
            pass $test
        } else {
-           return
+           return -1
        }
     } else {
        if {[mi_runto_main] < 0} {
-           return
+           return -1
        }
        if {[mi_send_resuming_command_raw "123-exec-continue" $test] >= 0} {
            pass $test
        } else {
-           return
+           return -1
        }
     }
 
@@ -107,5 +102,18 @@ proc do_test {sync_command} {
 }
 
 foreach_with_prefix sync-command {"run" "continue"} {
-    do_test ${sync-command}
+    if {[mi_clean_restart $binfile "separate-mi-tty"] != 0} {
+       fail "could not start gdb"
+       break
+    }
+
+    set res [do_test ${sync-command}]
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
+
+    if { $res == -1 } {
+       break
+    }
 }
index 5981bc1ad24c1821ce25dca26fa1e4de288a4c79..effc760d6a7fe8fe1ea4914f14c9f96e0ee04f42 100644 (file)
@@ -59,6 +59,10 @@ proc do_test { ui_to_run } {
        # the expected ^running record.
        mi_runto_main
     }
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
 }
 
 foreach_with_prefix ui_to_run {first second} {
index e168a5eee45f261e6799f2f9992c1c6811a5a9a8..675965fec606e568ea330ce579d0ee237cac1cd8 100644 (file)
@@ -385,21 +385,10 @@ proc_with_prefix test_setup { mode } {
     global mi_spawn_id
     global decimal
     global binfile
-    global GDBFLAGS
     global async
 
     set any "\[^\r\n\]*"
 
-    save_vars { GDBFLAGS } {
-       if { $mode == "non-stop" } {
-           set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop 1\""]
-       }
-
-       if { [mi_clean_restart $binfile "separate-mi-tty"] != 0 } {
-           return -1
-       }
-    }
-
     if { [mi_runto_main] < 0 } {
        return -1
     }
@@ -1300,7 +1289,7 @@ proc_with_prefix test_cli_in_mi_frame { mode cli_in_mi_mode } {
     }
 }
 
-foreach_with_prefix mode { "all-stop" "non-stop" } {
+proc do_test { mode } {
     set test "setup done"
     if { [test_setup $mode] == -1 } {
        fail $test
@@ -1331,3 +1320,25 @@ foreach_with_prefix mode { "all-stop" "non-stop" } {
        test_cli_in_mi_frame $mode $exec_mode
     }
 }
+
+foreach_with_prefix mode { "all-stop" "non-stop" } {
+    save_vars { GDBFLAGS } {
+       if { $mode == "non-stop" } {
+           set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop 1\""]
+       }
+
+       if { [mi_clean_restart $binfile "separate-mi-tty"] != 0 } {
+           break
+       }
+    }
+
+    set res [do_test $mode]
+
+    # mi_clean_restart and gdb_finish call gdb_exit, which doesn't work for
+    # separate-mi-tty.  Use mi_gdb_exit instead.
+    mi_gdb_exit
+
+    if { $res == -1 } {
+       break
+    }
+}