dump.exp revision 1.3 1 1.3 christos # Copyright 2002-2015 Free Software Foundation, Inc.
2 1.1 christos
3 1.1 christos # This program is free software; you can redistribute it and/or modify
4 1.1 christos # it under the terms of the GNU General Public License as published by
5 1.1 christos # the Free Software Foundation; either version 3 of the License, or
6 1.1 christos # (at your option) any later version.
7 1.1 christos #
8 1.1 christos # This program is distributed in the hope that it will be useful,
9 1.1 christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 1.1 christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 1.1 christos # GNU General Public License for more details.
12 1.1 christos #
13 1.1 christos # You should have received a copy of the GNU General Public License
14 1.1 christos # along with this program. If not, see <http://www.gnu.org/licenses/>.
15 1.1 christos
16 1.1 christos # This file was written by Michael Snyder (msnyder (at) redhat.com)
17 1.1 christos # This is a test for the gdb command "dump".
18 1.1 christos
19 1.1 christos
20 1.1 christos standard_testfile
21 1.1 christos
22 1.1 christos set options {debug}
23 1.1 christos
24 1.1 christos set is64bitonly "no"
25 1.1 christos set endian "auto"
26 1.1 christos
27 1.1 christos if [istarget "alpha*-*-*"] then {
28 1.1 christos # SREC etc cannot handle 64-bit addresses. Force the test
29 1.1 christos # program into the low 31 bits of the address space.
30 1.1 christos lappend options "additional_flags=-Wl,-taso"
31 1.1 christos }
32 1.1 christos
33 1.1 christos if {[istarget "spu*-*-*"]} then {
34 1.1 christos # The internal address format used for the combined Cell/B.E.
35 1.1 christos # debugger requires 64-bit.
36 1.1 christos set is64bitonly "yes"
37 1.1 christos }
38 1.1 christos
39 1.1 christos if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable ${options}] != "" } {
40 1.1 christos untested dump.exp
41 1.1 christos return -1
42 1.1 christos }
43 1.1 christos
44 1.1 christos # Start with a fresh gdb.
45 1.1 christos
46 1.1 christos gdb_exit
47 1.1 christos gdb_start
48 1.1 christos gdb_reinitialize_dir $srcdir/$subdir
49 1.1 christos
50 1.1 christos gdb_test "dump mem /dev/null 0x10 0x20" "Cannot access memory at address 0x10" \
51 1.1 christos "inaccessible memory is reported"
52 1.1 christos
53 1.1 christos gdb_load ${binfile}
54 1.1 christos
55 1.1 christos # Check the address of a variable. If it is bigger than 32-bit,
56 1.1 christos # assume our target has 64-bit addresses that are not supported by SREC,
57 1.1 christos # IHEX and TEKHEX. We skip those tests then.
58 1.1 christos set max_32bit_address "0xffffffff"
59 1.1 christos set data_address [get_hexadecimal_valueof "&intarray" 0x100000000]
60 1.1 christos if {${data_address} > ${max_32bit_address}} then {
61 1.1 christos set is64bitonly "yes"
62 1.1 christos }
63 1.1 christos
64 1.1 christos # Clean up any stale output files from previous test runs
65 1.1 christos
66 1.1 christos set filenames {}
67 1.1 christos set all_files {
68 1.1 christos intarr1.bin intarr1b.bin intarr1.ihex
69 1.1 christos intarr1.srec intarr1.tekhex intarr2.bin intarr2b.bin intarr2.ihex
70 1.1 christos intarr2.srec intarr2.tekhex intstr1.bin intstr1b.bin intstr1.ihex
71 1.1 christos intstr1.srec intstr1.tekhex intstr2.bin intstr2b.bin intstr2.ihex
72 1.1 christos intstr2.srec intstr2.tekhex intarr3.srec
73 1.1 christos }
74 1.1 christos
75 1.1 christos # This loop sets variables dynamically -- each name listed in
76 1.1 christos # $ALL_FILES is both a file name and a variable name.
77 1.1 christos foreach file $all_files {
78 1.1 christos if {[is_remote host]} {
79 1.1 christos set this_name $file
80 1.1 christos } else {
81 1.1 christos set this_name [standard_output_file $file]
82 1.1 christos }
83 1.1 christos
84 1.1 christos lappend filenames [set ${file} $this_name]
85 1.1 christos }
86 1.1 christos
87 1.1 christos remote_exec host "rm -f $filenames"
88 1.1 christos
89 1.1 christos # Test help (FIXME:)
90 1.1 christos
91 1.1 christos # Run target program until data structs are initialized.
92 1.1 christos
93 1.1 christos if { ! [ runto checkpoint1 ] } then {
94 1.1 christos untested dump.exp
95 1.1 christos return -1
96 1.1 christos }
97 1.1 christos
98 1.1 christos # Get the endianness for the later use with endianless formats.
99 1.1 christos
100 1.1 christos gdb_test_multiple "show endian" "show endian" {
101 1.1 christos -re ".* (big|little) endian.*$gdb_prompt $" {
102 1.1 christos set endian $expect_out(1,string)
103 1.1 christos pass "endianness: $endian"
104 1.1 christos }
105 1.1 christos }
106 1.1 christos
107 1.1 christos # Now generate some dump files.
108 1.1 christos
109 1.1 christos proc make_dump_file { command msg } {
110 1.1 christos global gdb_prompt
111 1.1 christos
112 1.1 christos gdb_test_multiple "${command}" "$msg" {
113 1.1 christos -re ".*\[Ee\]rror.*$gdb_prompt $" { fail $msg }
114 1.1 christos -re ".*\[Ww\]arning.*$gdb_prompt $" { fail $msg }
115 1.1 christos -re ".*\[Uu\]ndefined .*$gdb_prompt $" { fail $msg }
116 1.1 christos -re ".*$gdb_prompt $" { pass $msg }
117 1.1 christos }
118 1.1 christos }
119 1.1 christos
120 1.1 christos make_dump_file "dump val [set intarr1.bin] intarray" \
121 1.1 christos "dump array as value, default"
122 1.1 christos
123 1.1 christos make_dump_file "dump val [set intstr1.bin] intstruct" \
124 1.1 christos "dump struct as value, default"
125 1.1 christos
126 1.1 christos make_dump_file "dump bin val [set intarr1b.bin] intarray" \
127 1.1 christos "dump array as value, binary"
128 1.1 christos
129 1.1 christos make_dump_file "dump bin val [set intstr1b.bin] intstruct" \
130 1.1 christos "dump struct as value, binary"
131 1.1 christos
132 1.1 christos make_dump_file "dump srec val [set intarr1.srec] intarray" \
133 1.1 christos "dump array as value, srec"
134 1.1 christos
135 1.1 christos make_dump_file "dump srec val [set intstr1.srec] intstruct" \
136 1.1 christos "dump struct as value, srec"
137 1.1 christos
138 1.1 christos make_dump_file "dump ihex val [set intarr1.ihex] intarray" \
139 1.1 christos "dump array as value, intel hex"
140 1.1 christos
141 1.1 christos make_dump_file "dump ihex val [set intstr1.ihex] intstruct" \
142 1.1 christos "dump struct as value, intel hex"
143 1.1 christos
144 1.1 christos make_dump_file "dump tekhex val [set intarr1.tekhex] intarray" \
145 1.1 christos "dump array as value, tekhex"
146 1.1 christos
147 1.1 christos make_dump_file "dump tekhex val [set intstr1.tekhex] intstruct" \
148 1.1 christos "dump struct as value, tekhex"
149 1.1 christos
150 1.1 christos proc capture_value { expression args } {
151 1.1 christos global gdb_prompt
152 1.1 christos global expect_out
153 1.1 christos
154 1.1 christos set output_string ""
155 1.1 christos if {[llength $args] > 0} {
156 1.1 christos # Convert $args into a simple string and don't use EXPRESSION
157 1.1 christos # in the test name.
158 1.1 christos set test "[join $args]; capture"
159 1.1 christos } {
160 1.1 christos set test "capture $expression"
161 1.1 christos }
162 1.1 christos gdb_test_multiple "print ${expression}" "$test" {
163 1.1 christos -re "\\$\[0-9\]+ = (\[^\r\n\]+).*$gdb_prompt $" {
164 1.1 christos set output_string "$expect_out(1,string)"
165 1.1 christos pass "$test"
166 1.1 christos }
167 1.1 christos -re "(Cannot access memory at address \[^\r\n\]+).*$gdb_prompt $" {
168 1.1 christos # Even a failed value is valid
169 1.1 christos set output_string "$expect_out(1,string)"
170 1.1 christos pass "$test"
171 1.1 christos }
172 1.1 christos }
173 1.1 christos return $output_string
174 1.1 christos }
175 1.1 christos
176 1.1 christos # POINTER is a pointer and this proc captures the value of POINTER along
177 1.1 christos # with POINTER's type. For example, POINTER is "&intarray", this proc will
178 1.1 christos # call "p &intarray", capture "(int (*)[32]) 0x804a0e0", and return this
179 1.1 christos # string.
180 1.1 christos
181 1.1 christos proc capture_pointer_with_type { pointer } {
182 1.1 christos global gdb_prompt
183 1.1 christos global expect_out
184 1.1 christos
185 1.1 christos set test "capture type of pointer $pointer"
186 1.1 christos set output_string ""
187 1.1 christos gdb_test_multiple "p ${pointer}" $test {
188 1.1 christos -re "\\$\[0-9\]+ = .*$gdb_prompt $" {
189 1.1 christos # Expected output of "p ${pointer}" is like "$7 = (int (*)[32]) 0x804a0e0",
190 1.1 christos # and we want to extract "(int (*)[32]) 0x804a0e0" from it via
191 1.1 christos # following regexp.
192 1.1 christos if [regexp " \\(.*\\).* 0x\[0-9a-fA-F\]+" $expect_out(0,string) output_string] {
193 1.1 christos # OUTPUT_STRING is expected to be like "(int (*)[32]) 0x804a0e0".
194 1.1 christos pass "$test"
195 1.1 christos } else {
196 1.1 christos fail "$test"
197 1.1 christos }
198 1.1 christos }
199 1.1 christos }
200 1.1 christos
201 1.1 christos return $output_string
202 1.1 christos }
203 1.1 christos
204 1.1 christos set array_start [capture_value "/x &intarray\[0\]"]
205 1.1 christos set array_end [capture_value "/x &intarray\[32\]"]
206 1.1 christos set struct_start [capture_value "/x &intstruct"]
207 1.1 christos set struct_end [capture_value "/x &intstruct + 1"]
208 1.1 christos
209 1.1 christos set array_val [capture_value "intarray"]
210 1.1 christos set struct_val [capture_value "intstruct"]
211 1.1 christos
212 1.1 christos set array_ptr_type [capture_pointer_with_type "&intarray"]
213 1.1 christos set struct_ptr_type [capture_pointer_with_type "&intstruct"]
214 1.1 christos
215 1.1 christos make_dump_file "dump mem [set intarr2.bin] $array_start $array_end" \
216 1.1 christos "dump array as memory, default"
217 1.1 christos
218 1.1 christos make_dump_file "dump mem [set intstr2.bin] $struct_start $struct_end" \
219 1.1 christos "dump struct as memory, default"
220 1.1 christos
221 1.1 christos make_dump_file "dump bin mem [set intarr2b.bin] $array_start $array_end" \
222 1.1 christos "dump array as memory, binary"
223 1.1 christos
224 1.1 christos make_dump_file "dump bin mem [set intstr2b.bin] $struct_start $struct_end" \
225 1.1 christos "dump struct as memory, binary"
226 1.1 christos
227 1.1 christos make_dump_file "dump srec mem [set intarr2.srec] $array_start $array_end" \
228 1.1 christos "dump array as memory, srec"
229 1.1 christos
230 1.1 christos make_dump_file "dump srec mem [set intstr2.srec] $struct_start $struct_end" \
231 1.1 christos "dump struct as memory, srec"
232 1.1 christos
233 1.1 christos make_dump_file "dump ihex mem [set intarr2.ihex] $array_start $array_end" \
234 1.1 christos "dump array as memory, ihex"
235 1.1 christos
236 1.1 christos make_dump_file "dump ihex mem [set intstr2.ihex] $struct_start $struct_end" \
237 1.1 christos "dump struct as memory, ihex"
238 1.1 christos
239 1.1 christos make_dump_file "dump tekhex mem [set intarr2.tekhex] $array_start $array_end" \
240 1.1 christos "dump array as memory, tekhex"
241 1.1 christos
242 1.1 christos make_dump_file "dump tekhex mem [set intstr2.tekhex] $struct_start $struct_end" \
243 1.1 christos "dump struct as memory, tekhex"
244 1.1 christos
245 1.1 christos # test complex expressions
246 1.1 christos make_dump_file \
247 1.1 christos "dump srec mem [set intarr3.srec] &intarray \(char *\) &intarray + sizeof intarray" \
248 1.1 christos "dump array as mem, srec, expressions"
249 1.1 christos
250 1.1 christos proc test_restore_saved_value { restore_args msg oldval newval } {
251 1.1 christos global gdb_prompt
252 1.1 christos
253 1.1 christos gdb_test "restore $restore_args" \
254 1.1 christos "Restoring .*" \
255 1.1 christos "$msg; file restored ok"
256 1.1 christos if { ![string compare $oldval \
257 1.1 christos [capture_value $newval "$msg"]] } then {
258 1.1 christos pass "$msg; value restored ok"
259 1.1 christos } else {
260 1.1 christos fail "$msg; value restored ok"
261 1.1 christos }
262 1.1 christos }
263 1.1 christos
264 1.1 christos if ![string compare $is64bitonly "no"] then {
265 1.1 christos
266 1.1 christos gdb_test "print zero_all ()" ".*"
267 1.1 christos
268 1.1 christos test_restore_saved_value "[set intarr1.srec]" "array as value, srec" \
269 1.1 christos $array_val "intarray"
270 1.1 christos
271 1.1 christos test_restore_saved_value "[set intstr1.srec]" "struct as value, srec" \
272 1.1 christos $struct_val "intstruct"
273 1.1 christos
274 1.1 christos gdb_test "print zero_all ()" "void" "zero all"
275 1.1 christos
276 1.1 christos test_restore_saved_value "[set intarr2.srec]" "array as memory, srec" \
277 1.1 christos $array_val "intarray"
278 1.1 christos
279 1.1 christos test_restore_saved_value "[set intstr2.srec]" "struct as memory, srec" \
280 1.1 christos $struct_val "intstruct"
281 1.1 christos
282 1.1 christos gdb_test "print zero_all ()" ".*"
283 1.1 christos
284 1.1 christos test_restore_saved_value "[set intarr1.ihex]" "array as value, ihex" \
285 1.1 christos $array_val "intarray"
286 1.1 christos
287 1.1 christos test_restore_saved_value "[set intstr1.ihex]" "struct as value, ihex" \
288 1.1 christos $struct_val "intstruct"
289 1.1 christos
290 1.1 christos gdb_test "print zero_all ()" ".*"
291 1.1 christos
292 1.1 christos test_restore_saved_value "[set intarr2.ihex]" "array as memory, ihex" \
293 1.1 christos $array_val "intarray"
294 1.1 christos
295 1.1 christos test_restore_saved_value "[set intstr2.ihex]" "struct as memory, ihex" \
296 1.1 christos $struct_val "intstruct"
297 1.1 christos
298 1.1 christos gdb_test "print zero_all ()" ".*"
299 1.1 christos
300 1.1 christos test_restore_saved_value "[set intarr1.tekhex]" "array as value, tekhex" \
301 1.1 christos $array_val "intarray"
302 1.1 christos
303 1.1 christos test_restore_saved_value "[set intstr1.tekhex]" "struct as value, tekhex" \
304 1.1 christos $struct_val "intstruct"
305 1.1 christos
306 1.1 christos gdb_test "print zero_all ()" ".*"
307 1.1 christos
308 1.1 christos test_restore_saved_value "[set intarr2.tekhex]" "array as memory, tekhex" \
309 1.1 christos $array_val "intarray"
310 1.1 christos
311 1.1 christos test_restore_saved_value "[set intstr2.tekhex]" "struct as memory, tekhex" \
312 1.1 christos $struct_val "intstruct"
313 1.1 christos }
314 1.1 christos
315 1.1 christos gdb_test "print zero_all ()" ".*"
316 1.1 christos
317 1.1 christos test_restore_saved_value "[set intarr1.bin] binary $array_start" \
318 1.1 christos "array as value, binary" \
319 1.1 christos $array_val "intarray"
320 1.1 christos
321 1.1 christos test_restore_saved_value "[set intstr1.bin] binary $struct_start" \
322 1.1 christos "struct as value, binary" \
323 1.1 christos $struct_val "intstruct"
324 1.1 christos
325 1.1 christos gdb_test "print zero_all ()" ".*"
326 1.1 christos
327 1.1 christos test_restore_saved_value "[set intarr2.bin] binary $array_start" \
328 1.1 christos "array as memory, binary" \
329 1.1 christos $array_val "intarray"
330 1.1 christos
331 1.1 christos test_restore_saved_value "[set intstr2.bin] binary $struct_start" \
332 1.1 christos "struct as memory, binary" \
333 1.1 christos $struct_val "intstruct"
334 1.1 christos
335 1.1 christos # test restore with offset.
336 1.1 christos
337 1.1 christos set array2_start [capture_value "/x &intarray2\[0\]"]
338 1.1 christos set struct2_start [capture_value "/x &intstruct2"]
339 1.1 christos set array2_offset \
340 1.1 christos [capture_value "(char *) &intarray2 - (char *) &intarray"]
341 1.1 christos set struct2_offset \
342 1.1 christos [capture_value "(char *) &intstruct2 - (char *) &intstruct"]
343 1.1 christos
344 1.1 christos gdb_test "print zero_all ()" ".*"
345 1.1 christos
346 1.1 christos
347 1.1 christos if ![string compare $is64bitonly "no"] then {
348 1.1 christos test_restore_saved_value "[set intarr1.srec] $array2_offset" \
349 1.1 christos "array copy, srec" \
350 1.1 christos $array_val "intarray2"
351 1.1 christos
352 1.1 christos test_restore_saved_value "[set intstr1.srec] $struct2_offset" \
353 1.1 christos "struct copy, srec" \
354 1.1 christos $struct_val "intstruct2"
355 1.1 christos
356 1.1 christos gdb_test "print zero_all ()" ".*"
357 1.1 christos
358 1.1 christos test_restore_saved_value "[set intarr1.ihex] $array2_offset" \
359 1.1 christos "array copy, ihex" \
360 1.1 christos $array_val "intarray2"
361 1.1 christos
362 1.1 christos test_restore_saved_value "[set intstr1.ihex] $struct2_offset" \
363 1.1 christos "struct copy, ihex" \
364 1.1 christos $struct_val "intstruct2"
365 1.1 christos
366 1.1 christos gdb_test "print zero_all ()" ".*"
367 1.1 christos
368 1.1 christos test_restore_saved_value "[set intarr1.tekhex] $array2_offset" \
369 1.1 christos "array copy, tekhex" \
370 1.1 christos $array_val "intarray2"
371 1.1 christos
372 1.1 christos test_restore_saved_value "[set intstr1.tekhex] $struct2_offset" \
373 1.1 christos "struct copy, tekhex" \
374 1.1 christos $struct_val "intstruct2"
375 1.1 christos }
376 1.1 christos
377 1.1 christos gdb_test "print zero_all ()" ".*"
378 1.1 christos
379 1.1 christos test_restore_saved_value "[set intarr1.bin] binary $array2_start" \
380 1.1 christos "array copy, binary" \
381 1.1 christos $array_val "intarray2"
382 1.1 christos
383 1.1 christos test_restore_saved_value "[set intstr1.bin] binary $struct2_start" \
384 1.1 christos "struct copy, binary" \
385 1.1 christos $struct_val "intstruct2"
386 1.1 christos
387 1.1 christos #
388 1.1 christos # test restore with start/stop addresses.
389 1.1 christos #
390 1.1 christos # For this purpose, we will restore just the third element of the array,
391 1.1 christos # and check to see that adjacent elements are not modified.
392 1.1 christos #
393 1.1 christos # We will need the address and offset of the third and fourth elements.
394 1.1 christos #
395 1.1 christos
396 1.1 christos set element3_start [capture_value "/x &intarray\[3\]"]
397 1.1 christos set element4_start [capture_value "/x &intarray\[4\]"]
398 1.1 christos set element3_offset \
399 1.1 christos [capture_value "/x (char *) &intarray\[3\] - (char *) &intarray\[0\]"]
400 1.1 christos set element4_offset \
401 1.1 christos [capture_value "/x (char *) &intarray\[4\] - (char *) &intarray\[0\]"]
402 1.1 christos
403 1.1 christos if ![string compare $is64bitonly "no"] then {
404 1.1 christos gdb_test "print zero_all ()" ".*"
405 1.1 christos
406 1.1 christos test_restore_saved_value "[set intarr1.srec] 0 $element3_start $element4_start" \
407 1.1 christos "array partial, srec" 4 "intarray\[3\]"
408 1.1 christos
409 1.1 christos gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 1"
410 1.1 christos gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 1"
411 1.1 christos
412 1.1 christos gdb_test "print zero_all ()" ".*"
413 1.1 christos
414 1.1 christos test_restore_saved_value "[set intarr1.ihex] 0 $element3_start $element4_start" \
415 1.1 christos "array partial, ihex" 4 "intarray\[3\]"
416 1.1 christos
417 1.1 christos gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 2"
418 1.1 christos gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 2"
419 1.1 christos
420 1.1 christos gdb_test "print zero_all ()" ".*"
421 1.1 christos
422 1.1 christos test_restore_saved_value "[set intarr1.tekhex] 0 $element3_start $element4_start" \
423 1.1 christos "array partial, tekhex" 4 "intarray\[3\]"
424 1.1 christos
425 1.1 christos gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 3"
426 1.1 christos gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 3"
427 1.1 christos }
428 1.1 christos
429 1.1 christos gdb_test "print zero_all ()" ".*"
430 1.1 christos
431 1.1 christos test_restore_saved_value \
432 1.1 christos "[set intarr1.bin] binary $array_start $element3_offset $element4_offset" \
433 1.1 christos "array partial, binary" 4 "intarray\[3\]"
434 1.1 christos
435 1.1 christos gdb_test "print intarray\[2\] == 0" " = 1" "element 2 not changed - 4"
436 1.1 christos gdb_test "print intarray\[4\] == 0" " = 1" "element 4 not changed - 4"
437 1.1 christos
438 1.1 christos if ![string compare $is64bitonly "no"] then {
439 1.1 christos gdb_test "print zero_all ()" ".*" ""
440 1.1 christos
441 1.1 christos # restore with expressions
442 1.1 christos test_restore_saved_value \
443 1.1 christos "[set intarr3.srec] (char*)${array2_start}-(char*)${array_start} &intarray\[3\] &intarray\[4\]" \
444 1.1 christos "array partial with expressions" 4 "intarray2\[3\]"
445 1.1 christos
446 1.1 christos gdb_test "print intarray2\[2\] == 0" " = 1" "element 2 not changed, == 4"
447 1.1 christos gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
448 1.1 christos }
449 1.1 christos
450 1.1 christos
451 1.1 christos # Now start a fresh gdb session, and reload the saved value files.
452 1.1 christos
453 1.1 christos gdb_exit
454 1.1 christos gdb_start
455 1.1 christos gdb_file_cmd ${binfile}
456 1.1 christos
457 1.1 christos # Now fix the endianness at the correct state.
458 1.1 christos
459 1.1 christos gdb_test_multiple "set endian $endian" "set endianness" {
460 1.1 christos -re ".* (big|little) endian.*$gdb_prompt $" {
461 1.1 christos pass "setting $endian endianness"
462 1.1 christos }
463 1.1 christos }
464 1.1 christos
465 1.1 christos # Reload saved values one by one, and compare.
466 1.1 christos
467 1.1 christos if { ![string compare $array_val \
468 1.1 christos [capture_value "intarray" "file binfile; intarray"]] } then {
469 1.1 christos fail "start with intarray un-initialized"
470 1.1 christos } else {
471 1.1 christos pass "start with intarray un-initialized"
472 1.1 christos }
473 1.1 christos
474 1.1 christos if { ![string compare $struct_val \
475 1.1 christos [capture_value "intstruct" "file binfile; intstruct"]] } then {
476 1.1 christos fail "start with intstruct un-initialized"
477 1.1 christos } else {
478 1.1 christos pass "start with intstruct un-initialized"
479 1.1 christos }
480 1.1 christos
481 1.1 christos proc test_reload_saved_value { filename msg oldval newval } {
482 1.1 christos global gdb_prompt
483 1.1 christos
484 1.1 christos gdb_file_cmd $filename
485 1.1 christos if { ![string compare $oldval \
486 1.1 christos [capture_value $newval "$msg"]] } then {
487 1.1 christos pass "$msg; value restored ok"
488 1.1 christos } else {
489 1.1 christos fail "$msg; value restored ok"
490 1.1 christos }
491 1.1 christos }
492 1.1 christos
493 1.1 christos # srec format can not be loaded for 64-bit-only platforms
494 1.1 christos if ![string compare $is64bitonly "no"] then {
495 1.1 christos test_reload_saved_value "[set intarr1.srec]" "reload array as value, srec" \
496 1.1 christos $array_val "\*$array_ptr_type"
497 1.1 christos test_reload_saved_value "[set intstr1.srec]" "reload struct as value, srec" \
498 1.1 christos $struct_val "\*$struct_ptr_type"
499 1.1 christos test_reload_saved_value "[set intarr2.srec]" "reload array as memory, srec" \
500 1.1 christos $array_val "\*$array_ptr_type"
501 1.1 christos test_reload_saved_value "[set intstr2.srec]" "reload struct as memory, srec" \
502 1.1 christos $struct_val "\*$struct_ptr_type"
503 1.1 christos }
504 1.1 christos
505 1.1 christos # ihex format can not be loaded for 64-bit-only platforms
506 1.1 christos if ![string compare $is64bitonly "no"] then {
507 1.1 christos
508 1.1 christos test_reload_saved_value "[set intarr1.ihex]" \
509 1.1 christos "reload array as value, intel hex" \
510 1.1 christos $array_val "\*$array_ptr_type"
511 1.1 christos test_reload_saved_value "[set intstr1.ihex]" \
512 1.1 christos "reload struct as value, intel hex" \
513 1.1 christos $struct_val "\*$struct_ptr_type"
514 1.1 christos test_reload_saved_value "[set intarr2.ihex]" \
515 1.1 christos "reload array as memory, intel hex" \
516 1.1 christos $array_val "\*$array_ptr_type"
517 1.1 christos test_reload_saved_value "[set intstr2.ihex]" \
518 1.1 christos "reload struct as memory, intel hex" \
519 1.1 christos $struct_val "\*$struct_ptr_type"
520 1.1 christos }
521 1.1 christos
522 1.1 christos # tekhex format can not be loaded for 64-bit-only platforms
523 1.1 christos if ![string compare $is64bitonly "no"] then {
524 1.1 christos test_reload_saved_value "[set intarr1.tekhex]" \
525 1.1 christos "reload array as value, tekhex" \
526 1.1 christos $array_val "\*$array_ptr_type"
527 1.1 christos test_reload_saved_value "[set intstr1.tekhex]" \
528 1.1 christos "reload struct as value, tekhex" \
529 1.1 christos $struct_val "\*$struct_ptr_type"
530 1.1 christos test_reload_saved_value "[set intarr2.tekhex]" \
531 1.1 christos "reload array as memory, tekhex" \
532 1.1 christos $array_val "\*$array_ptr_type"
533 1.1 christos test_reload_saved_value "[set intstr2.tekhex]" \
534 1.1 christos "reload struct as memory, tekhex" \
535 1.1 christos $struct_val "\*$struct_ptr_type"
536 1.1 christos }
537 1.1 christos
538 1.1 christos # clean up files
539 1.1 christos
540 1.1 christos remote_exec host "rm -f $filenames"
541