summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb_plugins/mmio.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/gdb_plugins/mmio.py b/gdb_plugins/mmio.py
index 25ebcc3..ea367c7 100644
--- a/gdb_plugins/mmio.py
+++ b/gdb_plugins/mmio.py
@@ -1,3 +1,4 @@
+import gdb
import gdb.xmethod
class RefWorker(gdb.xmethod.XMethodWorker):
@@ -65,3 +66,28 @@ class Matcher(gdb.xmethod.XMethodMatcher):
return method.worker(ptr_type)
gdb.xmethod.register_xmethod_matcher(None, Matcher(), replace = True)
+
+def get_mmio_ptr_type(pt):
+ if pt.name.startswith('mmio_ptr<'):
+ return pt.template_argument(0)
+
+ for field in pt.fields():
+ if not field.is_base_class:
+ continue
+
+ t = get_mmio_ptr_type(field.type)
+
+ if t is not None:
+ return t
+
+ return None
+
+class MMIOPtr(gdb.Function):
+ def __init__(self):
+ gdb.Function.__init__(self, 'mmio_ptr')
+
+ def invoke(self, obj):
+ t = get_mmio_ptr_type(obj.type)
+ return obj['p'].cast(t.pointer())
+
+MMIOPtr()