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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gdb-7.2/] [gdb/] [testsuite/] [gdb.trace/] [tfind.exp] - Blame information for rev 861

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

Line No. Rev Author Line
1 330 jeremybenn
#   Copyright 1998, 2002, 2005, 2007, 2008, 2009, 2010
2
#   Free Software Foundation, Inc.
3
#
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.
8
#
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.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see .
16
 
17
# This file was written by Michael Snyder (msnyder@cygnus.com)
18
 
19
load_lib "trace-support.exp";
20
 
21
if $tracelevel then {
22
    strace $tracelevel
23
}
24
 
25
 
26
gdb_exit
27
gdb_start
28
 
29
set testfile "actions"
30
set srcfile ${testfile}.c
31
set binfile $objdir/$subdir/tfind
32
 
33
if { [gdb_compile "$srcdir/$subdir/$srcfile" "$binfile" \
34
          executable {debug nowarnings}] != "" } {
35
    untested tfind.exp
36
    return -1
37
}
38
gdb_load $binfile
39
gdb_test "tstop"       ".*" ""
40
gdb_test "tfind none"  ".*" ""
41
runto_main
42
gdb_reinitialize_dir $srcdir/$subdir
43
 
44
# We generously give ourselves one "pass" if we successfully
45
# detect that this test cannot be run on this target!
46
if { ![gdb_target_supports_trace] } then {
47
    pass "Current target does not support trace"
48
    return 1;
49
 
50
}
51
 
52
# If testing on a remote host, download the source file.
53
# remote_download host $srcdir/$subdir/$srcfile
54
 
55
# define relative source line numbers:
56
# all subsequent line numbers are relative to this first one (baseline)
57
set baseline  [gdb_find_recursion_test_baseline $srcfile];
58
if { $baseline == -1 } then {
59
    fail "Could not find gdb_recursion_test function"
60
    return;
61
}
62
 
63
set testline1 [expr $baseline + 1]
64
set testline2 [expr $baseline + 5]
65
set testline3 [expr $baseline + 6]
66
set testline4 [expr $baseline + 7]
67
set testline5 [expr $baseline + 8]
68
 
69
#
70
# test tfind command
71
#
72
 
73
gdb_delete_tracepoints
74
set tdp1 [gdb_gettpnum "\*gdb_recursion_test"]
75
set tdp2 [gdb_gettpnum $testline2]
76
set tdp3 [gdb_gettpnum $testline3]
77
set tdp4 [gdb_gettpnum $testline4]
78
set tdp5 [gdb_gettpnum $testline5]
79
if { $tdp1 <= 0 || $tdp2 <= 0 || $tdp3 <= 0 || \
80
     $tdp4 <= 0 || $tdp5 <= 0 } then {
81
    fail "setting tracepoints"
82
    return;
83
}
84
 
85
# 6.1 test tstart command
86
 
87
set return_me 1
88
gdb_test_multiple "tstart" "6.1: tstart" {
89
    -re "Trace can only be run on remote targets.*$gdb_prompt $" {
90
        fail "6.1: tstart (not connected to remote?)"
91
    }
92
    -re "Target does not support this command.*$gdb_prompt $" {
93
        fail "6.1: tstart (connected to wrong target?)"
94
    }
95
    -re "Target returns error code.*$gdb_prompt $" {
96
        fail "6.1: tstart (connected to wrong target?)"
97
    }
98
    -re "$gdb_prompt $" {
99
        pass "6.1: tstart"
100
        set return_me 0
101
    }
102
}
103
 
104
if { $return_me == 1 } then {
105
    return -1;
106
}
107
 
108
# test tstatus (when trace on)
109
gdb_test "tstatus" "\[Tt\]race is running.*" "test tstatus on"
110
 
111
# 6.2 test help tstart
112
gdb_test "help tstart" "Start trace data collection." "6.2: help tstart"
113
 
114
gdb_test "break end" ".*" ""
115
gdb_test "continue" \
116
    "Continuing.*Breakpoint $decimal, end.*" \
117
    "run trace experiment"
118
 
119
# 7.1 test tstop command
120
 
