about summary refs log tree commit diff stats
path: root/snapshot.py
diff options
context:
space:
mode:
authorTheofilos Augoustis <theofilos.augoustis@gmail.com>2023-12-27 14:41:01 +0100
committerTheofilos Augoustis <theofilos.augoustis@gmail.com>2023-12-27 14:41:01 +0100
commitf2246e641d494d5df76458db4fb4928f5c2cfc7f (patch)
treeb2a0c2a1493dadb002f90f2932e22d89f659f3ea /snapshot.py
parent2ddf26ab93c5c625c468c7d554b995e5d6b04d3a (diff)
downloadfocaccia-f2246e641d494d5df76458db4fb4928f5c2cfc7f.tar.gz
focaccia-f2246e641d494d5df76458db4fb4928f5c2cfc7f.zip
Extend error reporting system
Add error severities and the ability to filter for them. Include more
information in comparison error messages.
Diffstat (limited to 'snapshot.py')
-rw-r--r--snapshot.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/snapshot.py b/snapshot.py
index be18af3..9c9e4b3 100644
--- a/snapshot.py
+++ b/snapshot.py
@@ -1,8 +1,10 @@
 from arch.arch import Arch
 
 class MemoryAccessError(Exception):
-    def __init__(self, msg: str):
+    def __init__(self, addr: int, size: int, msg: str):
         super().__init__(msg)
+        self.mem_addr = addr
+        self.mem_size = size
 
 class SparseMemory:
     """Sparse memory.
@@ -35,7 +37,8 @@ class SparseMemory:
         while size > 0:
             page_addr, off = self._to_page_addr_and_offset(addr)
             if page_addr not in self._pages:
-                raise MemoryAccessError(f'Address {addr} is not contained in'
+                raise MemoryAccessError(addr, size,
+                                        f'Address {addr} is not contained in'
                                         f' the sparse memory.')
             data = self._pages[page_addr]
             assert(len(data) == self.page_size)