1 # step.exp
-- Expect script to test gdb with step.c
2 # Copyright
(C
) 1992, 1997 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
2 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
, write to the Free Software
16 # Foundation
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
18 # Please email
any bugs
, comments
, and
/or additions to this file to
:
19 # bug
-gdb@prep.ai.mit.edu
21 # This file was written by Hiro Sugawara.
(hiro@lynx.com
)
23 # This test really needs some major surgery to be acceptable
, but
24 # I
'm just about burnt out on lynx work, so I'm not doing it now.
26 #
* The test has an indeterminate number of pass
/fails
27 #
for each run
(it runs a small group of tests until
28 # it
's timer kicks off). This is very bad for nightly
29 # automated regression testing.
31 # * It tries to "step" from withint he prologue of a
32 # function. This isn't support in gdb
(it
's going
33 # to act like a continue).
35 # * This test rarely check that it stopped in sensible
36 # places. (see previous bullet -- this test doesn't
37 # catch the fact it continued rather than stepped
)
46 proc set_bp
{ where
} {
49 send_gdb
"break $where\n"
50 # The first regexp is what we
get with
-g
, the second without
-g.
52 -re
"Break.* at .*: file .*, line \[0-9\]*.*$gdb_prompt $" {}
53 -re
"Breakpoint \[0-9\]* at 0x\[0-9a-f\]*.*$gdb_prompt $" {}
54 -re
"$gdb_prompt $" { fail "setting breakpoint at $where" ; return 0 }
55 timeout
{ fail
"setting breakpoint at $where (timeout)" ; return 0 }
60 proc step_it
{ cmd
} {
66 -re
"0x\[0-9A-Fa-f\]* *in.*\r\n$gdb_prompt $" { pass "step_it"; return 0 }
67 -re
"0x\[0-9A-Fa-f\]* *\[0-9\]*.*\r\n$gdb_prompt $" { pass "step_it"; return 1 }
68 -re
"Program exited .*\n$gdb_prompt $" {
72 -re
"$gdb_prompt $" { fail "single-stepping ($cmd).\n" ; return -1 }
73 timeout
{ fail
"single-stepping ($cmd) timout.\n" ; return -1 }
85 proc continue_all
{} {
90 -re
"Breakpoint \[0-9\]*, thread\[0-9\]* .*$gdb_prompt $" {
94 -re
"Program exited .*\n$gdb_prompt $" {
98 -re
"$gdb_prompt $" { fail "continue" ; return -1 }
99 timeout
{ fail
"continue (timeout)" ; return -1 }
103 proc check_threads
{ num_threads
} {
107 send_gdb
"info threads\n"
108 while { $num_threads
> 0 } {
110 -re
"\\* *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
112 set num_threads
[expr $num_threads
- 1]
114 -re
" *\[0-9\]* process \[0-9\]* thread \[0-9\]* .*\n" {
115 set num_threads
[expr $num_threads
- 1]
117 -re
"$gdb_prompt $" {
118 if { $num_threads
< 0 } {
119 fail
"check_threads (too many)" ; return -1
123 timeout
{ fail
"check_threads (timeout)" ; return -1 }
127 if { $curr_thread
== 0 } {
128 fail
"check_threads (no current thread)\n"
131 if { $curr_thread
> 1 } {
132 fail
"check_threads (more than one current thread)\n"
138 proc test_cond_wait
{} {
139 global program_exited
145 while { [step_inst
] } {
146 if { $program_exited
} { break }
148 if { $stepi_counter
> 30 } {
149 fail
"too many stepi's per line\n"
153 if { $program_exited
} { break }
155 if { $program_exited
} { break }
157 if { $program_exited
} { break }
174 # Start with a fresh gdb.
178 gdb_reinitialize_dir $srcdir
/$subdir
179 gdb_load $objdir
/$subdir
/$binfile
181 send_gdb
"set width 0\n"
182 gdb_expect
-re
"$gdb_prompt $"
187 # Check to see
if we have an executable to test.
If not
, then either we
188 # haven
't tried to compile one, or the compilation failed for some reason.
189 # In either case, just notify the user and skip the tests in this file.
194 if ![file exists $objdir/$subdir/$binfile] then {
196 warning "$binfile does not exist; tests suppressed."