121
set return_me 1
122
gdb_test_multiple "tstop" "7.1: tstop" {
123
    -re "Trace can only be run on remote targets.*$gdb_prompt $" {
124
        fail "7.1: tstop (not connected to remote?)"
125
    }
126
    -re "Target does not support this command.*$gdb_prompt $" {
127
        fail "7.1: tstop (connected to wrong target?)"
128
    }
129
    -re "Target returns error code.*$gdb_prompt $" {
130
        fail "7.1: tstop (connected to wrong target?)"
131
    }
132
    -re "$gdb_prompt $" {
133
        pass "7.1: tstop"
134
        set return_me 0
135
    }
136
}
137
 
138
if { $return_me == 1 } then {
139
    return -1;
140
}
141
 
142
# 7.2 test help tstop
143
gdb_test "help tstop" "Stop trace data collection." "7.2: help tstop"
144
 
145
# test tstatus (when trace off)
146
gdb_test "tstatus" "Trace stopped by a tstop command.*" \
147
    "test tstatus off after tstop"
148
 
149
## record starting PC
150
set save_pc [gdb_readexpr "(unsigned long) \$pc"];
151
if { $save_pc == -1 } then {
152
    fail "could not read PC"
153
    return;
154
}
155
 
156
# 8.7  tfind start
157
## check $trace_frame == 0
158
gdb_tfind_test "8.7: tfind start command" "start" "0";
159
## check $pc != startPC
160
gdb_test "printf \"x \%d x\\n\", \$pc != $save_pc" \
161
        "x 1 x" \
162
        "8.7b: tfind start"
163
 
164
# 8.8  tfind none
165
## check $trace_frame == -1
166
gdb_tfind_test "8.8: tfind none" "none" "-1";
167
## check $pc == startPC
168
gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
169
        "x 1 x" \
170
        "8.8b: tfind none (restores non-trace PC)"
171
 
172
# 8.9  tfind end
173
## check $trace_frame == -1
174
gdb_tfind_test "8.9: tfind end, selects no frame" "end" "-1";
175
## check $pc == startPC
176
gdb_test "printf \"x \%d x\\n\", \$pc == $save_pc" \
177
        "x 1 x" \
178
        "8.9b: tfind end (restores non-tracing PC)"
179
 
180
# 8.1  tfind n
181
## check $trace_frame == n
182
gdb_tfind_test "8.1: tfind 1" "1" "1"
183
## check $trace_line corresponds to tracepoint for frame n
184
gdb_test "print \$trace_line" "$testline2" "8.1b: tfind 1 (correct line)"
185
 
186
# 8.28 tfind invalid n (big number)
187
## check "not found" error
188
## check $trace_frame != n
189
gdb_test "tfind 32767" \
190
        "failed to find.*" \
191
        "8.28: tfind  command rejects invalid frame number"
192
 
193
gdb_test "printf \"x \%d x\\n\", \$trace_frame == 32767" \
194
        "x 0 x" \
195
        "8.28: tfind  rejected bad input (32767)"
196
 
197
# 8.31 tfind negative n
198
## check error
199
gdb_test "tfind -3" "invalid input.*" "8.31: tfind  rejects negative input"
200
## check $trace_frame != -n
201
gdb_test "printf \"x \%d x\\n\", \$trace_frame == -3" "x 0 x" \
202
        "8.31: tfind  rejected negative input (-3)"
203
 
204
# 8.10 tfind 
205
## check $trace_frame += 1
206
 
207
gdb_tfind_test "8.10: tfind start" "start" "0";
208
gdb_test "print \$trace_line" "$baseline"  \
209
        "8.10: tfind 0 (correct line $baseline)"
210
gdb_tfind_test "8.10: tfind noargument 1" "" "1";
211
gdb_test "print \$trace_line" "$testline2" \
212
        "8.10: tfind 1 (correct line $testline2)"
213
gdb_tfind_test "8.10: tfind noargument 2" "" "2";
214
gdb_test "print \$trace_line" "$testline3" \
215
        "8.10: tfind 2 (correct line $testline3)"
216
gdb_tfind_test "8.10: tfind noargument 3" "" "3";
217
gdb_test "print \$trace_line" "$testline4" \
218
        "8.10: tfind 3 (correct line $testline4)"
219
 
