This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch 2/2] Fixes to gdb.base/dump.exp: Combine dump and restore in a single session


On 06/21/2011 06:42 PM, Yao Qi wrote:
> 
>   - 1 Start gdb, and run to checkpoint1.  Dump memory into files of
> different formats.
>   - 3 Start gdb, and restore these dump files.  Compare results in dump
> files are the same them in memory.
> 

In short, this patch is to combine session 1 and session 3 into one
single session, so that symbol address is unchanged.  In this new
session, firstly, we dump memory contents to different formats of files,
clear content in struct and array, and then, restore memory contents
from dumped files one by one, and compare the results.

-- 
Yao (éå)
2011-06-21  Yao Qi  <yao@codesourcery.com>

	gdb/testsuite/
	* gdb.base/dump.exp: Start GDB once, and do `dump' and `restore'
	tests together.

---
 gdb/testsuite/gdb.base/dump.exp |  186 +++++++++++++++++----------------------
 1 files changed, 81 insertions(+), 105 deletions(-)

diff --git a/gdb/testsuite/gdb.base/dump.exp b/gdb/testsuite/gdb.base/dump.exp
index 7042abc..ef34957 100644
--- a/gdb/testsuite/gdb.base/dump.exp
+++ b/gdb/testsuite/gdb.base/dump.exp
@@ -217,49 +217,6 @@ make_dump_file \
 	"dump srec mem intarr3.srec &intarray \(char *\) &intarray + sizeof intarray" \
 	"dump array as mem, srec, expressions"
 
-
-# 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"]] } then {
-    fail "start with intarray un-initialized"
-} else {
-    pass "start with intarray un-initialized"
-}
-
-if { ![string compare $struct_val \
-	   [capture_value "intstruct" "file binfile"]] } 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"
-    }
-}
-
 proc test_restore_saved_value { restore_args msg oldval newval } {
     global gdb_prompt
     
@@ -274,71 +231,10 @@ proc test_restore_saved_value { restore_args msg oldval newval } {
     }
 }
 
-# srec format can not be loaded for 64-bit-only platforms
 if ![string compare $is64bitonly "no"] then {
-  test_reload_saved_value "intarr1.srec" "reload array as value, srec" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
-	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "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 "intarr1.ihex" "reload array as value, intel hex" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
-	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "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 "intarr1.tekhex" "reload array as value, tekhex" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
-	$struct_val "\*$struct_ptr_type"
-  test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
-	$array_val "\*$array_ptr_type"
-  test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
-	$struct_val "\*$struct_ptr_type"
-}
 
-# Start a fresh gdb session
-
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
-
-# Run to main.
-if { ! [ runto_main ] } then {
-    untested dump.exp
-    return -1
-}
-
-if { ![string compare $array_val \
-	   [capture_value "intarray" "load binfile"]] } then {
-    fail "start with intarray un-initialized, runto main"
-} else {
-    pass "start with intarray un-initialized, runto main"
-}
-
-if { ![string compare $struct_val \
-	   [capture_value "intstruct" "load binfile"]] } then {
-    fail "start with intstruct un-initialized, runto main"
-} else {
-    pass "start with intstruct un-initialized, runto main"
-}
+  gdb_test "print zero_all ()" ".*"
 
-if ![string compare $is64bitonly "no"] then {
   test_restore_saved_value "intarr1.srec" "array as value, srec" \
 	$array_val "intarray"
 
@@ -521,6 +417,86 @@ if ![string compare $is64bitonly "no"] then {
   gdb_test "print intarray2\[4\] == 0" " = 1" "element 4 not changed, == 4"
 }
 
+
+# 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"]] } then {
+    fail "start with intarray un-initialized"
+} else {
+    pass "start with intarray un-initialized"
+}
+
+if { ![string compare $struct_val \
+	   [capture_value "intstruct" "file binfile"]] } 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 "intarr1.srec" "reload array as value, srec" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "intstr1.srec" "reload struct as value, srec" \
+	$struct_val "\*$struct_ptr_type"
+  test_reload_saved_value "intarr2.srec" "reload array as memory, srec" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "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 "intarr1.ihex" "reload array as value, intel hex" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "intstr1.ihex" "reload struct as value, intel hex" \
+	$struct_val "\*$struct_ptr_type"
+  test_reload_saved_value "intarr2.ihex" "reload array as memory, intel hex" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "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 "intarr1.tekhex" "reload array as value, tekhex" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "intstr1.tekhex" "reload struct as value, tekhex" \
+	$struct_val "\*$struct_ptr_type"
+  test_reload_saved_value "intarr2.tekhex" "reload array as memory, tekhex" \
+	$array_val "\*$array_ptr_type"
+  test_reload_saved_value "intstr2.tekhex" "reload struct as memory, tekhex" \
+	$struct_val "\*$struct_ptr_type"
+}
+
 # clean up files
 
 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"
-- 
1.7.0.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]