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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.trace/] [tfind.exp] - Blame information for rev 1767

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

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