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.trace/] [tfind.exp] - Blame information for rev 157

Details | Compare with Previous | View Log

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