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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [testsuite/] [gdb.base/] [dump.exp] - Blame information for rev 1181

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

Line No. Rev Author Line
1 1181 sfurman
 
2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; either version 2 of the License, or
5
# (at your option) any later version.
6
#
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
# GNU General Public License for more details.
11
#
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
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@redhat.com)
20
# This is a test for the gdb command "dump".
21
 
22
if $tracelevel then {
23
        strace $tracelevel
24
}
25
 
26
set prms_id 0
27
set bug_id 0
28
 
29
set testfile "dump"
30
 
31
set srcfile  ${testfile}.c
32
set binfile  ${objdir}/${subdir}/${testfile}
33
 
34
if  { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable {debug}] != "" } {
35
     gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
36
}
37
 
38
# Start with a fresh gdb.
39
 
40
gdb_exit
41
gdb_start
42
gdb_reinitialize_dir $srcdir/$subdir
43
gdb_load ${binfile}
44
 
45
# Clean up any stale output files from previous test runs
46
 
47
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
48
 
49
# Test help (FIXME:)
50
 
51
# Run target program until data structs are initialized.
52
 
53
if { ! [ runto checkpoint1 ] } then {
54
    gdb_suppress_entire_file "Program failed to run, so all tests in this file will automatically fail."
55
}
56
 
57
# Now generate some dump files.
58
 
59
proc make_dump_file { command msg } {
60
  global gdb_prompt
61
 
62
    send_gdb "${command}\n"
63
    gdb_expect {
64
        -re ".*\[Ee\]rror.*$gdb_prompt $"      { fail $msg }
65
        -re ".*\[Ww\]arning.*$gdb_prompt $"    { fail $msg }
66
        -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
67
        -re ".*$gdb_prompt $" { pass $msg }
68
        timeout                                { fail "$msg (timeout)" }
69
    }
70
}
71
 
72
make_dump_file "dump val intarr1.bin intarray" \
73
        "dump array as value, default"
74
 
75
make_dump_file "dump val intstr1.bin intstruct" \
76
        "dump struct as value, default"
77
 
78
make_dump_file "dump bin val intarr1b.bin intarray" \
79
        "dump array as value, binary"
80
 
81
make_dump_file "dump bin val intstr1b.bin intstruct" \
82
        "dump struct as value, binary"
83
 
84
make_dump_file "dump srec val intarr1.srec intarray" \
85
        "dump array as value, srec"
86
 
87
make_dump_file "dump srec val intstr1.srec intstruct" \
88
        "dump struct as value, srec"
89
 
90
make_dump_file "dump ihex val intarr1.ihex intarray" \
91
        "dump array as value, intel hex"
92
 
93
make_dump_file "dump ihex val intstr1.ihex intstruct" \
94
        "dump struct as value, intel hex"
95
 
96
make_dump_file "dump tekhex val intarr1.tekhex intarray" \
97
        "dump array as value, tekhex"
98
 
99
make_dump_file "dump tekhex val intstr1.tekhex intstruct" \
100
        "dump struct as value, tekhex"
101
 
102
proc capture_value { expression } {
103
    global gdb_prompt
104
    global expect_out
105
 
106
    set output_string ""
107
    send_gdb "print ${expression}\n"
108
    gdb_expect {
109
        -re ".*\[\r\n\]+.\[0123456789\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
110
            set output_string $expect_out(1,string)
111
        }
112
        default {
113
            fail "capture_value failed on $expression."
114
        }
115
    }
116
    return $output_string
117
}
118
 
119
set array_start  [capture_value "/x &intarray\[0\]"]
120
set array_end    [capture_value "/x &intarray\[32\]"]
121
set struct_start [capture_value "/x &intstruct"]
122
set struct_end   [capture_value "/x &intstruct + 1"]
123
 
124
set array_val    [capture_value "intarray"]
125
set struct_val   [capture_value "intstruct"]
126
 
127
make_dump_file "dump mem intarr2.bin $array_start $array_end" \
128
        "dump array as memory, default"
129
 
130
make_dump_file "dump  mem intstr2.bin $struct_start $struct_end" \
131
        "dump struct as memory, default"
132
 
133
make_dump_file "dump bin mem intarr2b.bin $array_start $array_end" \
134
        "dump array as memory, binary"
135
 
136
make_dump_file "dump bin mem intstr2b.bin $struct_start $struct_end" \
137
        "dump struct as memory, binary"
138
 
139
make_dump_file "dump srec mem intarr2.srec $array_start $array_end" \
140
        "dump array as memory, srec"
141
 
142
make_dump_file "dump srec mem intstr2.srec $struct_start $struct_end" \
143
        "dump struct as memory, srec"
144
 
145
make_dump_file "dump ihex mem intarr2.ihex $array_start $array_end" \
146
        "dump array as memory, ihex"
147
 
148
make_dump_file "dump ihex mem intstr2.ihex $struct_start $struct_end" \
149
        "dump struct as memory, ihex"
150
 
151
make_dump_file "dump tekhex mem intarr2.tekhex $array_start $array_end" \
152
        "dump array as memory, tekhex"
