fix a bug in QemuController.get_register
authorTobias Platen <tplaten@posteo.de>
Wed, 15 Apr 2020 16:38:00 +0000 (18:38 +0200)
committerTobias Platen <tplaten@posteo.de>
Wed, 15 Apr 2020 16:38:00 +0000 (18:38 +0200)
src/soc/simulator/qemu.py

index 9eb103bae227e00a2a1d2ec4f43d7e39e4f44960..1669dafe90c466a4177f74845332c7ba4e7aa7c5 100644 (file)
@@ -32,10 +32,12 @@ class QemuController:
         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))
-        assert 'register-values' in res[0]['payload']
-        val = int(res[0]['payload']['register-values'][0]['value'], 0)
-        return val
+        res = self.gdb.write('-data-list-register-values x {}'.format(num),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 step(self):
         return self.gdb.write('-exec-next-instruction')