+
+# Now start a fresh gdb session, and reload the saved value files.
+
+gdb_exit
+gdb_start
+gdb_file_cmd ${binfile}
+
+# Now fix the endianness at the correct state.
+
+gdb_test_multiple "set endian $endian" "set endianness" {
+ -re ".* (big|little) endian.*$gdb_prompt $" {
+ pass "setting $endian endianness"
+ }
+}
+
+# Reload saved values one by one, and compare.
+
+if { ![string compare $array_val \
+ [capture_value "intarray" "file binfile; intarray"]] } then {
+ fail "start with intarray un-initialized"
+} else {
+ pass "start with intarray un-initialized"
+}
+
+if { ![string compare $struct_val \
+ [capture_value "intstruct" "file binfile; intstruct"]] } then {
+ fail "start with intstruct un-initialized"
+} else {
+ pass "start with intstruct un-initialized"
+}
+
+proc test_reload_saved_value { filename msg oldval newval } {
+ global gdb_prompt
+
+ gdb_file_cmd $filename
+ if { ![string compare $oldval \
+ [capture_value $newval "$msg"]] } then {
+ pass "$msg; value restored ok"
+ } else {
+ fail "$msg; value restored ok"
+ }
+}
+
+# srec format can not be loaded for 64-bit-only platforms
+if ![string compare $is64bitonly "no"] then {
+ test_reload_saved_value "[set intarr1.srec]" "reload array as value, srec" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr1.srec]" "reload struct as value, srec" \
+ $struct_val "\*$struct_ptr_type"
+ test_reload_saved_value "[set intarr2.srec]" "reload array as memory, srec" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr2.srec]" "reload struct as memory, srec" \
+ $struct_val "\*$struct_ptr_type"
+}
+
+# ihex format can not be loaded for 64-bit-only platforms
+if ![string compare $is64bitonly "no"] then {
+
+ test_reload_saved_value "[set intarr1.ihex]" \
+ "reload array as value, intel hex" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr1.ihex]" \
+ "reload struct as value, intel hex" \
+ $struct_val "\*$struct_ptr_type"
+ test_reload_saved_value "[set intarr2.ihex]" \
+ "reload array as memory, intel hex" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr2.ihex]" \
+ "reload struct as memory, intel hex" \
+ $struct_val "\*$struct_ptr_type"
+}
+
+# tekhex format can not be loaded for 64-bit-only platforms
+if ![string compare $is64bitonly "no"] then {
+ test_reload_saved_value "[set intarr1.tekhex]" \
+ "reload array as value, tekhex" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr1.tekhex]" \
+ "reload struct as value, tekhex" \
+ $struct_val "\*$struct_ptr_type"
+ test_reload_saved_value "[set intarr2.tekhex]" \
+ "reload array as memory, tekhex" \
+ $array_val "\*$array_ptr_type"
+ test_reload_saved_value "[set intstr2.tekhex]" \
+ "reload struct as memory, tekhex" \
+ $struct_val "\*$struct_ptr_type"
+}
+