153
 
154
make_dump_file "dump tekhex mem intstr2.tekhex $struct_start $struct_end" \
155
        "dump struct as memory, tekhex"
156
 
157
# test complex expressions
158
make_dump_file \
159
        "dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
160
        "dump array as mem, srec, expressions"
161
 
162
 
163
# Now start a fresh gdb session, and reload the saved value files.
164
 
165
gdb_exit
166
gdb_start
167
gdb_file_cmd ${binfile}
168
 
169
# Reload saved values one by one, and compare.
170
 
171
if { ![string compare $array_val [capture_value "intarray"]] } then {
172
    fail "start with intarray un-initialized"
173
} else {
174
    pass "start with intarray un-initialized"
175
}
176
 
177
if { ![string compare $struct_val [capture_value "intstruct"]] } then {
178
    fail "start with intstruct un-initialized"
179
} else {
180
    pass "start with intstruct un-initialized"
181
}
182
 
183
proc test_reload_saved_value { filename msg oldval newval } {
184
    global gdb_prompt
185
 
186
    gdb_file_cmd $filename
187
    if { ![string compare $oldval [capture_value $newval]] } then {
188
        pass $msg
189
    } else {
190
        fail $msg
191
    }
192
}
193
 
194
proc test_restore_saved_value { restore_args msg oldval newval } {
195
    global gdb_prompt
196
 
197
    gdb_test "restore $restore_args" \
198
            "Restoring .*" \
199
            "Restore command, $msg"
200
 
201
    if { ![string compare $oldval [capture_value $newval]] } then {
202
        pass "Restored value, $msg"
203
    } else {
204
        fail "Restored value, $msg"
205
    }
206
}
207
 
208
test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
209
        $array_val "intarray"
210
test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
211
        $struct_val "intstruct"
212
test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
213
        $array_val "intarray"
214
test_reload_saved_value "intstr2.srec" "reload struct as memory, srec" \
215
        $struct_val "intstruct"
216
 
217
test_reload_saved_value "intarr1.ihex" "reload array as value, intel hex" \
218
        $array_val "intarray"
219
test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
220
        $struct_val "intstruct"
221
test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
222
        $array_val "intarray"
223
test_reload_saved_value "intstr2.ihex" "reload struct as memory, intel hex" \
224
        $struct_val "intstruct"
225
 
226
test_reload_saved_value "intarr1.tekhex" "reload array as value, tekhex" \
227
        $array_val "intarray"
228
test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
229
        $struct_val "intstruct"
230
test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
231
        $array_val "intarray"
232
test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
233
        $struct_val "intstruct"
234
 
235
# Start a fresh gdb session
236
 
237
gdb_exit
238
gdb_start
239
gdb_reinitialize_dir $srcdir/$subdir
240
gdb_load ${binfile}
241
 
242
# Run to main.
243
if { ! [ runto main ] } then {
244
    gdb_suppress_entire_file "Program failed to run, so remaining tests in this file will automatically fail."
245
}
246
 
247
if { ![string compare $array_val [capture_value "intarray"]] } then {
248
    fail "start with intarray un-initialized, runto main"
249
} else {
250
    pass "start with intarray un-initialized, runto main"
251
}
252
 
253
if { ![string compare $struct_val [capture_value "intstruct"]] } then {
254
    fail "start with intstruct un-initialized, runto main"
255
} else {
256
    pass "start with intstruct un-initialized, runto main"
257
}
258
 
259
test_restore_saved_value "intarr1.srec" "array as value, srec" \
260
        $array_val "intarray"
261
 
262
test_restore_saved_value "intstr1.srec" "struct as value, srec" \
263
        $struct_val "intstruct"
264
 
265
gdb_test "print zero_all ()" "void" "zero all"
266
 
267
test_restore_saved_value "intarr2.srec" "array as memory, srec" \
268
        $array_val "intarray"
269
 
270
test_restore_saved_value "intstr2.srec" "struct as memory, srec" \
271
        $struct_val "intstruct"
272
 
273
gdb_test "print zero_all ()" ""
274
 
275
test_restore_saved_value "intarr1.ihex" "array as value, ihex" \
276
        $array_val "intarray"
277
 
278
test_restore_saved_value "intstr1.ihex" "struct as value, ihex" \
279
        $struct_val "intstruct"
280
 
281
gdb_test "print zero_all ()" ""
282
 
283
test_restore_saved_value "intarr2.ihex" "array as memory, ihex" \
284
        $array_val "intarray"
285
 
286
test_restore_saved_value "intstr2.ihex" "struct as memory, ihex" \
287
        $struct_val "intstruct"
288
 
289
gdb_test "print zero_all ()" ""
290
 
291
test_restore_saved_value "intarr1.tekhex" "array as value, tekhex" \
292
        $array_val "intarray"
293
 
294
test_restore_saved_value "intstr1.tekhex" "struct as value, tekhex" \
295
        $struct_val "intstruct"
296
 
297
gdb_test "print zero_all ()" ""
298
 
299
test_restore_saved_value "intarr2.tekhex" "array as memory, tekhex" \
300
        $array_val "intarray"
