old-cross-binutils/gdb/testsuite/gdb.threads/step.exp
Tom Tromey fda326dd1d gdb
* infrun.c (print_exited_reason): Include inferior id and pid in
	message.
gdb/testsuite
	* lib/opencl.exp (skip_opencl_tests): Update for exit message
	change.
	* lib/mi-support.exp (mi_gdb_test): Update for exit message
	change.
	* lib/gdb.exp (gdb_test_multiple): Update comment.  Update for
	exit message change.
	(skip_altivec_tests): Update for exit message change.
	(skip_vsx_tests): Likewise.
	(gdb_continue_to_end): Likewise.  Add 'command' argument.
	* lib/cell.exp (skip_cell_tests): Update for exit message change.
	* gdb.threads/tls.exp: Update for exit message change.
	* gdb.threads/thread-unwindonsignal.exp: Use
	gdb_continue_to_end.
	* gdb.threads/step.exp (step_it): Update for exit message change.
	(continue_all): Likewise.
	* gdb.threads/print-threads.exp (test_all_threads): Update for
	exit message change.
	* gdb.threads/interrupted-hand-call.exp: Use
	gdb_continue_to_end.
	* gdb.threads/execl.exp: Use gdb_continue_to_end.
	* gdb.python/py-prettyprint.exp (run_lang_tests): Use
	gdb_continue_to_end.
	* gdb.hp/gdb.objdbg/objdbg02.exp: Use gdb_continue_to_end.
	* gdb.hp/gdb.objdbg/objdbg01.exp: Use gdb_continue_to_end.
	* gdb.hp/gdb.defects/solib-d.exp: Update for exit message change.
	* gdb.cp/method.exp: Update for exit message change.
	* gdb.cp/mb-templates.exp: Update for exit message change.
	* gdb.cp/mb-inline.exp: Use gdb_continue_to_end.
	* gdb.cp/annota3.exp: Update for exit message change.
	* gdb.cp/annota2.exp: Update for exit message change.
	* gdb.cell/fork.exp: Use gdb_continue_to_end.
	* gdb.base/term.exp: Update for exit message change.
	* gdb.base/step-test.exp (test_i): Update for exit message change.
	* gdb.base/sigstep.exp (advance): Update for exit message change.
	(advancei): Likewise.
	* gdb.base/siginfo.exp: Update for exit message change.
	* gdb.base/shlib-call.exp: Use gdb_continue_to_end.
	* gdb.base/reread.exp: Use gdb_continue_to_end.
	* gdb.base/langs.exp: Use gdb_continue_to_end.
	* gdb.base/interrupt.exp: Update for exit message change.
	* gdb.base/gdb1555.exp: Update for exit message change.
	* gdb.base/exe-lock.exp: Use gdb_continue_to_end.
	* gdb.base/ending-run.exp: Update for exit message change.
	* gdb.base/chng-syms.exp: Update for exit message change.
	* gdb.base/checkpoint.exp: Update for exit message change.
	* gdb.base/catch-syscall.exp (check_for_program_end): Use
	gdb_continue_to_end.
	(test_catch_syscall_with_wrong_args): Likewise.
	* gdb.base/call-signal-resume.exp: Use gdb_continue_to_end.
	* gdb.base/break-interp.exp (test_ld): Update for exit message
	change.
	* gdb.base/bang.exp: Update for exit message change.
	* gdb.base/attach.exp (do_attach_tests): Use gdb_continue_to_end.
	(do_call_attach_tests): Likewise.
	* gdb.base/a2-run.exp: Update for exit message change.
	* gdb.arch/ppc-dfp.exp: Update for exit message change.
	* gdb.ada/tasks.exp: Use gdb_continue_to_end.
	* gdb.ada/catch_ex.exp: Use gdb_continue_to_end.
2011-03-07 16:03:04 +00:00

195 lines
4.9 KiB
Text

