Add test for memory read from invalid address.
authorTim Newsome <tim@sifive.com>
Mon, 3 Oct 2016 17:40:17 +0000 (10:40 -0700)
committerTim Newsome <tim@sifive.com>
Mon, 3 Oct 2016 17:40:17 +0000 (10:40 -0700)
debug/gdbserver.py
debug/targets/freedom-e300/openocd.cfg

index 81aafa345a1e60c2d24163bb742de0e50ad48906..91c385f548909d86e0da527c42d203119bd03134 100755 (executable)
@@ -293,6 +293,16 @@ class MemTest64(SimpleMemoryTest):
     def test(self):
         self.access_test(8, 'long long')
 
     def test(self):
         self.access_test(8, 'long long')
 
+class MemTestReadInvalid(SimpleMemoryTest):
+    def test(self):
+        # This test relies on 'gdb_report_data_abort enable' being executed in
+        # the openocd.cfg file.
+        try:
+            self.gdb.p("*((int*)0xdeadbeef)")
+            assert False, "Access should have failed."
+        except testlib.CannotAccess as e:
+            assertEqual(e.address, 0xdeadbeef)
+
 class MemTestBlock(GdbTest):
     def test(self):
         length = 1024
 class MemTestBlock(GdbTest):
     def test(self):
         length = 1024
index d448989243ecc7d893ed4eca399eb2d62b737c76..0596b15cb5f31cefb2d2857493cfaa3a731150c2 100644 (file)
@@ -8,6 +8,8 @@ jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10e31913
 set _TARGETNAME $_CHIPNAME.cpu
 target create $_TARGETNAME riscv -chain-position $_TARGETNAME
 
 set _TARGETNAME $_CHIPNAME.cpu
 target create $_TARGETNAME riscv -chain-position $_TARGETNAME
 
+gdb_report_data_abort enable
+
 init
 
 halt
 init
 
 halt