diff options
Diffstat (limited to 'gdb/testsuite/gdb.threads')
123 files changed, 582 insertions, 320 deletions
diff --git a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp index b41e3b2..64d2f53 100644 --- a/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp +++ b/gdb/testsuite/gdb.threads/access-mem-running-thread-exit.exp @@ -51,10 +51,10 @@ proc test { non_stop } { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop $non_stop\"" - clean_restart ${binfile} + clean_restart ${::testfile} } - if ![runto setup_done] { + if {![runto setup_done]} { return -1 } @@ -74,42 +74,45 @@ proc test { non_stop } { delete_breakpoints # Start the second inferior. - with_test_prefix "second inferior" { - # With stub targets that do reload on run, if we let the new - # inferior share inferior 1's connection, runto would - # fail because GDB is already connected to something, like - # e.g. with --target_board=native-gdbserver: - # - # (gdb) kill - # ... - # (gdb) target remote localhost:2348 - # Already connected to a remote target. Disconnect? (y or n) - # - # Instead, start the inferior with no connection, and let - # gdb_load/runto spawn a new remote connection/gdbserver. - # - # OTOH, with extended-remote, we must let the new inferior - # reuse the current connection, so that runto below can - # issue the "run" command, and have the inferior run on the - # remote target. If we forced no connection, then "run" would - # either fail if "set auto-connect-native-target" is on, like - # the native-extended-gdbserver board enforces, or it would - # run the inferior on the native target, which isn't what is - # being tested. - # - # Since it's reload_on_run targets that need special care, we - # default to reusing the connection on most targets. - if [target_info exists gdb,do_reload_on_run] { - gdb_test "add-inferior -no-connection" "New inferior 2.*" - } else { - gdb_test "add-inferior" "New inferior 2.*" - } - gdb_test "inferior 2" "Switching to inferior 2 .*" - - gdb_load $binfile - - if ![runto setup_done] { - return -1 + if {[allow_multi_inferior_tests]} { + with_test_prefix "second inferior" { + # With stub targets that do reload on run, if we let the + # new inferior share inferior 1's connection, runto would + # fail because GDB is already connected to something, like + # e.g. with --target_board=native-gdbserver: + # + # (gdb) kill + # ... + # (gdb) target remote localhost:2348 + # Already connected to a remote target. Disconnect? (y or n) + # + # Instead, start the inferior with no connection, and let + # gdb_load/runto spawn a new remote connection/gdbserver. + # + # OTOH, with extended-remote, we must let the new inferior + # reuse the current connection, so that runto below can + # issue the "run" command, and have the inferior run on + # the remote target. If we forced no connection, then + # "run" would either fail if "set + # auto-connect-native-target" is on, like the + # native-extended-gdbserver board enforces, or it would + # run the inferior on the native target, which isn't what + # is being tested. + # + # Since it's reload_on_run targets that need special care, + # we default to reusing the connection on most targets. + if {[target_info exists gdb,do_reload_on_run]} { + gdb_test "add-inferior -no-connection" "New inferior 2.*" + } else { + gdb_test "add-inferior" "New inferior 2.*" + } + gdb_test "inferior 2" "Switching to inferior 2 .*" + + gdb_load $binfile + + if {![runto setup_done]} { + return -1 + } } } @@ -158,13 +161,15 @@ proc test { non_stop } { verbose -log "xxxxx: iteration $iter" gdb_test -nopass "info threads" - if {$inf == 1} { - set inf 2 - } else { - set inf 1 - } + if {[allow_multi_inferior_tests]} { + if {$inf == 1} { + set inf 2 + } else { + set inf 1 + } - my_gdb_test "inferior $inf" ".*" "inferior $inf" + my_gdb_test "inferior $inf" ".*" "inferior $inf" + } my_gdb_test "print global_var = 555" " = 555" \ "write to global_var" @@ -182,7 +187,7 @@ proc test { non_stop } { } foreach non_stop { "off" "on" } { - set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"] + set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}] with_test_prefix "$stop_mode" { test $non_stop } diff --git a/gdb/testsuite/gdb.threads/async.exp b/gdb/testsuite/gdb.threads/async.exp index b1e562a..6347333 100644 --- a/gdb/testsuite/gdb.threads/async.exp +++ b/gdb/testsuite/gdb.threads/async.exp @@ -32,7 +32,7 @@ proc test_current_thread {expected_thr} { global gdb_prompt global binfile - clean_restart $binfile + clean_restart $::testfile if {![runto "all_started"]} { return diff --git a/gdb/testsuite/gdb.threads/attach-into-signal.exp b/gdb/testsuite/gdb.threads/attach-into-signal.exp index 0629736..ca452c1 100644 --- a/gdb/testsuite/gdb.threads/attach-into-signal.exp +++ b/gdb/testsuite/gdb.threads/attach-into-signal.exp @@ -58,7 +58,7 @@ proc corefunc { threadtype executable } { # nonthreaded: pass $test verbose -log "$test succeeded on the attempt # $attempt of $attempts" - set passes [expr $passes + 1] + set passes [expr {$passes + 1}] } -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" { set ok 0 @@ -84,11 +84,11 @@ proc corefunc { threadtype executable } { if { $ok == 0} { # We just lack the luck, we should try it again. - set attempt [expr $attempt + 1] + set attempt [expr {$attempt + 1}] } else { pass $test verbose -log "$test succeeded on the attempt # $attempt of $attempts" - set passes [expr $passes + 1] + set passes [expr {$passes + 1}] } } }] != 0 } { diff --git a/gdb/testsuite/gdb.threads/attach-non-stop.exp b/gdb/testsuite/gdb.threads/attach-non-stop.exp index 9404edd..b8da5b1 100644 --- a/gdb/testsuite/gdb.threads/attach-non-stop.exp +++ b/gdb/testsuite/gdb.threads/attach-non-stop.exp @@ -37,7 +37,7 @@ proc test {target_non_stop non_stop cmd} { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"maint set target-non-stop $target_non_stop\"" append GDBFLAGS " -ex \"set non-stop $non_stop\"" - clean_restart $binfile + clean_restart $::testfile } set test_spawn_id [spawn_wait_for_attach $binfile] diff --git a/gdb/testsuite/gdb.threads/attach-stopped.exp b/gdb/testsuite/gdb.threads/attach-stopped.exp index e628adf..0391914 100644 --- a/gdb/testsuite/gdb.threads/attach-stopped.exp +++ b/gdb/testsuite/gdb.threads/attach-stopped.exp @@ -40,13 +40,13 @@ proc corefunc { threadtype } { set test_spawn_id [spawn_wait_for_attach $binfile] set testpid [spawn_id_get_pid $test_spawn_id] - # Stop the program + # Stop the program remote_exec build "kill -s STOP ${testpid}" - clean_restart $binfile + clean_restart $::testfile # Verify that we can attach to the stopped process. - + set test "$threadtype: attach2 to stopped, after setting file" gdb_test_multiple "attach $testpid" "$test" { -re "Attaching to program.*`?$escapedbinfile'?, process $testpid.*$gdb_prompt $" { diff --git a/gdb/testsuite/gdb.threads/bp_in_thread.exp b/gdb/testsuite/gdb.threads/bp_in_thread.exp index c63f179..5180c18 100644 --- a/gdb/testsuite/gdb.threads/bp_in_thread.exp +++ b/gdb/testsuite/gdb.threads/bp_in_thread.exp @@ -24,7 +24,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.threads/break-while-running.exp b/gdb/testsuite/gdb.threads/break-while-running.exp index fbc2b59..c1e1051 100644 --- a/gdb/testsuite/gdb.threads/break-while-running.exp +++ b/gdb/testsuite/gdb.threads/break-while-running.exp @@ -39,12 +39,12 @@ proc test { update_thread_list always_inserted non_stop } { global gdb_prompt global decimal - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set non-stop $non_stop" gdb_test_no_output "set breakpoint always-inserted $always_inserted" - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -152,8 +152,8 @@ proc test { update_thread_list always_inserted non_stop } { foreach update_thread_list { true false } { foreach always_inserted { "off" "on" } { foreach non_stop { "off" "on" } { - set stop_mode [expr ($non_stop=="off")?"all-stop":"non-stop"] - set update_list_mode [expr ($update_thread_list)?"w/ithr":"wo/ithr"] + set stop_mode [expr {($non_stop=="off")?"all-stop":"non-stop"}] + set update_list_mode [expr {($update_thread_list)?"w/ithr":"wo/ithr"}] with_test_prefix "$update_list_mode: always-inserted $always_inserted: $stop_mode" { test $update_thread_list $always_inserted $non_stop } diff --git a/gdb/testsuite/gdb.threads/check-libthread-db.exp b/gdb/testsuite/gdb.threads/check-libthread-db.exp index b97ab49..6d63185 100644 --- a/gdb/testsuite/gdb.threads/check-libthread-db.exp +++ b/gdb/testsuite/gdb.threads/check-libthread-db.exp @@ -40,7 +40,7 @@ set initial_thread_re "($thread_re1|$thread_re2)" with_test_prefix "user-initiated check" { # User-initiated check with libthread_db not loaded. - clean_restart ${binfile} + clean_restart ${::testfile} gdb_test "maint show check-libthread-db" \ "Whether to check libthread_db at load time is off." @@ -85,7 +85,7 @@ with_test_prefix "automated load-time check" { # Automated load-time check with NPTL possibly uninitialized. with_test_prefix "libpthread.so possibly not initialized" { - clean_restart ${binfile} + clean_restart ${::testfile} gdb_test_no_output "maint set check-libthread-db 1" gdb_test_no_output "set debug libthread-db 1" @@ -104,7 +104,7 @@ with_test_prefix "automated load-time check" { # Automated load-time check with NPTL fully operational. if { [can_spawn_for_attach] } { with_test_prefix "libpthread.so fully initialized" { - clean_restart ${binfile} + clean_restart ${::testfile} gdb_test_no_output "maint set check-libthread-db 1" gdb_test_no_output "set debug libthread-db 1" diff --git a/gdb/testsuite/gdb.threads/clone-attach-detach.exp b/gdb/testsuite/gdb.threads/clone-attach-detach.exp index 3da2c3e..b0f5e52 100644 --- a/gdb/testsuite/gdb.threads/clone-attach-detach.exp +++ b/gdb/testsuite/gdb.threads/clone-attach-detach.exp @@ -19,7 +19,7 @@ # clone as proxy for when libthread_db is not available. # This only works on targets with the Linux kernel. -if ![istarget *-*-linux*] { +if {![istarget *-*-linux*]} { return } @@ -27,7 +27,7 @@ require can_spawn_for_attach standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/clone-thread_db.exp b/gdb/testsuite/gdb.threads/clone-thread_db.exp index 7ee233d..12349e2 100644 --- a/gdb/testsuite/gdb.threads/clone-thread_db.exp +++ b/gdb/testsuite/gdb.threads/clone-thread_db.exp @@ -16,17 +16,17 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # This only works on targets with the Linux kernel. -if ![istarget *-*-linux*] { +if {![istarget *-*-linux*]} { return } standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp index 5069cd2..1da2e23 100644 --- a/gdb/testsuite/gdb.threads/continue-pending-after-query.exp +++ b/gdb/testsuite/gdb.threads/continue-pending-after-query.exp @@ -51,7 +51,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads} proc test {} { global srcfile gdb_prompt - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/continue-pending-status.exp b/gdb/testsuite/gdb.threads/continue-pending-status.exp index 9cde85a..447b683 100644 --- a/gdb/testsuite/gdb.threads/continue-pending-status.exp +++ b/gdb/testsuite/gdb.threads/continue-pending-status.exp @@ -21,11 +21,11 @@ require {!target_info exists gdb,nointerrupts} standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/corethreads.exp b/gdb/testsuite/gdb.threads/corethreads.exp index 3b50ae3..0011dc3 100644 --- a/gdb/testsuite/gdb.threads/corethreads.exp +++ b/gdb/testsuite/gdb.threads/corethreads.exp @@ -29,6 +29,7 @@ if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executa set corefile [core_find $binfile] if {$corefile == ""} { + untested "unable to create or find corefile" return 0 } diff --git a/gdb/testsuite/gdb.threads/create-fail.exp b/gdb/testsuite/gdb.threads/create-fail.exp index 14f3f4b..5d633f9 100644 --- a/gdb/testsuite/gdb.threads/create-fail.exp +++ b/gdb/testsuite/gdb.threads/create-fail.exp @@ -33,7 +33,7 @@ for {set i 1} {$i <= $iterations} {incr i} { clean_restart ${executable} - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/current-lwp-dead.exp b/gdb/testsuite/gdb.threads/current-lwp-dead.exp index 7aa7ab9..c8364df 100644 --- a/gdb/testsuite/gdb.threads/current-lwp-dead.exp +++ b/gdb/testsuite/gdb.threads/current-lwp-dead.exp @@ -47,6 +47,6 @@ gdb_breakpoint $line gdb_continue_to_breakpoint "fn_return" ".*at-fn_return.*" # Confirm thread 2 is really gone. -gdb_test "info threads 2" "No threads match '2'\\." +gdb_test "info threads 2" "No threads matched\\." gdb_continue_to_end "" continue 1 diff --git a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp index 1fbfc40..bdc519f 100644 --- a/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp +++ b/gdb/testsuite/gdb.threads/del-pending-thread-bp.exp @@ -44,7 +44,7 @@ if { [prepare_for_testing "failed to prepare" $testfile $srcfile \ gdb_locate_shlib $binfile_lib -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/detach-step-over.exp b/gdb/testsuite/gdb.threads/detach-step-over.exp index e48b83c..98b412c 100644 --- a/gdb/testsuite/gdb.threads/detach-step-over.exp +++ b/gdb/testsuite/gdb.threads/detach-step-over.exp @@ -50,6 +50,8 @@ require can_spawn_for_attach +require allow_multi_inferior_tests + standard_testfile set bp_lineno [gdb_get_line_number "Set breakpoint here"] @@ -64,7 +66,7 @@ proc start_gdb_for_test {condition_eval target_non_stop non_stop displaced} { append ::GDBFLAGS " -ex \"set non-stop $non_stop\"" append ::GDBFLAGS " -ex \"set displaced $displaced\"" append ::GDBFLAGS " -ex \"set schedule-multiple on\"" - clean_restart $::binfile + clean_restart $::testfile } gdb_test_no_output "set breakpoint condition-evaluation $condition_eval" @@ -227,7 +229,7 @@ proc_with_prefix test_detach_command {condition_eval target_non_stop non_stop di set running_count 0 set interrupted 0 - set running_expected [expr ($::n_threads + 1) * 2] + set running_expected [expr {($::n_threads + 1) * 2}] gdb_test_multiple "info threads" "threads running" { -re "\\(running\\)" { incr running_count @@ -355,7 +357,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1} return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/execl.exp b/gdb/testsuite/gdb.threads/execl.exp index 502d387..a42dce9 100644 --- a/gdb/testsuite/gdb.threads/execl.exp +++ b/gdb/testsuite/gdb.threads/execl.exp @@ -31,7 +31,7 @@ if {[gdb_compile "${srcdir}/${subdir}/${srcfile1}" "${binfile1}" executable {deb return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if { [is_remote target] } { gdb_remote_download target $binfile1 } diff --git a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp index 5245988..29ec34c 100644 --- a/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp +++ b/gdb/testsuite/gdb.threads/foll-fork-other-thread.exp @@ -17,6 +17,8 @@ # another thread, in different combinations of "set follow-fork # parent/child", and other execution modes. +require allow_fork_tests + standard_testfile # Line where to stop the main thread. @@ -44,7 +46,7 @@ proc do_test { fork_func follow target-non-stop non-stop displaced-stepping } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart ${::binfile}-${fork_func} + clean_restart ${::testfile}-${fork_func} } gdb_test_no_output "set displaced-stepping ${displaced-stepping}" diff --git a/gdb/testsuite/gdb.threads/fork-child-threads.exp b/gdb/testsuite/gdb.threads/fork-child-threads.exp index abe9769..d1b413c 100644 --- a/gdb/testsuite/gdb.threads/fork-child-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-child-threads.exp @@ -13,10 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Only GNU/Linux is known to support `set follow-fork-mode child'. -if { ! [istarget "*-*-linux*"] } { - return 0 -} +require allow_fork_tests standard_testfile @@ -24,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/fork-plus-threads.exp b/gdb/testsuite/gdb.threads/fork-plus-threads.exp index 3a5e66a..c41b164 100644 --- a/gdb/testsuite/gdb.threads/fork-plus-threads.exp +++ b/gdb/testsuite/gdb.threads/fork-plus-threads.exp @@ -20,6 +20,8 @@ # # See https://sourceware.org/bugzilla/show_bug.cgi?id=18600 +require allow_fork_tests + # In remote mode, we cannot continue debugging after all # inferiors have terminated, and this test requires that. if { [target_info exists gdb_protocol] @@ -74,7 +76,7 @@ proc do_test { detach-on-fork } { set saw_cannot_remove_breakpoints 0 set saw_thread_stopped 0 - set expected_num_inferior_exits [expr ${detach-on-fork} == "off" ? 11 : 1] + set expected_num_inferior_exits [expr {${detach-on-fork} == "off" ? 11 : 1}] # Flags indicating if we have see the exit for each inferior. for {set i 1} {$i <= $expected_num_inferior_exits} {incr i} { diff --git a/gdb/testsuite/gdb.threads/fork-thread-pending.exp b/gdb/testsuite/gdb.threads/fork-thread-pending.exp index d0a1ca1..e0e3625 100644 --- a/gdb/testsuite/gdb.threads/fork-thread-pending.exp +++ b/gdb/testsuite/gdb.threads/fork-thread-pending.exp @@ -13,11 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -# Only GNU/Linux is known to support `set follow-fork-mode child'. -# -if { ! [istarget "*-*-linux*"] } { - return 0 -} +require allow_fork_tests standard_testfile @@ -25,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 @@ -79,7 +75,7 @@ gdb_test_multiple "info threads" "$test" { # Start over, but this time, don't switch away from the fork event thread. -clean_restart $binfile +clean_restart $::testfile if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp index 1f76898..d65fe83d 100644 --- a/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp +++ b/gdb/testsuite/gdb.threads/forking-threads-plus-breakpoint.exp @@ -16,6 +16,8 @@ # This test verifies that several threads forking while another thread # is constantly stepping over a breakpoint is properly handled. +require allow_fork_tests + standard_testfile set linenum [gdb_get_line_number "set break here"] @@ -35,7 +37,7 @@ proc probe_displaced_stepping_support {} { global binfile gdb_prompt with_test_prefix "probe displaced-stepping support" { - clean_restart $binfile + clean_restart $::testfile gdb_test_no_output "set displaced on" if {![runto_main]} { @@ -74,7 +76,7 @@ proc do_test { cond_bp_target detach_on_fork displaced } { save_vars { GDBFLAGS } { set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop on\""] - clean_restart $binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.threads/gcore-thread.exp b/gdb/testsuite/gdb.threads/gcore-thread.exp index 4e00f80..f32e9b4 100644 --- a/gdb/testsuite/gdb.threads/gcore-thread.exp +++ b/gdb/testsuite/gdb.threads/gcore-thread.exp @@ -123,7 +123,7 @@ proc load_core { filename } { } # FIXME: now what can we test about the thread state? - # We do not know for certain that there should be at least + # We do not know for certain that there should be at least # three threads, because who knows what kind of many-to-one # mapping various OS's may do? Let's assume that there must # be at least two threads: diff --git a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp index d1be1d0..f9c9e87 100644 --- a/gdb/testsuite/gdb.threads/hand-call-in-threads.exp +++ b/gdb/testsuite/gdb.threads/hand-call-in-threads.exp @@ -44,7 +44,7 @@ proc get_dummy_frame_number { } { return "" } -clean_restart ${binfile} +clean_restart ${::testfile} if { ![runto_main] } { return 0 @@ -74,7 +74,7 @@ gdb_test "show scheduler-locking" ".* locking scheduler .* is \"on\"." "show sch # stop without returning. # Add one for the main thread. -set total_nr_threads [expr $NR_THREADS + 1] +set total_nr_threads [expr {$NR_THREADS + 1}] # Thread numbering in gdb is origin-1, so begin numbering at 1. for { set i 1 } { $i <= $total_nr_threads } { incr i } { diff --git a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp index 6b859ff..479c2ff 100644 --- a/gdb/testsuite/gdb.threads/hand-call-new-thread.exp +++ b/gdb/testsuite/gdb.threads/hand-call-new-thread.exp @@ -18,11 +18,11 @@ standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} { return -1 } -if ![runto_main] { +if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.threads/ia64-sigill.exp b/gdb/testsuite/gdb.threads/ia64-sigill.exp index ac6ff20..46954de 100644 --- a/gdb/testsuite/gdb.threads/ia64-sigill.exp +++ b/gdb/testsuite/gdb.threads/ia64-sigill.exp @@ -27,7 +27,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" ${binfile} executable clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/inf-thr-count.exp b/gdb/testsuite/gdb.threads/inf-thr-count.exp index d7a7687..4508be2 100644 --- a/gdb/testsuite/gdb.threads/inf-thr-count.exp +++ b/gdb/testsuite/gdb.threads/inf-thr-count.exp @@ -43,33 +43,31 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # Start GDB. Ensure we are in non-stop mode as we need to read from # the inferior while it is running. save_vars {GDBFLAGS} { - append GDBFLAGS " -ex \"set non-stop on\"" - clean_restart $binfile + append GDBFLAGS { -ex "set non-stop on"} + clean_restart $::testfile } -if ![runto_main] { +if {![runto_main]} { return -1 } gdb_breakpoint breakpt gdb_continue_to_breakpoint "first breakpt call" +set re_var [string_to_regexp "$"]$decimal + # Check we can see a single thread to begin with. -gdb_test "p \$_inferior_thread_count" \ - "^\\\$$::decimal = 1" \ - "only one thread in \$_inferior_thread_count" +gdb_test {p $_inferior_thread_count} \ + "^$re_var = 1" \ + {only one thread in $_inferior_thread_count} # We don't want thread events, it makes it harder to match GDB's # output. gdb_test_no_output "set print thread-events off" # Continue the program in the background. -set test "continue&" -gdb_test_multiple "continue&" $test { - -re "Continuing\\.\r\n$gdb_prompt " { - pass $test - } -} +gdb_test -no-prompt-anchor "continue&" \ + [string_to_regexp "Continuing."] # Read the 'stage' flag from the inferior. This is initially 0, but # will be set to 1 once the extra thread has been created, and then 2 @@ -88,8 +86,17 @@ proc wait_for_stage { num } { set failure_count 0 set cmd "print /d stage" set stage_flag 0 + + set re_int -?$::decimal + + set re_msg \ + [multi_line \ + "Cannot execute this command while the target is running" \ + {Use the "interrupt" command to stop the target} \ + [string_to_regexp "and then try again."]] + gdb_test_multiple "$cmd" "wait for 'stage' flag to be $num" { - -re -wrap "^Cannot execute this command while the target is running\\.\r\nUse the \"interrupt\" command to stop the target\r\nand then try again\\." { + -re -wrap ^$re_msg { fail "$gdb_test_name (can't read asynchronously)" gdb_test_no_output "interrupt" @@ -101,7 +108,7 @@ proc wait_for_stage { num } { } } - -re -wrap "^\\$\[0-9\]* = (\[-\]*\[0-9\]*).*" { + -re -wrap "^$::re_var = ($re_int).*" { set stage_flag $expect_out(1,string) if {$stage_flag != $num} { set stage_flag 0 @@ -131,8 +138,8 @@ if {![wait_for_stage 1]} { if {[target_info exists gdb_protocol] && ([target_info gdb_protocol] == "remote" || [target_info gdb_protocol] == "extended-remote")} { - set new_thread_re "\\\[New Thread \[^\r\n\]+\\\]\r\n" - set exit_thread_re "\\\[Thread \[^\r\n\]+ exited\\\]\r\n" + set new_thread_re {\[New Thread [^\r\n]+\]\r\n} + set exit_thread_re {\[Thread [^\r\n]+ exited\]\r\n} } else { set new_thread_re "" set exit_thread_re "" @@ -141,9 +148,9 @@ if {[target_info exists gdb_protocol] # This is the test we actually care about. Check that the # $_inferior_thread_count convenience variable shows the correct # thread count; the new thread should be visible. -gdb_test "with print thread-events on -- p \$_inferior_thread_count" \ - "^${new_thread_re}\\\$$::decimal = 2" \ - "second thread visible in \$_inferior_thread_count" +gdb_test {with print thread-events on -- p $_inferior_thread_count} \ + "^${new_thread_re}$re_var = 2" \ + {second thread visible in $_inferior_thread_count} # Set a variable in the inferior, this will cause the second thread to # exit. @@ -157,19 +164,25 @@ if {![wait_for_stage 2]} { } # Check that the second thread has gone away. -gdb_test "with print thread-events on -- p \$_inferior_thread_count" \ - "^${exit_thread_re}\\\$$::decimal = 1" \ - "back to one thread visible in \$_inferior_thread_count" +gdb_test {with print thread-events on -- p $_inferior_thread_count} \ + "^${exit_thread_re}$re_var = 1" \ + {back to one thread visible in $_inferior_thread_count} # Set a variable in the inferior, this will cause the second thread to # exit. -gdb_test_no_output "set variable spin = 0" \ +gdb_test_no_output -no-prompt-anchor "set variable spin = 0" \ "set 'spin' flag to allow main thread to exit" # When the second thread exits, the main thread joins with it, and # then proceeds to hit the breakpt function again. +set re_breakpt [string_to_regexp "breakpt ()"] +set re \ + [multi_line \ + "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, $re_breakpt\[^\r\n\]+" \ + "\[^\r\n\]+" \ + ""] gdb_test_multiple "" "wait for main thread to stop" { - -re "Thread 1 \[^\r\n\]+ hit Breakpoint $decimal, breakpt \\(\\)\[^\r\n\]+\r\n\[^\r\n\]+\r\n" { + -re $re { pass $gdb_test_name } } diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp index 62a183c..35a1fe5 100644 --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-other-thread-event.exp @@ -53,7 +53,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart ${::testfile} } if { ![runto_main] } { diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp index 0f068c6..ed98998 100644 --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-simple.exp @@ -42,7 +42,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart ${::testfile} } if { ![runto_main] } { diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp index c404a7d..bc12fb4 100644 --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-single.exp @@ -38,7 +38,7 @@ proc start_gdb_and_runto_main { target_async target_non_stop } { append ::GDBFLAGS \ " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart ${::testfile} } if { ![runto_main] } { diff --git a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp index 9dbaa4f..03c6959 100644 --- a/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp +++ b/gdb/testsuite/gdb.threads/infcall-from-bp-cond-timeout.exp @@ -52,7 +52,7 @@ proc run_test { target_async target_non_stop non_stop other_thread_bp unwind } { append ::GDBFLAGS " -ex \"maint non-stop $non_stop\"" append ::GDBFLAGS " -ex \"maintenance set target-async ${target_async}\"" - clean_restart ${::binfile} + clean_restart ${::testfile} } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp index 68fd7b7..59a5bcf 100644 --- a/gdb/testsuite/gdb.threads/infcall-thread-announce.exp +++ b/gdb/testsuite/gdb.threads/infcall-thread-announce.exp @@ -23,7 +23,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads} return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp index 2d57136..784caf9 100644 --- a/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp +++ b/gdb/testsuite/gdb.threads/info-threads-cur-sal.exp @@ -25,7 +25,7 @@ if {[gdb_compile_pthreads \ clean_restart ${executable} -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/info-threads-options.c b/gdb/testsuite/gdb.threads/info-threads-options.c new file mode 100644 index 0000000..2c4cd85 --- /dev/null +++ b/gdb/testsuite/gdb.threads/info-threads-options.c @@ -0,0 +1,77 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2022-2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include <stdio.h> +#include <unistd.h> +#include <stdlib.h> +#include <pthread.h> + +#define NUM 4 + +static pthread_barrier_t threads_started_barrier; + +static void +stop_here () +{ +} + +static void +spin () +{ + while (1) + usleep (1); +} + +static void * +work (void *arg) +{ + int id = *(int *) arg; + + pthread_barrier_wait (&threads_started_barrier); + + if (id % 2 == 0) + stop_here (); + else + spin (); + + pthread_exit (NULL); +} + +int +main () +{ + /* Ensure we stop if GDB crashes and DejaGNU fails to kill us. */ + alarm (10); + + pthread_t threads[NUM]; + int ids[NUM]; + + pthread_barrier_init (&threads_started_barrier, NULL, NUM + 1); + + for (int i = 0; i < NUM; i++) + { + ids[i] = i; + pthread_create (&threads[i], NULL, work, &ids[i]); + } + + /* Wait until all threads are seen running. */ + pthread_barrier_wait (&threads_started_barrier); + + stop_here (); + + return 0; +} diff --git a/gdb/testsuite/gdb.threads/info-threads-options.exp b/gdb/testsuite/gdb.threads/info-threads-options.exp new file mode 100644 index 0000000..b322261 --- /dev/null +++ b/gdb/testsuite/gdb.threads/info-threads-options.exp @@ -0,0 +1,131 @@ +# Copyright (C) 2022-2025 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Test the filter flags of the "info threads" command. + +standard_testfile + +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ + executable debug] != "" } { + return -1 +} + +save_vars { GDBFLAGS } { + append GDBFLAGS " -ex \"set non-stop on\"" + clean_restart $::testfile +} + +if {![runto_main]} { + return -1 +} + +gdb_breakpoint "stop_here" +gdb_test_multiple "continue -a&" "" { + -re "Continuing.\r\n$gdb_prompt " { + pass $gdb_test_name + } +} + +set expected_hits 3 +set fill "\[^\r\n\]+" +set num_hits 0 +gdb_test_multiple "" "hit the breakpoint" -lbl { + -re "\r\nThread ${fill} hit Breakpoint ${decimal}," { + incr num_hits + if {$num_hits < $expected_hits} { + exp_continue + } + } +} +gdb_assert {$num_hits == $expected_hits} "expected threads hit the bp" + +# Count the number of running/stopped threads reported +# by the "info threads" command. We also capture thread ids +# for additional tests. +set running_tid "invalid" +set stopped_tid "invalid" + +set eol "(?=\r\n)" + +foreach_with_prefix flag {"" "-running" "-stopped" "-running -stopped"} { + set num_running 0 + set num_stopped 0 + gdb_test_multiple "info threads $flag" "info threads $flag" -lbl { + -re "Id${fill}Target Id${fill}Frame${fill}${eol}" { + exp_continue + } + -re "^\r\n. (${decimal})${fill}Thread ${fill}.running.${eol}" { + incr num_running + set running_tid $expect_out(1,string) + exp_continue + } + -re "^\r\n. (${decimal})${fill}Thread ${fill}stop_here ${fill}${eol}" { + incr num_stopped + set stopped_tid $expect_out(1,string) + exp_continue + } + -re "^\r\n$gdb_prompt $" { + pass $gdb_test_name + } + } + + if {$flag eq "-running"} { + gdb_assert {$num_running == 2} "num running" + gdb_assert {$num_stopped == 0} "num stopped" + } elseif {$flag eq "-stopped"} { + gdb_assert {$num_running == 0} "num running" + gdb_assert {$num_stopped == 3} "num stopped" + } else { + gdb_assert {$num_running == 2} "num running" + gdb_assert {$num_stopped == 3} "num stopped" + } +} + +verbose -log "running_tid=$running_tid, stopped_tid=$stopped_tid" + +# Test specifying thread ids. +gdb_test "info threads -running $stopped_tid" \ + "No threads matched\\." \ + "info thread -running for a stopped thread" +gdb_test "info threads -stopped $running_tid" \ + "No threads matched\\." \ + "info thread -stopped for a running thread" + +set ws "\[ \t\]+" +foreach tid "\"$running_tid\" \"$running_tid $stopped_tid\"" { + gdb_test "info threads -running $tid" \ + [multi_line \ + "${ws}Id${ws}Target Id${ws}Frame${ws}" \ + "${ws}${running_tid}${ws}Thread ${fill}.running."] \ + "info thread -running with [llength $tid] thread ids" +} + +foreach tid "\"$stopped_tid\" \"$stopped_tid $running_tid\"" { + gdb_test "info threads -stopped $tid" \ + [multi_line \ + "${ws}Id${ws}Target Id${ws}Frame${ws}" \ + "${ws}${stopped_tid}${ws}Thread ${fill} stop_here ${fill}"] \ + "info thread -stopped with [llength $tid] thread ids" +} + +gdb_test_multiple "info threads -stopped -running $stopped_tid $running_tid" \ + "filter flags and tids combined" { + -re -wrap ".*stop_here.*running.*" { + pass $gdb_test_name + } + -re -wrap ".*running.*stop_here.*" { + pass $gdb_test_name + } +} diff --git a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp index 05587eb..d3f328b 100644 --- a/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp +++ b/gdb/testsuite/gdb.threads/interrupt-while-step-over.exp @@ -84,7 +84,7 @@ proc test_one_iteration {} { exp_continue } -re "$gdb_prompt " { - if ![gdb_assert $saw_continuing $test] { + if {![gdb_assert $saw_continuing $test]} { return 1 } } @@ -101,7 +101,7 @@ proc test_one_iteration {} { exp_continue } -re "$gdb_prompt " { - if ![gdb_assert {$running_count == $NUM_THREADS} $test] { + if {![gdb_assert {$running_count == $NUM_THREADS} $test]} { return 1 } } @@ -151,7 +151,7 @@ proc test_one_iteration {} { exp_continue } -re "$gdb_prompt " { - if ![gdb_assert {$running_count == 0} $test] { + if {![gdb_assert {$running_count == 0} $test]} { return 1 } } @@ -169,12 +169,12 @@ proc testdriver {displaced} { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop on\"" - clean_restart $binfile + clean_restart $::testfile } gdb_test_no_output "set displaced-stepping $displaced" - if ![runto all_started] { + if {![runto all_started]} { return } set break_line [gdb_get_line_number "set breakpoint here"] diff --git a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp index 3a2bc63..15c48b1 100644 --- a/gdb/testsuite/gdb.threads/interrupted-hand-call.exp +++ b/gdb/testsuite/gdb.threads/interrupted-hand-call.exp @@ -28,7 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if { ![runto_main] } { return 0 diff --git a/gdb/testsuite/gdb.threads/kill.exp b/gdb/testsuite/gdb.threads/kill.exp index 3e6aa8b..72f829c 100644 --- a/gdb/testsuite/gdb.threads/kill.exp +++ b/gdb/testsuite/gdb.threads/kill.exp @@ -23,7 +23,7 @@ standard_testfile proc test {threaded} { global testfile srcfile decimal - with_test_prefix [expr ($threaded)?"threaded":"non-threaded"] { + with_test_prefix [expr {($threaded)?"threaded":"non-threaded"}] { set options {debug} if {$threaded} { diff --git a/gdb/testsuite/gdb.threads/killed.exp b/gdb/testsuite/gdb.threads/killed.exp index b1cec80b0..635ffc8 100644 --- a/gdb/testsuite/gdb.threads/killed.exp +++ b/gdb/testsuite/gdb.threads/killed.exp @@ -29,7 +29,7 @@ # There is absolutely no warranty for GDB. Type "show warranty" for details. # This GDB was configured as "i686-pc-linux-gnu"... # (gdb) run -# Starting program: /home/jimb/foo/play/killed +# Starting program: /home/jimb/foo/play/killed # [New Thread 1024 (LWP 6487)] # [New Thread 2049 (LWP 6488)] # [New Thread 1026 (LWP 6489)] @@ -42,17 +42,17 @@ # Cannot find thread 2049: generic error # (gdb) The program is running. Exit anyway? (y or n) y # Cannot find thread 2049: generic error -# (gdb) +# (gdb) # [7]+ Stopped $D6/gdb/gdb -nw killed # $ kill %7 -# +# # [7]+ Stopped $D6/gdb/gdb -nw killed # $ kill -9 %7 -# +# # [7]+ Stopped $D6/gdb/gdb -nw killed -# $ +# $ # [7]+ Killed $D6/gdb/gdb -nw killed -# $ +# $ standard_testfile @@ -62,7 +62,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_run_cmd gdb_test "" "" "run program to completion" diff --git a/gdb/testsuite/gdb.threads/leader-exit-attach.exp b/gdb/testsuite/gdb.threads/leader-exit-attach.exp index 641d6b5..2df4a18 100644 --- a/gdb/testsuite/gdb.threads/leader-exit-attach.exp +++ b/gdb/testsuite/gdb.threads/leader-exit-attach.exp @@ -31,7 +31,7 @@ set testpid [spawn_id_get_pid $test_spawn_id] # Wait a bit for the leader thread to exit, before attaching. sleep 2 -clean_restart ${binfile} +clean_restart ${::testfile} # Save this early as we may not be able to talk with GDBserver anymore # when we need to check it. diff --git a/gdb/testsuite/gdb.threads/leader-exit.exp b/gdb/testsuite/gdb.threads/leader-exit.exp index 1bc017b..85039b8 100644 --- a/gdb/testsuite/gdb.threads/leader-exit.exp +++ b/gdb/testsuite/gdb.threads/leader-exit.exp @@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab clean_restart ${executable} -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/linux-dp.exp b/gdb/testsuite/gdb.threads/linux-dp.exp index 1652f78..c0ef9c7 100644 --- a/gdb/testsuite/gdb.threads/linux-dp.exp +++ b/gdb/testsuite/gdb.threads/linux-dp.exp @@ -44,7 +44,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" runto_main @@ -117,7 +117,7 @@ for {set i 0} {$i < 5} {incr i} { } else { fail "create philosopher: $i" } - + set threads_after {} gdb_test_multiple "info threads" "info threads after: $i" { -re "info threads\r\n" { @@ -172,7 +172,7 @@ for {set i 1} {$i < $nthreads} {incr i} { append info_threads_ptn "$i *Thread .*" } append info_threads_ptn "\[\r\n\]+$gdb_prompt $" -set info_threads_manager_ptn "[expr $nthreads + 1] *Thread .*$info_threads_ptn" +set info_threads_manager_ptn "[expr {$nthreads + 1}] *Thread .*$info_threads_ptn" gdb_test_multiple "info threads" "info threads 2" { -re "$info_threads_manager_ptn" { @@ -241,7 +241,7 @@ for {set i 0} {$only_five > 0 && $i < 10} {incr i} { -re ".*$gdb_prompt $" { set only_five 0 } - timeout { + timeout { set only_five -1 } } @@ -331,7 +331,7 @@ set any_interesting 0 catch {unset seen} array set seen {} for {set i 1} {$i <= $nthreads} {incr i} { - if [check_philosopher_stack $i seen] { + if {[check_philosopher_stack $i seen]} { set any_interesting 1 } } diff --git a/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp b/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp index 3006b83..a63f0be 100644 --- a/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp +++ b/gdb/testsuite/gdb.threads/local-watch-wrong-thread.exp @@ -28,7 +28,7 @@ if {[gdb_compile_pthreads \ return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set can-use-hw-watchpoints 1" "" diff --git a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp index 20e7bc4..1ce0194 100644 --- a/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp +++ b/gdb/testsuite/gdb.threads/main-thread-exit-during-detach.exp @@ -50,7 +50,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ proc run_test { spawn_inferior } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop on\"" - clean_restart $::binfile + clean_restart $::testfile } # Setup the inferior. When complete the main thread (#1) will diff --git a/gdb/testsuite/gdb.threads/manythreads.exp b/gdb/testsuite/gdb.threads/manythreads.exp index ae51c5a..0a09897 100644 --- a/gdb/testsuite/gdb.threads/manythreads.exp +++ b/gdb/testsuite/gdb.threads/manythreads.exp @@ -22,7 +22,7 @@ require {!target_info exists gdb,nointerrupts} standard_testfile set opts { debug } -if [info exists DEBUG] { +if {[info exists DEBUG]} { # make check RUNTESTFLAGS='gdb.threads/manythreads.exp DEBUG=1' lappend opts "additional_flags=-DDEBUG" } @@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" runto_main diff --git a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp index 1c3231c..c42c1a9 100644 --- a/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp +++ b/gdb/testsuite/gdb.threads/multi-create-ns-info-thr.exp @@ -25,7 +25,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads} gdb_test_no_output "set pagination off" gdb_test_no_output "set non-stop on" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/multi-create.exp b/gdb/testsuite/gdb.threads/multi-create.exp index 966d44d..cb86aac 100644 --- a/gdb/testsuite/gdb.threads/multi-create.exp +++ b/gdb/testsuite/gdb.threads/multi-create.exp @@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} runto_main # Run to the beginning of create_function several times. Make sure diff --git a/gdb/testsuite/gdb.threads/multiple-step-overs.exp b/gdb/testsuite/gdb.threads/multiple-step-overs.exp index 84eef1a..c3456c2 100644 --- a/gdb/testsuite/gdb.threads/multiple-step-overs.exp +++ b/gdb/testsuite/gdb.threads/multiple-step-overs.exp @@ -35,7 +35,7 @@ proc setup {} { with_test_prefix "setup" { clean_restart $executable - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp index 1aa9253..2694ce5 100644 --- a/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp +++ b/gdb/testsuite/gdb.threads/multiple-successive-infcall.exp @@ -23,7 +23,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -clean_restart "${binfile}" +clean_restart "${::testfile}" if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/names.exp b/gdb/testsuite/gdb.threads/names.exp index 6f38c4e..808fa24 100644 --- a/gdb/testsuite/gdb.threads/names.exp +++ b/gdb/testsuite/gdb.threads/names.exp @@ -20,11 +20,11 @@ require {!target_info exists gdb,no_thread_names} standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads}]} { return -1 } -if ![runto "all_threads_ready"] { +if {![runto "all_threads_ready"]} { return } diff --git a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp index cf8d687..293b100 100644 --- a/gdb/testsuite/gdb.threads/next-bp-other-thread.exp +++ b/gdb/testsuite/gdb.threads/next-bp-other-thread.exp @@ -28,9 +28,9 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # Test all "set scheduler-locking" variants. foreach schedlock {"off" "step" "on" } { with_test_prefix "schedlock=$schedlock" { - clean_restart $binfile + clean_restart $::testfile - if ![runto_main] { + if {![runto_main]} { continue } diff --git a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp index bd81438..82e85a6 100644 --- a/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp +++ b/gdb/testsuite/gdb.threads/next-fork-exec-other-thread.exp @@ -25,6 +25,8 @@ # 20.04.5 LTS with 32-bit kernel + 32-bit userland. It was NOT reproducible # using a circa 2023 Raspberry Pi OS w/ 64-bit kernel and 32-bit userland. +require allow_fork_tests + standard_testfile # Line where to stop the main thread. @@ -65,7 +67,7 @@ proc do_test { fork_func target-non-stop non-stop displaced-stepping } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart ${::binfile}-${fork_func} + clean_restart ${::testfile}-${fork_func} } gdb_test_no_output "set displaced-stepping ${displaced-stepping}" diff --git a/gdb/testsuite/gdb.threads/next-fork-other-thread.exp b/gdb/testsuite/gdb.threads/next-fork-other-thread.exp index 183fda6..9349091 100644 --- a/gdb/testsuite/gdb.threads/next-fork-other-thread.exp +++ b/gdb/testsuite/gdb.threads/next-fork-other-thread.exp @@ -16,6 +16,8 @@ # Test doing a "next" on a thread during which forks or vforks happen in other # threads. +require allow_fork_tests + standard_testfile # Line where to stop the main thread. @@ -56,7 +58,7 @@ proc do_test { fork_func target-non-stop non-stop displaced-stepping } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart ${::binfile}-${fork_func} + clean_restart ${::testfile}-${fork_func} } gdb_test_no_output "set displaced-stepping ${displaced-stepping}" diff --git a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp index edeabaf..96b5433 100644 --- a/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp +++ b/gdb/testsuite/gdb.threads/no-unwaited-for-left.exp @@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab clean_restart ${executable} -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp index 846fe89..7d2956d 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-1.exp @@ -31,7 +31,7 @@ proc do_test { lock_sched nonstop } { clean_restart ${executable} } - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp index 860b6b5..bb66644 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-2.exp @@ -33,7 +33,7 @@ proc do_test { lock_sched nonstop } { clean_restart ${executable} } - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp index b50bfac..4490b30 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-3.exp @@ -34,7 +34,7 @@ proc do_test { lock_sched nonstop } { clean_restart ${executable} } - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp index 9892d83..533e14f 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exc-4.exp @@ -33,7 +33,7 @@ proc do_test { lock_sched nonstop } { clean_restart ${executable} } - if ![runto_main] { + if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-ldr-exit.exp b/gdb/testsuite/gdb.threads/non-ldr-exit.exp index b09a37e..4dd1b79 100644 --- a/gdb/testsuite/gdb.threads/non-ldr-exit.exp +++ b/gdb/testsuite/gdb.threads/non-ldr-exit.exp @@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads} return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp index 5def610..788a7e8 100644 --- a/gdb/testsuite/gdb.threads/non-stop-fair-events.exp +++ b/gdb/testsuite/gdb.threads/non-stop-fair-events.exp @@ -28,7 +28,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile $options] == -1} gdb_test_no_output "set non-stop on" -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/omp-par-scope.exp b/gdb/testsuite/gdb.threads/omp-par-scope.exp index 27dbaf0..2a097f5 100644 --- a/gdb/testsuite/gdb.threads/omp-par-scope.exp +++ b/gdb/testsuite/gdb.threads/omp-par-scope.exp @@ -30,7 +30,7 @@ if { [test_compiler_info "clang*"] } { set have_nested_function_support 0 set opts {openmp debug} -if [support_nested_function_tests] { +if {[support_nested_function_tests]} { lappend opts "additional_flags=-DHAVE_NESTED_FUNCTION_SUPPORT" set have_nested_function_support 1 } @@ -191,7 +191,7 @@ with_test_prefix "multi_scope" { # Nested functions in C are a GNU extension, so only do the nested function # tests if compiling with -DHAVE_NESTED_FUNCTION_SUPPORT was successful. -if $have_nested_function_support { +if {$have_nested_function_support} { with_test_prefix "nested_func" { gdb_breakpoint [gdb_get_line_number "nested_func: tn="] diff --git a/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp b/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp index e6e311e..9cc4978 100644 --- a/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp +++ b/gdb/testsuite/gdb.threads/pending-fork-event-detach-ns.exp @@ -29,6 +29,8 @@ # parent thread from waitpid'ing it, preventing the main thread from joining # it, prevent it from writing the flag file, failing the test. +require allow_fork_tests + standard_testfile if { [is_remote target] } { @@ -50,7 +52,7 @@ proc do_test { } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"set non-stop on\"" - clean_restart $::binfile + clean_restart $::testfile } if { ![runto break_here_first] } { diff --git a/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp b/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp index 8e77ab0..fa86488 100644 --- a/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp +++ b/gdb/testsuite/gdb.threads/pending-fork-event-detach.exp @@ -34,6 +34,8 @@ # event, and erroneously create a new inferior for it. Once fixed, the child # process' thread is hidden by whoever holds the pending fork event. +require allow_fork_tests + standard_testfile .c -touch-file.c set touch_file_bin $binfile-touch-file @@ -91,7 +93,8 @@ proc do_test { target-non-stop who_forks fork_function stop_mode } { save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" - clean_restart $this_binfile + clean_restart + gdb_load $this_binfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.threads/pending-step.exp b/gdb/testsuite/gdb.threads/pending-step.exp index 1c2422e..d31f879 100644 --- a/gdb/testsuite/gdb.threads/pending-step.exp +++ b/gdb/testsuite/gdb.threads/pending-step.exp @@ -54,7 +54,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/print-threads.exp b/gdb/testsuite/gdb.threads/print-threads.exp index 51a14b2..a3fcba3 100644 --- a/gdb/testsuite/gdb.threads/print-threads.exp +++ b/gdb/testsuite/gdb.threads/print-threads.exp @@ -32,7 +32,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab # Now we can proceed with the real testing. -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" #gdb_test_no_output "set print address off" @@ -50,13 +50,13 @@ proc test_all_threads { name kill } { set j 0 gdb_test_multiple "continue" "all threads ran once" { -re "Breakpoint \[0-9\]+, thread_function \\(arg=.*\\) at .*print-threads.c:\[0-9\]+.*$gdb_prompt" { - set i [expr $i + 1] + set i [expr {$i + 1}] pass "hit thread_function breakpoint, $i" send_gdb "continue\n" exp_continue } -re "Breakpoint \[0-9\]+, .* kill \\(.*\\) .*$gdb_prompt" { - set j [expr $j + 1] + set j [expr {$j + 1}] if { $kill == 1 } { pass "hit kill breakpoint, $j" } else { @@ -96,7 +96,7 @@ runto_main gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*print-threads.c, line \[0-9\]*\\." "break thread_function, 2" gdb_test_no_output "set var slow = 1" # Extend the timeout for slower tests. -set timeout [expr $oldtimeout + 120] +set timeout [expr {$oldtimeout + 120}] test_all_threads "slow" 0 set timeout $oldtimeout @@ -105,6 +105,6 @@ gdb_test "break thread_function" "Breakpoint \[0-9\]+ at 0x\[0-9a-f\]+: file .*p gdb_test_no_output "set var slow = 1" "set var slow = 1, 2" gdb_breakpoint "kill" # Extend the timeout for slower tests. -set timeout [expr $oldtimeout + 120] +set timeout [expr {$oldtimeout + 120}] test_all_threads "slow with kill breakpoint" 1 set timeout $oldtimeout diff --git a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp index 776c08e..63ddfec 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-detaching.exp @@ -43,6 +43,7 @@ # threads are reaped. We test that as well. standard_testfile +set testfile_base $testfile # Test that GDBserver exits. @@ -187,7 +188,7 @@ proc do_detach {multi_process cmd child_exit} { perror "unhandled command: $cmd" } } else { - if $is_remote { + if {$is_remote} { set extra "\r\nEnding remote debugging\." } else { set extra "" @@ -214,9 +215,9 @@ proc test_detach {multi_process cmd} { with_test_prefix "detach" { global binfile - clean_restart ${binfile} + clean_restart ${::testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -242,9 +243,9 @@ proc test_detach_watch {wp multi_process cmd} { with_test_prefix "watchpoint:$wp" { global binfile decimal - clean_restart ${binfile} + clean_restart ${::testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -290,9 +291,9 @@ proc test_detach_killed_outside {multi_process cmd} { with_test_prefix "killed outside" { global binfile - clean_restart ${binfile} + clean_restart ${::testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -334,14 +335,15 @@ proc do_test {multi_process cmd} { return } - set binfile [standard_output_file ${testfile}-$multi_process-$cmd] + set testfile $::testfile_base-$multi_process-$cmd + set binfile [standard_output_file $testfile] set options {debug pthreads} if {$multi_process} { lappend options "additional_flags=-DMULTIPROCESS" } if {[build_executable "failed to build" \ - $testfile-$multi_process-$cmd $srcfile $options] == -1} { + $testfile $srcfile $options] == -1} { return -1 } diff --git a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp index 26dc8cc..a990dc9 100644 --- a/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp +++ b/gdb/testsuite/gdb.threads/process-dies-while-handling-bp.exp @@ -42,7 +42,7 @@ proc do_test { non_stop cond_bp_target } { save_vars { GDBFLAGS } { set GDBFLAGS [concat $GDBFLAGS " -ex \"set non-stop $non_stop\""] - clean_restart $binfile + clean_restart $::testfile } if {![runto_main]} { diff --git a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp index c1be1cd..e11b904 100644 --- a/gdb/testsuite/gdb.threads/pthread_cond_wait.exp +++ b/gdb/testsuite/gdb.threads/pthread_cond_wait.exp @@ -17,7 +17,7 @@ # bug-gdb@gnu.org # This file verifies that GDB is able to compute a backtrace for a thread -# being blocked on a call to pthread_cond_wait(). +# being blocked on a call to pthread_cond_wait(). standard_testfile @@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} runto_main gdb_test "break break_me" \ @@ -36,7 +36,7 @@ gdb_test "continue" \ ".*Breakpoint 2, break_me ().*" \ "run to break_me" -# +# # Backtrace all threads, find the one running noreturn, and # verify that we are able to get a sensible backtrace, including # the frame for the pthread_cond_wait() call. diff --git a/gdb/testsuite/gdb.threads/pthreads.exp b/gdb/testsuite/gdb.threads/pthreads.exp index 0437e74..04ae91e2 100644 --- a/gdb/testsuite/gdb.threads/pthreads.exp +++ b/gdb/testsuite/gdb.threads/pthreads.exp @@ -34,7 +34,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" #gdb_test_no_output "set print address off" diff --git a/gdb/testsuite/gdb.threads/queue-signal.exp b/gdb/testsuite/gdb.threads/queue-signal.exp index f791ffa..6ab8bbb 100644 --- a/gdb/testsuite/gdb.threads/queue-signal.exp +++ b/gdb/testsuite/gdb.threads/queue-signal.exp @@ -20,9 +20,9 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp index c398137..0937e2a 100644 --- a/gdb/testsuite/gdb.threads/schedlock-new-thread.exp +++ b/gdb/testsuite/gdb.threads/schedlock-new-thread.exp @@ -18,7 +18,7 @@ standard_testfile .c foreach_with_prefix schedlock {off on} { - set sl [expr $schedlock == "on" ? 1 : 0] + set sl [expr {$schedlock == "on" ? 1 : 0}] if { [build_executable "failed to prepare" $testfile-$sl \ $srcfile \ [list debug pthreads additional_flags=-DSCHEDLOCK=$sl]] \ @@ -30,8 +30,8 @@ foreach_with_prefix schedlock {off on} { proc test {non-stop schedlock} { save_vars ::GDBFLAGS { append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - set sl [expr $schedlock == "on" ? 1 : 0] - clean_restart $::binfile-$sl + set sl [expr {$schedlock == "on" ? 1 : 0}] + clean_restart $::testfile-$sl } set linenum1 [gdb_get_line_number "set break 1 here"] diff --git a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp index 434b058..137f652 100644 --- a/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp +++ b/gdb/testsuite/gdb.threads/schedlock-thread-exit.exp @@ -28,7 +28,7 @@ if { [build_executable "failed to prepare" ${testfile} ${srcfile} \ } proc do_test { } { - clean_restart $::binfile + clean_restart $::testfile # One of the launched threads will report a stop on thread_func. Some # others will also stop on thread_func and have a pending status. diff --git a/gdb/testsuite/gdb.threads/schedlock.exp b/gdb/testsuite/gdb.threads/schedlock.exp index 4e2b835..1257868 100644 --- a/gdb/testsuite/gdb.threads/schedlock.exp +++ b/gdb/testsuite/gdb.threads/schedlock.exp @@ -41,7 +41,7 @@ proc get_args { description } { global NUM set pattern "(\[0-9\]+)" - for {set i 1} {[expr $i < $NUM]} {incr i} { + for {set i 1} {$i < $NUM} {incr i} { append pattern ", (\[0-9\]+)" } @@ -51,7 +51,7 @@ proc get_args { description } { pass $test set result "" - for {set i 1} {[expr $i <= $NUM]} {incr i} { + for {set i 1} {[expr {$i <= $NUM}]} {incr i} { lappend result $expect_out($i,string) } return $result @@ -122,7 +122,7 @@ proc my_continue { msg } { proc step_ten_loops { cmd } { global gdb_prompt - for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} { + for {set i 0} {$i < 10} {incr i} { set other_step 0 set test "$cmd to increment, $i" gdb_test_multiple $cmd $test { @@ -183,7 +183,7 @@ my_continue "initial" set cont_args [get_args "after initial"] set bad 0 -for {set i 0} {[expr $i < $NUM]} {set i [expr $i + 1]} { +for {set i 0} {$i < $NUM} {incr i} { if {[lindex $start_args $i] == [lindex $cont_args $i]} { incr bad } @@ -233,7 +233,7 @@ proc check_result { cmd before_thread before_args locked } { } else { if {$i == $before_thread} { if {$cmd == "continue" - || [lindex $before_args $i] == [expr [lindex $after_args $i] - 10]} { + || [lindex $before_args $i] == [lindex $after_args $i] - 10} { pass "$test" } else { fail "$test (wrong amount)" diff --git a/gdb/testsuite/gdb.threads/siginfo-threads.exp b/gdb/testsuite/gdb.threads/siginfo-threads.exp index ecc372d..253c4c0 100644 --- a/gdb/testsuite/gdb.threads/siginfo-threads.exp +++ b/gdb/testsuite/gdb.threads/siginfo-threads.exp @@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" \ clean_restart $testfile -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp index 2586800..6d344e3 100644 --- a/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp +++ b/gdb/testsuite/gdb.threads/signal-command-handle-nopass.exp @@ -35,7 +35,7 @@ proc test { step_over } { global srcfile binfile tdlabel_re with_test_prefix "step-over $step_over" { - clean_restart ${binfile} + clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp index 73f88c1..acb018b 100644 --- a/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp +++ b/gdb/testsuite/gdb.threads/signal-command-multiple-signals-pending.exp @@ -32,7 +32,7 @@ proc test { schedlock } { global srcfile binfile tdlabel_re with_test_prefix "schedlock $schedlock" { - clean_restart ${binfile} + clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp index 7445cad..9de0908 100644 --- a/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp +++ b/gdb/testsuite/gdb.threads/signal-delivered-right-thread.exp @@ -29,7 +29,7 @@ proc test { command } { global srcfile binfile tdlabel_re with_test_prefix "$command" { - clean_restart ${binfile} + clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/signal-sigtrap.exp b/gdb/testsuite/gdb.threads/signal-sigtrap.exp index 8154ddf..849d628 100644 --- a/gdb/testsuite/gdb.threads/signal-sigtrap.exp +++ b/gdb/testsuite/gdb.threads/signal-sigtrap.exp @@ -32,7 +32,7 @@ proc test { sigtrap_thread } { global srcfile binfile tdlabel_re with_test_prefix "sigtrap thread $sigtrap_thread" { - clean_restart ${binfile} + clean_restart ${::testfile} if {![runto "thread_function"]} { return 0 diff --git a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp index e2f7581..b7a110d 100644 --- a/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp +++ b/gdb/testsuite/gdb.threads/signal-while-stepping-over-bp-other-thread.exp @@ -51,7 +51,7 @@ proc get_value {var test} { clean_restart $executable -if ![runto_main] { +if {![runto_main]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/sigstep-threads.exp b/gdb/testsuite/gdb.threads/sigstep-threads.exp index 0580cd0..9aed9e3 100644 --- a/gdb/testsuite/gdb.threads/sigstep-threads.exp +++ b/gdb/testsuite/gdb.threads/sigstep-threads.exp @@ -23,7 +23,7 @@ if { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executa clean_restart $executable -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -65,7 +65,7 @@ for {set i 0} {$i < 100} {incr i} { set step_at $now } } - if $failed { + if {$failed} { return } } diff --git a/gdb/testsuite/gdb.threads/sigthread.exp b/gdb/testsuite/gdb.threads/sigthread.exp index 9d2f9b5..dea8eb8 100644 --- a/gdb/testsuite/gdb.threads/sigthread.exp +++ b/gdb/testsuite/gdb.threads/sigthread.exp @@ -24,7 +24,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/staticthreads.exp b/gdb/testsuite/gdb.threads/staticthreads.exp index 0374666..44cc686 100644 --- a/gdb/testsuite/gdb.threads/staticthreads.exp +++ b/gdb/testsuite/gdb.threads/staticthreads.exp @@ -34,7 +34,7 @@ foreach_with_prefix have_tls { "-DHAVE_TLS" "" } { } } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" @@ -51,7 +51,7 @@ gdb_test_multiple "continue" "$test" { kfail gdb/1328 "$test" } } - + # See if handle SIG32 helps (a little) with a static multi-threaded # program. @@ -59,7 +59,7 @@ gdb_test_multiple "continue" "$test" { set sig "SIG32" # SIGRTMIN is 37 on hppa-linux -if [istarget hppa*-*-*] { +if {[istarget hppa*-*-*]} { set sig "SIG37" } @@ -94,11 +94,11 @@ gdb_test_multiple "quit" "$test" { pass "$test" } } -clean_restart ${binfile} +clean_restart ${::testfile} if { "$have_tls" != "" } { - if ![runto_main] { + if {![runto_main]} { return -1 } gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"] diff --git a/gdb/testsuite/gdb.threads/step-N-all-progress.exp b/gdb/testsuite/gdb.threads/step-N-all-progress.exp index c874d79..031e36a 100644 --- a/gdb/testsuite/gdb.threads/step-N-all-progress.exp +++ b/gdb/testsuite/gdb.threads/step-N-all-progress.exp @@ -31,7 +31,7 @@ proc test {non-stop target-non-stop} { save_vars ::GDBFLAGS { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart $::binfile + clean_restart $::testfile } if { ![runto_main] } { diff --git a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp index 309c826..82861a9 100644 --- a/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp +++ b/gdb/testsuite/gdb.threads/step-bg-decr-pc-switch-thread.exp @@ -34,7 +34,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug pthreads} return -1 } -if ![runto_main] { +if {![runto_main]} { return } @@ -55,7 +55,7 @@ gdb_test_no_output "next&" "next& over inf loop" set test "switch to main thread" gdb_test_multiple "thread 1" $test { -re "Cannot execute this command while the target is running.*$gdb_prompt $" { - + # With remote targets, we can't send any other remote packet # until the target stops. Switching thread wants to ask the # remote side whether the thread is alive. diff --git a/gdb/testsuite/gdb.threads/step-over-exec.exp b/gdb/testsuite/gdb.threads/step-over-exec.exp index 7c553f2..22b9a13 100644 --- a/gdb/testsuite/gdb.threads/step-over-exec.exp +++ b/gdb/testsuite/gdb.threads/step-over-exec.exp @@ -71,11 +71,12 @@ proc do_test { execr_thread different_text_segments displaced_stepping } { return -1 } - clean_restart ${execr_binfile} + clean_restart + gdb_load $execr_binfile gdb_test_no_output "set displaced-stepping $displaced_stepping" - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp index 65aa2f1..3a96e0e 100644 --- a/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp +++ b/gdb/testsuite/gdb.threads/step-over-lands-on-breakpoint.exp @@ -32,7 +32,7 @@ proc do_test {displaced command} { with_test_prefix "displaced=$displaced: $command" { clean_restart $executable - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp b/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp index cf10bdc..fdd2b27 100644 --- a/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp +++ b/gdb/testsuite/gdb.threads/step-over-thread-exit-while-stop-all-threads.exp @@ -29,7 +29,7 @@ if { [build_executable "failed to prepare" $testfile \ proc test {displaced-stepping target-non-stop} { save_vars ::GDBFLAGS { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" - clean_restart $::binfile + clean_restart $::testfile } gdb_test_no_output "set displaced-stepping ${displaced-stepping}" diff --git a/gdb/testsuite/gdb.threads/step-over-thread-exit.exp b/gdb/testsuite/gdb.threads/step-over-thread-exit.exp index 31037a7..8ed2b21 100644 --- a/gdb/testsuite/gdb.threads/step-over-thread-exit.exp +++ b/gdb/testsuite/gdb.threads/step-over-thread-exit.exp @@ -55,7 +55,7 @@ proc test {step_over_mode non-stop target-non-stop schedlock cmd ns_stop_all} { save_vars ::GDBFLAGS { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart $::binfile + clean_restart $::testfile } if { $step_over_mode == "none" } { diff --git a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp index 9a028fe..0e99656 100644 --- a/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp +++ b/gdb/testsuite/gdb.threads/step-over-trips-on-watchpoint.exp @@ -38,7 +38,7 @@ proc do_test { displaced with_bp } { global gdb_prompt global hex - if ${with_bp} { + if {${with_bp}} { set prefix "with thread-specific bp" } else { set prefix "no thread-specific bp" @@ -49,7 +49,7 @@ proc do_test { displaced with_bp } { with_test_prefix $command { clean_restart $executable - if ![runto_main] { + if {![runto_main]} { continue } @@ -106,7 +106,7 @@ proc do_test { displaced with_bp } { gdb_test "p watch_me = 0" " = 0" "clear watch_me" gdb_test "watch watch_me" "Hardware watchpoint .*" - if ${with_bp} { + if {${with_bp}} { gdb_test "b *$after_address_triggers_watch thread 1" \ "Breakpoint .*" \ "set breakpoint specific to thread 1" diff --git a/gdb/testsuite/gdb.threads/stepi-over-clone.exp b/gdb/testsuite/gdb.threads/stepi-over-clone.exp index 5da123e..e0b14cb 100644 --- a/gdb/testsuite/gdb.threads/stepi-over-clone.exp +++ b/gdb/testsuite/gdb.threads/stepi-over-clone.exp @@ -58,8 +58,8 @@ gdb_test "continue" \ # Return true if INSN is a syscall instruction. proc is_syscall_insn { insn } { - if [istarget x86_64-*-* ] { - return { $insn == "syscall" } + if {[istarget x86_64-*-* ]} { + return [string equal $insn "syscall"] } else { error "port me" } @@ -76,7 +76,7 @@ gdb_test_multiple "disassemble" "" { -re "^(?:=>)?\\s+(${hex})\\s+<\\+${decimal}>:\\s+(\[^\r\n\]+)\r\n" { set addr $expect_out(1,string) set insn [string trim $expect_out(2,string)] - if [is_syscall_insn $insn] { + if {[is_syscall_insn $insn]} { verbose -log "Found a syscall at: $addr" lappend syscall_addrs $addr } @@ -106,7 +106,7 @@ proc test {non_stop displaced third_thread} { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop $non_stop\"" append GDBFLAGS " -ex \"set displaced $displaced\"" - clean_restart $binfile + clean_restart $::testfile } runto_main diff --git a/gdb/testsuite/gdb.threads/stepi-random-signal.exp b/gdb/testsuite/gdb.threads/stepi-random-signal.exp index 8ac81e8..a2d7743 100644 --- a/gdb/testsuite/gdb.threads/stepi-random-signal.exp +++ b/gdb/testsuite/gdb.threads/stepi-random-signal.exp @@ -31,7 +31,7 @@ if { [gdb_compile_pthreads \ clean_restart $executable # Start the second thread. -if ![runto start] { +if {![runto start]} { return -1 } diff --git a/gdb/testsuite/gdb.threads/switch-threads.exp b/gdb/testsuite/gdb.threads/switch-threads.exp index d43603c..1f67a45 100644 --- a/gdb/testsuite/gdb.threads/switch-threads.exp +++ b/gdb/testsuite/gdb.threads/switch-threads.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.threads/thread-bp-deleted.exp b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp index 2eadd38..19b5001 100644 --- a/gdb/testsuite/gdb.threads/thread-bp-deleted.exp +++ b/gdb/testsuite/gdb.threads/thread-bp-deleted.exp @@ -31,14 +31,15 @@ if {[build_executable "failed to prepare" $testfile $srcfile \ # We need to do things a little differently when using the remote protocol. set is_remote \ - [expr [target_info exists gdb_protocol] \ - && ([string equal [target_info gdb_protocol] "remote"] \ - || [string equal [target_info gdb_protocol] "extended-remote"])] + [expr \ + {[target_info exists gdb_protocol] + && ([string equal [target_info gdb_protocol] "remote"] + || [string equal [target_info gdb_protocol] "extended-remote"])}] # This test requires background execution, which relies on non-stop mode. save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"maint set target-non-stop on\"" - clean_restart ${binfile} + clean_restart ${::testfile} } if {![runto_main]} { @@ -147,7 +148,7 @@ if {$is_remote} { exp_continue } - -re "No threads match '99'\\.\r\n$gdb_prompt $" { + -re "No threads matched\\.\r\n$gdb_prompt $" { if {!$saw_thread_exited && !$saw_bp_deleted && $attempt_count > 0} { sleep 1 incr attempt_count -1 diff --git a/gdb/testsuite/gdb.threads/thread-execl.c b/gdb/testsuite/gdb.threads/thread-execl.c index 403aa31..2d312d4 100644 --- a/gdb/testsuite/gdb.threads/thread-execl.c +++ b/gdb/testsuite/gdb.threads/thread-execl.c @@ -25,8 +25,9 @@ static const char *image; void * thread_execler (void *arg) { - /* Exec ourselves again. */ - if (execl (image, image, NULL) == -1) + /* Exec ourselves again. Pass an extra argument so that the + post-exec image knows to not re-exec yet again. */ + if (execl (image, image, "1", NULL) == -1) { perror ("execl"); abort (); @@ -40,6 +41,11 @@ main (int argc, char **argv) { pthread_t thread; + /* An extra argument means we're in the post-exec image, so we're + done. Don't re-exec again. */ + if (argc > 1) + exit (0); + image = argv[0]; pthread_create (&thread, NULL, thread_execler, NULL); diff --git a/gdb/testsuite/gdb.threads/thread-execl.exp b/gdb/testsuite/gdb.threads/thread-execl.exp index 04ba518..d1c80df 100644 --- a/gdb/testsuite/gdb.threads/thread-execl.exp +++ b/gdb/testsuite/gdb.threads/thread-execl.exp @@ -35,13 +35,13 @@ proc do_test { schedlock } { set prefix "schedlock $schedlock" } with_test_prefix "$prefix" { - clean_restart ${binfile} + clean_restart ${::testfile} if {$schedlock == "non-stop"} { gdb_test_no_output "set non-stop 1" } - if ![runto_main] { + if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/thread-find.exp b/gdb/testsuite/gdb.threads/thread-find.exp index 456f7d3..171b94b 100644 --- a/gdb/testsuite/gdb.threads/thread-find.exp +++ b/gdb/testsuite/gdb.threads/thread-find.exp @@ -21,7 +21,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" runto_main diff --git a/gdb/testsuite/gdb.threads/thread-specific-bp.exp b/gdb/testsuite/gdb.threads/thread-specific-bp.exp index c4858f2..8f48b61 100644 --- a/gdb/testsuite/gdb.threads/thread-specific-bp.exp +++ b/gdb/testsuite/gdb.threads/thread-specific-bp.exp @@ -118,7 +118,7 @@ proc check_thread_specific_breakpoint {non_stop} { foreach_with_prefix non_stop {on off} { save_vars { GDBFLAGS } { append GDBFLAGS " -ex \"set non-stop $non_stop\"" - clean_restart $binfile + clean_restart $::testfile } check_thread_specific_breakpoint $non_stop diff --git a/gdb/testsuite/gdb.threads/thread-specific.exp b/gdb/testsuite/gdb.threads/thread-specific.exp index bf9c63b..d1e6f4d 100644 --- a/gdb/testsuite/gdb.threads/thread-specific.exp +++ b/gdb/testsuite/gdb.threads/thread-specific.exp @@ -62,7 +62,7 @@ proc get_thread_list { } { return $thr_list } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set print sevenbit-strings" gdb_test_no_output "set width 0" diff --git a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp index 5f4ac1f..dc74714 100644 --- a/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp +++ b/gdb/testsuite/gdb.threads/thread-unwindonsignal.exp @@ -28,7 +28,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if { ![runto_main] } { return 0 diff --git a/gdb/testsuite/gdb.threads/thread_check.exp b/gdb/testsuite/gdb.threads/thread_check.exp index ee5f35a..6378e8a 100644 --- a/gdb/testsuite/gdb.threads/thread_check.exp +++ b/gdb/testsuite/gdb.threads/thread_check.exp @@ -15,16 +15,16 @@ # This file was written by Manoj Iyer. (manjo@austin.ibm.com) # Test break points and single step on thread functions. -# +# # Test Purpose: -# - Test that breakpoints, continue in a threaded application works. +# - Test that breakpoints, continue in a threaded application works. # On powerpc64-unknown-linux-gnu system, running kernel version # 2.6.5-7.71-pseries64 this test is known to fail due to kernel bug # in ptrace system call. # # Test Strategy: # - thread_check.c creates 2 threads -# - start gdb +# - start gdb # - create 2 breakpoints #1 main() #2 tf() (the thread function) # - run gdb till #1 main() breakpoint is reached # - continue to breakpoint #2 tf() @@ -39,7 +39,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 1 @@ -62,7 +62,7 @@ gdb_test "continue" \ ".*Breakpoint 2,.*tf.*at.*$srcfile:.*" \ "continue to tf" -# +# # backtrace from thread function. # gdb_test "backtrace" \ diff --git a/gdb/testsuite/gdb.threads/threadapply.exp b/gdb/testsuite/gdb.threads/threadapply.exp index c53db79..de264b6 100644 --- a/gdb/testsuite/gdb.threads/threadapply.exp +++ b/gdb/testsuite/gdb.threads/threadapply.exp @@ -25,7 +25,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} # # Run to `main' where we begin our tests. @@ -60,7 +60,7 @@ gdb_test "thread apply all backthread" "Thread ..*\\\$\[0-9]+ = 0x14.*Thread ..* # Go into the thread_function to check that a simple "thread apply" # does not change the selected frame. gdb_test "step" "thread_function.*" "step to the thread_function" -gdb_test "up" ".*in main.*" "go up in the stack frame" +gdb_test "up" ".*in main.*" "go up in the stack frame" gdb_test "thread apply all print 1" "Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1.*Thread ..*\\\$\[0-9]+ = 1" "run a simple print command on all threads" gdb_test "down" "#0.*thread_function.*" "go down and check selected frame" @@ -73,9 +73,9 @@ proc thr_apply_detach {thread_set} { global binfile global break_line - clean_restart ${binfile} + clean_restart ${::testfile} - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -104,7 +104,7 @@ proc kill_and_remove_inferior {thread_set} { # The test starts multiple inferiors, therefore non-extended # remote is not supported. - if [use_gdb_stub] { + if {[use_gdb_stub]} { unsupported "using gdb stub" return } @@ -112,7 +112,7 @@ proc kill_and_remove_inferior {thread_set} { set any "\[^\r\n\]*" set ws "\[ \t\]\+" - clean_restart ${binfile} + clean_restart ${::testfile} with_test_prefix "start inferior 1" { runto_main @@ -224,6 +224,8 @@ proc kill_and_remove_inferior {thread_set} { # Test both "all" and a thread list, because those are implemented as # different commands in GDB. -foreach_with_prefix thread_set {"all" "1.1"} { - kill_and_remove_inferior $thread_set +if {[allow_multi_inferior_tests]} { + foreach_with_prefix thread_set {"all" "1.1"} { + kill_and_remove_inferior $thread_set + } } diff --git a/gdb/testsuite/gdb.threads/threadcrash.exp b/gdb/testsuite/gdb.threads/threadcrash.exp index 15d2a20..d57f437 100644 --- a/gdb/testsuite/gdb.threads/threadcrash.exp +++ b/gdb/testsuite/gdb.threads/threadcrash.exp @@ -132,8 +132,9 @@ proc do_full_test {} { set pthread_kill ".*" } - for {set i 0} {$i < $thread_count } {incr i} { - set thread_num [expr [llength $test_list] - $i] + set loop_iterations [llength $test_list] + for {set i 0} {$i < $loop_iterations } {incr i} { + set thread_num [expr {$loop_iterations - $i}] set type [lindex $test_list $i] if { $type == 1 } { @@ -237,7 +238,7 @@ proc_with_prefix test_corefile {} { proc_with_prefix test_gcore {} { - clean_restart "$::binfile" + clean_restart "$::testfile" gdb_test "handle SIGUSR1 nostop print pass" \ ".*SIGUSR1.*No.*Yes.*Yes.*User defined signal 1" \ @@ -270,12 +271,12 @@ proc_with_prefix test_gcore {} { standard_testfile -if [prepare_for_testing "failed to prepare" $testfile $srcfile \ - {debug pthreads}] { +if {[prepare_for_testing "failed to prepare" $testfile $srcfile \ + {debug pthreads}]} { return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set backtrace limit unlimited" diff --git a/gdb/testsuite/gdb.threads/threads-after-exec.exp b/gdb/testsuite/gdb.threads/threads-after-exec.exp index db26315..a6a3fb7 100644 --- a/gdb/testsuite/gdb.threads/threads-after-exec.exp +++ b/gdb/testsuite/gdb.threads/threads-after-exec.exp @@ -19,11 +19,11 @@ standard_testfile .c proc do_test { } { - if [prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}] { + if {[prepare_for_testing "failed to prepare" $::testfile $::srcfile {debug pthreads}]} { return -1 } - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp index ce2df7c..b55e80c 100644 --- a/gdb/testsuite/gdb.threads/threxit-hop-specific.exp +++ b/gdb/testsuite/gdb.threads/threxit-hop-specific.exp @@ -23,7 +23,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" \ return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} runto_main diff --git a/gdb/testsuite/gdb.threads/tid-reuse.exp b/gdb/testsuite/gdb.threads/tid-reuse.exp index 6762127..ca5edc1 100644 --- a/gdb/testsuite/gdb.threads/tid-reuse.exp +++ b/gdb/testsuite/gdb.threads/tid-reuse.exp @@ -22,7 +22,7 @@ if {[prepare_for_testing "failed to prepare" $testfile $srcfile { debug pthreads return -1 } -if ![runto_main] { +if {![runto_main]} { return -1 } @@ -72,6 +72,6 @@ delete_breakpoints gdb_breakpoint "after_reuse_time" # Higher than what the test program sleeps before exiting. -set timeout [expr $reuse_time * 2] +set timeout [expr {$reuse_time * 2}] gdb_continue_to_breakpoint "after_reuse_time" diff --git a/gdb/testsuite/gdb.threads/tls-core.exp b/gdb/testsuite/gdb.threads/tls-core.exp index 96b1c6a..587ae61 100644 --- a/gdb/testsuite/gdb.threads/tls-core.exp +++ b/gdb/testsuite/gdb.threads/tls-core.exp @@ -27,7 +27,7 @@ set core_supported [expr {$corefile != ""}] # Generate a core file with "gcore". -clean_restart ${binfile} +clean_restart ${::testfile} runto thread_proc @@ -43,7 +43,7 @@ proc tls_core_test {supported corefile} { upvar host_triplet host_triplet upvar binfile binfile - clean_restart ${binfile} + clean_restart ${::testfile} set test "load core file" if {$supported} { diff --git a/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp index 01abcfa..44c12f5 100644 --- a/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp +++ b/gdb/testsuite/gdb.threads/tls-nodebug-pie.exp @@ -20,7 +20,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/tls-nodebug.exp b/gdb/testsuite/gdb.threads/tls-nodebug.exp index ebfa752..971f26c 100644 --- a/gdb/testsuite/gdb.threads/tls-nodebug.exp +++ b/gdb/testsuite/gdb.threads/tls-nodebug.exp @@ -26,7 +26,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp index 6f3c711..fb684c9 100644 --- a/gdb/testsuite/gdb.threads/tls-sepdebug.exp +++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp @@ -83,7 +83,7 @@ foreach library_path [list $absdir [relative_filename [pwd] $absdir]] \ gdb_load ${binmainfile} - if ![runto_main] { + if {![runto_main]} { return } diff --git a/gdb/testsuite/gdb.threads/tls-shared.exp b/gdb/testsuite/gdb.threads/tls-shared.exp index 35596bc..66dd52f 100644 --- a/gdb/testsuite/gdb.threads/tls-shared.exp +++ b/gdb/testsuite/gdb.threads/tls-shared.exp @@ -29,7 +29,7 @@ if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_li } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_load_shlib ${binfile_lib} if {![runto_main]} { @@ -52,6 +52,6 @@ gdb_test "break $line_number" \ gdb_test "continue" \ "main .* at .*:.*return 0.*break here to check result.*" \ "continue to break" -# This is more of a gcc/glibc test, really. +# This is more of a gcc/glibc test, really. # gdb_test "print result" "3" diff --git a/gdb/testsuite/gdb.threads/tls-so_extern.exp b/gdb/testsuite/gdb.threads/tls-so_extern.exp index 3cef672..a0aa5f8 100644 --- a/gdb/testsuite/gdb.threads/tls-so_extern.exp +++ b/gdb/testsuite/gdb.threads/tls-so_extern.exp @@ -28,7 +28,7 @@ if { [gdb_compile_shlib_pthreads ${srcdir}/${subdir}/${srcfile_lib} ${binfile_li } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_load_shlib ${binfile_lib} if {![runto_main]} { diff --git a/gdb/testsuite/gdb.threads/tls-var.exp b/gdb/testsuite/gdb.threads/tls-var.exp index de74bd9..8d8b82e 100644 --- a/gdb/testsuite/gdb.threads/tls-var.exp +++ b/gdb/testsuite/gdb.threads/tls-var.exp @@ -27,7 +27,7 @@ if { [gdb_compile ${srcdir}/${subdir}/${srcfile} ${objfile} object {debug}] != " clean_restart ${executable} -if ![runto_main] { +if {![runto_main]} { return 0 } diff --git a/gdb/testsuite/gdb.threads/tls.exp b/gdb/testsuite/gdb.threads/tls.exp index 1bc5df2..3dbc802 100644 --- a/gdb/testsuite/gdb.threads/tls.exp +++ b/gdb/testsuite/gdb.threads/tls.exp @@ -56,7 +56,7 @@ proc get_me_variable {tnum} { fail "$tnum thread print me" } timeout { - fail "$tnum thread print me (timeout)" + fail "$tnum thread print me (timeout)" } } return ${value_of_me} @@ -116,8 +116,8 @@ proc select_thread {thread} { ### Do a backtrace for the current thread, and check that the 'spin' routine ### is in it. This means we have one of the threads we created, rather -### than the main thread. Record the thread in the spin_threads -### array. Also remember the level of the 'spin' routine in the backtrace, for +### than the main thread. Record the thread in the spin_threads +### array. Also remember the level of the 'spin' routine in the backtrace, for ### later use. proc check_thread_stack {number spin_threads spin_threads_level} { global gdb_prompt @@ -148,18 +148,18 @@ proc check_thread_stack {number spin_threads spin_threads_level} { pass "backtrace of thread number $number not relevant" } timeout { - fail "backtrace of thread number $number (timeout)" + fail "backtrace of thread number $number (timeout)" } } } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_multiple "print a_thread_local" "" { -re -wrap "Cannot find thread-local variables on this target" { kfail "gdb/25807" $gdb_test_name } - -re -wrap "Cannot read .a_thread_local. without registers" { + -re -wrap "Cannot (?:read|find address of TLS symbol) .a_thread_local. without registers" { pass $gdb_test_name } } @@ -169,7 +169,7 @@ if {![runto_main]} { } # Set a breakpoint at the "spin" routine to -# test the thread local's value. +# test the thread local's value. # gdb_test "b [gdb_get_line_number "here we know tls value"]" \ ".*Breakpoint 2.*tls.*" "set breakpoint at all threads" @@ -247,7 +247,7 @@ array set spin_threads_level {} unset spin_threads_level # For each thread check its backtrace to see if it is stopped at the -# spin routine. +# spin routine. for {set i 1} {$i <= $no_of_threads} {incr i} { check_thread_stack $i spin_threads spin_threads_level } @@ -268,7 +268,7 @@ foreach i [array names spin_threads] { # any intermediate point in spin, too, but that is much less # likely. gdb_test "up $level" ".*spin.*sem_(wait|post).*" "thread $i up" - check_thread_local $i + check_thread_local $i } } @@ -278,7 +278,7 @@ if {$thrs_in_spin == 0} { gdb_test "continue" ".*Breakpoint 4.*before exit.*" "threads exited" -send_gdb "info thread\n" +send_gdb "info thread\n" gdb_expect { -re ".* 1 *${tdlabel_re}.*2 *${tdlabel_re}.*$gdb_prompt $" { fail "too many threads left at end" diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp index e23db0a..7c2b309 100644 --- a/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp +++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exec.exp @@ -16,6 +16,8 @@ # Test following a vfork child that execs, when the vfork parent is a # threaded program, and it's a non-main thread that vforks. +require allow_fork_tests + standard_testfile if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} { @@ -28,7 +30,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} proc test_vfork {detach} { global binfile - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp index a6b7f49..a5e7475 100644 --- a/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp +++ b/gdb/testsuite/gdb.threads/vfork-follow-child-exit.exp @@ -16,6 +16,8 @@ # Test following a vfork child that exits, when the vfork parent is a # threaded program, and it's a non-main thread that vforks. +require allow_fork_tests + standard_testfile if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} { @@ -28,7 +30,7 @@ if {[build_executable "failed to prepare" $testfile $srcfile {debug pthreads}]} proc test_vfork {detach} { global binfile - clean_restart $binfile + clean_restart $::testfile if {![runto_main]} { return 0 diff --git a/gdb/testsuite/gdb.threads/vfork-multi-inferior.exp b/gdb/testsuite/gdb.threads/vfork-multi-inferior.exp index fd081b3..1f87427 100644 --- a/gdb/testsuite/gdb.threads/vfork-multi-inferior.exp +++ b/gdb/testsuite/gdb.threads/vfork-multi-inferior.exp @@ -25,6 +25,10 @@ # To catch the bug, this test verifies that we can hit a breakpoint after a # vfork call, while a second inferior runs in the background. +require allow_fork_tests + +require allow_multi_inferior_tests + require !use_gdb_stub standard_testfile .c -sleep.c diff --git a/gdb/testsuite/gdb.threads/vfork-multi-thread.exp b/gdb/testsuite/gdb.threads/vfork-multi-thread.exp index 2b9294d..fce974b 100644 --- a/gdb/testsuite/gdb.threads/vfork-multi-thread.exp +++ b/gdb/testsuite/gdb.threads/vfork-multi-thread.exp @@ -30,6 +30,8 @@ # breakpoints are removed, so the main thread would miss the breakpoint and run # until exit. +require allow_fork_tests + standard_testfile if { [build_executable "failed to prepare" ${testfile} ${srcfile} {debug pthreads}] } { @@ -57,7 +59,7 @@ proc do_test { target-non-stop non-stop follow-fork-mode detach-on-fork schedule save_vars { ::GDBFLAGS } { append ::GDBFLAGS " -ex \"maintenance set target-non-stop ${target-non-stop}\"" append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\"" - clean_restart ${::binfile} + clean_restart ${::testfile} } gdb_test_no_output "set follow-fork-mode ${follow-fork-mode}" diff --git a/gdb/testsuite/gdb.threads/watchpoint-fork.exp b/gdb/testsuite/gdb.threads/watchpoint-fork.exp index 376ca2a..68fc99e 100644 --- a/gdb/testsuite/gdb.threads/watchpoint-fork.exp +++ b/gdb/testsuite/gdb.threads/watchpoint-fork.exp @@ -21,6 +21,8 @@ # must be done before starting the test so as to not disrupt the execution # of the actual test. +require allow_fork_tests + set allow_hw_watchpoint_tests_p [allow_hw_watchpoint_tests] set testfile watchpoint-fork @@ -67,7 +69,7 @@ proc test {type symbol} { # Testcase uses it for the `follow-fork-mode child' type. gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" - if ![runto_main] { + if {![runto_main]} { return } @@ -124,7 +126,7 @@ proc test {type symbol} { # Testcase uses it for the `follow-fork-mode child' type. gdb_test "handle SIGUSR1 nostop noprint pass" "No\[ \t\]+No\[ \t\]+Yes.*" - if ![runto_main] { + if {![runto_main]} { return } @@ -163,7 +165,7 @@ proc test {type symbol} { test parent FOLLOW_PARENT # Only GNU/Linux is known to support `set follow-fork-mode child'. -if [istarget "*-*-linux*"] { +if {[istarget "*-*-linux*"]} { test child FOLLOW_CHILD } else { untested "${testfile}: child" diff --git a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp index 5d98913..067986a 100644 --- a/gdb/testsuite/gdb.threads/watchthreads-reorder.exp +++ b/gdb/testsuite/gdb.threads/watchthreads-reorder.exp @@ -41,7 +41,7 @@ foreach reorder {0 1} { with_test_prefix "reorder$reorder" { gdb_test "set can-use-hw-watchpoints 1" - if ![runto_main] { + if {![runto_main]} { return -1 } @@ -72,7 +72,7 @@ foreach reorder {0 1} { with_test_prefix "reorder$reorder" { "Hardware read watchpoint \[0-9\]+: thread\[12\]_rwatch\r\n\r\nValue = 0\r\n0x\[0-9a-f\]+ in thread\[12\]_func .*" \ "continue a" - if $reorder { + if {$reorder} { # GDB orders watchpoints by their addresses so inserting new variables # with lower addresses will shift the former watchpoints to higher # debug registers. diff --git a/gdb/testsuite/gdb.threads/watchthreads.exp b/gdb/testsuite/gdb.threads/watchthreads.exp index 49fc762..e2d629d 100644 --- a/gdb/testsuite/gdb.threads/watchthreads.exp +++ b/gdb/testsuite/gdb.threads/watchthreads.exp @@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart $binfile +clean_restart $::testfile gdb_test_no_output "set can-use-hw-watchpoints 1" "" # @@ -67,11 +67,11 @@ for {set i 0} {$i < 30} {incr i} { # At least one hardware watchpoint was hit. Check if both were. set string $expect_out(1,string) - if [regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr $args_0+1]\r" $string] { + if {[regexp "Hardware watchpoint 2: args\\\[0\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_0\[^\r\]*\r\[^\r\]*New value = [expr {$args_0+1}]\r" $string]} { incr args_0 incr test_flag_0 } - if [regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr $args_1+1]\r" $string] { + if {[regexp "Hardware watchpoint 3: args\\\[1\\\]\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $args_1\[^\r\]*\r\[^\r\]*New value = [expr {$args_1+1}]\r" $string]} { incr args_1 incr test_flag_1 } @@ -97,7 +97,7 @@ for {set i 0} {$i < 30} {incr i} { } } - if [ regexp "$expected_loc" $string ] { + if {[ regexp "$expected_loc" $string ]} { set test_flag 1 } else { fail "threaded watch loop" @@ -140,23 +140,23 @@ if { $test_flag == 1 } { # Verify that we hit first watchpoint in main thread. set message "first watchpoint on args\[0\] hit" if { $args_0 > 0 } { - pass $message + pass $message } else { - fail $message + fail $message } # Verify that we hit second watchpoint in main thread. set message "first watchpoint on args\[1\] hit" if { $args_1 > 0 } { - pass $message + pass $message } else { - fail $message + fail $message } # Verify that we hit first watchpoint in child thread. set message "watchpoint on args\[0\] hit in thread" if { $args_0 > 1 } { - pass $message + pass $message } else { fail $message } @@ -164,9 +164,9 @@ if { $args_0 > 1 } { # Verify that we hit second watchpoint in child thread. set message "watchpoint on args\[1\] hit in thread" if { $args_1 > 1 } { - pass $message + pass $message } else { - fail $message + fail $message } # Verify that all watchpoint hits are accounted for. @@ -174,12 +174,12 @@ set message "combination of threaded watchpoints = 30" if { [target_no_stopped_data] } { # See above. If we allow two watchpoints to be hit at once, we # may have more than 30 hits total. - set result [expr $args_0 + $args_1 >= 30] + set result [expr {$args_0 + $args_1 >= 30}] } else { - set result [expr $args_0 + $args_1 == 30] + set result [expr {$args_0 + $args_1 == 30}] } if { $result } { - pass $message + pass $message } else { - fail $message + fail $message } diff --git a/gdb/testsuite/gdb.threads/watchthreads2.exp b/gdb/testsuite/gdb.threads/watchthreads2.exp index 2426be4..a31c1a7 100644 --- a/gdb/testsuite/gdb.threads/watchthreads2.exp +++ b/gdb/testsuite/gdb.threads/watchthreads2.exp @@ -31,7 +31,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} gdb_test_no_output "set can-use-hw-watchpoints 1" "" @@ -89,7 +89,7 @@ set x_thread_loc "thread_function \\\(arg=.*\\\) at .*watchthreads.c:$x_inc_line # X is incremented under a mutex, so we should get NR_THREADS * X_INCR_COUNT # hits. -set limit [expr $NR_THREADS*$X_INCR_COUNT] +set limit [expr {$NR_THREADS*$X_INCR_COUNT}] set x_count 0 set done 0 @@ -102,7 +102,7 @@ for {set i 0} {!$done && $i < $limit} {incr i} { -re "(.*Hardware watchpoint.*)$gdb_prompt $" { set string $expect_out(1,string) - if [regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr $x_count+1]\r" $string] { + if {[regexp "Hardware watchpoint 3: x\[^\r\]*\r\[^\r\]*\r\[^\r\]*Old value = $x_count\[^\r\]*\r\[^\r\]*New value = [expr {$x_count+1}]\r" $string]} { incr x_count set test_flag 1 } else { diff --git a/gdb/testsuite/gdb.threads/wp-replication.exp b/gdb/testsuite/gdb.threads/wp-replication.exp index 68f5eb0..1b63d57 100644 --- a/gdb/testsuite/gdb.threads/wp-replication.exp +++ b/gdb/testsuite/gdb.threads/wp-replication.exp @@ -34,7 +34,7 @@ if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executab return -1 } -clean_restart ${binfile} +clean_restart ${::testfile} # Force hardware watchpoints to be used. gdb_test_no_output "set can-use-hw-watchpoints 1" "" @@ -126,7 +126,7 @@ gdb_test_no_output "set var test_ready=1" \ "set var test_ready=1" # Set the number of expected watchpoint triggers. -set TRIGGERS [expr "$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD"] +set TRIGGERS [expr {$NR_THREADS * $hwatch_count * $NR_TRIGGERS_PER_THREAD}] # Move the threads and hit the watchpoints TRIGGERS times. for { set i 1 } { $i <= $TRIGGERS } { incr i } { |