From: Tom de Vries Date: Mon, 24 Feb 2025 20:44:15 +0000 (+0100) Subject: [gdb/testsuite] Exit left-over gdb in gdb.mi/mi-break.exp X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1533f0297dbb19ced8101b6eaf7898f7615938ac;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Exit left-over gdb in gdb.mi/mi-break.exp 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 PR testsuite/32709 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32709 --- diff --git a/gdb/testsuite/gdb.mi/mi-break.exp b/gdb/testsuite/gdb.mi/mi-break.exp index 86e7b57260a..aa8603f4ef0 100644 --- a/gdb/testsuite/gdb.mi/mi-break.exp +++ b/gdb/testsuite/gdb.mi/mi-break.exp @@ -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 { diff --git a/gdb/testsuite/gdb.mi/mi-multi-commands.exp b/gdb/testsuite/gdb.mi/mi-multi-commands.exp index 028e187366a..ce4379c8636 100644 --- a/gdb/testsuite/gdb.mi/mi-multi-commands.exp +++ b/gdb/testsuite/gdb.mi/mi-multi-commands.exp @@ -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" } { diff --git a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp index 08c72182217..261ab7d0369 100644 --- a/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp +++ b/gdb/testsuite/gdb.mi/mi-thread-bp-deleted.exp @@ -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 } diff --git a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp index 715e0f7e804..6026e7b4727 100644 --- a/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp +++ b/gdb/testsuite/gdb.mi/mi-thread-specific-bp.exp @@ -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 + } } diff --git a/gdb/testsuite/gdb.mi/mi-watch.exp b/gdb/testsuite/gdb.mi/mi-watch.exp index a5a442eb13e..cf97d416535 100644 --- a/gdb/testsuite/gdb.mi/mi-watch.exp +++ b/gdb/testsuite/gdb.mi/mi-watch.exp @@ -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 diff --git a/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp b/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp index 938e6deec05..9e529880814 100644 --- a/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp +++ b/gdb/testsuite/gdb.mi/new-ui-bp-deleted.exp @@ -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 } diff --git a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp index 28a42dcb665..bf1365e18ad 100644 --- a/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp +++ b/gdb/testsuite/gdb.mi/new-ui-mi-sync.exp @@ -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 + } } diff --git a/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp b/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp index 5981bc1ad24..effc760d6a7 100644 --- a/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp +++ b/gdb/testsuite/gdb.mi/run-with-two-mi-uis.exp @@ -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} { diff --git a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp index e168a5eee45..675965fec60 100644 --- a/gdb/testsuite/gdb.mi/user-selected-context-sync.exp +++ b/gdb/testsuite/gdb.mi/user-selected-context-sync.exp @@ -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 + } +}