OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.base/] [step-test.exp] - Blame information for rev 24

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 24 jeremybenn
# This testcase is part of GDB, the GNU debugger.
2
 
3
# Copyright 1997, 1998, 1999, 2000, 2002, 2001, 2003, 2004, 2007, 2008
4
# Free Software Foundation, Inc.
5
 
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 3 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program.  If not, see .  */
18
# step-test.exp -- Expect script to test stepping in gdb
19
 
20
if $tracelevel then {
21
    strace $tracelevel
22
}
23
 
24
set testfile step-test
25
set srcfile ${testfile}.c
26
set binfile ${objdir}/${subdir}/${testfile}
27
 
28
remote_exec build "rm -f ${binfile}"
29
if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
30
     untested step-test.exp
31
     return -1
32
}
33
 
34
gdb_exit
35
gdb_start
36
gdb_reinitialize_dir $srcdir/$subdir
37
gdb_load ${binfile}
38
 
39
if ![runto_main] then {
40
   fail "Can't run to main"
41
   return 0
42
}
43
 
44
# Set a breakpoint at line 45, if stepi then finish fails, we would
45
# run to the end of the program, which would mess up the rest of the tests.
46
 
47
# Vanilla step/next
48
#
49
gdb_test "next" ".*${decimal}.*x = 1;.*" "next 1"
50
gdb_test "step" ".*${decimal}.*y = 2;.*" "step 1"
51
 
52
# With count
53
#
54
gdb_test "next 2" ".*${decimal}.*w = w.*2;.*" "next 2"
55
gdb_test "step 3" ".*${decimal}.*z = z.*5;.*" "step 3"
56
gdb_test "next" ".*${decimal}.*callee.*OVER.*" "next 3"
57
 
58
# Step over call
59
#
60
gdb_test "next" ".*${decimal}.*callee.*INTO.*" "next over"
61
 
62
# Step into call
63
#
64
gdb_test "step" ".*${decimal}.*myglob.*"   "step into"
65
 
66
# Step out of call
67
#
68
# I wonder if this is really portable.  Are there any caller-saves
69
# platforms, on which `finish' will return you to some kind of pop
70
# instruction, which is attributed to the line containing the function
71
# call?
72
 
73
# On PA64, we end up at a different instruction than PA32.
74
# On IA-64, we also end up on callee instead of on the next line due
75
# to the restoration of the global pointer (which is a caller-save).
76
# Similarly on MIPS PIC targets.
77
set test "step out"
78
if { [istarget "hppa2.0w-hp-hpux*"] || [istarget "ia64-*-*"] || [istarget "mips*-*-*"]} {
79
    gdb_test_multiple "finish" "$test" {
80
        -re ".*${decimal}.*a.*5.*= a.*3.*$gdb_prompt $" {
81
            pass "$test"
82
        }
83
        -re ".*${decimal}.*callee.*INTO.*$gdb_prompt $" {
84
            pass "$test"
85
        }
86
    }
87
} else {
88
    gdb_test "finish" ".*${decimal}.*a.*5.*= a.*3.*" "step out"
89
}
90
 
91
### Testing nexti and stepi.
92
###
93
### test_i NAME COMMAND HERE THERE
94
###
95
### Send COMMAND to gdb over and over, while the output matches the
96
### regexp HERE, followed by the gdb prompt.  Pass if the output
97
### eventually matches the regexp THERE, followed by the gdb prompt;
98
### fail if we have to iterate more than a hundred times, we time out
99
### talking to gdb, or we get output which is neither HERE nor THERE.  :)
100
###
101
### Use NAME as the name of the test.
102
###
103
### The exact regexps used are "$HERE.*$gdb_prompt $"
104
###                        and "$THERE.*$gdb_prompt $"
105
###
106
proc test_i {name command here there} {
107
    global gdb_prompt
108
 
109
    set i 0
110
    gdb_test_multiple "$command" "$name" {
111
        -re "$here.*$gdb_prompt $" {
112
            # Have we gone for too many steps without seeing any progress?
113
            if {[incr i] >= 100} {
114
                fail "$name (no progress after 100 steps)"
115
                return
116
            }
117
            send_gdb "$command\n"
118
            exp_continue
119
        }
120
        -re "$there.*$gdb_prompt $" {
121
            # We've reached the next line.  Rah.
122
            pass "$name"
123
            return
124
        }
125
    }
126
}
127
 
