Rework location of structure members
Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
parent
0e244900ba
commit
0ef702383a
30
main.py
30
main.py
|
@ -167,10 +167,13 @@ class Bear():
|
|||
|
||||
entry['type'] = safe_DIE_name(die_type, '?')
|
||||
|
||||
if 'DW_AT_data_member_location' in die_type.attributes:
|
||||
entry['offset'] = die_type.attributes['DW_AT_data_member_location'].value * 8
|
||||
if 'address' in entry:
|
||||
entry['address'] = hex(int(entry['address'], 16) + die_type.attributes['DW_AT_data_member_location'].value)
|
||||
if ('DW_AT_member_location' in die_type.attributes) or ('DW_AT_data_member_location' in die_type.attributes):
|
||||
at_member_location_name = 'DW_AT_member_location' if 'DW_AT_member_location' in die_type.attributes else 'DW_AT_data_member_location'
|
||||
|
||||
if LocationParser.attribute_has_location(die_type.attributes[at_member_location_name], die_type.cu['version']):
|
||||
ll = self.parse_location(die_type, die_type.attributes[at_member_location_name])
|
||||
lloc = self.dump_expr(die_type, ll.loc_expr)
|
||||
entry['address'] = hex(int(entry['address'], 16) + lloc[0].args[0])
|
||||
|
||||
if 'DW_AT_type' in die_type.attributes and die_type.tag not in ['DW_TAG_base_type', 'DW_TAG_structure_type', 'DW_TAG_array_type']:
|
||||
# Check if the type is a redefinition of a base type
|
||||
|
@ -210,20 +213,19 @@ class Bear():
|
|||
child_entry = dict()
|
||||
child_entry['name'] = safe_DIE_name(child_die, '?')
|
||||
|
||||
if 'DW_AT_data_bit_offset' in child_die.attributes:
|
||||
child_offset_bit = child_die.attributes['DW_AT_data_bit_offset'].value
|
||||
if child_offset_bit >= 8:
|
||||
child_offset = child_offset + math.floor(child_offset_bit / 8)
|
||||
child_offset_bit = child_offset_bit - math.floor(child_offset_bit / 8) * 8
|
||||
|
||||
if 'address' in entry:
|
||||
child_entry['address'] = hex(int(entry['address'], 16) + child_offset)
|
||||
if ('DW_AT_member_location' in child_die.attributes) or ('DW_AT_data_member_location' in child_die.attributes):
|
||||
at_member_location_name = 'DW_AT_member_location' if 'DW_AT_member_location' in child_die.attributes else 'DW_AT_data_member_location'
|
||||
|
||||
if LocationParser.attribute_has_location(child_die.attributes[at_member_location_name], child_die.cu['version']):
|
||||
ll = self.parse_location(child_die, child_die.attributes[at_member_location_name])
|
||||
lloc = self.dump_expr(child_die, ll.loc_expr)
|
||||
child_entry['address'] = hex(int(entry['address'], 16) + lloc[0].args[0])
|
||||
else:
|
||||
child_entry['address'] = entry['address']
|
||||
|
||||
self.truly_resolve_type(child_entry, typ_die)
|
||||
|
||||
if ('size_byte' in child_entry) and ('DW_AT_data_bit_offset' not in child_die.attributes) and ('DW_AT_bit_offset' not in child_die.attributes):
|
||||
child_offset = child_offset + child_entry['size_byte']
|
||||
|
||||
child_dies.append(child_entry)
|
||||
entry['children'] = child_dies
|
||||
elif die_type.tag == 'DW_TAG_array_type':
|
||||
|
|
Loading…
Reference in New Issue
Block a user