]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/step-test.exp
This commit was generated by cvs2svn to track changes on a CVS vendor
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / step-test.exp
CommitLineData
c906108c
SS
1# Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
16
17# Please email any bugs, comments, and/or additions to this file to:
18# bug-gdb@prep.ai.mit.edu
19
20# use this to debug:
21#
22#log_user 1
23
24# step-test.exp -- Expect script to test stepping in gdb
25
26if $tracelevel then {
27 strace $tracelevel
28}
29
30set testfile step-test
31set srcfile ${srcdir}/${subdir}/${testfile}.c
32set binfile ${objdir}/${subdir}/${testfile}
33
34remote_exec build "rm -f ${binfile}"
35if { [gdb_compile "${srcfile}" "${binfile}" executable {debug}] != "" } {
36 gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
37}
38
39gdb_exit
40gdb_start
41gdb_reinitialize_dir $srcdir/$subdir
42gdb_load ${binfile}
43
44if ![runto_main] then {
45 fail "Can't run to main"
46 return 0
47}
48
49# Vanilla step/next
50#
51gdb_test "next" ".*${decimal}.*x = 1;.*" "next 1"
52gdb_test "step" ".*${decimal}.*y = 2;.*" "step 1"
53
54# With count
55#
56gdb_test "next 2" ".*${decimal}.*w = w.*2;.*" "next 2"
57gdb_test "step 3" ".*${decimal}.*z = z.*5;.*" "step 3"
58gdb_test "next" ".*${decimal}.*callee.*OVER.*" "next 3"
59
60# Step over call
61#
62gdb_test "next" ".*${decimal}.*callee.*INTO.*" "next over"
63
64# Step into call
65#
66gdb_test "step" ".*${decimal}.*glob.*" "step into"
67
68# Step out of call
69#
70# I wonder if this is really portable. Are there any caller-saves
71# platforms, on which `finish' will return you to some kind of pop
72# instruction, which is attributed to the line containing the function
73# call?
74gdb_test "finish" ".*${decimal}.*a.*5.*= a.*3.*" "step out"
75
76### Testing nexti and stepi.
77###
78### test_i NAME COMMAND HERE THERE
79###
80### Send COMMAND to gdb over and over, while the output matches the
81### regexp HERE, followed by the gdb prompt. Pass if the output
82### eventually matches the regexp THERE, followed by the gdb prompt;
83### fail if we have to iterate more than a hundred times, we time out
84### talking to gdb, or we get output which is neither HERE nor THERE. :)
85###
86### Use NAME as the name of the test.
87###
88### The exact regexps used are "$HERE.*$gdb_prompt $"
89### and "$THERE.*$gdb_prompt $"
90###
91proc test_i {name command here there} {
92 global gdb_prompt
93
94 set i 0
95 while 1 {
96 send_gdb "${command}\n"
97 gdb_expect {
98 -re "$here.*$gdb_prompt $" {
99 # Okay, we're still on the same line. Just step again.
100 }
101 -re "$there.*$gdb_prompt $" {
102 # We've reached the next line. Rah.
103 pass "$name"
104 return
105 }
106 -re "$gdb_prompt $" {
107 # We got something else. Fail.
108 fail "$name"
109 return
110 }
111 timeout {
112 fail "$name (timeout)"
113 return
114 }
115 }
116
117 # Have we gone for too many steps without seeing any progress?
118 if {[incr i] >= 100} {
119 fail "$name (no progress after 100 steps)"
120 return
121 }
122 }
123}
124
125test_i "stepi to next line" "stepi" \
126 ".*${decimal}.*a.*5.* = a.*3" \
127 ".*${decimal}.*callee.*STEPI"
128test_i "stepi into function" "stepi" \
129 ".*${decimal}.*callee.*STEPI" \
130 ".*callee \\(\\) at .*step-test\\.c"
131gdb_test "finish" ".*${decimal}.*callee.*NEXTI.*" "stepi: finish call"
132test_i "nexti over function" "nexti" \
133 ".*${decimal}.*callee.*NEXTI" \
134 ".*${decimal}.*y = w \\+ z;"
135
136# On some platforms, if we try to step into a function call that
137# passes a large structure by value, then we actually end up stepping
138# into memcpy, bcopy, or some such --- GCC emits the call to pass the
139# argument. Opinion is bitterly divided about whether this is the
140# right behavior for GDB or not, but we'll catch it here, so folks
141# won't forget about it.
142
143send_gdb "break [gdb_get_line_number "step-test.exp: large struct by value"]\n"
144gdb_test "continue" \
145 ".*Breakpoint ${decimal},.*large_struct_by_value.*" \
146 "run to pass large struct"
147gdb_test "step" \
148 ".*step-test.exp: arrive here 1.*" \
149 "large struct by value"
150
151gdb_test "continue" ".*Program exited normally.*" "run to finish"
152
153return 0