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