128
test_i "stepi to next line" "stepi" \
129
       ".*${decimal}.*a.*5.* = a.*3" \
130
       ".*${decimal}.*callee.*STEPI"
131
test_i "stepi into function" "stepi" \
132
       ".*${decimal}.*callee.*STEPI" \
133
       ".*callee \\(\\) at .*step-test\\.c"
134
 
135
# Continue to step until we reach the function's body.  This makes it
136
# more likely that we've actually completed the prologue, so "finish"
137
# will work.
138
test_i "stepi into function's first source line" "stepi" \
139
        ".*${decimal}.*int callee" \
140
        ".*${decimal}.*myglob.*; return 0;"
141
 
142
# Have to be careful here, if the finish does not work,
143
# then we may run to the end of the program, which
144
# will cause erroneous failures in the rest of the tests
145
set test "stepi: finish call"
146
gdb_test_multiple "finish" "$test" {
147
    -re ".*${decimal}.*callee.*NEXTI.*$gdb_prompt $" {
148
        pass "$test"
149
    }
150
    -re ".*(Program received|Program exited).*$gdb_prompt $" {
151
        # Oops... We ran to the end of the program...  Better reset
152
        if {![runto_main]} then {
153
            fail "$test (Can't run to main)"
154
            return 0
155
        }
156
        if {![runto step-test.c:45]} {
157
            fail "$test (Can't run to line 45)"
158
            return 0
159
        }
160
        fail "$test"
161
    }
162
    -re ".*${decimal}.*callee.*STEPI.*$gdb_prompt $" {
163
        # On PA64, we end up at a different instruction than PA32.
164
        # On IA-64, we end up on callee instead of on the following line due
165
        # to the restoration of the global pointer.
166
        # Similarly on MIPS PIC targets.
167
        if { [istarget "hppa2.0w-hp-hpux*"] || [istarget "ia64-*-*"] || [istarget "mips*-*-*"] } {
168
            test_i "$test" "stepi" \
169
                ".*${decimal}.*callee.*STEPI"  ".*${decimal}.*callee.*NEXTI"
170
        } else {
171
            fail "$test"
172
        }
173
    }
174
}
175
 
176
test_i "nexti over function" "nexti" \
177
       ".*${decimal}.*callee.*NEXTI" \
178
       ".*${decimal}.*y = w \\+ z;"
179
 
180
# On some platforms, if we try to step into a function call that
181
# passes a large structure by value, then we actually end up stepping
182
# into memcpy, bcopy, or some such --- GCC emits the call to pass the
183
# argument.  Opinion is bitterly divided about whether this is the
184
# right behavior for GDB or not, but we'll catch it here, so folks
185
# won't forget about it.
186
# Update 4/4/2002 - Regardless of which opinion you have, you would
187
# probably have to agree that gdb is currently behaving as designed,
188
# in the absence of additional code to not stop in functions used
189
# internally by the compiler.  Since the testsuite should be checking
190
# for conformance to the design, the correct behavior is to accept the
191
# cases where gdb stops in memcpy/bcopy.
192
 
193
gdb_test \
194
  "break [gdb_get_line_number "step-test.exp: large struct by value"]" \
195
  ".*Breakpoint.* at .*" \
196
  "set breakpoint at call to large_struct_by_value"
197
gdb_test "continue" \
198
         ".*Breakpoint ${decimal},.*large_struct_by_value.*" \
199
         "run to pass large struct"
200
set test "large struct by value"
201
gdb_test_multiple "step" "$test" {
202
    -re ".*step-test.exp: arrive here 1.*$gdb_prompt $" {
203
        pass "$test"
204
    }
205
    -re ".*(memcpy|bcopy).*$gdb_prompt $" {
206
        send_gdb "finish\n" ; gdb_expect -re "$gdb_prompt $"
207
        send_gdb "step\n"
208
        exp_continue
209
    }
210
}
211
 
212
gdb_continue_to_end "step-test.exp"
213
 
214
return 0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.