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