301
 
302
test_restore_saved_value "intstr2.tekhex" "struct as memory, tekhex" \
303
        $struct_val "intstruct"
304
 
305
gdb_test "print zero_all ()" ""
306
 
307
test_restore_saved_value "intarr1.bin binary $array_start" \
308
        "array as value, binary" \
309
        $array_val "intarray"
310
 
311
test_restore_saved_value "intstr1.bin binary $struct_start" \
312
        "struct as value, binary" \
313
        $struct_val "intstruct"
314
 
315
gdb_test "print zero_all ()" ""
316
 
317
test_restore_saved_value "intarr2.bin binary $array_start" \
318
        "array as memory, binary" \
319
        $array_val "intarray"
320
 
321
test_restore_saved_value "intstr2.bin binary $struct_start" \
322
        "struct as memory, binary" \
323
        $struct_val "intstruct"
324
 
325
# test restore with offset.
326
 
327
set array2_start   [capture_value "/x &intarray2\[0\]"]
328
set struct2_start  [capture_value "/x &intstruct2"]
329
set array2_offset  \
330
        [capture_value "/x (char *) &intarray2 - (char *) &intarray"]
331
set struct2_offset \
332
        [capture_value "/x (char *) &intstruct2 - (char *) &intstruct"]
333
 
334
gdb_test "print zero_all ()" ""
335
 
336
test_restore_saved_value "intarr1.srec $array2_offset" \
337
        "array copy, srec" \
338
        $array_val "intarray2"
339
 
340
test_restore_saved_value "intstr1.srec $struct2_offset" \
341
        "struct copy, srec" \
342
        $struct_val "intstruct2"
343
 
344
gdb_test "print zero_all ()" ""
345
 
346
test_restore_saved_value "intarr1.ihex $array2_offset" \
347
        "array copy, ihex" \
348
        $array_val "intarray2"
349
 
350
test_restore_saved_value "intstr1.ihex $struct2_offset" \
351
        "struct copy, ihex" \
352
        $struct_val "intstruct2"
353
 
354
gdb_test "print zero_all ()" ""
355
 
356
test_restore_saved_value "intarr1.tekhex $array2_offset" \
357
        "array copy, tekhex" \
358
        $array_val "intarray2"
359
 
360
test_restore_saved_value "intstr1.tekhex $struct2_offset" \
361
        "struct copy, tekhex" \
362
        $struct_val "intstruct2"
363
 
364
gdb_test "print zero_all ()" ""
365
 
366
test_restore_saved_value "intarr1.bin binary $array2_start" \
367
        "array copy, binary" \
368
        $array_val "intarray2"
369
 
370
test_restore_saved_value "intstr1.bin binary $struct2_start" \
371
        "struct copy, binary" \
372
        $struct_val "intstruct2"
373
 
374
#
375
# test restore with start/stop addresses.
376
#
377
# For this purpose, we will restore just the third element of the array,
378
# and check to see that adjacent elements are not modified.
379
#
380
# We will need the address and offset of the third and fourth elements.
381
#
382
 
383
set element3_start  [capture_value "/x &intarray\[3\]"]
384
set element4_start  [capture_value "/x &intarray\[4\]"]
385
set element3_offset \
386
        [capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
387
set element4_offset \
388
        [capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
389
 
390
gdb_test "print zero_all ()" ""
391
 
392
test_restore_saved_value "intarr1.srec 0 $element3_start $element4_start" \
393
        "array partial, srec" \
394
        [capture_value "4"] "intarray\[3\]"
395
 
396
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
397
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
398
 
399
gdb_test "print zero_all ()" ""
400
 
401
test_restore_saved_value "intarr1.ihex 0 $element3_start $element4_start" \
402
        "array partial, ihex" \
403
        [capture_value "4"] "intarray\[3\]"
404
 
405
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
406
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
407
 
408
gdb_test "print zero_all ()" ""
409
 
410
test_restore_saved_value "intarr1.tekhex 0 $element3_start $element4_start" \
411
        "array partial, tekhex" \
412
        [capture_value "4"] "intarray\[3\]"
413
 
414
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
415
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
416
 
417
gdb_test "print zero_all ()" ""
418
 
419
test_restore_saved_value \
420
    "intarr1.bin binary $array_start $element3_offset $element4_offset" \
421
    "array partial, binary" \
422
    [capture_value "4"] "intarray\[3\]"
423
 
424
gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
425
gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
426
 
427
gdb_test "print zero_all ()" "" ""
428
 
429
# restore with expressions
430
test_restore_saved_value \
431
        "intarr3.srec ${array2_start}-${array_start} &intarray\[3\] &intarray\[4\]" \
432
        "array partial with expressions" \
433
        [capture_value "4"] "intarray2\[3\]"
434
 
435
gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
436
gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
437
 
438
 
439
# clean up files
440
 
441
remote_exec build "rm -f intarr1.bin intarr1b.bin intarr1.ihex intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex intstr2.srec intstr2.tekhex intarr3.srec"
442
 

powered by: WebSVN 2.1.0

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