add means to get pc and other qemu registers
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 9 Jun 2020 22:12:58 +0000 (23:12 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Tue, 9 Jun 2020 22:12:58 +0000 (23:12 +0100)
src/soc/simulator/qemu.py

index 1669dafe90c466a4177f74845332c7ba4e7aa7c5..d45c17c85289af15d9f25ef73ded1da37b73d781 100644 (file)
@@ -31,14 +31,26 @@ class QemuController:
     def get_registers(self):
         return self.gdb.write('-data-list-register-values x')
 
-    def get_register(self, num):
-        res = self.gdb.write('-data-list-register-values x {}'.format(num),timeout_sec=1.0) # increase this timeout if needed
+    def _get_register(self, fmt):
+        res = self.gdb.write('-data-list-register-values '+fmt,
+                             timeout_sec=1.0) # increase this timeout if needed
         for x in res:
             if(x["type"]=="result"):
                 assert 'register-values' in x['payload']
                 return int(x['payload']['register-values'][0]['value'], 0)
         return None
 
+    def get_pc(self): return self._get_register('pc')
+    def get_cr(self): return self._get_register('cnd')
+    def get_xer(self): return self._get_register('xer')
+    def get_msr(self): return self._get_register('msr')
+    def get_lr(self): return self._get_register('lr')
+    def get_fpscr(self): return self._get_register('fpscr')
+    def get_ctr(self): return self._get_register('cnt') # probably
+
+    def get_register(self, num):
+        return self._get_register('x {}'.format(num))
+
     def step(self):
         return self.gdb.write('-exec-next-instruction')