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]
Other format: [Raw text]

[PATCH] Make gdb1476.exp more robust


Peter Schauer pointed out to me that excuting code at address 0 might
have ill effects on targets that don't have an MMU.  He suggested
testing whether we could read from that address, and only run the
tests if we can't.

This makes sense to me, so I checked this patch in.

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* gdb.base/gdb1476.exp: Only run the tests if we can't read the
	memory at address 0.

Index: gdb.base/gdb1476.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.base/gdb1476.exp,v
retrieving revision 1.1
diff -u -p -r1.1 gdb1476.exp
--- gdb.base/gdb1476.exp 5 Jan 2004 22:55:33 -0000 1.1
+++ gdb.base/gdb1476.exp 7 Jan 2004 22:07:02 -0000
@@ -48,6 +48,21 @@ if ![runto_main] then {
     gdb_suppress_tests
 }
 
+# If we can examine what's at memory address 0, it is possible that we
+# could also execute it.  This could pobably make us run away,
+# executing random code, which could have all sorts of ill effects,
+# especially on targets without an MMU.  Don't run the tests in that
+# case.
+
+send_gdb "x 0\n"
+gdb_expect {
+    -re "0x0:.*Error accessing memory address 0x0.*$gdb_prompt $" { }
+    -re ".*$gdb_prompt $" {
+	untested "Memory at address 0 is possibly executable"
+	return
+    }
+}
+
 gdb_test "continue" "Program received signal SIGSEGV.*" \
 	"continue to null pointer call"
 


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