1 # step.exp -- Expect script to test gdb with step.c
2 # Copyright (C) 1992, 1997, 2007-2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This test really needs some major surgery to be acceptable, but
20 # I'm just about burnt out on lynx work, so I'm not doing it now.
22 # * The test has an indeterminate number of pass/fails
23 # for each run (it runs a small group of tests until
24 # it's timer kicks off). This is very bad for nightly
25 # automated regression testing.
27 # * It tries to "step" from withint he prologue of a
28 # function. This isn't support in gdb (it's going
29 # to act like a continue).
31 # * This test rarely check that it stopped in sensible
32 # places. (see previous bullet -- this test doesn't
33 # catch the fact it continued rather than stepped)
38 proc set_bp { where } {
41 send_gdb "break $where\n"
42 # The first regexp is what we get with -g, the second without -g.
44 -re "Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {}
45 -re "Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {}
46 -re "$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 }
47 timeout { fail "setting breakpoint at $where (timeout)" ; return 0 }
52 proc step_it { cmd } {
55 global inferior_exited_re
59 -re "0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 }
60 -re "0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 }
61 -re "$inferior_exited_re .*\n$gdb_prompt $" {
65 -re "$gdb_prompt $" { fail "single-stepping ($cmd).\n" ; return -1 }
66 timeout { fail "single-stepping ($cmd) timout.\n" ; return -1 }
78 proc continue_all {} {
80 global inferior_exited_re
84 -re "Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" {
88 -re "$inferior_exited_re .*\n$gdb_prompt $" {
92 -re "$gdb_prompt $" { fail "continue" ; return -1 }
93 timeout { fail "continue (timeout)" ; return -1 }
97 proc check_threads { num_threads } {
101 send_gdb "info threads\n"
102 while { $num_threads > 0 } {
104 -re "\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
106 set num_threads [expr $num_threads - 1]
108 -re " *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
109 set num_threads [expr $num_threads - 1]
111 -re "$gdb_prompt $" {
112 if { $num_threads < 0 } {
113 fail "check_threads (too many)" ; return -1
117 timeout { fail "check_threads (timeout)" ; return -1 }
121 if { $curr_thread == 0 } {
122 fail "check_threads (no current thread)\n"
125 if { $curr_thread > 1 } {
126 fail "check_threads (more than one current thread)\n"
132 proc test_cond_wait {} {
133 global program_exited
139 while { [step_inst] } {
140 if { $program_exited } { break }
142 if { $stepi_counter > 30 } {
143 fail "too many stepi's per line\n"
147 if { $program_exited } { break }
149 if { $program_exited } { break }
151 if { $program_exited } { break }
164 # Start with a fresh gdb.
168 gdb_reinitialize_dir $srcdir/$subdir
169 gdb_load $objdir/$subdir/$binfile
171 send_gdb "set width 0\n"
172 gdb_expect -re "$gdb_prompt $"
177 # Check to see if we have an executable to test. If not, then either we
178 # haven't tried to compile one, or the compilation failed for some reason.
179 # In either case, just notify the user and skip the tests in this file.
184 if ![file exists $objdir/$subdir/$binfile] then {
186 warning "$binfile does not exist; tests suppressed."