220
gdb_tfind_test "8.11: tfind 3" "3" "3";
221
gdb_test "print \$trace_line" "$testline4" \
222
        "8.11: tfind 3 (correct line $testline4)"
223
gdb_tfind_test "8.11: tfind backward 2" "-" "2";
224
gdb_test "print \$trace_line" "$testline3" \
225
        "8.11: tfind 2 (correct line $testline3)"
226
gdb_tfind_test "8.11: tfind backward 1" "-" "1";
227
gdb_test "print \$trace_line" "$testline2" \
228
        "8.11: tfind 1 (correct line $testline2)"
229
gdb_tfind_test "8.11: tfind backward 0" "-" "0";
230
gdb_test "print \$trace_line" "$baseline"  \
231
        "8.11: tfind 0 (correct line $baseline)"
232
 
233
gdb_tfind_test "8.12: tfind none" "none" "-1";
234
gdb_tfind_test "8.12: tfind tracepoint " "tracepoint $tdp2" \
235
        "\$tracepoint" "$tdp2";
236
gdb_test "print \$trace_line" "$testline2" \
237
        "8.12: tfind tracepoint  (line $testline2)"
238
 
239
gdb_tfind_test "8.25: tfind none" "none" "-1";
240
gdb_test "tfind tracepoint 0" "failed to find.*" \
241
        "8.25: tfind tracepoint rejects zero"
242
gdb_test "tfind tracepoint 32767" "failed to find.*" \
243
        "8.25: tfind tracepoint rejects nonexistant tracepoint (32767)"
244
gdb_test "tfind tracepoint -1" "failed to find.*" \
245
        "8.25: tfind tracepoint rejects nonexistant tracepoint (-1)"
246
 
247
# 8.37 tfind tracepoint n where n no longer exists (but used to)
248
gdb_test_no_output "delete trace $tdp2" ""
249
gdb_tfind_test "8.37: tfind none" "none" "-1";
250
gdb_tfind_test "8.37: tfind deleted tracepoint" \
251
        "tracepoint $tdp2" \
252
        "\$tracepoint" "$tdp2";
253
gdb_test "print \$trace_line" "$testline2" \
254
        "8.37: tfind deleted tracepoint (line $testline2)"
255
 
256
# 8.13 tfind tracepoint 
257
## check $tracepoint same before and after, $trace_frame changed
258
 
259
gdb_tfind_test "8.13: tfind none" "none" "-1";
260
gdb_tfind_test "8.13: tracepoint $tdp1" "tracepoint $tdp1" \
261
        "\$tracepoint" "$tdp1";
262
gdb_test "print \$trace_line" "$baseline" \
263
        "8.13: tfind tracepoint $tdp1 (line $baseline)"
264
gdb_test_no_output "set \$save_frame = \$trace_frame" ""
265
gdb_tfind_test "8.13: tracepoint " "tracepoint" \
266
        "\$tracepoint" "$tdp1";
267
gdb_test "printf \"x \%d x\\n\", \$trace_frame == \$save_frame" \
268
        "x 0 x" \
269
        "8.13: tracepoint , tracepoint number unchanged"
270
 
271
# 1.12 set tracepoint in prologue
272
#
273
# tdp1 was set at *gdb_recursion_test (ie. the hard address of the
274
# function, before the prologue).  Test to see that it succeeded.
275
# Current pc should be equal to the address of the function.
276
 
277
gdb_test "printf \"x \%d x\\n\", \$pc == gdb_recursion_test" \
278
        "x 1 x" \
279
        "1.12: set tracepoint in prologue"
280
 
281
# 8.14 tfind pc x
282
## check pc == x, $trace_frame != -1
283
gdb_tfind_test "8.14: tfind 3" "3" "3"
284
gdb_test "print \$trace_line" "$testline4" \
285
        "8.14: tfind 3 (line $testline4)"
286
 
287
gdb_test_no_output "set \$test_pc = \$pc" ""
288
gdb_tfind_test "8.14: tfind none" "none" "-1"
289
gdb_tfind_test "8.14: tfind pc" "pc \$test_pc" "\$trace_frame != -1" "1";
290
gdb_test "print \$trace_line" "$testline4" \
291
        "8.14: tfind pc x (line $testline4)"
