summaryrefslogtreecommitdiff
path: root/data/eo/eo_gdb.py
diff options
context:
space:
mode:
Diffstat (limited to 'data/eo/eo_gdb.py')
-rw-r--r--data/eo/eo_gdb.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/data/eo/eo_gdb.py b/data/eo/eo_gdb.py
index 76b8fbd..ec4d21c 100644
--- a/data/eo/eo_gdb.py
+++ b/data/eo/eo_gdb.py
@@ -93,3 +93,52 @@ class Eo_resolve(gdb.Function):
93 93
94 94
95Eo_resolve() 95Eo_resolve()
96
97
98class Eo_data_get(gdb.Function):
99 def __init__(self):
100 gdb.Function.__init__(self, 'eo_data_get')
101
102 def invoke(self, ptr, kls_name):
103 ptr = ptr.cast(null_ptr.type) # Make sure it's the right type
104
105 if int(ptr) == 0:
106 gdb.write('Object is not a valid pointer (NULL).\n')
107 return null_ptr
108
109 kls_name = kls_name.string()
110 extns = ptr['klass']['mro']
111 kls = None
112
113 i = 0
114 while int(extns[i]) != 0:
115 if extns[i]['desc']['name'].string() == kls_name:
116 kls = extns[i]
117 i += 1
118
119 if kls is None:
120 gdb.write('Class "{}" not found in the object mro.\n'
121 .format(kls_name))
122 return null_ptr
123
124 # Check if not mixin
125 if int(kls['desc']['type']) != 3:
126 return gdb.parse_and_eval('(void *) (((char *) {}) + {})'
127 .format(ptr, kls['data_offset']))
128 else:
129 extn_off = ptr['klass']['extn_data_off']
130 if int(extn_off) == 0:
131 return null_ptr
132
133 i = 0
134 while int(extn_off[i]['klass']) != 0:
135 kls = extn_off[i]['klass']
136 if kls['desc']['name'].string() == kls_name:
137 return gdb.parse_and_eval('(void *) (((char *) {}) + {})'
138 .format(ptr, kls['data_offset']))
139 i += 1
140
141 return null_ptr
142
143
144Eo_data_get()