dwarf: add Die.size()

Instead of having to do die.find_constant(DW_AT.byte_size).
This commit is contained in:
Omar Sandoval 2018-03-08 21:30:05 -08:00
parent 35e6750f5a
commit 2efa9343fb
2 changed files with 7 additions and 4 deletions

View File

@ -1434,6 +1434,9 @@ cdef class Die:
cpdef str name(self):
return self.find_string(DW_AT_name)
def size(self):
return self.find_constant(DW_AT_byte_size)
cpdef uint64_t address(self):
cdef const DieAttrib *low_pc = self.find_attrib(DW_AT_low_pc)
if low_pc.form != DW_FORM_addr:

View File

@ -604,7 +604,7 @@ class TypeFactory:
if dwarf_type.tag == DW_TAG.base_type:
encoding = dwarf_type.find_constant(DW_AT.encoding)
size = dwarf_type.find_constant(DW_AT.byte_size)
size = dwarf_type.size()
if encoding == DW_ATE.boolean:
return BoolType(dwarf_type.name(), size, qualifiers)
elif encoding == DW_ATE.float:
@ -623,7 +623,7 @@ class TypeFactory:
size = None
members = None
else:
size = dwarf_type.find_constant(DW_AT.byte_size)
size = dwarf_type.size()
members = []
for child in dwarf_type.children():
if child.tag != DW_TAG.member:
@ -657,7 +657,7 @@ class TypeFactory:
signed = None
enumerators = None
else:
size = dwarf_type.find_constant(DW_AT.byte_size)
size = dwarf_type.size()
encoding = dwarf_type.find_constant(DW_AT.encoding)
if encoding == DW_ATE.signed:
signed = True
@ -682,7 +682,7 @@ class TypeFactory:
self.from_dwarf_type(dwarf_type.type()),
qualifiers)
elif dwarf_type.tag == DW_TAG.pointer_type:
size = dwarf_type.find_constant(DW_AT.byte_size)
size = dwarf_type.size()
try:
deref_type = dwarf_type.type()
except DwarfAttribNotFoundError: