Running tclint on the test-cases in gdb.threads shows a few problems.
Fix these.
Tested on x86_64-linux.
"gdb/testsuite/gdb.cp",
"gdb/testsuite/gdb.dwarf2",
"gdb/testsuite/gdb.mi",
-"gdb/testsuite/gdb.threads",
"gdb/testsuite/gdb.trace",
# IGNORE (document reason in trailing comment):
"gdb/testsuite/gdb.stabs", # To be removed.
clean_restart ${::testfile}
}
- if ![runto setup_done] {
+ if {![runto setup_done]} {
return -1
}
#
# 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] {
+ 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_load $binfile
- if ![runto setup_done] {
+ if {![runto setup_done]} {
return -1
}
}
}
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
}
# 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
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 } {
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 $::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 $" {
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
}
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
}
# 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
}
standard_testfile
-if [prepare_for_testing "failed to prepare" $testfile $srcfile {debug}] {
+if {[prepare_for_testing "failed to prepare" $testfile $srcfile {debug}]} {
return -1
}
# 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
}
proc test {} {
global srcfile gdb_prompt
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
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
}
clean_restart ${executable}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
gdb_locate_shlib $binfile_lib
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
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
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
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} {
}
# 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:
# 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 } {
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
}
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart $::testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart $::testfile
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert $saw_continuing $test] {
+ if {![gdb_assert $saw_continuing $test]} {
return 1
}
}
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert {$running_count == $NUM_THREADS} $test] {
+ if {![gdb_assert {$running_count == $NUM_THREADS} $test]} {
return 1
}
}
exp_continue
}
-re "$gdb_prompt " {
- if ![gdb_assert {$running_count == 0} $test] {
+ if {![gdb_assert {$running_count == 0} $test]} {
return 1
}
}
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"]
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} {
# 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)]
# 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
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
} else {
fail "create philosopher: $i"
}
-
+
set threads_after {}
gdb_test_multiple "info threads" "info threads after: $i" {
-re "info threads\r\n" {
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" {
-re ".*$gdb_prompt $" {
set only_five 0
}
- timeout {
+ timeout {
set only_five -1
}
}
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
}
}
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"
}
gdb_test_no_output "set pagination off"
gdb_test_no_output "set non-stop on"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
with_test_prefix "setup" {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
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
}
with_test_prefix "schedlock=$schedlock" {
clean_restart $::testfile
- if ![runto_main] {
+ if {![runto_main]} {
continue
}
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
clean_restart ${executable}
}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
gdb_test_no_output "set non-stop on"
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
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
}
# 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="]
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 {
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
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
perror "unhandled command: $cmd"
}
} else {
- if $is_remote {
+ if {$is_remote} {
set extra "\r\nEnding remote debugging\."
} else {
set extra ""
clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
# 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
".*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.
clean_restart ${::testfile}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
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]] \
proc test {non-stop schedlock} {
save_vars ::GDBFLAGS {
append ::GDBFLAGS " -ex \"set non-stop ${non-stop}\""
- set sl [expr $schedlock == "on" ? 1 : 0]
+ set sl [expr {$schedlock == "on" ? 1 : 0}]
clean_restart $::testfile-$sl
}
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\]+)"
}
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
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 {
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
}
} 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)"
clean_restart $testfile
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart $executable
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
clean_restart $executable
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
set step_at $now
}
}
- if $failed {
+ if {$failed} {
return
}
}
kfail gdb/1328 "$test"
}
}
-
+
# See if handle SIG32 helps (a little) with a static multi-threaded
# program.
set sig "SIG32"
# SIGRTMIN is 37 on hppa-linux
-if [istarget hppa*-*-*] {
+if {[istarget hppa*-*-*]} {
set sig "SIG37"
}
if { "$have_tls" != "" } {
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
gdb_breakpoint [gdb_get_line_number "tlsvar-is-set"]
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return
}
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.
gdb_test_no_output "set displaced-stepping $displaced_stepping"
- if ![runto_main] {
+ if {![runto_main]} {
return
}
with_test_prefix "displaced=$displaced: $command" {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
return
}
global gdb_prompt
global hex
- if ${with_bp} {
+ if {${with_bp}} {
set prefix "with thread-specific bp"
} else {
set prefix "no thread-specific bp"
with_test_prefix $command {
clean_restart $executable
- if ![runto_main] {
+ if {![runto_main]} {
continue
}
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"
# 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"
}
-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
}
clean_restart $executable
# Start the second thread.
-if ![runto start] {
+if {![runto start]} {
return -1
}
# 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 } {
gdb_test_no_output "set non-stop 1"
}
- if ![runto_main] {
+ if {![runto_main]} {
return 0
}
# 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()
".*Breakpoint 2,.*tf.*at.*$srcfile:.*" \
"continue to tf"
-#
+#
# backtrace from thread function.
#
gdb_test "backtrace" \
# 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"
clean_restart ${::testfile}
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
# 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
}
set loop_iterations [llength $test_list]
for {set i 0} {$i < $loop_iterations } {incr i} {
- set thread_num [expr $loop_iterations - $i]
+ set thread_num [expr {$loop_iterations - $i}]
set type [lindex $test_list $i]
if { $type == 1 } {
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
}
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
}
return -1
}
-if ![runto_main] {
+if {![runto_main]} {
return -1
}
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"
gdb_load ${binmainfile}
- if ![runto_main] {
+ if {![runto_main]} {
return
}
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"
clean_restart ${executable}
-if ![runto_main] {
+if {![runto_main]} {
return 0
}
fail "$tnum thread print me"
}
timeout {
- fail "$tnum thread print me (timeout)"
+ fail "$tnum thread print me (timeout)"
}
}
return ${value_of_me}
### 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
pass "backtrace of thread number $number not relevant"
}
timeout {
- fail "backtrace of thread number $number (timeout)"
+ fail "backtrace of thread number $number (timeout)"
}
}
}
}
# 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"
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
}
# 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
}
}
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"
# 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
}
# 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
}
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"
gdb_test "set can-use-hw-watchpoints 1"
- if ![runto_main] {
+ if {![runto_main]} {
return -1
}
"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.
# 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
}
}
}
- if [ regexp "$expected_loc" $string ] {
+ if {[ regexp "$expected_loc" $string ]} {
set test_flag 1
} else {
fail "threaded watch loop"
# 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
}
# 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.
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
}
# 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
-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 {
"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 } {