+2010-06-02 Michael Snyder <msnyder@msnyder-server.eng.vmware.com>
+
+ * gdb.threads/attach-stopped.exp:
+ Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/attachstop-mt.exp:
+ Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/gcore-thread.exp:
+ Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/hand-call-in-threads.exp:
+ Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/linux-dp.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/print-threads.exp:
+ Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/pthreads.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/schedlock.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.threads/sigthread.exp: Replace uses of send_gdb / gdb_expect.
+
+ * gdb.trace/actions.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/backtrace.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/collection.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/deltrace.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/infotrace.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/limits.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/report.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/save-trace.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/tfind.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/tracecmd.exp: Replace uses of send_gdb / gdb_expect.
+ * gdb.trace/tsv.exp: Replace uses of send_gdb / gdb_expect.
+
2010-06-02 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.cp/re-set-overloaded.exp, gdb.cp/re-set-overloaded.cc: New.
# This breakpoint is there for old/non-x86 kernels not restarting syscalls.
gdb_breakpoint [gdb_get_line_number "Second sleep"]
set test "$threadtype: attach2 continue"
- send_gdb "continue\n"
- gdb_expect {
- -re "Continuing"
- { pass "continue ($test)" }
- timeout
- { fail "continue ($test) (timeout)" }
+ gdb_test_multiple "continue" "continue ($test)" {
+ -re "Continuing" {
+ pass "continue ($test)"
+ }
}
# For this to work we must be sure to consume the "Continuing."
gdb_breakpoint [gdb_get_line_number "Ridiculous time"]
gdb_breakpoint [gdb_get_line_number "cut the sleep time"]
set test "attach4 continue"
-send_gdb "continue\n"
-gdb_expect {
- -re "Continuing"
- { pass "continue ($test)" }
- timeout
- { fail "continue ($test) (timeout)" }
+gdb_test_multiple "continue" "continue ($test)" {
+ -re "Continuing" {
+ pass "continue ($test)"
+ }
}
# For this to work we must be sure to consume the "Continuing."
set prev_timeout $timeout
set timeout 30
-send_gdb "help gcore\n"
-gdb_expect {
+gdb_test_multiple "help gcore" "help gcore" {
-re "Undefined command: .gcore.*$gdb_prompt $" {
# gcore command not supported -- nothing to test here.
unsupported "gdb does not support gcore on this target"
-re "Save a core file .*$gdb_prompt $" {
pass "help gcore"
}
- -re ".*$gdb_prompt $" {
- fail "help gcore"
- }
- timeout {
- fail "help gcore (timeout)"
- }
}
if { ! [ runto_main ] } then {
return -1
}
-send_gdb "info threads\n"
-gdb_expect {
+gdb_test_multiple "info threads" "threads are supported" {
-re ".* main .*$gdb_prompt $" {
# OK, threads are supported.
}
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-send_gdb "core ${objdir}/${subdir}/gcore.test\n"
-gdb_expect {
- -re ".* is not a core dump:.*$gdb_prompt $" {
- fail "re-load generated corefile (bad file format)"
- # No use proceeding from here.
- return;
- }
- -re ".*: No such file or directory.*$gdb_prompt $" {
- fail "re-load generated corefile (file not found)"
- # No use proceeding from here.
- return;
- }
- -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
- fail "re-load generated corefile (incomplete note section)"
+gdb_test_multiple "core ${objdir}/${subdir}/gcore.test" \
+ "re-load generated corefile" {
+ -re ".* is not a core dump:.*$gdb_prompt $" {
+ fail "re-load generated corefile (bad file format)"
+ # No use proceeding from here.
+ return;
+ }
+ -re ".*: No such file or directory.*$gdb_prompt $" {
+ fail "re-load generated corefile (file not found)"
+ # No use proceeding from here.
+ return;
+ }
+ -re ".*Couldn't find .* registers in core file.*$gdb_prompt $" {
+ fail "re-load generated corefile (incomplete note section)"
+ }
+ -re "Core was generated by .*$gdb_prompt $" {
+ pass "re-load generated corefile"
+ }
}
- -re "Core was generated by .*$gdb_prompt $" {
- pass "re-load generated corefile"
- }
- -re ".*$gdb_prompt $" {
- fail "re-load generated corefile"
- }
- timeout {
- fail "re-load generated corefile (timeout)"
- }
-}
# FIXME: now what can we test about the thread state?
# We do not know for certain that there should be at least
}
proc get_dummy_frame_number { } {
- global gdb_prompt
-
- send_gdb "bt\n"
- gdb_expect {
- -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $"
- {
- return $expect_out(1,string)
- }
- -re "$gdb_prompt $"
- {
- return ""
- }
- timeout
- {
- return ""
- }
- }
- return ""
+ global gdb_prompt
+
+ gdb_test_multiple "bt" "" {
+ -re "#(\[0-9\]*) *<function called from gdb>.*$gdb_prompt $" {
+ return $expect_out(1,string)
+ }
+ -re "$gdb_prompt $" {
+ return ""
+ }
+ timeout {
+ return ""
+ }
+ }
+ return ""
}
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
-send_gdb "set print sevenbit-strings\n" ; gdb_expect -re "$gdb_prompt $"
+gdb_test_no_output "set print sevenbit-strings"
runto_main
# There should be no threads initially.
set expect_manager -1
for {set i 0} {$i < 5} {incr i} {
gdb_continue_to_breakpoint "about to create philosopher: $i"
- send_gdb "info threads\n"
set threads_before {}
- gdb_expect {
+ gdb_test_multiple "info threads" "info threads before: $i" {
-re "info threads\r\n" {
exp_continue
}
}
-re "^$gdb_prompt $" {
}
- timeout {
- fail "(timeout) info threads before: $i"
- }
}
- send_gdb "next\n"
set threads_created 0
- gdb_expect {
+ gdb_test_multiple "next" "create philosopher: $i" {
-re "^next\r\n" {
exp_continue
}
}
-re "$gdb_prompt $" {
}
- timeout {
- fail "(timeout) create philosopher: $i"
- }
}
if { $threads_created == 0 } {
# Not all targets announce new threads as they are created.
fail "create philosopher: $i"
}
- send_gdb "info threads\n"
set threads_after {}
- gdb_expect {
+ gdb_test_multiple "info threads" "info threads after: $i" {
-re "info threads\r\n" {
exp_continue
}
fail "info threads after: $i"
}
}
- timeout {
- fail "(timeout) info threads after: $i"
- }
}
-
}
set nthreads 6
set only_five 1
for {set i 0} {$only_five > 0 && $i < 10} {incr i} {
gdb_continue_to_breakpoint "thread 5's print, pass: $i"
- send_gdb "info threads\n"
- gdb_expect {
+ gdb_test_multiple "info threads" "" {
-re "\\* 5 Thread .* print_philosopher .*\r\n$gdb_prompt $" {
# Okay this time.
}
proc select_thread {thread} {
global gdb_prompt
- send_gdb "thread $thread\n"
- gdb_expect {
- -re "\\\[Switching to thread .*\\\].*\r\n$gdb_prompt $" {
- pass "selected thread: $thread"
- }
- -re "$gdb_prompt $" {
- fail "selected thread: $thread"
- }
- timeout {
- fail "selected thread: $thread (timeout)"
- }
- }
+ gdb_test "thread $thread" \
+ "\\\[Switching to thread .*\\\].*" \
+ "selected thread: $thread"
}
### Select THREAD, check for a plausible backtrace, and make sure
set interesting 0
select_thread $thread
- send_gdb "where\n"
- gdb_expect {
+ gdb_test_multiple "where" "$name" {
-re ".* in philosopher \\(data=(0x\[0-9a-f\]+).*\r\n$gdb_prompt $" {
set data $expect_out(1,string)
if {[info exists seen($data)]} {
## be an xfail.
pass $name
}
- -re "$gdb_prompt $" {
- fail $name
- }
- timeout {
- fail "$name (timeout)"
- }
}
return $interesting
set i 0
set j 0
- send_gdb "continue\n"
- gdb_expect {
+ 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]
pass "Hit thread_function breakpoint, $i ($name)"
fail "Running threads ($name) (unknown output)"
}
}
- -re "$gdb_prompt" {
- fail "Running threads ($name) (unknown output)"
- }
- timeout {
- fail "Running threads ($name) (timeout)"
- }
}
}
# to stop. Since no other breakpoints are set at this time
# we should stop only when we have been previously called 15 times.
- send_gdb "continue\n"
- gdb_expect {
- -re "Continuing.*common_routine.*at.*$srcfile.*$gdb_prompt $" {}
- default {
- fail "continue until common routine run 15 times"
- return 0
- }
- timeout {
- fail "continue until common routine run 15 times (timeout)"
- return 0
+ set return_me 1
+
+ gdb_test_multiple "continue" "continue until common routine run 15 times" {
+ -re "Continuing.*common_routine.*at.*$srcfile.*$gdb_prompt $" {
+ set return_me 0
}
}
+ if { $return_me == 1 } then {
+ return 0;
+ }
+
# Check that we stopped when we actually expected to stop, by
# verifying that there have been 15 previous hits.
# trap and the next. So stopping after 16 or 17 hits should be
# considered acceptable.
- send_gdb "p common_routine::hits\n"
- gdb_expect {
- -re ".*= 15\r\n$gdb_prompt $" {
- pass "stopped before calling common_routine 15 times"
- }
- -re ".*= 16\r\n$gdb_prompt $" {
- pass "stopped before calling common_routine 15 times (16 times)"
- }
- -re ".*= 17\r\n$gdb_prompt $" {
- pass "stopped before calling common_routine 15 times (17 times)"
- }
- default {
- fail "stopped before calling common_routine 15 times"
- return 0
- }
- -re ".*$gdb_prompt $" {
- fail "stopped before calling common_routine 15 times"
- return 0
- }
- timeout {
- fail "stopped before calling common_routine 15 times (timeout)"
- return 0
+ gdb_test_multiple "p common_routine::hits" \
+ "stopped before calling common_routine 15 times" {
+ -re ".*= 15\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times"
+ }
+ -re ".*= 16\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times (16 times)"
+ }
+ -re ".*= 17\r\n$gdb_prompt $" {
+ pass "stopped before calling common_routine 15 times (17 times)"
+ }
}
- }
# Also check that all of the threads have run, which will only be true
# if the full_coverage variable is set.
- send_gdb "p common_routine::full_coverage\n"
- gdb_expect {
- -re ".* = 1.*$gdb_prompt $" {}
- -re ".* = 0.*$gdb_prompt $" {
- fail "some threads didn't run"
- return 0
- }
- default {
- fail "some threads didn't run"
- return 0
- }
- timeout {
- fail "some threads didn't run (timeout)"
- return 0
+ set return_me 1
+ gdb_test_multiple "p common_routine::full_coverage" \
+ "some threads didn't run" {
+ -re ".* = 1.*$gdb_prompt $" {
+ }
+ -re ".* = 0.*$gdb_prompt $" {
+ fail "some threads didn't run"
+ set return_me 0
+ }
}
- }
# Looks fine, return success.
- return 1
+ return $return_me
}
proc test_startup {} {
global main_id thread1_id thread2_id
# We should be able to do an info threads before starting any others.
- send_gdb "info threads\n"
- gdb_expect {
+ set return_me 1
+ gdb_test_multiple "info threads" "info threads" {
-re ".*Thread.*main.*$gdb_prompt $" {
pass "info threads"
+ set return_me 0
}
-re "\r\n$gdb_prompt $" {
unsupported "gdb does not support pthreads for this machine"
- return 0
}
}
+ if { $return_me == 1 } then {
+ return 0;
+ }
+
# Extract the thread id number of main thread from "info threads" output.
- send_gdb "info threads\n"
- gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)"
+ gdb_test_multiple "info threads" "get main thread id" {
+ -re "(\[0-9\]+)(${horiz}Thread${horiz}main.*)($gdb_prompt $)" {
+ }
+ }
+
set main_id $expect_out(1,string)
# Check that we can continue and create the first thread.
gdb_test "disable" ""
# Extract the thread id number of thread 1 from "info threads" output.
- send_gdb "info threads\n"
- gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)"
+ gdb_test_multiple "info threads" "get thread 1 id" {
+ -re "(\[0-9\]+)(${horiz}Thread${horiz}thread1.*)($gdb_prompt $)" {
+ }
+ }
+
set thread1_id $expect_out(1,string)
# Check that we can continue and create the second thread,
"Continue to creation of second thread"
# Extract the thread id number of thread 2 from "info threads" output.
- send_gdb "info threads\n"
- gdb_expect -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)"
+ gdb_test_multiple "info threads" "get thread 2 id" {
+ -re "(\[0-9\]+)(${horiz}Thread${horiz}thread2.*)($gdb_prompt $)" {
+ }
+ }
+
set thread2_id $expect_out(1,string)
return 1
}
# Send a continue followed by ^C to the process to stop it.
- send_gdb "continue\n"
- gdb_expect {
+ gdb_test_multiple "continue" "continue with all threads running" {
-re "Continuing." {
pass "Continue with all threads running"
}
- timeout {
- fail "Continue with all threads running (timeout)"
- }
}
after 2000
send_gdb "\003"
"Breakpoint .* at 0x.* file .* line .*" \
"set break at common_routine in thread 2"
- send_gdb "continue\n"
- gdb_expect {
+ gdb_test_multiple "continue" "continue to bkpt at common_routine in thread 2" {
-re "Breakpoint .* common_routine \\(arg=2\\).*" {
pass "continue to bkpt at common_routine in thread 2"
- send_gdb "backtrace\n"
- gdb_expect {
- -re "#0.*common_routine \\(arg=2\\).*#1.*thread2.*" {
- pass "backtrace from thread 2 bkpt in common_routine"
- }
- default {
- fail "backtrace from thread 2 bkpt in common_routine"
- }
- timeout {
- fail "backtrace from thread 2 bkpt in common_routine (timeout)"
- }
- }
+ gdb_test "backtrace" \
+ "#0.*common_routine \\(arg=2\\).*#1.*thread2.*" \
+ "backtrace from thread 2 bkpt in common_routine"
}
-re "Breakpoint .* common_routine \\(arg=0\\).*" {
fail "continue to bkpt at common_routine in thread 2 (arg=0)"
-re "Breakpoint .* common_routine \\(arg=1\\).*" {
fail "continue to bkpt at common_routine in thread 2 (arg=1)"
}
- -re ".*$gdb_prompt" {
- fail "continue to bkpt at common_routine in thread 2"
- }
- default {
- fail "continue to bkpt at common_routine in thread 2 (default)"
- }
- timeout {
- fail "continue to bkpt at common_routine in thread 2 (timeout)"
- }
}
}
# Now we can proceed with the real testing.
proc get_args { } {
- global list_count
- global gdb_prompt
- global NUM
+ global list_count
+ global gdb_prompt
+ global NUM
- set pattern "(\[0-9\]+)"
- for {set i 1} {[expr $i < $NUM]} {incr i} {
- append pattern ", (\[0-9\]+)"
- }
+ set pattern "(\[0-9\]+)"
+ for {set i 1} {[expr $i < $NUM]} {incr i} {
+ append pattern ", (\[0-9\]+)"
+ }
- send_gdb "print args\n"
- gdb_expect {
- -re "\\\$\[0-9\]+ = {$pattern}.*$gdb_prompt"
- {
- set list_count [expr $list_count + 1]
- pass "listed args ($list_count)"
+ gdb_test_multiple "print args" "listed args ($list_count)" {
+ -re "\\\$\[0-9\]+ = {$pattern}.*$gdb_prompt $" {
+ set list_count [expr $list_count + 1]
+ pass "listed args ($list_count)"
- set result ""
- for {set i 1} {[expr $i <= $NUM]} {incr i} {
- lappend result $expect_out($i,string)
+ set result ""
+ for {set i 1} {[expr $i <= $NUM]} {incr i} {
+ lappend result $expect_out($i,string)
+ }
+ return $result
}
- return $result
- }
- -re "$gdb_prompt"
- {
- fail "listed args ($list_count) (unknown output)"
- }
- timeout
- {
- fail "listed args ($list_count) (timeout)"
- }
- }
+ }
}
proc stop_process { description } {
}
proc get_current_thread { description } {
- global gdb_prompt
+ global gdb_prompt
- send_gdb "bt\n"
- gdb_expect {
- -re "thread_function \\(arg=0x(\[0-9\])\\).*$gdb_prompt $"
- {
- pass $description
- return $expect_out(1,string)
- }
- -re "$gdb_prompt $"
- {
- fail "$description (unknown output)"
- }
- timeout
- {
- fail "$description (timeout)"
- }
- }
+ gdb_test_multiple "bt" "$description" {
+ -re "thread_function \\(arg=0x(\[0-9\])\\).*$gdb_prompt $" {
+ pass $description
+ return $expect_out(1,string)
+ }
+ }
+ return ""
}
proc my_continue { msg } {
- send_gdb "continue\n"
- gdb_expect {
- -re "Continuing"
- { pass "continue ($msg)" }
- timeout
- { fail "continue ($msg) (timeout)" }
- }
+ gdb_test_multiple "continue" "continuing ($msg)" {
+ -re "Continuing" {
+ pass "continue ($msg)"
+ }
+ }
- stop_process "stop all threads ($msg)"
+ stop_process "stop all threads ($msg)"
- # Make sure we're in one of the non-main looping threads.
- gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"]
- gdb_continue_to_breakpoint "return to loop ($msg)"
- delete_breakpoints
+ # Make sure we're in one of the non-main looping threads.
+ gdb_breakpoint [concat [gdb_get_line_number "schedlock.exp: main loop"] " if arg != 0"]
+ gdb_continue_to_breakpoint "return to loop ($msg)"
+ delete_breakpoints
}
proc step_ten_loops { msg } {
global gdb_prompt
for {set i 0} {[expr $i < 10]} {set i [expr $i + 1]} {
- send_gdb "step\n"
set other_step 0
- gdb_expect {
+ gdb_test_multiple "step" "step to increment ($msg $i)" {
-re ".*myp\\) \\+\\+;\[\r\n\]+$gdb_prompt $" {
pass "step to increment ($msg $i)"
}
# FIXME cascade?
}
}
- timeout {
- fail "step to increment ($msg $i) (timeout)"
- }
}
}
}
runto_main
# See if scheduler locking is available on this target.
-send_gdb "set scheduler-locking off\n"
global gdb_prompt
-gdb_expect {
- -re "Target .* cannot support this command"
- {
- unsupported "target does not support scheduler locking"
- return
+gdb_test_multiple "set scheduler-locking off" "scheduler locking set to none" {
+ -re "Target .* cannot support this command" {
+ unsupported "target does not support scheduler locking"
+ return
}
- -re "$gdb_prompt $"
- {
- pass "scheduler locking set to none"
+ -re "$gdb_prompt $" {
+ pass "scheduler locking set to none"
}
- timeout
- {
- unsupported "target does not support scheduler locking (timeout)"
- return
+ timeout {
+ unsupported "target does not support scheduler locking (timeout)"
+ return
}
}
gdb_test "handle SIGUSR1 nostop noprint pass"
gdb_test "handle SIGUSR2 nostop noprint pass"
-send_gdb "continue\n"
-gdb_expect {
+gdb_test_multiple "continue" "continue" {
-re "Continuing" {
pass "continue"
}
- timeout {
- fail "continue (timeout)"
- }
}
# For this to work we must be sure to consume the "Continuing."