This is the mail archive of the gdb-patches@sources.redhat.com 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]

[RFA]: Fix gdb.base/long_long.exp for targets with 2-byte pointers


Hi!

The gdb.base/long_long.exp validation uses p/a commands.  In the output,
it assumes the pointers are at least 4-bytes.  It fails on HC11 because
pointers are only 2-byte long.

In the patch, I propose to check the size of the pointer and check the
output of the p/a commands accordingly.

Can you approve this patch?

	Stephane

2001-05-20  Stephane Carrez  <Stephane.Carrez@worldnet.fr>

	* gdb.base/long_long.exp: Detect size of pointer.  Take into
	account 2-byte pointers when testing for p/a results.
Index: testsuite/gdb.base/long_long.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/long_long.exp,v
retrieving revision 1.4
diff -u -p -r1.4 long_long.exp
--- long_long.exp	2001/03/08 21:09:22	1.4
+++ long_long.exp	2001/05/20 11:39:29
@@ -95,6 +95,16 @@ gdb_expect {
     default { }
 }
 
+# Detect targets with 2-byte pointers.
+
+set sizeof_ptr 4
+send_gdb "print sizeof(void*)\n"
+gdb_expect {
+    -re ".* = 2.*$gdb_prompt $" { set sizeof_ptr 2 }
+    -re ".*$gdb_prompt $" { }
+    default { }
+}
+
 gdb_test "n 4"   ".*38.*" "get to known place"
 
 # Check the hack for long long prints.
@@ -120,7 +130,11 @@ gdb_test "p/d oct" ".*-63999259854741684
 gdb_test "p/u oct" ".*12046818088235383159.*"
 gdb_test "p/o oct" ".*.*"
 gdb_test "p/t oct" ".*1010011100101110111001010011100101110111000001010011100101110111.*"
-gdb_test "p/a oct" ".*0x.*77053977.*"
+if { $sizeof_ptr == 2 } {
+  gdb_test "p/a oct" ".*0x.*3977.*"
+} else {
+  gdb_test "p/a oct" ".*0x.*77053977.*"
+}
 gdb_test "p/c oct" ".*'w'.*"
 
 if { $sizeof_double == 8 } {
@@ -156,7 +170,13 @@ if { $target_bigendian_p } {
 	gdb_test "p/u *(int *)&oct" ".*2804868409.*"
 	gdb_test "p/o *(int *)&oct" ".*024713562471.*"
 	gdb_test "p/t *(int *)&oct" ".*10100111001011101110010100111001.*"
-	gdb_test "p/a *(int *)&oct" ".*0xf*a72ee539.*"
+
+	if { $sizeof_ptr == 2 } {
+	    gdb_test "p/a *(int *)&oct" ".*0xe539.*"
+	} else {
+	    gdb_test "p/a *(int *)&oct" ".*0xf*a72ee539.*"
+	}
+
 	gdb_test "p/c *(int *)&oct" ".*57 '9'.*"
 	gdb_test "p/f *(int *)&oct" ".*-2.42716126e-15.*"
 
@@ -166,7 +186,12 @@ if { $target_bigendian_p } {
 	gdb_test "p/u *(int *)&oct" ".*42798.*"
 	gdb_test "p/o *(int *)&oct" ".*0123456.*"
 	gdb_test "p/t *(int *)&oct" ".*1010011100101110.*"
-	gdb_test "p/a *(int *)&oct" ".*0xffffa72e.*"
+
+	if { $sizeof_ptr == 2 } {
+	    gdb_test "p/a *(int *)&oct" ".*0xa72e.*"
+	} else {
+	    gdb_test "p/a *(int *)&oct" ".*0xffffa72e.*"
+	}
 	gdb_test "p/c *(int *)&oct" ".*46 '.'.*"
 	gdb_test "p/f *(int *)&oct" ".*-22738.*"
 
@@ -176,9 +201,17 @@ if { $target_bigendian_p } {
     gdb_test "p/u *(short *)&oct" ".*42798.*"
     gdb_test "p/o *(short *)&oct" ".*0123456.*"
     gdb_test "p/t *(short *)&oct" ".*1010011100101110.*"
-    gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
+    if { $sizeof_ptr == 2 } {
+        gdb_test "p/a *(short *)&oct" ".*0xa72e.*"
+    } else {
+        gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
+    }
     gdb_test "p/c *(short *)&oct" ".* 46 '.'.*"
-    gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
+    if { $sizeof_ptr == 2 } {
+        gdb_test "p/a *(short *)&oct" ".*0xa72e.*"
+    } else {
+        gdb_test "p/a *(short *)&oct" ".*0xf*ffffa72e.*"
+    }
     gdb_test "p/f *(short *)&oct" ".*-22738.*"
 
     gdb_test "x/x &oct" ".*0xa72ee539.*"
@@ -186,7 +219,11 @@ if { $target_bigendian_p } {
     gdb_test "x/u &oct" ".*2804868409.*"
     gdb_test "x/o &oct" ".*024713562471.*"
     gdb_test "x/t &oct" ".*10100111001011101110010100111001.*"
-    gdb_test "x/a &oct" ".*0xa72ee539.*"
+    if { $sizeof_ptr == 2 } {
+	gdb_test "x/a &oct" ".*0xa72e.*"
+    } else {
+	gdb_test "x/a &oct" ".*0xa72ee539.*"
+    }
     gdb_test "x/c &oct" ".*-89 .*"
     # FIXME GDB's output is correct, but this longer match fails.
     # gdb_test "x/c &oct" ".*-89 '\\\\247'.*"

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