Deal with gdb reporting pmpcfg0 not existing.
authorTim Newsome <tim@sifive.com>
Mon, 8 Jan 2018 20:36:49 +0000 (12:36 -0800)
committerTim Newsome <tim@sifive.com>
Mon, 8 Jan 2018 20:36:49 +0000 (12:36 -0800)
It's an optional register.

debug/gdbserver.py
debug/testlib.py

index bf279503ecb41c921ec82695de213ebac45c9642..8c500bcf80109b8f051d32d1130e0f4fcdebe5d6 100755 (executable)
@@ -855,9 +855,13 @@ class PrivRw(PrivTest):
         """Test reading/writing priv."""
         # Disable physical memory protection by allowing U mode access to all
         # memory.
-        self.gdb.p("$pmpcfg0=0xf")  # TOR, R, W, X
-        self.gdb.p("$pmpaddr0=0x%x" %
-                ((self.hart.ram + self.hart.ram_size) >> 2))
+        try:
+            self.gdb.p("$pmpcfg0=0xf")  # TOR, R, W, X
+            self.gdb.p("$pmpaddr0=0x%x" %
+                    ((self.hart.ram + self.hart.ram_size) >> 2))
+        except testlib.CouldNotFetch:
+            # PMP registers are optional
+            pass
 
         # Leave the PC at _start, where the first 4 instructions should be
         # legal in any mode.
index c6bf59cfddad690eb3b35d2474b88cc94e996725..7727f10d5af2947b8b2ec3de39fd74d5f3185a45 100644 (file)
@@ -329,6 +329,12 @@ class CannotAccess(Exception):
         Exception.__init__(self)
         self.address = address
 
+class CouldNotFetch(Exception):
+    def __init__(self, regname, explanation):
+        Exception.__init__(self)
+        self.regname = regname
+        self.explanation = explanation
+
 Thread = collections.namedtuple('Thread', ('id', 'description', 'target_id',
     'name', 'frame'))
 
@@ -514,6 +520,9 @@ class Gdb(object):
         m = re.search("Cannot access memory at address (0x[0-9a-f]+)", output)
         if m:
             raise CannotAccess(int(m.group(1), 0))
+        m = re.search(r"Could not fetch register \"(\w+)\"; (.*)$", output)
+        if m:
+            raise CouldNotFetch(m.group(1), m.group(2))
         rhs = output.split('=')[-1]
         return self.parse_string(rhs)