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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [testsuite/] [gdb.base/] [step-test.exp] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
# Copyright (C) 1997, 1998, 1999 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
 
26
if $tracelevel then {
27
    strace $tracelevel
28
}
29
 
30
set testfile step-test
31
set srcfile ${srcdir}/${subdir}/${testfile}.c
32
set binfile ${objdir}/${subdir}/${testfile}
33
 
34
remote_exec build "rm -f ${binfile}"
35
if { [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
 
39
gdb_exit
40
gdb_start
41
gdb_reinitialize_dir $srcdir/$subdir
42
gdb_load ${binfile}
43
 
44
if ![runto_main] then {
45
   fail "Can't run to main"
46
   return 0
47
}
48
 
49
# Set a breakpoint at line 45, if stepi then finish fails, we would
50
# run to the end of the program, which would mess up the rest of the tests.
51
 
52
# Vanilla step/next
53
#
54
gdb_test "next" ".*${decimal}.*x = 1;.*" "next 1"
55
gdb_test "step" ".*${decimal}.*y = 2;.*" "step 1"
56
 
57
# With count
58
#
59
gdb_test "next 2" ".*${decimal}.*w = w.*2;.*" "next 2"
60
gdb_test "step 3" ".*${decimal}.*z = z.*5;.*" "step 3"
61
gdb_test "next" ".*${decimal}.*callee.*OVER.*" "next 3"
62
 
63
# Step over call
64
#
65
gdb_test "next" ".*${decimal}.*callee.*INTO.*" "next over"
66
 
67
# Step into call
68
#
69
gdb_test "step" ".*${decimal}.*myglob.*"   "step into"
70
 
71
# Step out of call
72
#
73
# I wonder if this is really portable.  Are there any caller-saves
74
# platforms, on which `finish' will return you to some kind of pop
75
# instruction, which is attributed to the line containing the function
76
# call?
77
 
78
# On PA64 we end up at a different instruction than PA32
79
if { [istarget "hppa2.0w-hp-hpux*"] } {
80
    send_gdb "finish\n"
81
    gdb_expect {
82
        -re ".*${decimal}.*a.*5.*= a.*3.*$gdb_prompt $" { pass "step out 1" }
83
        -re ".*${decimal}.*callee.*INTO.*$gdb_prompt $" { pass "step out 2" }
84
        timeout { fail "step out" }
85
    }
86
} else {
87
    gdb_test "finish" ".*${decimal}.*a.*5.*= a.*3.*" "step out"
88
}
89
 
90
### Testing nexti and stepi.
91
###
92
### test_i NAME COMMAND HERE THERE
93
###
94
### Send COMMAND to gdb over and over, while the output matches the
95
### regexp HERE, followed by the gdb prompt.  Pass if the output
96
### eventually matches the regexp THERE, followed by the gdb prompt;
97
### fail if we have to iterate more than a hundred times, we time out
98
### talking to gdb, or we get output which is neither HERE nor THERE.  :)
99
###
100
### Use NAME as the name of the test.
101
###
102
### The exact regexps used are "$HERE.*$gdb_prompt $"
103
###                        and "$THERE.*$gdb_prompt $"
104
###
105
proc test_i {name command here there} {
106
    global gdb_prompt
107
 
108
    set i 0
109
    while 1 {
110
        send_gdb "${command}\n"
111
        gdb_expect {
112
            -re "$here.*$gdb_prompt $" {
113
                # Okay, we're still on the same line.  Just step again.
114
            }
115
            -re "$there.*$gdb_prompt $" {
116
                # We've reached the next line.  Rah.
117
                pass "$name"
118
                return
119
            }
120
            -re "$gdb_prompt $" {
121
                # We got something else.  Fail.
122
                fail "$name"
123
                return
124
            }
125
            timeout {
126
                fail "$name (timeout)"
127
                return
128
            }
129
        }
130
 
131
        # Have we gone for too many steps without seeing any progress?
132
        if {[incr i] >= 100} {
133
            fail "$name (no progress after 100 steps)"
134
            return
135
        }
136
    }
137
}
138
 
139
test_i "stepi to next line" "stepi" \
140
       ".*${decimal}.*a.*5.* = a.*3" \
141
       ".*${decimal}.*callee.*STEPI"
142
test_i "stepi into function" "stepi" \
143
       ".*${decimal}.*callee.*STEPI" \
144
       ".*callee \\(\\) at .*step-test\\.c"
145
 
146
# Continue to step until we reach the function's body.  This makes it
147
# more likely that we've actually completed the prologue, so "finish"
148
# will work.
149
test_i "stepi into function's first source line" "stepi" \
150
        ".*${decimal}.*int callee" \
151
        ".*${decimal}.*myglob.*; return 0;"
152
 
153
# Have to be careful here, if the finish does not work,
154
# then we may run to the end of the program, which
155
# will cause erroneous failures in the rest of the tests
156
send_gdb "finish\n"
157
gdb_expect {
158
  -re ".*(Program received|Program exited).*$gdb_prompt $" {
159
    # Oops... We ran to the end of the program...  Better reset
160
    if {![runto_main]} then {
161
      fail "Can't run to main"
162
      return 0
163
    }
164
    if {![runto step-test.c:45]} {
165
      fail "Can't run to line 45"
166
      return 0
167
    }
168
    fail "stepi: finish call"
169
  }
170
  -re ".*${decimal}.*callee.*NEXTI.*$gdb_prompt $" {
171
    pass "stepi: finish call"
172
  }
173
  -re ".*${decimal}.*callee.*STEPI.*$gdb_prompt $" {
174
    # On PA64 we end up at a different instruction than PA32
175
    if { [istarget "hppa2.0w-hp-hpux*"] } {
176
        pass "stepi: finish call 2"
177
    } else {
178
        fail "stepi: finish call 2"
179
        return
180
    }
181
  }
182
  -re "$gdb_prompt $" {
183
    # We got something else.  Fail.
184
    fail "stepi: finish call"
185
    return
186
  }
187
  timeout {
188
    fail "stepi: finish call (timeout)"
189
    return
190
  }
191
}
192
 
193
test_i "nexti over function" "nexti" \
194
       ".*${decimal}.*callee.*NEXTI" \
195
       ".*${decimal}.*y = w \\+ z;"
196
 
197
# On some platforms, if we try to step into a function call that
198
# passes a large structure by value, then we actually end up stepping
199
# into memcpy, bcopy, or some such --- GCC emits the call to pass the
200
# argument.  Opinion is bitterly divided about whether this is the
201
# right behavior for GDB or not, but we'll catch it here, so folks
202
# won't forget about it.
203
 
204
gdb_test \
205
  "break [gdb_get_line_number "step-test.exp: large struct by value"]" \
206
  ".*Breakpoint.* at .*" \
207
  "set breakpoint at call to large_struct_by_value"
208
gdb_test "continue" \
209
         ".*Breakpoint ${decimal},.*large_struct_by_value.*" \
210
         "run to pass large struct"
211
gdb_test "step" \
212
         ".*step-test.exp: arrive here 1.*" \
213
         "large struct by value"
214
 
215
gdb_continue_to_end "step-test.exp"
216
 
217
return 0

powered by: WebSVN 2.1.0

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