def parse_typedef(txt): off = dwarfutils.extract_offset(txt) name = dwarfutils.extract_name(txt) if "__builtin_va_list" in name: name = name.upper() type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) DIEs[off] = DIETypedef(name=name, ttype=(type_off, type_name))
def parse_const_type(txt): off = dwarfutils.extract_offset(txt) try: type_off, type_name = dwarfutils.extract_type(txt) except AttributeError: type_off, type_name = None, None else: extract_and_parse_die(type_off) DIEs[off] = DIEConst(ttype=(type_off, type_name))
def parse_subroutine_type(txt): off = dwarfutils.extract_offset(txt) try: type_off, type_name = dwarfutils.extract_type(txt) except AttributeError: type_off, type_name = None, "void" else: extract_and_parse_die(type_off) DIEs[off] = DIESubroutine(ttype=(type_off, type_name), members=list()) parse_subroutine(off)
def parse_subroutine(parent_off): txts = dwarfutils.extract_dies_by_offset(args.dwarffile.name, parent_off, children=True) assert dwarfutils.extract_tag(txts[0]) == "TAG_subroutine_type" for txt in txts[1:]: if "TAG_formal_parameter" in txt: off = dwarfutils.extract_offset(txt) type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) DIEs[off] = DIEFormalParameter(ttype=(type_off, type_name)) DIEs[parent_off].members.append(off) elif "TAG_unspecified_parameters" in txt: pass elif "NULL" in txt: return else: raise NotImplementedError
def parse_member_type(txt): off = dwarfutils.extract_offset(txt) try: name = dwarfutils.extract_name(txt) except AttributeError: name = None type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) try: location = dwarfutils.extract_location(txt) except AttributeError: try: location = dwarfutils.extract_bit_location(txt) except AttributeError: location = -1 try: bit_size = dwarfutils.extract_bit_size(txt) except AttributeError: bit_size = -1 DIEs[off] = DIEMember(name=name, ttype=(type_off, type_name), location=location, bit_size=bit_size)
def parse_array_type(txt): off = dwarfutils.extract_offset(txt) type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) DIEs[off] = DIEArray(ttype=(type_off, type_name), size=_extract_array_count(off))
def parse_volatile_type(txt): off = dwarfutils.extract_offset(txt) type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) DIEs[off] = DIEVolatile(ttype=(type_off, type_name))
def parse_variable_type(txt): off = dwarfutils.extract_offset(txt) name = dwarfutils.extract_name(txt) type_off, type_name = dwarfutils.extract_type(txt) extract_and_parse_die(type_off) DIEs[off] = DIEVariable(name=name, ttype=(type_off, type_name))