diff options
| author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2021-09-15 23:07:49 +0200 | 
|---|---|---|
| committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2021-09-15 23:07:49 +0200 | 
| commit | 0a62e7ae6c1974599f128a8c00221bbfbf6c6d83 (patch) | |
| tree | 007d24d6501ff6d3985ac6b4dff10dbe70efe7d8 | |
| parent | 5398e8a86f337038f62bbde99fdaabcba0f1dd5d (diff) | |
gdb_plugins: Add $mmio_ptr function.
| -rw-r--r-- | gdb_plugins/mmio.py | 26 | 
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() | 