292
gdb_test "printf \"x \%d x\\n\", \$pc == \$test_pc" \
293
        "x 1 x" \
294
        "8.14: tfind pc x"
295
 
296
# 8.15 tfind pc 
297
## check pc same before and after, $trace_frame changed
298
gdb_tfind_test "8.15: tfind 3" "3" "3"
299
gdb_test "print \$trace_line" "$testline4" \
300
        "8.15: tfind 3 (line $testline4)"
301
gdb_test_no_output "set \$test_pc = \$pc" ""
302
gdb_tfind_test "8.15: tfind pc" "pc" "\$pc == \$test_pc" "1"
303
gdb_test "print \$trace_line" "$testline4" \
304
        "8.15: tfind pc (line $testline4)"
305
gdb_test "printf \"x \%d x\\n\", \$trace_frame != 3" "x 1 x" \
306
        "8.15: trace frame didn't change"
307
 
308
# 8.26 tfind pc invalid x
309
## check error, pc != x (trace_frame unchanged?)
310
gdb_tfind_test "8.26: tfind start" "start" "0"
311
gdb_test "tfind pc  0" "failed to find.*" "8.26: tfind pc zero"
312
gdb_test "tfind pc -1" "failed to find.*" "8.26: tfind pc -1"
313
 
314
# 8.16 tfind line n
315
## check #trace_frame != -1, $trace_line == n
316
gdb_tfind_test "8.16: tfind none" "none" "-1"
317
gdb_tfind_test "8.16: tfind line $testline3" \
318
        "line $testline3" \
319
        "\$trace_line == $testline3" "1"
320
 
321
# 8.17 tfind line  (# 8.19, 8.20)
322
## check $trace_line changed, no error, pc changed, frame changed, tdp changed
323
gdb_tfind_test "8.17: tfind none" "none" "-1"
324
gdb_tfind_test "8.17: tfind line $testline3" "line $testline3" "\$trace_line == $testline3" "1"
325
gdb_tfind_test "8.17: tfind line " "line" "\$trace_line != $testline3" "1"
326
 
327
# 8.36 tfind and disassembly
328
gdb_tfind_test "8.36: tfind start" "start" "0"
329
set timeout 60
330
# look for disassembly of function label
331
gdb_test "disassemble gdb_c_test" \
332
    "<(\.\[0-9\]+|)>:.*End of assembler dump.*" \
333
    "8.36: trace disassembly"
334
 
335
gdb_test "tfind line 0" \
336
        "out of range.*|failed to find.*" \
337
        "8.18: tfind line 0";
338
gdb_test "tfind line 32767" \
339
        "out of range.*|failed to find.*" \
340
        "8.27: tfind line 32767";
341
gdb_test "tfind line NoSuChFiLe.c:$baseline" \
342
        "No source file named.*" \
343
        "8.27: tfind line in bad source file";
344
 
345
# 8.32 tfind invalid subcommand (tfind foo)
346
## check error
347
gdb_test "tfind NoSuChOpTiOn 21" \
348
        "No symbol.*|\[Ww\]arning.*|\[Ee\]rror.*" \
349
        "8.32: tfind with bad subcommand"
350
 
351
# 8.38 test help tfind
352
gdb_test "help tfind"       "Select a trace frame.*"      \
353
        "8.38: help tfind"
354
gdb_test "help tfind pc"    "Select a trace frame by PC.*" \
355
        "8.38: help tfind PC"
356
gdb_test "help tfind end"   "Synonym for 'none'.*"        \
357
        "8.38: help tfind end"
358
gdb_test "help tfind none"  "De-select any trace frame.*" \
359
        "8.38: help tfind none"
360
gdb_test "help tfind line"  "Select a trace frame by source line.*" \
361
        "8.38: help tfind line"
362
gdb_test "help tfind start" "Select the first trace frame.*" \
363
        "8.38: help tfind start"
364
gdb_test "help tfind range" "Select a trace frame whose PC is in.*" \
365
        "8.38: help tfind range"
366
gdb_test "help tfind trace" "Select a trace frame by tracepoint number.*" \
367
        "8.38: help tfind tracepoint"
368
 
369
# Finished!
370
gdb_tfind_test "8.17: tfind none" "none" "-1"

powered by: WebSVN 2.1.0

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