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_enumeration_type(txt):
    off = dwarfutils.extract_offset(txt)
    try:
        name = dwarfutils.extract_name(txt)
    except AttributeError:
        name = None
    DIEs[off] = DIEEnumeration(name=name, members=list())
    parse_enumeration(off)
def parse_union_type(txt):
    off = dwarfutils.extract_offset(txt)
    try:
        name = dwarfutils.extract_name(txt)
    except AttributeError:
        name = None
    byte_size = dwarfutils.extract_byte_size(txt)
    DIEs[off] = DIEUnion(name=name, byte_size=byte_size, members=list())
    parse_union(off)
def parse_structure_type(txt):
    off = dwarfutils.extract_offset(txt)
    try:
        name = dwarfutils.extract_name(txt)
    except AttributeError:
        name = None
    try:
        byte_size = dwarfutils.extract_byte_size(txt)
    except AttributeError:
        assert "AT_declaration" in txt
        byte_size = -1
    DIEs[off] = DIEStructure(name=name, byte_size=byte_size, members=list())
    parse_struct(off)
def parse_enumeration(parent_off):
    txts = dwarfutils.extract_dies_by_offset(args.dwarffile.name,
                                             parent_off,
                                             children=True)
    assert dwarfutils.extract_tag(txts[0]) == "TAG_enumeration_type"
    for txt in txts[1:]:
        if "TAG_enumerator" in txt:
            off = dwarfutils.extract_offset(txt)
            DIEs[off] = DIEEnumerator(
                name=dwarfutils.extract_name(txt),
                const_value=dwarfutils.extract_const_value(txt))
            DIEs[parent_off].members.append(off)
        elif "NULL" in txt:
            return
        else:
            raise NotImplementedError
    else:
        assert "AT_declaration" in txts[0]
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_compile_unit_type(txt):
    off = dwarfutils.extract_offset(txt)
    DIEs[off] = DIECompileUnit(name=dwarfutils.extract_name(txt))
def parse_base_type(txt):
    off = dwarfutils.extract_offset(txt)
    DIEs[off] = DIEBase(name=dwarfutils.extract_name(txt),
                        byte_size=dwarfutils.extract_byte_size(txt))
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))