# step.exp -- Expect script to test gdb with step.c
# Copyright (C) 1992, 1997, 2007, 2008, 2009, 2010, 2011
# 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/>.
# This file was written by Hiro Sugawara. (hiro@lynx.com)
#
# This test really needs some major surgery to be acceptable, but
# I'm just about burnt out on lynx work, so I'm not doing it now.
#
# * The test has an indeterminate number of pass/fails
# for each run (it runs a small group of tests until
# it's timer kicks off). This is very bad for nightly
# automated regression testing.
#
# * It tries to "step" from withint he prologue of a
# function. This isn't support in gdb (it's going
# to act like a continue).
#
# * This test rarely check that it stopped in sensible
# places. (see previous bullet -- this test doesn't
# catch the fact it continued rather than stepped)
if $tracelevel then {
strace $tracelevel
}
set program_exited 0
proc set_bp { where } {
global gdb_prompt
send_gdb "break $where\n"
# The first regexp is what we get with -g, the second without -g.
gdb_expect {
-re "Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {}
-re "Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {}
-re "$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 }
timeout { fail "setting breakpoint at $where (timeout)" ; return 0 }
}
pass "set_bp"
}
proc step_it { cmd } {
global gdb_prompt
global program_exited
global inferior_exited_re
send_gdb "$cmd\n"
gdb_expect {
-re "0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 }
-re "0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 }
-re "$inferior_exited_re .*\n$gdb_prompt $" {
set program_exited 1
return -1
}
-re "$gdb_prompt $" { fail "single-stepping ($cmd).\n" ; return -1 }
timeout { fail "single-stepping ($cmd) timout.\n" ; return -1 }
}
}
proc step_inst {} {
step_it "stepi"
}
proc step_source {} {
step_it "step"
}
proc continue_all {} {
global gdb_prompt
global inferior_exited_re
send_gdb "continue\n"
gdb_expect {
-re "Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" {
pass "continue_all"
return 0
}
-re "$inferior_exited_re .*\n$gdb_prompt $" {
set program_exited 1
return 1;
}
-re "$gdb_prompt $" { fail "continue" ; return -1 }
timeout { fail "continue (timeout)" ; return -1 }
}
}
proc check_threads { num_threads } {
global gdb_prompt
set curr_thread 0
send_gdb "info threads\n"
while { $num_threads > 0 } {
gdb_expect {
-re "\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
incr curr_thread
set num_threads [expr $num_threads - 1]
}
-re " *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
set num_threads [expr $num_threads - 1]
}
-re "$gdb_prompt $" {
if { $num_threads < 0 } {
fail "check_threads (too many)" ; return -1
}
break
}
timeout { fail "check_threads (timeout)" ; return -1 }
}
}
if { $curr_thread == 0 } {
fail "check_threads (no current thread)\n"
return -1
}
if { $curr_thread > 1 } {
fail "check_threads (more than one current thread)\n"
return -1
}
return 0
}
proc test_cond_wait {} {
global program_exited
set_bp 135
runto 179
while { 1 } {
set stepi_counter 0
while { [step_inst] } {
if { $program_exited } { break }
incr stepi_counter
if { $stepi_counter > 30 } {
fail "too many stepi's per line\n"
return -1
}
}
if { $program_exited } { break }
step_source
if { $program_exited } { break }
continue_all
if { $program_exited } { break }
check_threads 3
}
}
proc do_tests {} {
global subdir
global objdir
global srcdir
global binfile
global gdb_prompt
# Start with a fresh gdb.
gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load $objdir/$subdir/$binfile
send_gdb "set width 0\n"
gdb_expect -re "$gdb_prompt $"
test_cond_wait
}
# Check to see if we have an executable to test. If not, then either we
# haven't tried to compile one, or the compilation failed for some reason.
# In either case, just notify the user and skip the tests in this file.
set binfile "step"
set srcfile "step.c"
if ![file exists $objdir/$subdir/$binfile] then {
if $all_flag then {
warning "$binfile does not exist; tests suppressed."
}
} else {
do_tests
}