diff --git a/src/dwarf/dwarf.h b/src/dwarf/dwarf.h index f714ce40..b0ec11ac 100644 --- a/src/dwarf/dwarf.h +++ b/src/dwarf/dwarf.h @@ -39,24 +39,24 @@ typedef enum DW_Format #define DW_SentinelFromSize(address_size) ((address_size) == 4 ? max_U32 : (address_size) == 8 ? max_U64 : 0) #define DW_SectionKind_XList \ - X(Null, "", "", "" ) \ - X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" ) \ - X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" ) \ - X(Frame, ".debug_frame", "__debug_frame", ".debug_frame.dwo" ) \ - X(Info, ".debug_info", "__debug_info", ".debug_info.dwo" ) \ - X(Line, ".debug_line", "__debug_line", ".debug_line.dwo" ) \ - X(Loc, ".debug_loc", "__debug_loc", ".debug_loc.dwo" ) \ - X(MacInfo, ".debug_macinfo", "__debug_macinfo", ".debug_macinfo.dwo" ) \ - X(PubNames, ".debug_pubnames", "__debug_pubnames", ".debug_pubnames.dwo" ) \ - X(PubTypes, ".debug_pubtypes", "__debug_pubtypes", ".debug_pubtypes.dwo" ) \ - X(Ranges, ".debug_ranges", "__debug_ranges", ".debug_ranges.dwo" ) \ - X(Str, ".debug_str", "__debug_str", ".debug_str.dwo" ) \ - X(Addr, ".debug_addr", "__debug_addr", ".debug_addr.dwo" ) \ - X(LocLists, ".debug_loclists", "__debug_loclists", ".debug_loclists.dwo" ) \ - X(RngLists, ".debug_rnglists", "__debug_rnglists", ".debug_rnglists.dwo" ) \ - X(StrOffsets, ".debug_str_offsets", "__debug_str_offsets", ".debug_str_offsets.dwo") \ - X(LineStr, ".debug_line_str", "__debug_line_str", ".debug_line_str.dwo" ) \ - X(Names, ".debug_names", "__debug_names", ".debug_names.dwo" ) +X(Null, "", "", "" ) \ +X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" ) \ +X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" ) \ +X(Frame, ".debug_frame", "__debug_frame", ".debug_frame.dwo" ) \ +X(Info, ".debug_info", "__debug_info", ".debug_info.dwo" ) \ +X(Line, ".debug_line", "__debug_line", ".debug_line.dwo" ) \ +X(Loc, ".debug_loc", "__debug_loc", ".debug_loc.dwo" ) \ +X(MacInfo, ".debug_macinfo", "__debug_macinfo", ".debug_macinfo.dwo" ) \ +X(PubNames, ".debug_pubnames", "__debug_pubnames", ".debug_pubnames.dwo" ) \ +X(PubTypes, ".debug_pubtypes", "__debug_pubtypes", ".debug_pubtypes.dwo" ) \ +X(Ranges, ".debug_ranges", "__debug_ranges", ".debug_ranges.dwo" ) \ +X(Str, ".debug_str", "__debug_str", ".debug_str.dwo" ) \ +X(Addr, ".debug_addr", "__debug_addr", ".debug_addr.dwo" ) \ +X(LocLists, ".debug_loclists", "__debug_loclists", ".debug_loclists.dwo" ) \ +X(RngLists, ".debug_rnglists", "__debug_rnglists", ".debug_rnglists.dwo" ) \ +X(StrOffsets, ".debug_str_offsets", "__debug_str_offsets", ".debug_str_offsets.dwo") \ +X(LineStr, ".debug_line_str", "__debug_line_str", ".debug_line_str.dwo" ) \ +X(Names, ".debug_names", "__debug_names", ".debug_names.dwo" ) typedef U64 DW_SectionKind; typedef enum DW_SectionKindEnum @@ -64,7 +64,7 @@ typedef enum DW_SectionKindEnum #define X(_N,...) DW_Section_##_N, DW_SectionKind_XList #undef X - DW_Section_Count + DW_Section_COUNT } DW_SectionKindEnum; typedef U32 DW_SectionFlags; @@ -77,48 +77,48 @@ enum }; #define DW_Language_XList \ - X(Null, 0x00) \ - X(C89, 0x01) \ - X(C, 0x02) \ - X(Ada83, 0x03) \ - X(CPlusPlus, 0x04) \ - X(Cobol74, 0x05) \ - X(Cobol85, 0x06) \ - X(Fortran77, 0x07) \ - X(Fortran90, 0x08) \ - X(Pascal83, 0x09) \ - X(Modula2, 0x0A) \ - X(Java, 0x0B) \ - X(C99, 0x0C) \ - X(Ada95, 0x0D) \ - X(Fortran95, 0x0E) \ - X(PLI, 0x0F) \ - X(ObjC, 0x10) \ - X(ObjCPlusPlus, 0x11) \ - X(UPC, 0x12) \ - X(D, 0x13) \ - X(Python, 0x14) \ - X(OpenCL, 0x15) \ - X(Go, 0x16) \ - X(Modula3, 0x17) \ - X(Haskell, 0x18) \ - X(CPlusPlus03, 0x19) \ - X(CPlusPlus11, 0x1a) \ - X(OCaml, 0x1b) \ - X(Rust, 0x1c) \ - X(C11, 0x1d) \ - X(Swift, 0x1e) \ - X(Julia, 0x1f) \ - X(Dylan, 0x20) \ - X(CPlusPlus14, 0x21) \ - X(Fortran03, 0x22) \ - X(Fortran08, 0x23) \ - X(RenderScript, 0x24) \ - X(BLISS, 0x25) \ - X(MipsAssembler, 0x8001) \ - X(GoogleRenderScript, 0x8E57) \ - X(SunAssembler, 0x9001) \ - X(BorlandDelphi, 0xB000) +X(Null, 0x00) \ +X(C89, 0x01) \ +X(C, 0x02) \ +X(Ada83, 0x03) \ +X(CPlusPlus, 0x04) \ +X(Cobol74, 0x05) \ +X(Cobol85, 0x06) \ +X(Fortran77, 0x07) \ +X(Fortran90, 0x08) \ +X(Pascal83, 0x09) \ +X(Modula2, 0x0A) \ +X(Java, 0x0B) \ +X(C99, 0x0C) \ +X(Ada95, 0x0D) \ +X(Fortran95, 0x0E) \ +X(PLI, 0x0F) \ +X(ObjC, 0x10) \ +X(ObjCPlusPlus, 0x11) \ +X(UPC, 0x12) \ +X(D, 0x13) \ +X(Python, 0x14) \ +X(OpenCL, 0x15) \ +X(Go, 0x16) \ +X(Modula3, 0x17) \ +X(Haskell, 0x18) \ +X(CPlusPlus03, 0x19) \ +X(CPlusPlus11, 0x1a) \ +X(OCaml, 0x1b) \ +X(Rust, 0x1c) \ +X(C11, 0x1d) \ +X(Swift, 0x1e) \ +X(Julia, 0x1f) \ +X(Dylan, 0x20) \ +X(CPlusPlus14, 0x21) \ +X(Fortran03, 0x22) \ +X(Fortran08, 0x23) \ +X(RenderScript, 0x24) \ +X(BLISS, 0x25) \ +X(MipsAssembler, 0x8001) \ +X(GoogleRenderScript, 0x8E57) \ +X(SunAssembler, 0x9001) \ +X(BorlandDelphi, 0xB000) typedef U32 DW_Language; typedef enum DW_LanguageEnum @@ -131,10 +131,10 @@ typedef enum DW_LanguageEnum } DW_LanguageEnum; #define DW_Inl_XList \ - X(NotInlined, 0x00) \ - X(Inlined, 0x01) \ - X(DeclaredNotInlined, 0x02) \ - X(DeclaredInlined, 0x03) +X(NotInlined, 0x00) \ +X(Inlined, 0x01) \ +X(DeclaredNotInlined, 0x02) \ +X(DeclaredInlined, 0x03) typedef U32 DW_InlKind; typedef enum DW_InlKindEnum @@ -145,19 +145,19 @@ typedef enum DW_InlKindEnum } DW_InlKindEnum; #define DW_StdOpcode_XList \ - X(ExtendedOpcode, 0x00) \ - X(Copy, 0x01) \ - X(AdvancePc, 0x02) \ - X(AdvanceLine, 0x03) \ - X(SetFile, 0x04) \ - X(SetColumn, 0x05) \ - X(NegateStmt, 0x06) \ - X(SetBasicBlock, 0x07) \ - X(ConstAddPc, 0x08) \ - X(FixedAdvancePc, 0x09) \ - X(SetPrologueEnd, 0x0A) \ - X(SetEpilogueBegin, 0x0B) \ - X(SetIsa, 0x0C) +X(ExtendedOpcode, 0x00) \ +X(Copy, 0x01) \ +X(AdvancePc, 0x02) \ +X(AdvanceLine, 0x03) \ +X(SetFile, 0x04) \ +X(SetColumn, 0x05) \ +X(NegateStmt, 0x06) \ +X(SetBasicBlock, 0x07) \ +X(ConstAddPc, 0x08) \ +X(FixedAdvancePc, 0x09) \ +X(SetPrologueEnd, 0x0A) \ +X(SetEpilogueBegin, 0x0B) \ +X(SetIsa, 0x0C) typedef U8 DW_StdOpcode; typedef enum DW_StdOpcodeEnum @@ -169,13 +169,13 @@ typedef enum DW_StdOpcodeEnum } DW_StdOpcodeEnum; #define DW_ExtOpcode_XList \ - X(Undefined, 0x00) \ - X(EndSequence, 0x01) \ - X(SetAddress, 0x02) \ - X(DefineFile, 0x03) \ - X(SetDiscriminator, 0x04) \ - X(UserLo, 0x80) \ - X(UserHi, 0xff) +X(Undefined, 0x00) \ +X(EndSequence, 0x01) \ +X(SetAddress, 0x02) \ +X(DefineFile, 0x03) \ +X(SetDiscriminator, 0x04) \ +X(UserLo, 0x80) \ +X(UserHi, 0xff) typedef U8 DW_ExtOpcode; typedef enum DW_ExtOpcodeEnum @@ -186,10 +186,10 @@ typedef enum DW_ExtOpcodeEnum } DW_ExtOpcodeEnum; #define DW_IDCaseKind_XList \ - X(CaseSensitive, 0x00) \ - X(UpCase, 0x01) \ - X(DownCase, 0x02) \ - X(CaseInsensitive, 0x03) +X(CaseSensitive, 0x00) \ +X(UpCase, 0x01) \ +X(DownCase, 0x02) \ +X(CaseInsensitive, 0x03) typedef U64 DW_IDCaseKind; typedef enum DW_IDCaseKindEnum @@ -200,9 +200,9 @@ typedef enum DW_IDCaseKindEnum } DW_IDCaseKindEnum; #define DW_Vis_XList \ - X(Local, 0x01) \ - X(Exported, 0x02) \ - X(Qualified, 0x03) +X(Local, 0x01) \ +X(Exported, 0x02) \ +X(Qualified, 0x03) typedef enum DW_Vis { #define X(_N, _ID) DW_Vis_##_N = _ID, @@ -211,80 +211,80 @@ typedef enum DW_Vis } DW_Vis; #define DW_TagKind_V3_XList \ - X(ArrayType, 0x01) \ - X(ClassType, 0x02) \ - X(EntryPoint, 0x03) \ - X(EnumerationType, 0x04) \ - X(FormalParameter, 0x05) \ - X(ImportedDeclaration, 0x08) \ - X(Label, 0x0a) \ - X(LexicalBlock, 0x0b) \ - X(Member, 0x0d) \ - X(PointerType, 0x0f) \ - X(ReferenceType, 0x10) \ - X(CompileUnit, 0x11) \ - X(StringType, 0x12) \ - X(StructureType, 0x13) \ - X(SubroutineType, 0x15) \ - X(Typedef, 0x16) \ - X(UnionType, 0x17) \ - X(UnspecifiedParameters, 0x18) \ - X(Variant, 0x19) \ - X(CommonBlock, 0x1a) \ - X(CommonInclusion, 0x1b) \ - X(Inheritance, 0x1c) \ - X(InlinedSubroutine, 0x1d) \ - X(Module, 0x1e) \ - X(PtrToMemberType, 0x1f) \ - X(SetType, 0x20) \ - X(SubrangeType, 0x21) \ - X(WithStmt, 0x22) \ - X(AccessDeclaration, 0x23) \ - X(BaseType, 0x24) \ - X(CatchBlock, 0x25) \ - X(ConstType, 0x26) \ - X(Constant, 0x27) \ - X(Enumerator, 0x28) \ - X(FileType, 0x29) \ - X(Friend, 0x2a) \ - X(NameList, 0x2b) \ - X(NameListItem, 0x2c) \ - X(PackedType, 0x2d) \ - X(SubProgram, 0x2e) \ - X(TemplateTypeParameter, 0x2f) \ - X(TemplateValueParameter, 0x30) \ - X(ThrownType, 0x31) \ - X(TryBlock, 0x32) \ - X(VariantPart, 0x33) \ - X(Variable, 0x34) \ - X(VolatileType, 0x35) \ - X(DwarfProcedure, 0x36) \ - X(RestrictType, 0x37) \ - X(InterfaceType, 0x38) \ - X(Namespace, 0x39) \ - X(ImportedModule, 0x3a) \ - X(UnspecifiedType, 0x3b) \ - X(PartialUnit, 0x3c) \ - X(ImportedUnit, 0x3d) \ - X(Condition, 0x3f) \ - X(SharedType, 0x40) +X(ArrayType, 0x01) \ +X(ClassType, 0x02) \ +X(EntryPoint, 0x03) \ +X(EnumerationType, 0x04) \ +X(FormalParameter, 0x05) \ +X(ImportedDeclaration, 0x08) \ +X(Label, 0x0a) \ +X(LexicalBlock, 0x0b) \ +X(Member, 0x0d) \ +X(PointerType, 0x0f) \ +X(ReferenceType, 0x10) \ +X(CompileUnit, 0x11) \ +X(StringType, 0x12) \ +X(StructureType, 0x13) \ +X(SubroutineType, 0x15) \ +X(Typedef, 0x16) \ +X(UnionType, 0x17) \ +X(UnspecifiedParameters, 0x18) \ +X(Variant, 0x19) \ +X(CommonBlock, 0x1a) \ +X(CommonInclusion, 0x1b) \ +X(Inheritance, 0x1c) \ +X(InlinedSubroutine, 0x1d) \ +X(Module, 0x1e) \ +X(PtrToMemberType, 0x1f) \ +X(SetType, 0x20) \ +X(SubrangeType, 0x21) \ +X(WithStmt, 0x22) \ +X(AccessDeclaration, 0x23) \ +X(BaseType, 0x24) \ +X(CatchBlock, 0x25) \ +X(ConstType, 0x26) \ +X(Constant, 0x27) \ +X(Enumerator, 0x28) \ +X(FileType, 0x29) \ +X(Friend, 0x2a) \ +X(NameList, 0x2b) \ +X(NameListItem, 0x2c) \ +X(PackedType, 0x2d) \ +X(SubProgram, 0x2e) \ +X(TemplateTypeParameter, 0x2f) \ +X(TemplateValueParameter, 0x30) \ +X(ThrownType, 0x31) \ +X(TryBlock, 0x32) \ +X(VariantPart, 0x33) \ +X(Variable, 0x34) \ +X(VolatileType, 0x35) \ +X(DwarfProcedure, 0x36) \ +X(RestrictType, 0x37) \ +X(InterfaceType, 0x38) \ +X(Namespace, 0x39) \ +X(ImportedModule, 0x3a) \ +X(UnspecifiedType, 0x3b) \ +X(PartialUnit, 0x3c) \ +X(ImportedUnit, 0x3d) \ +X(Condition, 0x3f) \ +X(SharedType, 0x40) #define DW_TagKind_V5_XList \ - X(TypeUnit, 0x41) \ - X(RValueReferenceType, 0x42) \ - X(TemplateAlias, 0x43) \ - X(CoarrayType, 0x44) \ - X(GenericSubrange, 0x45) \ - X(DynamicType, 0x46) \ - X(AtomicType, 0x47) \ - X(CallSite, 0x48) \ - X(CallSiteParameter, 0x49) \ - X(SkeletonUnit, 0x4A) \ - X(ImmutableType, 0x4B) +X(TypeUnit, 0x41) \ +X(RValueReferenceType, 0x42) \ +X(TemplateAlias, 0x43) \ +X(CoarrayType, 0x44) \ +X(GenericSubrange, 0x45) \ +X(DynamicType, 0x46) \ +X(AtomicType, 0x47) \ +X(CallSite, 0x48) \ +X(CallSiteParameter, 0x49) \ +X(SkeletonUnit, 0x4A) \ +X(ImmutableType, 0x4B) #define DW_TagKind_GNU_XList \ - X(GNU_CallSite, 0x4109) \ - X(GNU_CallSiteParameter, 0x410a) +X(GNU_CallSite, 0x4109) \ +X(GNU_CallSiteParameter, 0x410a) typedef U64 DW_TagKind; typedef enum DW_TagKindEnum @@ -292,8 +292,8 @@ typedef enum DW_TagKindEnum DW_TagKind_Null, #define X(_N,_ID) DW_TagKind_##_N = _ID, DW_TagKind_V3_XList - DW_TagKind_V5_XList - DW_TagKind_GNU_XList + DW_TagKind_V5_XList + DW_TagKind_GNU_XList #undef X DW_TagKind_UserLo = 0x4080, DW_TagKind_UserHi = 0xffff @@ -302,35 +302,35 @@ typedef enum DW_TagKindEnum //- Attrib Class Encodings #define DW_AttribClass_V3_XList \ - X(Null, 0) \ - X(Undefined, 1) \ - X(Address, 2) \ - X(Block, 3) \ - X(Const, 4) \ - X(ExprLoc, 5) \ - X(Flag, 6) \ - X(LinePtr, 7) \ - X(LocListPtr, 8) \ - X(MacPtr, 9) \ - X(RngListPtr, 10) \ - X(Reference, 11) \ - X(String, 12) +X(Null, 0) \ +X(Undefined, 1) \ +X(Address, 2) \ +X(Block, 3) \ +X(Const, 4) \ +X(ExprLoc, 5) \ +X(Flag, 6) \ +X(LinePtr, 7) \ +X(LocListPtr, 8) \ +X(MacPtr, 9) \ +X(RngListPtr, 10) \ +X(Reference, 11) \ +X(String, 12) #define DW_AttribClass_V4_XList \ - X(LocList, 13) \ - X(RngList, 14) +X(LocList, 13) \ +X(RngList, 14) #define DW_AttribClass_V5_XList \ - X(StrOffsetsPtr, 15) \ - X(AddrPtr, 16) +X(StrOffsetsPtr, 15) \ +X(AddrPtr, 16) typedef U32 DW_AttribClass; typedef enum DW_AttribClassEnum { #define X(_N,_ID) DW_AttribClass_##_N = (1 << _ID), DW_AttribClass_V3_XList - DW_AttribClass_V4_XList - DW_AttribClass_V5_XList + DW_AttribClass_V4_XList + DW_AttribClass_V5_XList #undef X DW_AttribClass_AllPtrs = DW_AttribClass_AddrPtr|DW_AttribClass_LinePtr|DW_AttribClass_LocList|DW_AttribClass_LocListPtr| DW_AttribClass_MacPtr| DW_AttribClass_RngList| DW_AttribClass_RngListPtr| DW_AttribClass_StrOffsetsPtr, } DW_AttribClassEnum; @@ -338,172 +338,172 @@ typedef enum DW_AttribClassEnum //- Form Encodings #define DW_Form_V2_XList \ - X(Addr, 0x1) \ - X(Block2, 0x3) \ - X(Block4, 0x4) \ - X(Data2, 0x5) \ - X(Data4, 0x6) \ - X(Data8, 0x7) \ - X(String, 0x8) \ - X(Block, 0x9) \ - X(Block1, 0xa) \ - X(Data1, 0xb) \ - X(Flag, 0xc) \ - X(SData, 0xd) \ - X(Strp, 0xe) \ - X(UData, 0xf) \ - X(RefAddr, 0x10) \ - X(Ref1, 0x11) \ - X(Ref2, 0x12) \ - X(Ref4, 0x13) \ - X(Ref8, 0x14) \ - X(RefUData, 0x15) \ - X(Indirect, 0x16) +X(Addr, 0x1) \ +X(Block2, 0x3) \ +X(Block4, 0x4) \ +X(Data2, 0x5) \ +X(Data4, 0x6) \ +X(Data8, 0x7) \ +X(String, 0x8) \ +X(Block, 0x9) \ +X(Block1, 0xa) \ +X(Data1, 0xb) \ +X(Flag, 0xc) \ +X(SData, 0xd) \ +X(Strp, 0xe) \ +X(UData, 0xf) \ +X(RefAddr, 0x10) \ +X(Ref1, 0x11) \ +X(Ref2, 0x12) \ +X(Ref4, 0x13) \ +X(Ref8, 0x14) \ +X(RefUData, 0x15) \ +X(Indirect, 0x16) #define DW_Form_AttribClass_V2_XList \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) #define DW_Form_V4_XList \ - X(SecOffset, 0x17) \ - X(ExprLoc, 0x18) \ - X(FlagPresent, 0x19) \ - X(RefSig8, 0x20) +X(SecOffset, 0x17) \ +X(ExprLoc, 0x18) \ +X(FlagPresent, 0x19) \ +X(RefSig8, 0x20) #define DW_Form_AttribClass_V4_XList \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) \ - X(SecOffset, DW_AttribClass_LinePtr|DW_AttribClass_LocListPtr|DW_AttribClass_MacPtr|DW_AttribClass_RngListPtr) \ - X(ExprLoc, DW_AttribClass_ExprLoc) \ - X(FlagPresent, DW_AttribClass_Flag) \ - X(RefSig8, DW_AttribClass_Reference) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) \ +X(SecOffset, DW_AttribClass_LinePtr|DW_AttribClass_LocListPtr|DW_AttribClass_MacPtr|DW_AttribClass_RngListPtr) \ +X(ExprLoc, DW_AttribClass_ExprLoc) \ +X(FlagPresent, DW_AttribClass_Flag) \ +X(RefSig8, DW_AttribClass_Reference) #define DW_Form_V5_XList \ - X(Strx, 0x1a) \ - X(Addrx, 0x1b) \ - X(RefSup4, 0x1c) \ - X(StrpSup, 0x1d) \ - X(Data16, 0x1e) \ - X(LineStrp, 0x1f) \ - X(ImplicitConst, 0x21) \ - X(LocListx, 0x22) \ - X(RngListx, 0x23) \ - X(RefSup8, 0x24) \ - X(Strx1, 0x25) \ - X(Strx2, 0x26) \ - X(Strx3, 0x27) \ - X(Strx4, 0x28) \ - X(Addrx1, 0x29) \ - X(Addrx2, 0x2a) \ - X(Addrx3, 0x2b) \ - X(Addrx4, 0x2c) +X(Strx, 0x1a) \ +X(Addrx, 0x1b) \ +X(RefSup4, 0x1c) \ +X(StrpSup, 0x1d) \ +X(Data16, 0x1e) \ +X(LineStrp, 0x1f) \ +X(ImplicitConst, 0x21) \ +X(LocListx, 0x22) \ +X(RngListx, 0x23) \ +X(RefSup8, 0x24) \ +X(Strx1, 0x25) \ +X(Strx2, 0x26) \ +X(Strx3, 0x27) \ +X(Strx4, 0x28) \ +X(Addrx1, 0x29) \ +X(Addrx2, 0x2a) \ +X(Addrx3, 0x2b) \ +X(Addrx4, 0x2c) #define DW_Form_AttribClass_V5_XList \ - X(Addr, DW_AttribClass_Address) \ - X(Block2, DW_AttribClass_Block) \ - X(Block4, DW_AttribClass_Block) \ - X(Data2, DW_AttribClass_Const) \ - X(Data4, DW_AttribClass_Const) \ - X(Data8, DW_AttribClass_Const) \ - X(String, DW_AttribClass_String) \ - X(Block, DW_AttribClass_Block) \ - X(Block1, DW_AttribClass_Block) \ - X(Data1, DW_AttribClass_Const) \ - X(Flag, DW_AttribClass_Flag) \ - X(SData, DW_AttribClass_Const) \ - X(Strp, DW_AttribClass_String) \ - X(UData, DW_AttribClass_Const) \ - X(RefAddr, DW_AttribClass_Reference) \ - X(Ref1, DW_AttribClass_Reference) \ - X(Ref2, DW_AttribClass_Reference) \ - X(Ref4, DW_AttribClass_Reference) \ - X(Ref8, DW_AttribClass_Reference) \ - X(RefUData, DW_AttribClass_Reference) \ - X(Indirect, DW_AttribClass_Null) \ - X(SecOffset, DW_AttribClass_AllPtrs) \ - X(ExprLoc, DW_AttribClass_ExprLoc) \ - X(FlagPresent, DW_AttribClass_Flag) \ - X(RefSig8, DW_AttribClass_Reference) \ - X(Strx, DW_AttribClass_String) \ - X(Addrx, DW_AttribClass_Address) \ - X(RefSup4, DW_AttribClass_Reference) \ - X(StrpSup, DW_AttribClass_String) \ - X(Data16, DW_AttribClass_Const) \ - X(LineStrp, DW_AttribClass_String) \ - X(ImplicitConst, DW_AttribClass_Const) \ - X(LocListx, DW_AttribClass_LocListPtr) \ - X(RngListx, DW_AttribClass_RngList) \ - X(RefSup8, DW_AttribClass_Reference) \ - X(Strx1, DW_AttribClass_String) \ - X(Strx2, DW_AttribClass_String) \ - X(Strx3, DW_AttribClass_String) \ - X(Strx4, DW_AttribClass_String) \ - X(Addrx1, DW_AttribClass_Address) \ - X(Addrx2, DW_AttribClass_Address) \ - X(Addrx3, DW_AttribClass_Address) \ - X(Addrx4, DW_AttribClass_Address) +X(Addr, DW_AttribClass_Address) \ +X(Block2, DW_AttribClass_Block) \ +X(Block4, DW_AttribClass_Block) \ +X(Data2, DW_AttribClass_Const) \ +X(Data4, DW_AttribClass_Const) \ +X(Data8, DW_AttribClass_Const) \ +X(String, DW_AttribClass_String) \ +X(Block, DW_AttribClass_Block) \ +X(Block1, DW_AttribClass_Block) \ +X(Data1, DW_AttribClass_Const) \ +X(Flag, DW_AttribClass_Flag) \ +X(SData, DW_AttribClass_Const) \ +X(Strp, DW_AttribClass_String) \ +X(UData, DW_AttribClass_Const) \ +X(RefAddr, DW_AttribClass_Reference) \ +X(Ref1, DW_AttribClass_Reference) \ +X(Ref2, DW_AttribClass_Reference) \ +X(Ref4, DW_AttribClass_Reference) \ +X(Ref8, DW_AttribClass_Reference) \ +X(RefUData, DW_AttribClass_Reference) \ +X(Indirect, DW_AttribClass_Null) \ +X(SecOffset, DW_AttribClass_AllPtrs) \ +X(ExprLoc, DW_AttribClass_ExprLoc) \ +X(FlagPresent, DW_AttribClass_Flag) \ +X(RefSig8, DW_AttribClass_Reference) \ +X(Strx, DW_AttribClass_String) \ +X(Addrx, DW_AttribClass_Address) \ +X(RefSup4, DW_AttribClass_Reference) \ +X(StrpSup, DW_AttribClass_String) \ +X(Data16, DW_AttribClass_Const) \ +X(LineStrp, DW_AttribClass_String) \ +X(ImplicitConst, DW_AttribClass_Const) \ +X(LocListx, DW_AttribClass_LocListPtr) \ +X(RngListx, DW_AttribClass_RngList) \ +X(RefSup8, DW_AttribClass_Reference) \ +X(Strx1, DW_AttribClass_String) \ +X(Strx2, DW_AttribClass_String) \ +X(Strx3, DW_AttribClass_String) \ +X(Strx4, DW_AttribClass_String) \ +X(Addrx1, DW_AttribClass_Address) \ +X(Addrx2, DW_AttribClass_Address) \ +X(Addrx3, DW_AttribClass_Address) \ +X(Addrx4, DW_AttribClass_Address) #define DW_Form_GNU_XList \ - X(GNU_AddrIndex, 0x1f01) \ - X(GNU_StrIndex, 0x1f02) \ - X(GNU_RefAlt, 0x1f20) \ - X(GNU_StrpAlt, 0x1f21) +X(GNU_AddrIndex, 0x1f01) \ +X(GNU_StrIndex, 0x1f02) \ +X(GNU_RefAlt, 0x1f20) \ +X(GNU_StrpAlt, 0x1f21) #define DW_Form_AttribClass_GNU_XList \ - X(GNU_AddrIndex, DW_AttribClass_Undefined) \ - X(GNU_StrIndex, DW_AttribClass_Undefined) \ - X(GNU_RefAlt, DW_AttribClass_Undefined) \ - X(GNU_StrpAlt, DW_AttribClass_String) +X(GNU_AddrIndex, DW_AttribClass_Undefined) \ +X(GNU_StrIndex, DW_AttribClass_Undefined) \ +X(GNU_RefAlt, DW_AttribClass_Undefined) \ +X(GNU_StrpAlt, DW_AttribClass_String) typedef U64 DW_FormKind; -typedef enum DW_FormEnum +typedef enum DW_FormKindEnum { DW_Form_Null, #define X(_N, _ID) DW_Form_##_N = _ID, DW_Form_V2_XList - DW_Form_V4_XList - DW_Form_V5_XList - DW_Form_GNU_XList + DW_Form_V4_XList + DW_Form_V5_XList + DW_Form_GNU_XList #undef X -} DW_FormEnum; +} DW_FormKindEnum; typedef struct DW_Form { @@ -532,669 +532,669 @@ typedef struct DW_Form //- Attributes DWARF2 #define DW_AttribKind_V2_XList \ - X(Sibling, 0x1) \ - X(Location, 0x2) \ - X(Name, 0x3) \ - X(Ordering, 0x9) \ - X(ByteSize, 0xB) \ - X(BitOffset, 0xC) \ - X(BitSize, 0xD) \ - X(StmtList, 0x10) \ - X(LowPc, 0x11) \ - X(HighPc, 0x12) \ - X(Language, 0x13) \ - X(Discr, 0x15) \ - X(DiscrValue, 0x16) \ - X(Visibility, 0x17) \ - X(Import, 0x18) \ - X(StringLength, 0x19) \ - X(CommonReference, 0x1a) \ - X(CompDir, 0x1b) \ - X(ConstValue, 0x1c) \ - X(ContainingType, 0x1d) \ - X(DefaultValue, 0x1e) \ - X(Inline, 0x20) \ - X(IsOptional, 0x21) \ - X(LowerBound, 0x22) \ - X(Producer, 0x25) \ - X(Prototyped, 0x27) \ - X(ReturnAddr, 0x2a) \ - X(StartScope, 0x2c) \ - X(BitStride, 0x2e) \ - X(UpperBound, 0x2f) \ - X(AbstractOrigin, 0x31) \ - X(Accessibility, 0x32) \ - X(AddressClass, 0x33) \ - X(Artificial, 0x34) \ - X(BaseTypes, 0x35) \ - X(CallingConvention, 0x36) \ - X(Count, 0x37) \ - X(DataMemberLocation, 0x38) \ - X(DeclColumn, 0x39) \ - X(DeclFile, 0x3a) \ - X(DeclLine, 0x3b) \ - X(Declaration, 0x3c) \ - X(DiscrList, 0x3d) \ - X(Encoding, 0x3e) \ - X(External, 0x3f) \ - X(FrameBase, 0x40) \ - X(Friend, 0x41) \ - X(IdentifierCase, 0x42) \ - X(MacroInfo, 0x43) \ - X(NameListItem, 0x44) \ - X(Priority, 0x45) \ - X(Segment, 0x46) \ - X(Specification, 0x47) \ - X(StaticLink, 0x48) \ - X(Type, 0x49) \ - X(UseLocation, 0x4a) \ - X(VariableParameter, 0x4b) \ - X(Virtuality, 0x4c) \ - X(VTableElemLocation, 0x4d) +X(Sibling, 0x1) \ +X(Location, 0x2) \ +X(Name, 0x3) \ +X(Ordering, 0x9) \ +X(ByteSize, 0xB) \ +X(BitOffset, 0xC) \ +X(BitSize, 0xD) \ +X(StmtList, 0x10) \ +X(LowPc, 0x11) \ +X(HighPc, 0x12) \ +X(Language, 0x13) \ +X(Discr, 0x15) \ +X(DiscrValue, 0x16) \ +X(Visibility, 0x17) \ +X(Import, 0x18) \ +X(StringLength, 0x19) \ +X(CommonReference, 0x1a) \ +X(CompDir, 0x1b) \ +X(ConstValue, 0x1c) \ +X(ContainingType, 0x1d) \ +X(DefaultValue, 0x1e) \ +X(Inline, 0x20) \ +X(IsOptional, 0x21) \ +X(LowerBound, 0x22) \ +X(Producer, 0x25) \ +X(Prototyped, 0x27) \ +X(ReturnAddr, 0x2a) \ +X(StartScope, 0x2c) \ +X(BitStride, 0x2e) \ +X(UpperBound, 0x2f) \ +X(AbstractOrigin, 0x31) \ +X(Accessibility, 0x32) \ +X(AddressClass, 0x33) \ +X(Artificial, 0x34) \ +X(BaseTypes, 0x35) \ +X(CallingConvention, 0x36) \ +X(Count, 0x37) \ +X(DataMemberLocation, 0x38) \ +X(DeclColumn, 0x39) \ +X(DeclFile, 0x3a) \ +X(DeclLine, 0x3b) \ +X(Declaration, 0x3c) \ +X(DiscrList, 0x3d) \ +X(Encoding, 0x3e) \ +X(External, 0x3f) \ +X(FrameBase, 0x40) \ +X(Friend, 0x41) \ +X(IdentifierCase, 0x42) \ +X(MacroInfo, 0x43) \ +X(NameListItem, 0x44) \ +X(Priority, 0x45) \ +X(Segment, 0x46) \ +X(Specification, 0x47) \ +X(StaticLink, 0x48) \ +X(Type, 0x49) \ +X(UseLocation, 0x4a) \ +X(VariableParameter, 0x4b) \ +X(Virtuality, 0x4c) \ +X(VTableElemLocation, 0x4d) #define DW_AttribKind_ClassFlags_V2_XList \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const) \ - X(BitOffset, DW_AttribClass_Const) \ - X(BitSize, DW_AttribClass_Const) \ - X(StmtList, DW_AttribClass_Const) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_String|DW_AttribClass_Const|DW_AttribClass_Block) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(StartScope, DW_AttribClass_Const) \ - X(BitStride, DW_AttribClass_Const) /* dwarf-v1 DW_AttribKind_stride_size*/ \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Reference) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_Const) \ - X(NameListItem, DW_AttribClass_Block) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_Block|DW_AttribClass_Const) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_Reference) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const) \ +X(BitOffset, DW_AttribClass_Const) \ +X(BitSize, DW_AttribClass_Const) \ +X(StmtList, DW_AttribClass_Const) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_String|DW_AttribClass_Const|DW_AttribClass_Block) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(StartScope, DW_AttribClass_Const) \ +X(BitStride, DW_AttribClass_Const) /* dwarf-v1 DW_AttribKind_stride_size*/ \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Reference) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_Const) \ +X(NameListItem, DW_AttribClass_Block) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_Block|DW_AttribClass_Const) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_Reference) //- Attributes DWARF3 #define DW_AttribKind_V3_XList \ - X(Allocated, 0x4e) \ - X(Associated, 0x4f) \ - X(DataLocation, 0x50) \ - X(ByteStride, 0x51) \ - X(EntryPc, 0x52) \ - X(UseUtf8, 0x53) \ - X(Extension, 0x54) \ - X(Ranges, 0x55) \ - X(Trampoline, 0x56) \ - X(CallColumn, 0x57) \ - X(CallFile, 0x58) \ - X(CallLine, 0x59) \ - X(Description, 0x5a) \ - X(BinaryScale, 0x5b) \ - X(DecimalScale, 0x5c) \ - X(Small, 0x5d) \ - X(DecimalSign, 0x5e) \ - X(DigitCount, 0x5f) \ - X(PictureString, 0x60) \ - X(Mutable, 0x61) \ - X(ThreadsScaled, 0x62) \ - X(Explicit, 0x63) \ - X(ObjectPointer, 0x64) \ - X(Endianity, 0x65) \ - X(Elemental, 0x66) \ - X(Pure, 0x67) \ - X(Recursive, 0x68) +X(Allocated, 0x4e) \ +X(Associated, 0x4f) \ +X(DataLocation, 0x50) \ +X(ByteStride, 0x51) \ +X(EntryPc, 0x52) \ +X(UseUtf8, 0x53) \ +X(Extension, 0x54) \ +X(Ranges, 0x55) \ +X(Trampoline, 0x56) \ +X(CallColumn, 0x57) \ +X(CallFile, 0x58) \ +X(CallLine, 0x59) \ +X(Description, 0x5a) \ +X(BinaryScale, 0x5b) \ +X(DecimalScale, 0x5c) \ +X(Small, 0x5d) \ +X(DecimalSign, 0x5e) \ +X(DigitCount, 0x5f) \ +X(PictureString, 0x60) \ +X(Mutable, 0x61) \ +X(ThreadsScaled, 0x62) \ +X(Explicit, 0x63) \ +X(ObjectPointer, 0x64) \ +X(Endianity, 0x65) \ +X(Elemental, 0x66) \ +X(Pure, 0x67) \ +X(Recursive, 0x68) #define DW_AttribKind_ClassFlags_V3_XList \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const) \ - X(BitStride, DW_AttribClass_Const) \ - X(UpperBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_LocListPtr) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Block) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ - X(Allocated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_Block) \ - X(ByteStride, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngListPtr) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const) \ +X(BitStride, DW_AttribClass_Const) \ +X(UpperBound, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_LocListPtr) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Block) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ +X(Allocated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_Block) \ +X(ByteStride, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngListPtr) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) //- Attributes DWARF4 #define DW_AttribKind_V4_XList \ - X(Signature, 0x69) \ - X(MainSubProgram, 0x6a) \ - X(DataBitOffset, 0x6b) \ - X(ConstExpr, 0x6c) \ - X(EnumClass, 0x6d) \ - X(LinkageName, 0x6e) +X(Signature, 0x69) \ +X(MainSubProgram, 0x6a) \ +X(DataBitOffset, 0x6b) \ +X(ConstExpr, 0x6c) \ +X(EnumClass, 0x6d) \ +X(LinkageName, 0x6e) #define DW_AttribKind_ClassFlags_V4_XList \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ - X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Reference) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_ExprLoc) \ - X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngListPtr) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) \ - X(Signature, DW_AttribClass_Reference) \ - X(MainSubProgram, DW_AttribClass_Flag) \ - X(DataBitOffset, DW_AttribClass_Const) \ - X(ConstExpr, DW_AttribClass_Flag) \ - X(EnumClass, DW_AttribClass_Flag) \ - X(LinkageName, DW_AttribClass_String) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ +X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Reference) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_ExprLoc) \ +X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngListPtr) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) \ +X(Signature, DW_AttribClass_Reference) \ +X(MainSubProgram, DW_AttribClass_Flag) \ +X(DataBitOffset, DW_AttribClass_Const) \ +X(ConstExpr, DW_AttribClass_Flag) \ +X(EnumClass, DW_AttribClass_Flag) \ +X(LinkageName, DW_AttribClass_String) //- Attributes DWARF5 #define DW_AttribKind_V5_XList \ - X(StringLengthBitSize, 0x6f) \ - X(StringLengthByteSize, 0x70) \ - X(Rank, 0x71) \ - X(StrOffsetsBase, 0x72) \ - X(AddrBase, 0x73) \ - X(RngListsBase, 0x74) \ - X(DwoName, 0x76) \ - X(Reference, 0x77) \ - X(RValueReference, 0x78) \ - X(Macros, 0x79) \ - X(CallAllCalls, 0x7a) \ - X(CallAllSourceCalls, 0x7b) \ - X(CallAllTailCalls, 0x7c) \ - X(CallReturnPc, 0x7d) \ - X(CallValue, 0x7e) \ - X(CallOrigin, 0x7f) \ - X(CallParameter, 0x80) \ - X(CallPc, 0x81) \ - X(CallTailCall, 0x82) \ - X(CallTarget, 0x83) \ - X(CallTargetClobbered, 0x84) \ - X(CallDataLocation, 0x85) \ - X(CallDataValue, 0x86) \ - X(NoReturn, 0x87) \ - X(Alignment, 0x88) \ - X(ExportSymbols, 0x89) \ - X(Deleted, 0x8a) \ - X(Defaulted, 0x8b) \ - X(LocListsBase, 0x8c) +X(StringLengthBitSize, 0x6f) \ +X(StringLengthByteSize, 0x70) \ +X(Rank, 0x71) \ +X(StrOffsetsBase, 0x72) \ +X(AddrBase, 0x73) \ +X(RngListsBase, 0x74) \ +X(DwoName, 0x76) \ +X(Reference, 0x77) \ +X(RValueReference, 0x78) \ +X(Macros, 0x79) \ +X(CallAllCalls, 0x7a) \ +X(CallAllSourceCalls, 0x7b) \ +X(CallAllTailCalls, 0x7c) \ +X(CallReturnPc, 0x7d) \ +X(CallValue, 0x7e) \ +X(CallOrigin, 0x7f) \ +X(CallParameter, 0x80) \ +X(CallPc, 0x81) \ +X(CallTailCall, 0x82) \ +X(CallTarget, 0x83) \ +X(CallTargetClobbered, 0x84) \ +X(CallDataLocation, 0x85) \ +X(CallDataValue, 0x86) \ +X(NoReturn, 0x87) \ +X(Alignment, 0x88) \ +X(ExportSymbols, 0x89) \ +X(Deleted, 0x8a) \ +X(Defaulted, 0x8b) \ +X(LocListsBase, 0x8c) #define DW_AttribKind_ClassFlags_V5_XList \ - X(Sibling, DW_AttribClass_Reference) \ - X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(Name, DW_AttribClass_String) \ - X(Ordering, DW_AttribClass_Const) \ - X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(StmtList, DW_AttribClass_LinePtr) \ - X(LowPc, DW_AttribClass_Address) \ - X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(Language, DW_AttribClass_Const) \ - X(Discr, DW_AttribClass_Reference) \ - X(DiscrValue, DW_AttribClass_Const) \ - X(Visibility, DW_AttribClass_Const) \ - X(Import, DW_AttribClass_Reference) \ - X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(CommonReference, DW_AttribClass_Reference) \ - X(CompDir, DW_AttribClass_String) \ - X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ - X(ContainingType, DW_AttribClass_Reference) \ - X(DefaultValue, DW_AttribClass_Reference) \ - X(Inline, DW_AttribClass_Const) \ - X(IsOptional, DW_AttribClass_Flag) \ - X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Producer, DW_AttribClass_String) \ - X(Prototyped, DW_AttribClass_Flag) \ - X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ - X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ - X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(AbstractOrigin, DW_AttribClass_Reference) \ - X(Accessibility, DW_AttribClass_Const) \ - X(AddressClass, DW_AttribClass_Const) \ - X(Artificial, DW_AttribClass_Flag) \ - X(BaseTypes, DW_AttribClass_Reference) \ - X(CallingConvention, DW_AttribClass_Const) \ - X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(DeclColumn, DW_AttribClass_Const) \ - X(DeclFile, DW_AttribClass_Const) \ - X(DeclLine, DW_AttribClass_Const) \ - X(Declaration, DW_AttribClass_Flag) \ - X(DiscrList, DW_AttribClass_Block) \ - X(Encoding, DW_AttribClass_Const) \ - X(External, DW_AttribClass_Flag) \ - X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Friend, DW_AttribClass_Reference) \ - X(IdentifierCase, DW_AttribClass_Const) \ - X(MacroInfo, DW_AttribClass_MacPtr) \ - X(NameListItem, DW_AttribClass_Reference) \ - X(Priority, DW_AttribClass_Reference) \ - X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Specification, DW_AttribClass_Reference) \ - X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Type, DW_AttribClass_Reference) \ - X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(VariableParameter, DW_AttribClass_Flag) \ - X(Virtuality, DW_AttribClass_Const) \ - X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ - X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(DataLocation, DW_AttribClass_ExprLoc) \ - X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ - X(EntryPc, DW_AttribClass_Address|DW_AttribClass_Const) \ - X(UseUtf8, DW_AttribClass_Flag) \ - X(Extension, DW_AttribClass_Reference) \ - X(Ranges, DW_AttribClass_RngList) \ - X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ - X(CallColumn, DW_AttribClass_Const) \ - X(CallFile, DW_AttribClass_Const) \ - X(CallLine, DW_AttribClass_Const) \ - X(Description, DW_AttribClass_String) \ - X(BinaryScale, DW_AttribClass_Const) \ - X(DecimalScale, DW_AttribClass_Const) \ - X(Small, DW_AttribClass_Reference) \ - X(DecimalSign, DW_AttribClass_Const) \ - X(DigitCount, DW_AttribClass_Const) \ - X(PictureString, DW_AttribClass_String) \ - X(Mutable, DW_AttribClass_Flag) \ - X(ThreadsScaled, DW_AttribClass_Flag) \ - X(Explicit, DW_AttribClass_Flag) \ - X(ObjectPointer, DW_AttribClass_Reference) \ - X(Endianity, DW_AttribClass_Const) \ - X(Elemental, DW_AttribClass_Flag) \ - X(Pure, DW_AttribClass_Flag) \ - X(Recursive, DW_AttribClass_Flag) \ - X(Signature, DW_AttribClass_Reference) \ - X(MainSubProgram, DW_AttribClass_Flag) \ - X(DataBitOffset, DW_AttribClass_Const) \ - X(ConstExpr, DW_AttribClass_Flag) \ - X(EnumClass, DW_AttribClass_Flag) \ - X(LinkageName, DW_AttribClass_String) \ - X(StringLengthBitSize, DW_AttribClass_Const) \ - X(StringLengthByteSize, DW_AttribClass_Const) \ - X(Rank, DW_AttribClass_Const|DW_AttribClass_ExprLoc) \ - X(StrOffsetsBase, DW_AttribClass_StrOffsetsPtr) \ - X(AddrBase, DW_AttribClass_AddrPtr) \ - X(RngListsBase, DW_AttribClass_RngListPtr) \ - X(DwoName, DW_AttribClass_String) \ - X(Reference, DW_AttribClass_Flag) \ - X(RValueReference, DW_AttribClass_Flag) \ - X(Macros, DW_AttribClass_MacPtr) \ - X(CallAllCalls, DW_AttribClass_Flag) \ - X(CallAllSourceCalls, DW_AttribClass_Flag) \ - X(CallAllTailCalls, DW_AttribClass_Flag) \ - X(CallReturnPc, DW_AttribClass_Address) \ - X(CallValue, DW_AttribClass_ExprLoc) \ - X(CallOrigin, DW_AttribClass_ExprLoc) \ - X(CallParameter, DW_AttribClass_Reference) \ - X(CallPc, DW_AttribClass_Address) \ - X(CallTailCall, DW_AttribClass_Flag) \ - X(CallTarget, DW_AttribClass_ExprLoc) \ - X(CallTargetClobbered, DW_AttribClass_ExprLoc) \ - X(CallDataLocation, DW_AttribClass_ExprLoc) \ - X(CallDataValue, DW_AttribClass_ExprLoc) \ - X(NoReturn, DW_AttribClass_Flag) \ - X(Alignment, DW_AttribClass_Const) \ - X(ExportSymbols, DW_AttribClass_Flag) \ - X(Deleted, DW_AttribClass_Flag) \ - X(Defaulted, DW_AttribClass_Const) \ - X(LocListsBase, DW_AttribClass_LocListPtr) +X(Sibling, DW_AttribClass_Reference) \ +X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(Name, DW_AttribClass_String) \ +X(Ordering, DW_AttribClass_Const) \ +X(ByteSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitOffset, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(BitSize, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(StmtList, DW_AttribClass_LinePtr) \ +X(LowPc, DW_AttribClass_Address) \ +X(HighPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(Language, DW_AttribClass_Const) \ +X(Discr, DW_AttribClass_Reference) \ +X(DiscrValue, DW_AttribClass_Const) \ +X(Visibility, DW_AttribClass_Const) \ +X(Import, DW_AttribClass_Reference) \ +X(StringLength, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(CommonReference, DW_AttribClass_Reference) \ +X(CompDir, DW_AttribClass_String) \ +X(ConstValue, DW_AttribClass_Block|DW_AttribClass_Const|DW_AttribClass_String) \ +X(ContainingType, DW_AttribClass_Reference) \ +X(DefaultValue, DW_AttribClass_Reference) \ +X(Inline, DW_AttribClass_Const) \ +X(IsOptional, DW_AttribClass_Flag) \ +X(LowerBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Producer, DW_AttribClass_String) \ +X(Prototyped, DW_AttribClass_Flag) \ +X(ReturnAddr, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ +X(StartScope, DW_AttribClass_Const|DW_AttribClass_RngListPtr) \ +X(BitStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(UpperBound, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(AbstractOrigin, DW_AttribClass_Reference) \ +X(Accessibility, DW_AttribClass_Const) \ +X(AddressClass, DW_AttribClass_Const) \ +X(Artificial, DW_AttribClass_Flag) \ +X(BaseTypes, DW_AttribClass_Reference) \ +X(CallingConvention, DW_AttribClass_Const) \ +X(Count, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataMemberLocation, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(DeclColumn, DW_AttribClass_Const) \ +X(DeclFile, DW_AttribClass_Const) \ +X(DeclLine, DW_AttribClass_Const) \ +X(Declaration, DW_AttribClass_Flag) \ +X(DiscrList, DW_AttribClass_Block) \ +X(Encoding, DW_AttribClass_Const) \ +X(External, DW_AttribClass_Flag) \ +X(FrameBase, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Friend, DW_AttribClass_Reference) \ +X(IdentifierCase, DW_AttribClass_Const) \ +X(MacroInfo, DW_AttribClass_MacPtr) \ +X(NameListItem, DW_AttribClass_Reference) \ +X(Priority, DW_AttribClass_Reference) \ +X(Segment, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Specification, DW_AttribClass_Reference) \ +X(StaticLink, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Type, DW_AttribClass_Reference) \ +X(UseLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(VariableParameter, DW_AttribClass_Flag) \ +X(Virtuality, DW_AttribClass_Const) \ +X(VTableElemLocation, DW_AttribClass_ExprLoc|DW_AttribClass_LocList) \ +X(Allocated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(Associated, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(DataLocation, DW_AttribClass_ExprLoc) \ +X(ByteStride, DW_AttribClass_Const|DW_AttribClass_ExprLoc|DW_AttribClass_Reference) \ +X(EntryPc, DW_AttribClass_Address|DW_AttribClass_Const) \ +X(UseUtf8, DW_AttribClass_Flag) \ +X(Extension, DW_AttribClass_Reference) \ +X(Ranges, DW_AttribClass_RngList) \ +X(Trampoline, DW_AttribClass_Address|DW_AttribClass_Flag|DW_AttribClass_Reference|DW_AttribClass_String) \ +X(CallColumn, DW_AttribClass_Const) \ +X(CallFile, DW_AttribClass_Const) \ +X(CallLine, DW_AttribClass_Const) \ +X(Description, DW_AttribClass_String) \ +X(BinaryScale, DW_AttribClass_Const) \ +X(DecimalScale, DW_AttribClass_Const) \ +X(Small, DW_AttribClass_Reference) \ +X(DecimalSign, DW_AttribClass_Const) \ +X(DigitCount, DW_AttribClass_Const) \ +X(PictureString, DW_AttribClass_String) \ +X(Mutable, DW_AttribClass_Flag) \ +X(ThreadsScaled, DW_AttribClass_Flag) \ +X(Explicit, DW_AttribClass_Flag) \ +X(ObjectPointer, DW_AttribClass_Reference) \ +X(Endianity, DW_AttribClass_Const) \ +X(Elemental, DW_AttribClass_Flag) \ +X(Pure, DW_AttribClass_Flag) \ +X(Recursive, DW_AttribClass_Flag) \ +X(Signature, DW_AttribClass_Reference) \ +X(MainSubProgram, DW_AttribClass_Flag) \ +X(DataBitOffset, DW_AttribClass_Const) \ +X(ConstExpr, DW_AttribClass_Flag) \ +X(EnumClass, DW_AttribClass_Flag) \ +X(LinkageName, DW_AttribClass_String) \ +X(StringLengthBitSize, DW_AttribClass_Const) \ +X(StringLengthByteSize, DW_AttribClass_Const) \ +X(Rank, DW_AttribClass_Const|DW_AttribClass_ExprLoc) \ +X(StrOffsetsBase, DW_AttribClass_StrOffsetsPtr) \ +X(AddrBase, DW_AttribClass_AddrPtr) \ +X(RngListsBase, DW_AttribClass_RngListPtr) \ +X(DwoName, DW_AttribClass_String) \ +X(Reference, DW_AttribClass_Flag) \ +X(RValueReference, DW_AttribClass_Flag) \ +X(Macros, DW_AttribClass_MacPtr) \ +X(CallAllCalls, DW_AttribClass_Flag) \ +X(CallAllSourceCalls, DW_AttribClass_Flag) \ +X(CallAllTailCalls, DW_AttribClass_Flag) \ +X(CallReturnPc, DW_AttribClass_Address) \ +X(CallValue, DW_AttribClass_ExprLoc) \ +X(CallOrigin, DW_AttribClass_ExprLoc) \ +X(CallParameter, DW_AttribClass_Reference) \ +X(CallPc, DW_AttribClass_Address) \ +X(CallTailCall, DW_AttribClass_Flag) \ +X(CallTarget, DW_AttribClass_ExprLoc) \ +X(CallTargetClobbered, DW_AttribClass_ExprLoc) \ +X(CallDataLocation, DW_AttribClass_ExprLoc) \ +X(CallDataValue, DW_AttribClass_ExprLoc) \ +X(NoReturn, DW_AttribClass_Flag) \ +X(Alignment, DW_AttribClass_Const) \ +X(ExportSymbols, DW_AttribClass_Flag) \ +X(Deleted, DW_AttribClass_Flag) \ +X(Defaulted, DW_AttribClass_Const) \ +X(LocListsBase, DW_AttribClass_LocListPtr) //- Attributes GNU #define DW_AttribKind_GNU_XList \ - X(GNU_Vector, 0x2107) \ - X(GNU_GuardedBy, 0x2108) \ - X(GNU_PtGuardedBy, 0x2109) \ - X(GNU_Guarded, 0x210a) \ - X(GNU_PtGuarded, 0x210b) \ - X(GNU_LocksExcluded, 0x210c) \ - X(GNU_ExclusiveLocksRequired, 0x210d) \ - X(GNU_SharedLocksRequired, 0x210e) \ - X(GNU_OdrSignature, 0x210f) \ - X(GNU_TemplateName, 0x2110) \ - X(GNU_CallSiteValue, 0x2111) \ - X(GNU_CallSiteDataValue, 0x2112) \ - X(GNU_CallSiteTarget, 0x2113) \ - X(GNU_CallSiteTargetClobbered, 0x2114) \ - X(GNU_TailCall, 0x2115) \ - X(GNU_AllTailCallsSites, 0x2116) \ - X(GNU_AllCallSites, 0x2117) \ - X(GNU_AllSourceCallSites, 0x2118) \ - X(GNU_Macros, 0x2119) \ - X(GNU_Deleted, 0x211a) \ - X(GNU_DwoName, 0x2130) \ - X(GNU_DwoId, 0x2131) \ - X(GNU_RangesBase, 0x2132) \ - X(GNU_AddrBase, 0x2133) \ - X(GNU_PubNames, 0x2134) \ - X(GNU_PubTypes, 0x2135) \ - X(GNU_Discriminator, 0x2136) \ - X(GNU_LocViews, 0x2137) \ - X(GNU_EntryView, 0x2138) \ - X(GNU_DescriptiveType, 0x2302) \ - X(GNU_Numerator, 0x2303) \ - X(GNU_Denominator, 0x2304) \ - X(GNU_Bias, 0x2305) +X(GNU_Vector, 0x2107) \ +X(GNU_GuardedBy, 0x2108) \ +X(GNU_PtGuardedBy, 0x2109) \ +X(GNU_Guarded, 0x210a) \ +X(GNU_PtGuarded, 0x210b) \ +X(GNU_LocksExcluded, 0x210c) \ +X(GNU_ExclusiveLocksRequired, 0x210d) \ +X(GNU_SharedLocksRequired, 0x210e) \ +X(GNU_OdrSignature, 0x210f) \ +X(GNU_TemplateName, 0x2110) \ +X(GNU_CallSiteValue, 0x2111) \ +X(GNU_CallSiteDataValue, 0x2112) \ +X(GNU_CallSiteTarget, 0x2113) \ +X(GNU_CallSiteTargetClobbered, 0x2114) \ +X(GNU_TailCall, 0x2115) \ +X(GNU_AllTailCallsSites, 0x2116) \ +X(GNU_AllCallSites, 0x2117) \ +X(GNU_AllSourceCallSites, 0x2118) \ +X(GNU_Macros, 0x2119) \ +X(GNU_Deleted, 0x211a) \ +X(GNU_DwoName, 0x2130) \ +X(GNU_DwoId, 0x2131) \ +X(GNU_RangesBase, 0x2132) \ +X(GNU_AddrBase, 0x2133) \ +X(GNU_PubNames, 0x2134) \ +X(GNU_PubTypes, 0x2135) \ +X(GNU_Discriminator, 0x2136) \ +X(GNU_LocViews, 0x2137) \ +X(GNU_EntryView, 0x2138) \ +X(GNU_DescriptiveType, 0x2302) \ +X(GNU_Numerator, 0x2303) \ +X(GNU_Denominator, 0x2304) \ +X(GNU_Bias, 0x2305) #define DW_AttribKind_ClassFlags_GNU_XList \ - X(GNU_Vector, DW_AttribClass_Flag) \ - X(GNU_GuardedBy, DW_AttribClass_Undefined) \ - X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \ - X(GNU_Guarded, DW_AttribClass_Undefined) \ - X(GNU_PtGuarded, DW_AttribClass_Undefined) \ - X(GNU_LocksExcluded, DW_AttribClass_Undefined) \ - X(GNU_ExclusiveLocksRequired, DW_AttribClass_Undefined) \ - X(GNU_SharedLocksRequired, DW_AttribClass_Undefined) \ - X(GNU_OdrSignature, DW_AttribClass_Undefined) \ - X(GNU_TemplateName, DW_AttribClass_Undefined) \ - X(GNU_CallSiteValue, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteDataValue, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteTarget, DW_AttribClass_ExprLoc) \ - X(GNU_CallSiteTargetClobbered, DW_AttribClass_ExprLoc) \ - X(GNU_TailCall, DW_AttribClass_Flag) \ - X(GNU_AllTailCallsSites, DW_AttribClass_Flag) \ - X(GNU_AllCallSites, DW_AttribClass_Flag) \ - X(GNU_AllSourceCallSites, DW_AttribClass_Flag) \ - X(GNU_Macros, DW_AttribClass_Flag) \ - X(GNU_Deleted, DW_AttribClass_Undefined) \ - X(GNU_DwoName, DW_AttribClass_String) \ - X(GNU_DwoId, DW_AttribClass_Const) \ - X(GNU_RangesBase, DW_AttribClass_Undefined) \ - X(GNU_AddrBase, DW_AttribClass_AddrPtr) \ - X(GNU_PubNames, DW_AttribClass_Flag) \ - X(GNU_PubTypes, DW_AttribClass_Undefined) \ - X(GNU_Discriminator, DW_AttribClass_Const) \ - X(GNU_LocViews, DW_AttribClass_LocListPtr) \ - X(GNU_EntryView, DW_AttribClass_Undefined) \ - X(GNU_DescriptiveType, DW_AttribClass_Undefined) \ - X(GNU_Numerator, DW_AttribClass_Undefined) \ - X(GNU_Denominator, DW_AttribClass_Undefined) \ - X(GNU_Bias, DW_AttribClass_Undefined) +X(GNU_Vector, DW_AttribClass_Flag) \ +X(GNU_GuardedBy, DW_AttribClass_Undefined) \ +X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \ +X(GNU_Guarded, DW_AttribClass_Undefined) \ +X(GNU_PtGuarded, DW_AttribClass_Undefined) \ +X(GNU_LocksExcluded, DW_AttribClass_Undefined) \ +X(GNU_ExclusiveLocksRequired, DW_AttribClass_Undefined) \ +X(GNU_SharedLocksRequired, DW_AttribClass_Undefined) \ +X(GNU_OdrSignature, DW_AttribClass_Undefined) \ +X(GNU_TemplateName, DW_AttribClass_Undefined) \ +X(GNU_CallSiteValue, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteDataValue, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteTarget, DW_AttribClass_ExprLoc) \ +X(GNU_CallSiteTargetClobbered, DW_AttribClass_ExprLoc) \ +X(GNU_TailCall, DW_AttribClass_Flag) \ +X(GNU_AllTailCallsSites, DW_AttribClass_Flag) \ +X(GNU_AllCallSites, DW_AttribClass_Flag) \ +X(GNU_AllSourceCallSites, DW_AttribClass_Flag) \ +X(GNU_Macros, DW_AttribClass_Flag) \ +X(GNU_Deleted, DW_AttribClass_Undefined) \ +X(GNU_DwoName, DW_AttribClass_String) \ +X(GNU_DwoId, DW_AttribClass_Const) \ +X(GNU_RangesBase, DW_AttribClass_Undefined) \ +X(GNU_AddrBase, DW_AttribClass_AddrPtr) \ +X(GNU_PubNames, DW_AttribClass_Flag) \ +X(GNU_PubTypes, DW_AttribClass_Undefined) \ +X(GNU_Discriminator, DW_AttribClass_Const) \ +X(GNU_LocViews, DW_AttribClass_LocListPtr) \ +X(GNU_EntryView, DW_AttribClass_Undefined) \ +X(GNU_DescriptiveType, DW_AttribClass_Undefined) \ +X(GNU_Numerator, DW_AttribClass_Undefined) \ +X(GNU_Denominator, DW_AttribClass_Undefined) \ +X(GNU_Bias, DW_AttribClass_Undefined) //- Attributes LLVM #define DW_AttribKind_LLVM_XList \ - X(LLVM_IncludePath, 0x3e00) \ - X(LLVM_ConfigMacros, 0x3e01) \ - X(LLVM_SysRoot, 0x3e02) \ - X(LLVM_TagOffset, 0x3e03) \ - X(LLVM_ApiNotes, 0x3e07) +X(LLVM_IncludePath, 0x3e00) \ +X(LLVM_ConfigMacros, 0x3e01) \ +X(LLVM_SysRoot, 0x3e02) \ +X(LLVM_TagOffset, 0x3e03) \ +X(LLVM_ApiNotes, 0x3e07) #define DW_AttribKind_ClassFlags_LLVM_XList \ - X(LLVM_IncludePath, DW_AttribClass_String) \ - X(LLVM_ConfigMacros, DW_AttribClass_String) \ - X(LLVM_SysRoot, DW_AttribClass_String) \ - X(LLVM_TagOffset, DW_AttribClass_Undefined) \ - X(LLVM_ApiNotes, DW_AttribClass_String) +X(LLVM_IncludePath, DW_AttribClass_String) \ +X(LLVM_ConfigMacros, DW_AttribClass_String) \ +X(LLVM_SysRoot, DW_AttribClass_String) \ +X(LLVM_TagOffset, DW_AttribClass_Undefined) \ +X(LLVM_ApiNotes, DW_AttribClass_String) //- Attributes Apple #define DW_AttribKind_APPLE_XList \ - X(APPLE_Optimized, 0x3fe1) \ - X(APPLE_Flags, 0x3fe2) \ - X(APPLE_Isa, 0x3fe3) \ - X(APPLE_Block, 0x3fe4) \ - X(APPLE_MajorRuntimeVers, 0x3fe5) \ - X(APPLE_RuntimeClass, 0x3fe6) \ - X(APPLE_OmitFramePtr, 0x3fe7) \ - X(APPLE_PropertyName, 0x3fe8) \ - X(APPLE_PropertyGetter, 0x3fe9) \ - X(APPLE_PropertySetter, 0x3fea) \ - X(APPLE_PropertyAttribute, 0x3feb) \ - X(APPLE_ObjcCompleteType, 0x3fec) \ - X(APPLE_Property, 0x3fed) \ - X(APPLE_ObjDirect, 0x3fee) \ - X(APPLE_Sdk, 0x3fef) +X(APPLE_Optimized, 0x3fe1) \ +X(APPLE_Flags, 0x3fe2) \ +X(APPLE_Isa, 0x3fe3) \ +X(APPLE_Block, 0x3fe4) \ +X(APPLE_MajorRuntimeVers, 0x3fe5) \ +X(APPLE_RuntimeClass, 0x3fe6) \ +X(APPLE_OmitFramePtr, 0x3fe7) \ +X(APPLE_PropertyName, 0x3fe8) \ +X(APPLE_PropertyGetter, 0x3fe9) \ +X(APPLE_PropertySetter, 0x3fea) \ +X(APPLE_PropertyAttribute, 0x3feb) \ +X(APPLE_ObjcCompleteType, 0x3fec) \ +X(APPLE_Property, 0x3fed) \ +X(APPLE_ObjDirect, 0x3fee) \ +X(APPLE_Sdk, 0x3fef) #define DW_AttribKind_ClassFlags_APPLE_XList \ - X(APPLE_Optimized, DW_AttribClass_Flag) \ - X(APPLE_Flags, DW_AttribClass_Flag) \ - X(APPLE_Isa, DW_AttribClass_Flag) \ - X(APPLE_Block, DW_AttribClass_Undefined) \ - X(APPLE_MajorRuntimeVers, DW_AttribClass_Undefined) \ - X(APPLE_RuntimeClass, DW_AttribClass_Undefined) \ - X(APPLE_OmitFramePtr, DW_AttribClass_Flag) \ - X(APPLE_PropertyName, DW_AttribClass_Undefined) \ - X(APPLE_PropertyGetter, DW_AttribClass_Undefined) \ - X(APPLE_PropertySetter, DW_AttribClass_Undefined) \ - X(APPLE_PropertyAttribute, DW_AttribClass_Undefined) \ - X(APPLE_ObjcCompleteType, DW_AttribClass_Undefined) \ - X(APPLE_Property, DW_AttribClass_Undefined) \ - X(APPLE_ObjDirect, DW_AttribClass_Undefined) \ - X(APPLE_Sdk, DW_AttribClass_String) +X(APPLE_Optimized, DW_AttribClass_Flag) \ +X(APPLE_Flags, DW_AttribClass_Flag) \ +X(APPLE_Isa, DW_AttribClass_Flag) \ +X(APPLE_Block, DW_AttribClass_Undefined) \ +X(APPLE_MajorRuntimeVers, DW_AttribClass_Undefined) \ +X(APPLE_RuntimeClass, DW_AttribClass_Undefined) \ +X(APPLE_OmitFramePtr, DW_AttribClass_Flag) \ +X(APPLE_PropertyName, DW_AttribClass_Undefined) \ +X(APPLE_PropertyGetter, DW_AttribClass_Undefined) \ +X(APPLE_PropertySetter, DW_AttribClass_Undefined) \ +X(APPLE_PropertyAttribute, DW_AttribClass_Undefined) \ +X(APPLE_ObjcCompleteType, DW_AttribClass_Undefined) \ +X(APPLE_Property, DW_AttribClass_Undefined) \ +X(APPLE_ObjDirect, DW_AttribClass_Undefined) \ +X(APPLE_Sdk, DW_AttribClass_String) //- Attributes MIPS #define DW_AttribKind_MIPS_XList \ - X(MIPS_Fde, 0x2001) \ - X(MIPS_LoopBegin, 0x2002) \ - X(MIPS_TailLoopBegin, 0x2003) \ - X(MIPS_EpilogBegin, 0x2004) \ - X(MIPS_LoopUnrollFactor, 0x2005) \ - X(MIPS_SoftwarePipelineDepth, 0x2006) \ - X(MIPS_LinkageName, 0x2007) \ - X(MIPS_Stride, 0x2008) \ - X(MIPS_AbstractName, 0x2009) \ - X(MIPS_CloneOrigin, 0x200a) \ - X(MIPS_HasInlines, 0x200b) \ - X(MIPS_StrideByte, 0x200c) \ - X(MIPS_StrideElem, 0x200d) \ - X(MIPS_PtrDopeType, 0x200e) \ - X(MIPS_AllocatableDopeType, 0x200f) \ - X(MIPS_AssumedShapeDopeType, 0x2010) \ - X(MIPS_AssumedSize, 0x2011) +X(MIPS_Fde, 0x2001) \ +X(MIPS_LoopBegin, 0x2002) \ +X(MIPS_TailLoopBegin, 0x2003) \ +X(MIPS_EpilogBegin, 0x2004) \ +X(MIPS_LoopUnrollFactor, 0x2005) \ +X(MIPS_SoftwarePipelineDepth, 0x2006) \ +X(MIPS_LinkageName, 0x2007) \ +X(MIPS_Stride, 0x2008) \ +X(MIPS_AbstractName, 0x2009) \ +X(MIPS_CloneOrigin, 0x200a) \ +X(MIPS_HasInlines, 0x200b) \ +X(MIPS_StrideByte, 0x200c) \ +X(MIPS_StrideElem, 0x200d) \ +X(MIPS_PtrDopeType, 0x200e) \ +X(MIPS_AllocatableDopeType, 0x200f) \ +X(MIPS_AssumedShapeDopeType, 0x2010) \ +X(MIPS_AssumedSize, 0x2011) #define DW_AttribKind_ClassFlags_MIPS_XList \ - X(MIPS_Fde, DW_AttribClass_Block) \ - X(MIPS_LoopBegin, DW_AttribClass_Block) \ - X(MIPS_TailLoopBegin, DW_AttribClass_Block) \ - X(MIPS_EpilogBegin, DW_AttribClass_Block) \ - X(MIPS_LoopUnrollFactor, DW_AttribClass_Block) \ - X(MIPS_SoftwarePipelineDepth, DW_AttribClass_Block) \ - X(MIPS_LinkageName, DW_AttribClass_String) \ - X(MIPS_Stride, DW_AttribClass_Block) \ - X(MIPS_AbstractName, DW_AttribClass_String) \ - X(MIPS_CloneOrigin, DW_AttribClass_String) \ - X(MIPS_HasInlines, DW_AttribClass_Reference) \ - X(MIPS_StrideByte, DW_AttribClass_Reference) \ - X(MIPS_StrideElem, DW_AttribClass_Reference) \ - X(MIPS_PtrDopeType, DW_AttribClass_Reference) \ - X(MIPS_AllocatableDopeType, DW_AttribClass_Reference) \ - X(MIPS_AssumedShapeDopeType, DW_AttribClass_Reference) \ - X(MIPS_AssumedSize, DW_AttribClass_Reference) +X(MIPS_Fde, DW_AttribClass_Block) \ +X(MIPS_LoopBegin, DW_AttribClass_Block) \ +X(MIPS_TailLoopBegin, DW_AttribClass_Block) \ +X(MIPS_EpilogBegin, DW_AttribClass_Block) \ +X(MIPS_LoopUnrollFactor, DW_AttribClass_Block) \ +X(MIPS_SoftwarePipelineDepth, DW_AttribClass_Block) \ +X(MIPS_LinkageName, DW_AttribClass_String) \ +X(MIPS_Stride, DW_AttribClass_Block) \ +X(MIPS_AbstractName, DW_AttribClass_String) \ +X(MIPS_CloneOrigin, DW_AttribClass_String) \ +X(MIPS_HasInlines, DW_AttribClass_Reference) \ +X(MIPS_StrideByte, DW_AttribClass_Reference) \ +X(MIPS_StrideElem, DW_AttribClass_Reference) \ +X(MIPS_PtrDopeType, DW_AttribClass_Reference) \ +X(MIPS_AllocatableDopeType, DW_AttribClass_Reference) \ +X(MIPS_AssumedShapeDopeType, DW_AttribClass_Reference) \ +X(MIPS_AssumedSize, DW_AttribClass_Reference) typedef U32 DW_AttribKind; typedef enum DW_AttribKindEnum @@ -1202,38 +1202,38 @@ typedef enum DW_AttribKindEnum DW_AttribKind_Null, #define X(_N,_ID,...) DW_AttribKind_##_N = _ID, DW_AttribKind_V2_XList - DW_AttribKind_V3_XList - DW_AttribKind_V4_XList - DW_AttribKind_V5_XList - DW_AttribKind_GNU_XList - DW_AttribKind_LLVM_XList - DW_AttribKind_APPLE_XList - DW_AttribKind_MIPS_XList + DW_AttribKind_V3_XList + DW_AttribKind_V4_XList + DW_AttribKind_V5_XList + DW_AttribKind_GNU_XList + DW_AttribKind_LLVM_XList + DW_AttribKind_APPLE_XList + DW_AttribKind_MIPS_XList #undef X DW_AttribKind_UserLo = 0x2000, DW_AttribKind_UserHi = 0x3fff } DW_AttribKindEnum; #define DW_ATE_XList \ - X(Null, 0x00) \ - X(Address, 0x01) \ - X(Boolean, 0x02) \ - X(ComplexFloat, 0x03) \ - X(Float, 0x04) \ - X(Signed, 0x05) \ - X(SignedChar, 0x06) \ - X(Unsigned, 0x07) \ - X(UnsignedChar, 0x08) \ - X(ImaginaryFloat, 0x09) \ - X(PackedDecimal, 0x0A) \ - X(NumericString, 0x0B) \ - X(Edited, 0x0C) \ - X(SignedFixed, 0x0D) \ - X(UnsignedFixed, 0x0E) \ - X(DecimalFloat, 0x0F) \ - X(Utf, 0x10) \ - X(Ucs, 0x11) \ - X(Ascii, 0x12) +X(Null, 0x00) \ +X(Address, 0x01) \ +X(Boolean, 0x02) \ +X(ComplexFloat, 0x03) \ +X(Float, 0x04) \ +X(Signed, 0x05) \ +X(SignedChar, 0x06) \ +X(Unsigned, 0x07) \ +X(UnsignedChar, 0x08) \ +X(ImaginaryFloat, 0x09) \ +X(PackedDecimal, 0x0A) \ +X(NumericString, 0x0B) \ +X(Edited, 0x0C) \ +X(SignedFixed, 0x0D) \ +X(UnsignedFixed, 0x0E) \ +X(DecimalFloat, 0x0F) \ +X(Utf, 0x10) \ +X(Ucs, 0x11) \ +X(Ascii, 0x12) typedef U64 DW_ATE; typedef enum DW_ATEEnum @@ -1244,11 +1244,11 @@ typedef enum DW_ATEEnum } DW_ATEnum; #define DW_CallingConventionKind_XList \ - X(Normal, 0x0) \ - X(Program, 0x1) \ - X(NoCall, 0x3) \ - X(PassByValue, 0x4) \ - X(PassByReference, 0x5) +X(Normal, 0x0) \ +X(Program, 0x1) \ +X(NoCall, 0x3) \ +X(PassByValue, 0x4) \ +X(PassByReference, 0x5) typedef U64 DW_CallingConventionKind; typedef enum DW_CallingConventionKindEnum @@ -1259,9 +1259,9 @@ typedef enum DW_CallingConventionKindEnum } DW_CallingConventionKindEnum; #define DW_AccessKind_XList \ - X(Public, 0x00) \ - X(Private, 0x01) \ - X(Protected, 0x02) +X(Public, 0x00) \ +X(Private, 0x01) \ +X(Protected, 0x02) typedef U64 DW_AccessKind; typedef enum DW_AccessKindEnum @@ -1272,9 +1272,9 @@ typedef enum DW_AccessKindEnum } DW_AccessKindEnum; #define DW_VirtualityKind_XList \ - X(None, 0x00) \ - X(Virtual, 0x01) \ - X(PureVirtual, 0x02) +X(None, 0x00) \ +X(Virtual, 0x01) \ +X(PureVirtual, 0x02) typedef U64 DW_VirtualityKind; typedef enum DW_VirtualityEnum @@ -1285,14 +1285,14 @@ typedef enum DW_VirtualityEnum } DW_VirtualityEnum; #define DW_RngListEntryKind \ - X(EndOfList, 0x00) \ - X(BaseAddressx, 0x01) \ - X(StartxEndx, 0x02) \ - X(StartxLength, 0x03) \ - X(OffsetPair, 0x04) \ - X(BaseAddress, 0x05) \ - X(StartEnd, 0x06) \ - X(StartLength, 0x07) +X(EndOfList, 0x00) \ +X(BaseAddressx, 0x01) \ +X(StartxEndx, 0x02) \ +X(StartxLength, 0x03) \ +X(OffsetPair, 0x04) \ +X(BaseAddress, 0x05) \ +X(StartEnd, 0x06) \ +X(StartLength, 0x07) typedef U8 DW_RLE; typedef enum DW_RLE_Enum @@ -1303,15 +1303,15 @@ typedef enum DW_RLE_Enum } DW_RLE_Enum; #define DW_LocListEntry_XList \ - X(EndOfList, 0x00) \ - X(BaseAddressx, 0x01) \ - X(StartxEndx, 0x02) \ - X(StartxLength, 0x03) \ - X(OffsetPair, 0x04) \ - X(DefaultLocation, 0x05) \ - X(BaseAddress, 0x06) \ - X(StartEnd, 0x07) \ - X(StartLength, 0x08) +X(EndOfList, 0x00) \ +X(BaseAddressx, 0x01) \ +X(StartxEndx, 0x02) \ +X(StartxLength, 0x03) \ +X(OffsetPair, 0x04) \ +X(DefaultLocation, 0x05) \ +X(BaseAddress, 0x06) \ +X(StartEnd, 0x07) \ +X(StartLength, 0x08) #define DW_LocListEntry_GNU_XList(X) \ X(GNU_ViewPair, 0x9) @@ -1325,12 +1325,12 @@ typedef enum DW_LLE_Enum } DW_LLEEnum; #define DW_AddrClass_XList \ - X(None, 0) \ - X(Near16, 1) \ - X(Far16, 2) \ - X(Huge16, 3) \ - X(Near32, 4) \ - X(Far32, 5) +X(None, 0) \ +X(Near16, 1) \ +X(Far16, 2) \ +X(Huge16, 3) \ +X(Near32, 4) \ +X(Far32, 5) typedef U64 DW_AddrClass; typedef enum DW_AddrClassEnum @@ -1341,13 +1341,13 @@ typedef enum DW_AddrClassEnum } DW_AddrClassEnum; #define DW_CompUnitKind_XList \ - X(Reserved, 0) \ - X(Compile, 1) \ - X(Type, 2) \ - X(Partial, 3) \ - X(Skeleton, 4) \ - X(SplitCompile, 5) \ - X(SplitType, 6) +X(Reserved, 0) \ +X(Compile, 1) \ +X(Type, 2) \ +X(Partial, 3) \ +X(Skeleton, 4) \ +X(SplitCompile, 5) \ +X(SplitType, 6) typedef U8 DW_CompUnitKind; typedef enum DW_CompUnitKindEnum @@ -1360,12 +1360,12 @@ typedef enum DW_CompUnitKindEnum } DW_CompUnitKindEnum; #define DW_LNCT_XList \ - X(Path, 0x1) \ - X(DirectoryIndex, 0x2) \ - X(TimeStamp, 0x3) \ - X(Size, 0x4) \ - X(MD5, 0x5) \ - X(LLVM_Source, 0x2001) +X(Path, 0x1) \ +X(DirectoryIndex, 0x2) \ +X(TimeStamp, 0x3) \ +X(Size, 0x4) \ +X(MD5, 0x5) \ +X(LLVM_Source, 0x2001) typedef U64 DW_LNCT; typedef enum DW_LNCTEnum @@ -1390,32 +1390,32 @@ typedef enum // (opcode name, opcode id, operand count, operand types) #define DW_CFA_Kind_XList \ - X(Nop, 0x0) \ - X(SetLoc, 0x1, DW_CFA_OperandType_Value) \ - X(AdvanceLoc1, 0x2, DW_CFA_OperandType_Value) \ - X(AdvanceLoc2, 0x3, DW_CFA_OperandType_Value) \ - X(AdvanceLoc4, 0x4, DW_CFA_OperandType_Value) \ - X(OffsetExt, 0x5, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(RestoreExt, 0x6) \ - X(Undefined, 0x7, DW_CFA_OperandType_Register) \ - X(SameValue, 0x8, DW_CFA_OperandType_Register) \ - X(Register, 0x9, DW_CFA_OperandType_Register) \ - X(RememberState, 0xa) \ - X(RestoreState, 0xb) \ - X(DefCfa, 0xc, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(DefCfaRegister, 0xd, DW_CFA_OperandType_Register) \ - X(DefCfaOffset, 0xe, DW_CFA_OperandType_Value) \ - X(DefCfaExpr, 0xf, DW_CFA_OperandType_Expression) \ - X(Expr, 0x10, DW_CFA_OperandType_Expression) \ - X(OffsetExtSf, 0x11, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(DefCfaSf, 0x12, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(DefCfaOffsetSf, 0x13, DW_CFA_OperandType_Value) \ - X(ValOffset, 0x14, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(ValOffsetSf, 0x15, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(ValExpr, 0x16, DW_CFA_OperandType_Register, DW_CFA_OperandType_Expression) \ - X(AdvanceLoc, 0x40, DW_CFA_OperandType_Value) \ - X(Offset, 0x80, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ - X(Restore, 0xc0, DW_CFA_OperandType_Register) +X(Nop, 0x0) \ +X(SetLoc, 0x1, DW_CFA_OperandType_Value) \ +X(AdvanceLoc1, 0x2, DW_CFA_OperandType_Value) \ +X(AdvanceLoc2, 0x3, DW_CFA_OperandType_Value) \ +X(AdvanceLoc4, 0x4, DW_CFA_OperandType_Value) \ +X(OffsetExt, 0x5, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(RestoreExt, 0x6) \ +X(Undefined, 0x7, DW_CFA_OperandType_Register) \ +X(SameValue, 0x8, DW_CFA_OperandType_Register) \ +X(Register, 0x9, DW_CFA_OperandType_Register) \ +X(RememberState, 0xa) \ +X(RestoreState, 0xb) \ +X(DefCfa, 0xc, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(DefCfaRegister, 0xd, DW_CFA_OperandType_Register) \ +X(DefCfaOffset, 0xe, DW_CFA_OperandType_Value) \ +X(DefCfaExpr, 0xf, DW_CFA_OperandType_Expression) \ +X(Expr, 0x10, DW_CFA_OperandType_Expression) \ +X(OffsetExtSf, 0x11, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(DefCfaSf, 0x12, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(DefCfaOffsetSf, 0x13, DW_CFA_OperandType_Value) \ +X(ValOffset, 0x14, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(ValOffsetSf, 0x15, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(ValExpr, 0x16, DW_CFA_OperandType_Register, DW_CFA_OperandType_Expression) \ +X(AdvanceLoc, 0x40, DW_CFA_OperandType_Value) \ +X(Offset, 0x80, DW_CFA_OperandType_Register, DW_CFA_OperandType_Value) \ +X(Restore, 0xc0, DW_CFA_OperandType_Register) #define DW_CFA_OperandMax 2 #define DW_CFA_Mask_OpcodeHi 0xc0 @@ -1452,280 +1452,280 @@ typedef enum // (opcode name, opcode id, operand count, pop count, push count, operand0 type, operand1 type) #define DW_Expr_V3_XList \ - X(Null, 0x00, 0, 0, 0, Null, Null) \ - X(Addr, 0x03, 1, 0, 1, Addr, Null) \ - X(Deref, 0x06, 0, 1, 1, Null, Null) \ - X(Const1U, 0x08, 1, 0, 1, U8, Null) \ - X(Const1S, 0x09, 1, 0, 1, S8, Null) \ - X(Const2U, 0x0a, 1, 0, 1, U16, Null) \ - X(Const2S, 0x0b, 1, 0, 1, S16, Null) \ - X(Const4U, 0x0c, 1, 0, 1, U32, Null) \ - X(Const4S, 0x0d, 1, 0, 1, S32, Null) \ - X(Const8U, 0x0e, 1, 0, 1, U64, Null) \ - X(Const8S, 0x0f, 1, 0, 1, S64, Null) \ - X(ConstU, 0x10, 1, 0, 1, ULEB128, Null) \ - X(ConstS, 0x11, 1, 0, 1, SLEB128, Null) \ - X(Dup, 0x12, 0, 0, 1, Null, Null) \ - X(Drop, 0x13, 0, 1, 0, Null, Null) \ - X(Over, 0x14, 0, 0, 1, Null, Null) \ - X(Pick, 0x15, 1, 0, 1, U8, Null) \ - X(Swap, 0x16, 0, 0, 0, Null, Null) \ - X(Rot, 0x17, 0, 0, 0, Null, Null) \ - X(XDeref, 0x18, 0, 2, 1, Null, Null) \ - X(Abs, 0x19, 0, 1, 1, Null, Null) \ - X(And, 0x1a, 0, 2, 1, Null, Null) \ - X(Div, 0x1b, 0, 2, 1, Null, Null) \ - X(Minus, 0x1c, 0, 2, 1, Null, Null) \ - X(Mod, 0x1d, 0, 2, 1, Null, Null) \ - X(Mul, 0x1e, 0, 2, 1, Null, Null) \ - X(Neg, 0x1f, 0, 1, 1, Null, Null) \ - X(Not, 0x20, 0, 1, 1, Null, Null) \ - X(Or, 0x21, 0, 2, 1, Null, Null) \ - X(Plus, 0x22, 0, 2, 1, Null, Null) \ - X(PlusUConst, 0x23, 1, 1, 1, ULEB128, Null) \ - X(Shl, 0x24, 0, 2, 1, Null, Null) \ - X(Shr, 0x25, 0, 2, 1, Null, Null) \ - X(Shra, 0x26, 0, 2, 1, Null, Null) \ - X(Xor, 0x27, 0, 2, 1, Null, Null) \ - X(Bra, 0x28, 1, 1, 0, S16, Null) \ - X(Eq, 0x29, 0, 2, 1, Null, Null) \ - X(Ge, 0x2a, 0, 2, 1, Null, Null) \ - X(Gt, 0x2b, 0, 2, 1, Null, Null) \ - X(Le, 0x2c, 0, 2, 1, Null, Null) \ - X(Lt, 0x2d, 0, 2, 1, Null, Null) \ - X(Ne, 0x2e, 0, 2, 1, Null, Null) \ - X(Skip, 0x2f, 1, 0, 0, S16, Null) \ - X(Lit0, 0x30, 0, 0, 0, Null, Null) \ - X(Lit1, 0x31, 0, 0, 0, Null, Null) \ - X(Lit2, 0x32, 0, 0, 0, Null, Null) \ - X(Lit3, 0x33, 0, 0, 0, Null, Null) \ - X(Lit4, 0x34, 0, 0, 0, Null, Null) \ - X(Lit5, 0x35, 0, 0, 0, Null, Null) \ - X(Lit6, 0x36, 0, 0, 0, Null, Null) \ - X(Lit7, 0x37, 0, 0, 0, Null, Null) \ - X(Lit8, 0x38, 0, 0, 0, Null, Null) \ - X(Lit9, 0x39, 0, 0, 0, Null, Null) \ - X(Lit10, 0x3a, 0, 0, 0, Null, Null) \ - X(Lit11, 0x3b, 0, 0, 0, Null, Null) \ - X(Lit12, 0x3c, 0, 0, 0, Null, Null) \ - X(Lit13, 0x3d, 0, 0, 0, Null, Null) \ - X(Lit14, 0x3e, 0, 0, 0, Null, Null) \ - X(Lit15, 0x3f, 0, 0, 0, Null, Null) \ - X(Lit16, 0x40, 0, 0, 0, Null, Null) \ - X(Lit17, 0x41, 0, 0, 0, Null, Null) \ - X(Lit18, 0x42, 0, 0, 0, Null, Null) \ - X(Lit19, 0x43, 0, 0, 0, Null, Null) \ - X(Lit20, 0x44, 0, 0, 0, Null, Null) \ - X(Lit21, 0x45, 0, 0, 0, Null, Null) \ - X(Lit22, 0x46, 0, 0, 0, Null, Null) \ - X(Lit23, 0x47, 0, 0, 0, Null, Null) \ - X(Lit24, 0x48, 0, 0, 0, Null, Null) \ - X(Lit25, 0x49, 0, 0, 0, Null, Null) \ - X(Lit26, 0x4a, 0, 0, 0, Null, Null) \ - X(Lit27, 0x4b, 0, 0, 0, Null, Null) \ - X(Lit28, 0x4c, 0, 0, 0, Null, Null) \ - X(Lit29, 0x4d, 0, 0, 0, Null, Null) \ - X(Lit30, 0x4e, 0, 0, 0, Null, Null) \ - X(Lit31, 0x4f, 0, 0, 0, Null, Null) \ - X(Reg0, 0x50, 0, 0, 1, Null, Null) \ - X(Reg1, 0x51, 0, 0, 1, Null, Null) \ - X(Reg2, 0x52, 0, 0, 1, Null, Null) \ - X(Reg3, 0x53, 0, 0, 1, Null, Null) \ - X(Reg4, 0x54, 0, 0, 1, Null, Null) \ - X(Reg5, 0x55, 0, 0, 1, Null, Null) \ - X(Reg6, 0x56, 0, 0, 1, Null, Null) \ - X(Reg7, 0x57, 0, 0, 1, Null, Null) \ - X(Reg8, 0x58, 0, 0, 1, Null, Null) \ - X(Reg9, 0x59, 0, 0, 1, Null, Null) \ - X(Reg10, 0x5a, 0, 0, 1, Null, Null) \ - X(Reg11, 0x5b, 0, 0, 1, Null, Null) \ - X(Reg12, 0x5c, 0, 0, 1, Null, Null) \ - X(Reg13, 0x5d, 0, 0, 1, Null, Null) \ - X(Reg14, 0x5e, 0, 0, 1, Null, Null) \ - X(Reg15, 0x5f, 0, 0, 1, Null, Null) \ - X(Reg16, 0x60, 0, 0, 1, Null, Null) \ - X(Reg17, 0x61, 0, 0, 1, Null, Null) \ - X(Reg18, 0x62, 0, 0, 1, Null, Null) \ - X(Reg19, 0x63, 0, 0, 1, Null, Null) \ - X(Reg20, 0x64, 0, 0, 1, Null, Null) \ - X(Reg21, 0x65, 0, 0, 1, Null, Null) \ - X(Reg22, 0x66, 0, 0, 1, Null, Null) \ - X(Reg23, 0x67, 0, 0, 1, Null, Null) \ - X(Reg24, 0x68, 0, 0, 1, Null, Null) \ - X(Reg25, 0x69, 0, 0, 1, Null, Null) \ - X(Reg26, 0x6a, 0, 0, 1, Null, Null) \ - X(Reg27, 0x6b, 0, 0, 1, Null, Null) \ - X(Reg28, 0x6c, 0, 0, 1, Null, Null) \ - X(Reg29, 0x6d, 0, 0, 1, Null, Null) \ - X(Reg30, 0x6e, 0, 0, 1, Null, Null) \ - X(Reg31, 0x6f, 0, 0, 1, Null, Null) \ - X(BReg0, 0x70, 1, 0, 1, SLEB128, Null) \ - X(BReg1, 0x71, 1, 0, 1, SLEB128, Null) \ - X(BReg2, 0x72, 1, 0, 1, SLEB128, Null) \ - X(BReg3, 0x73, 1, 0, 1, SLEB128, Null) \ - X(BReg4, 0x74, 1, 0, 1, SLEB128, Null) \ - X(BReg5, 0x75, 1, 0, 1, SLEB128, Null) \ - X(BReg6, 0x76, 1, 0, 1, SLEB128, Null) \ - X(BReg7, 0x77, 1, 0, 1, SLEB128, Null) \ - X(BReg8, 0x78, 1, 0, 1, SLEB128, Null) \ - X(BReg9, 0x79, 1, 0, 1, SLEB128, Null) \ - X(BReg10, 0x7a, 1, 0, 1, SLEB128, Null) \ - X(BReg11, 0x7b, 1, 0, 1, SLEB128, Null) \ - X(BReg12, 0x7c, 1, 0, 1, SLEB128, Null) \ - X(BReg13, 0x7d, 1, 0, 1, SLEB128, Null) \ - X(BReg14, 0x7e, 1, 0, 1, SLEB128, Null) \ - X(BReg15, 0x7f, 1, 0, 1, SLEB128, Null) \ - X(BReg16, 0x80, 1, 0, 1, SLEB128, Null) \ - X(BReg17, 0x81, 1, 0, 1, SLEB128, Null) \ - X(BReg18, 0x82, 1, 0, 1, SLEB128, Null) \ - X(BReg19, 0x83, 1, 0, 1, SLEB128, Null) \ - X(BReg20, 0x84, 1, 0, 1, SLEB128, Null) \ - X(BReg21, 0x85, 1, 0, 1, SLEB128, Null) \ - X(BReg22, 0x86, 1, 0, 1, SLEB128, Null) \ - X(BReg23, 0x87, 1, 0, 1, SLEB128, Null) \ - X(BReg24, 0x88, 1, 0, 1, SLEB128, Null) \ - X(BReg25, 0x89, 1, 0, 1, SLEB128, Null) \ - X(BReg26, 0x8a, 1, 0, 1, SLEB128, Null) \ - X(BReg27, 0x8b, 1, 0, 1, SLEB128, Null) \ - X(BReg28, 0x8c, 1, 0, 1, SLEB128, Null) \ - X(BReg29, 0x8d, 1, 0, 1, SLEB128, Null) \ - X(BReg30, 0x8e, 1, 0, 1, SLEB128, Null) \ - X(BReg31, 0x8f, 1, 0, 1, SLEB128, Null) \ - X(RegX, 0x90, 1, 0, 1, ULEB128, Null) \ - X(FBReg, 0x91, 1, 0, 1, SLEB128, Null) \ - X(BRegX, 0x92, 2, 0, 1, ULEB128, SLEB128) \ - X(Piece, 0x93, 1, 0, 0, ULEB128, Null) \ - X(DerefSize, 0x94, 1, 1, 1, U8, Null) \ - X(XDerefSize, 0x95, 1, 2, 1, U8, Null) \ - X(Nop, 0x96, 0, 0, 0, Null, Null) \ - X(PushObjectAddress, 0x97, 0, 0, 1, Null, Null) \ - X(Call2, 0x98, 1, 0, 0, U16, Null) \ - X(Call4, 0x99, 1, 0, 0, U32, Null) \ - X(CallRef, 0x9a, 1, 0, 0, DwarfUInt,Null) \ - X(FormTlsAddress, 0x9b, 0, 0, 1, Null, Null) \ - X(CallFrameCfa, 0x9c, 0, 0, 1, Null, Null) \ - X(BitPiece, 0x9d, 2, 0, 0, ULEB128, ULEB128) +X(Null, 0x00, 0, 0, 0, Null, Null) \ +X(Addr, 0x03, 1, 0, 1, Addr, Null) \ +X(Deref, 0x06, 0, 1, 1, Null, Null) \ +X(Const1U, 0x08, 1, 0, 1, U8, Null) \ +X(Const1S, 0x09, 1, 0, 1, S8, Null) \ +X(Const2U, 0x0a, 1, 0, 1, U16, Null) \ +X(Const2S, 0x0b, 1, 0, 1, S16, Null) \ +X(Const4U, 0x0c, 1, 0, 1, U32, Null) \ +X(Const4S, 0x0d, 1, 0, 1, S32, Null) \ +X(Const8U, 0x0e, 1, 0, 1, U64, Null) \ +X(Const8S, 0x0f, 1, 0, 1, S64, Null) \ +X(ConstU, 0x10, 1, 0, 1, ULEB128, Null) \ +X(ConstS, 0x11, 1, 0, 1, SLEB128, Null) \ +X(Dup, 0x12, 0, 0, 1, Null, Null) \ +X(Drop, 0x13, 0, 1, 0, Null, Null) \ +X(Over, 0x14, 0, 0, 1, Null, Null) \ +X(Pick, 0x15, 1, 0, 1, U8, Null) \ +X(Swap, 0x16, 0, 0, 0, Null, Null) \ +X(Rot, 0x17, 0, 0, 0, Null, Null) \ +X(XDeref, 0x18, 0, 2, 1, Null, Null) \ +X(Abs, 0x19, 0, 1, 1, Null, Null) \ +X(And, 0x1a, 0, 2, 1, Null, Null) \ +X(Div, 0x1b, 0, 2, 1, Null, Null) \ +X(Minus, 0x1c, 0, 2, 1, Null, Null) \ +X(Mod, 0x1d, 0, 2, 1, Null, Null) \ +X(Mul, 0x1e, 0, 2, 1, Null, Null) \ +X(Neg, 0x1f, 0, 1, 1, Null, Null) \ +X(Not, 0x20, 0, 1, 1, Null, Null) \ +X(Or, 0x21, 0, 2, 1, Null, Null) \ +X(Plus, 0x22, 0, 2, 1, Null, Null) \ +X(PlusUConst, 0x23, 1, 1, 1, ULEB128, Null) \ +X(Shl, 0x24, 0, 2, 1, Null, Null) \ +X(Shr, 0x25, 0, 2, 1, Null, Null) \ +X(Shra, 0x26, 0, 2, 1, Null, Null) \ +X(Xor, 0x27, 0, 2, 1, Null, Null) \ +X(Bra, 0x28, 1, 1, 0, S16, Null) \ +X(Eq, 0x29, 0, 2, 1, Null, Null) \ +X(Ge, 0x2a, 0, 2, 1, Null, Null) \ +X(Gt, 0x2b, 0, 2, 1, Null, Null) \ +X(Le, 0x2c, 0, 2, 1, Null, Null) \ +X(Lt, 0x2d, 0, 2, 1, Null, Null) \ +X(Ne, 0x2e, 0, 2, 1, Null, Null) \ +X(Skip, 0x2f, 1, 0, 0, S16, Null) \ +X(Lit0, 0x30, 0, 0, 0, Null, Null) \ +X(Lit1, 0x31, 0, 0, 0, Null, Null) \ +X(Lit2, 0x32, 0, 0, 0, Null, Null) \ +X(Lit3, 0x33, 0, 0, 0, Null, Null) \ +X(Lit4, 0x34, 0, 0, 0, Null, Null) \ +X(Lit5, 0x35, 0, 0, 0, Null, Null) \ +X(Lit6, 0x36, 0, 0, 0, Null, Null) \ +X(Lit7, 0x37, 0, 0, 0, Null, Null) \ +X(Lit8, 0x38, 0, 0, 0, Null, Null) \ +X(Lit9, 0x39, 0, 0, 0, Null, Null) \ +X(Lit10, 0x3a, 0, 0, 0, Null, Null) \ +X(Lit11, 0x3b, 0, 0, 0, Null, Null) \ +X(Lit12, 0x3c, 0, 0, 0, Null, Null) \ +X(Lit13, 0x3d, 0, 0, 0, Null, Null) \ +X(Lit14, 0x3e, 0, 0, 0, Null, Null) \ +X(Lit15, 0x3f, 0, 0, 0, Null, Null) \ +X(Lit16, 0x40, 0, 0, 0, Null, Null) \ +X(Lit17, 0x41, 0, 0, 0, Null, Null) \ +X(Lit18, 0x42, 0, 0, 0, Null, Null) \ +X(Lit19, 0x43, 0, 0, 0, Null, Null) \ +X(Lit20, 0x44, 0, 0, 0, Null, Null) \ +X(Lit21, 0x45, 0, 0, 0, Null, Null) \ +X(Lit22, 0x46, 0, 0, 0, Null, Null) \ +X(Lit23, 0x47, 0, 0, 0, Null, Null) \ +X(Lit24, 0x48, 0, 0, 0, Null, Null) \ +X(Lit25, 0x49, 0, 0, 0, Null, Null) \ +X(Lit26, 0x4a, 0, 0, 0, Null, Null) \ +X(Lit27, 0x4b, 0, 0, 0, Null, Null) \ +X(Lit28, 0x4c, 0, 0, 0, Null, Null) \ +X(Lit29, 0x4d, 0, 0, 0, Null, Null) \ +X(Lit30, 0x4e, 0, 0, 0, Null, Null) \ +X(Lit31, 0x4f, 0, 0, 0, Null, Null) \ +X(Reg0, 0x50, 0, 0, 1, Null, Null) \ +X(Reg1, 0x51, 0, 0, 1, Null, Null) \ +X(Reg2, 0x52, 0, 0, 1, Null, Null) \ +X(Reg3, 0x53, 0, 0, 1, Null, Null) \ +X(Reg4, 0x54, 0, 0, 1, Null, Null) \ +X(Reg5, 0x55, 0, 0, 1, Null, Null) \ +X(Reg6, 0x56, 0, 0, 1, Null, Null) \ +X(Reg7, 0x57, 0, 0, 1, Null, Null) \ +X(Reg8, 0x58, 0, 0, 1, Null, Null) \ +X(Reg9, 0x59, 0, 0, 1, Null, Null) \ +X(Reg10, 0x5a, 0, 0, 1, Null, Null) \ +X(Reg11, 0x5b, 0, 0, 1, Null, Null) \ +X(Reg12, 0x5c, 0, 0, 1, Null, Null) \ +X(Reg13, 0x5d, 0, 0, 1, Null, Null) \ +X(Reg14, 0x5e, 0, 0, 1, Null, Null) \ +X(Reg15, 0x5f, 0, 0, 1, Null, Null) \ +X(Reg16, 0x60, 0, 0, 1, Null, Null) \ +X(Reg17, 0x61, 0, 0, 1, Null, Null) \ +X(Reg18, 0x62, 0, 0, 1, Null, Null) \ +X(Reg19, 0x63, 0, 0, 1, Null, Null) \ +X(Reg20, 0x64, 0, 0, 1, Null, Null) \ +X(Reg21, 0x65, 0, 0, 1, Null, Null) \ +X(Reg22, 0x66, 0, 0, 1, Null, Null) \ +X(Reg23, 0x67, 0, 0, 1, Null, Null) \ +X(Reg24, 0x68, 0, 0, 1, Null, Null) \ +X(Reg25, 0x69, 0, 0, 1, Null, Null) \ +X(Reg26, 0x6a, 0, 0, 1, Null, Null) \ +X(Reg27, 0x6b, 0, 0, 1, Null, Null) \ +X(Reg28, 0x6c, 0, 0, 1, Null, Null) \ +X(Reg29, 0x6d, 0, 0, 1, Null, Null) \ +X(Reg30, 0x6e, 0, 0, 1, Null, Null) \ +X(Reg31, 0x6f, 0, 0, 1, Null, Null) \ +X(BReg0, 0x70, 1, 0, 1, SLEB128, Null) \ +X(BReg1, 0x71, 1, 0, 1, SLEB128, Null) \ +X(BReg2, 0x72, 1, 0, 1, SLEB128, Null) \ +X(BReg3, 0x73, 1, 0, 1, SLEB128, Null) \ +X(BReg4, 0x74, 1, 0, 1, SLEB128, Null) \ +X(BReg5, 0x75, 1, 0, 1, SLEB128, Null) \ +X(BReg6, 0x76, 1, 0, 1, SLEB128, Null) \ +X(BReg7, 0x77, 1, 0, 1, SLEB128, Null) \ +X(BReg8, 0x78, 1, 0, 1, SLEB128, Null) \ +X(BReg9, 0x79, 1, 0, 1, SLEB128, Null) \ +X(BReg10, 0x7a, 1, 0, 1, SLEB128, Null) \ +X(BReg11, 0x7b, 1, 0, 1, SLEB128, Null) \ +X(BReg12, 0x7c, 1, 0, 1, SLEB128, Null) \ +X(BReg13, 0x7d, 1, 0, 1, SLEB128, Null) \ +X(BReg14, 0x7e, 1, 0, 1, SLEB128, Null) \ +X(BReg15, 0x7f, 1, 0, 1, SLEB128, Null) \ +X(BReg16, 0x80, 1, 0, 1, SLEB128, Null) \ +X(BReg17, 0x81, 1, 0, 1, SLEB128, Null) \ +X(BReg18, 0x82, 1, 0, 1, SLEB128, Null) \ +X(BReg19, 0x83, 1, 0, 1, SLEB128, Null) \ +X(BReg20, 0x84, 1, 0, 1, SLEB128, Null) \ +X(BReg21, 0x85, 1, 0, 1, SLEB128, Null) \ +X(BReg22, 0x86, 1, 0, 1, SLEB128, Null) \ +X(BReg23, 0x87, 1, 0, 1, SLEB128, Null) \ +X(BReg24, 0x88, 1, 0, 1, SLEB128, Null) \ +X(BReg25, 0x89, 1, 0, 1, SLEB128, Null) \ +X(BReg26, 0x8a, 1, 0, 1, SLEB128, Null) \ +X(BReg27, 0x8b, 1, 0, 1, SLEB128, Null) \ +X(BReg28, 0x8c, 1, 0, 1, SLEB128, Null) \ +X(BReg29, 0x8d, 1, 0, 1, SLEB128, Null) \ +X(BReg30, 0x8e, 1, 0, 1, SLEB128, Null) \ +X(BReg31, 0x8f, 1, 0, 1, SLEB128, Null) \ +X(RegX, 0x90, 1, 0, 1, ULEB128, Null) \ +X(FBReg, 0x91, 1, 0, 1, SLEB128, Null) \ +X(BRegX, 0x92, 2, 0, 1, ULEB128, SLEB128) \ +X(Piece, 0x93, 1, 0, 0, ULEB128, Null) \ +X(DerefSize, 0x94, 1, 1, 1, U8, Null) \ +X(XDerefSize, 0x95, 1, 2, 1, U8, Null) \ +X(Nop, 0x96, 0, 0, 0, Null, Null) \ +X(PushObjectAddress, 0x97, 0, 0, 1, Null, Null) \ +X(Call2, 0x98, 1, 0, 0, U16, Null) \ +X(Call4, 0x99, 1, 0, 0, U32, Null) \ +X(CallRef, 0x9a, 1, 0, 0, DwarfUInt,Null) \ +X(FormTlsAddress, 0x9b, 0, 0, 1, Null, Null) \ +X(CallFrameCfa, 0x9c, 0, 0, 1, Null, Null) \ +X(BitPiece, 0x9d, 2, 0, 0, ULEB128, ULEB128) #define DW_Expr_V4_XList \ - X(ImplicitValue, 0x9e, 2, 0, 1, Block, Null) \ - X(StackValue, 0x9f, 0, 0, 0, Null, Null) +X(ImplicitValue, 0x9e, 2, 0, 1, Block, Null) \ +X(StackValue, 0x9f, 0, 0, 0, Null, Null) #define DW_Expr_V5_XList \ - X(ImplicitPointer, 0xa0, 2, 0, 1, DwarfUInt, SLEB128) \ - X(Addrx, 0xa1, 1, 0, 1, ULEB128, Null) \ - X(Constx, 0xa2, 1, 0, 1, ULEB128, Null) \ - X(EntryValue, 0xa3, 1, 0, 0, Block, Null) \ - X(ConstType, 0xa4, 2, 0, 1, ULEB128, Block) \ - X(RegvalType, 0xa5, 2, 0, 1, ULEB128, ULEB128) \ - X(DerefType, 0xa6, 2, 1, 1, U8, ULEB128) \ - X(XDerefType, 0xa7, 2, 2, 1, U8, ULEB128) \ - X(Convert, 0xa8, 1, 1, 1, ULEB128, Null) \ - X(Reinterpret, 0xa9, 1, 1, 1, ULEB128, Null) +X(ImplicitPointer, 0xa0, 2, 0, 1, DwarfUInt, SLEB128) \ +X(Addrx, 0xa1, 1, 0, 1, ULEB128, Null) \ +X(Constx, 0xa2, 1, 0, 1, ULEB128, Null) \ +X(EntryValue, 0xa3, 1, 0, 0, Block, Null) \ +X(ConstType, 0xa4, 2, 0, 1, ULEB128, Block) \ +X(RegvalType, 0xa5, 2, 0, 1, ULEB128, ULEB128) \ +X(DerefType, 0xa6, 2, 1, 1, U8, ULEB128) \ +X(XDerefType, 0xa7, 2, 2, 1, U8, ULEB128) \ +X(Convert, 0xa8, 1, 1, 1, ULEB128, Null) \ +X(Reinterpret, 0xa9, 1, 1, 1, ULEB128, Null) #define DW_Expr_GNU_XList \ - X(GNU_PushTlsAddress, 0xe0, 0, 0, 1, Null, Null) \ - X(GNU_UnInit, 0xf0, 0, 0, 0, Null, Null) \ - X(GNU_ImplicitPointer, 0xf2, 2, 0, 1, DwarfUInt, SLEB128) \ - X(GNU_EntryValue, 0xf3, 1, 0, 0, Block, Null) \ - X(GNU_ConstType, 0xf4, 2, 0, 1, ULEB128, Block) \ - X(GNU_RegvalType, 0xf5, 2, 0, 1, ULEB128, ULEB128) \ - X(GNU_DerefType, 0xf6, 2, 1, 1, U8, ULEB128) \ - X(GNU_Convert, 0xf7, 1, 1, 1, ULEB128, Null) \ - X(GNU_ParameterRef, 0xfa, 1, 0, 0, U32, Null) \ - X(GNU_AddrIndex, 0xfb, 0, 0, 1, Null, Null) \ - X(GNU_ConstIndex, 0xfc, 1, 0, 1, ULEB128, Null) +X(GNU_PushTlsAddress, 0xe0, 0, 0, 1, Null, Null) \ +X(GNU_UnInit, 0xf0, 0, 0, 0, Null, Null) \ +X(GNU_ImplicitPointer, 0xf2, 2, 0, 1, DwarfUInt, SLEB128) \ +X(GNU_EntryValue, 0xf3, 1, 0, 0, Block, Null) \ +X(GNU_ConstType, 0xf4, 2, 0, 1, ULEB128, Block) \ +X(GNU_RegvalType, 0xf5, 2, 0, 1, ULEB128, ULEB128) \ +X(GNU_DerefType, 0xf6, 2, 1, 1, U8, ULEB128) \ +X(GNU_Convert, 0xf7, 1, 1, 1, ULEB128, Null) \ +X(GNU_ParameterRef, 0xfa, 1, 0, 0, U32, Null) \ +X(GNU_AddrIndex, 0xfb, 0, 0, 1, Null, Null) \ +X(GNU_ConstIndex, 0xfc, 1, 0, 1, ULEB128, Null) typedef U8 DW_ExprOp; typedef enum DW_ExprOpEnum { #define X(_N, _ID, _OPER_COUNT, _POP_COUNT, _PUSH_COUNT, ...) DW_ExprOp_##_N = _ID, DW_Expr_V3_XList - DW_Expr_V4_XList - DW_Expr_V5_XList - DW_Expr_GNU_XList + DW_Expr_V4_XList + DW_Expr_V5_XList + DW_Expr_GNU_XList #undef X } DW_ExprOpEnum; //- Regs #define DW_Regs_X64_XList \ - X(Rax, 0, rax, 0, 8) \ - X(Rdx, 1, rdx, 0, 8) \ - X(Rcx, 2, rcx, 0, 8) \ - X(Rbx, 3, rbx, 0, 8) \ - X(Rsi, 4, rsi, 0, 8) \ - X(Rdi, 5, rdi, 0, 8) \ - X(Rbp, 6, rbp, 0, 8) \ - X(Rsp, 7, rsp, 0, 8) \ - X(R8, 8, r8, 0, 8) \ - X(R9, 9, r9, 0, 8) \ - X(R10, 10, r10, 0, 8) \ - X(R11, 11, r11, 0, 8) \ - X(R12, 12, r12, 0, 8) \ - X(R13, 13, r13, 0, 8) \ - X(R14, 14, r14, 0, 8) \ - X(R15, 15, r15, 0, 8) \ - X(Rip, 16, rip, 0, 8) \ - X(Xmm0, 17, zmm0, 0, 16) \ - X(Xmm1, 18, zmm1, 0, 16) \ - X(Xmm2, 19, zmm2, 0, 16) \ - X(Xmm3, 20, zmm3, 0, 16) \ - X(Xmm4, 21, zmm4, 0, 16) \ - X(Xmm5, 22, zmm5, 0, 16) \ - X(Xmm6, 23, zmm6, 0, 16) \ - X(Xmm7, 24, zmm7, 0, 16) \ - X(Xmm8, 25, zmm8, 0, 16) \ - X(Xmm9, 26, zmm9, 0, 16) \ - X(Xmm10, 27, zmm10, 0, 16) \ - X(Xmm11, 28, zmm11, 0, 16) \ - X(Xmm12, 29, zmm12, 0, 16) \ - X(Xmm13, 30, zmm13, 0, 16) \ - X(Xmm14, 31, zmm14, 0, 16) \ - X(Xmm15, 32, zmm15, 0, 16) \ - X(Xmm16, 67, zmm16, 0, 16) \ - X(Xmm17, 68, zmm17, 0, 16) \ - X(Xmm18, 69, zmm18, 0, 16) \ - X(Xmm19, 70, zmm19, 0, 16) \ - X(Xmm20, 71, zmm20, 0, 16) \ - X(Xmm21, 72, zmm21, 0, 16) \ - X(Xmm22, 73, zmm22, 0, 16) \ - X(Xmm23, 74, zmm23, 0, 16) \ - X(Xmm24, 75, zmm24, 0, 16) \ - X(Xmm25, 76, zmm25, 0, 16) \ - X(Xmm26, 77, zmm26, 0, 16) \ - X(Xmm27, 78, zmm27, 0, 16) \ - X(Xmm28, 79, zmm28, 0, 16) \ - X(Xmm29, 80, zmm29, 0, 16) \ - X(Xmm30, 81, zmm30, 0, 16) \ - X(Xmm31, 82, zmm31, 0, 16) \ - X(St0, 33, st0, 0, 10) \ - X(St1, 34, st1, 0, 10) \ - X(St2, 35, st2, 0, 10) \ - X(St3, 36, st3, 0, 10) \ - X(St4, 37, st4, 0, 10) \ - X(St5, 38, st5, 0, 10) \ - X(St6, 39, st6, 0, 10) \ - X(St7, 40, st7, 0, 10) \ - X(Mm0, 41, st0, 0, 8) \ - X(Mm1, 42, st1, 0, 8) \ - X(Mm2, 43, st2, 0, 8) \ - X(Mm3, 44, st3, 0, 8) \ - X(Mm4, 45, st4, 0, 8) \ - X(Mm5, 46, st5, 0, 8) \ - X(Mm6, 47, st6, 0, 8) \ - X(Mm7, 48, st7, 0, 8) \ - X(Rflags, 49, rflags, 0, 4) \ - X(Es, 50, es, 0, 2) \ - X(Cs, 51, cs, 0, 2) \ - X(Ss, 52, ss, 0, 2) \ - X(Ds, 53, ds, 0, 2) \ - X(Fs, 54, fs, 0, 2) \ - X(Gs, 55, gs, 0, 2) \ - X(FsBase, 58, fsbase, 0, 8) \ - X(GsBase, 59, gsbase, 0, 8) - // privileged registers: - // X(Tr, 62, nil, 0, 0) \ - // X(Ldtr, 63, nil, 0, 0) +X(Rax, 0, rax, 0, 8) \ +X(Rdx, 1, rdx, 0, 8) \ +X(Rcx, 2, rcx, 0, 8) \ +X(Rbx, 3, rbx, 0, 8) \ +X(Rsi, 4, rsi, 0, 8) \ +X(Rdi, 5, rdi, 0, 8) \ +X(Rbp, 6, rbp, 0, 8) \ +X(Rsp, 7, rsp, 0, 8) \ +X(R8, 8, r8, 0, 8) \ +X(R9, 9, r9, 0, 8) \ +X(R10, 10, r10, 0, 8) \ +X(R11, 11, r11, 0, 8) \ +X(R12, 12, r12, 0, 8) \ +X(R13, 13, r13, 0, 8) \ +X(R14, 14, r14, 0, 8) \ +X(R15, 15, r15, 0, 8) \ +X(Rip, 16, rip, 0, 8) \ +X(Xmm0, 17, zmm0, 0, 16) \ +X(Xmm1, 18, zmm1, 0, 16) \ +X(Xmm2, 19, zmm2, 0, 16) \ +X(Xmm3, 20, zmm3, 0, 16) \ +X(Xmm4, 21, zmm4, 0, 16) \ +X(Xmm5, 22, zmm5, 0, 16) \ +X(Xmm6, 23, zmm6, 0, 16) \ +X(Xmm7, 24, zmm7, 0, 16) \ +X(Xmm8, 25, zmm8, 0, 16) \ +X(Xmm9, 26, zmm9, 0, 16) \ +X(Xmm10, 27, zmm10, 0, 16) \ +X(Xmm11, 28, zmm11, 0, 16) \ +X(Xmm12, 29, zmm12, 0, 16) \ +X(Xmm13, 30, zmm13, 0, 16) \ +X(Xmm14, 31, zmm14, 0, 16) \ +X(Xmm15, 32, zmm15, 0, 16) \ +X(Xmm16, 67, zmm16, 0, 16) \ +X(Xmm17, 68, zmm17, 0, 16) \ +X(Xmm18, 69, zmm18, 0, 16) \ +X(Xmm19, 70, zmm19, 0, 16) \ +X(Xmm20, 71, zmm20, 0, 16) \ +X(Xmm21, 72, zmm21, 0, 16) \ +X(Xmm22, 73, zmm22, 0, 16) \ +X(Xmm23, 74, zmm23, 0, 16) \ +X(Xmm24, 75, zmm24, 0, 16) \ +X(Xmm25, 76, zmm25, 0, 16) \ +X(Xmm26, 77, zmm26, 0, 16) \ +X(Xmm27, 78, zmm27, 0, 16) \ +X(Xmm28, 79, zmm28, 0, 16) \ +X(Xmm29, 80, zmm29, 0, 16) \ +X(Xmm30, 81, zmm30, 0, 16) \ +X(Xmm31, 82, zmm31, 0, 16) \ +X(St0, 33, st0, 0, 10) \ +X(St1, 34, st1, 0, 10) \ +X(St2, 35, st2, 0, 10) \ +X(St3, 36, st3, 0, 10) \ +X(St4, 37, st4, 0, 10) \ +X(St5, 38, st5, 0, 10) \ +X(St6, 39, st6, 0, 10) \ +X(St7, 40, st7, 0, 10) \ +X(Mm0, 41, st0, 0, 8) \ +X(Mm1, 42, st1, 0, 8) \ +X(Mm2, 43, st2, 0, 8) \ +X(Mm3, 44, st3, 0, 8) \ +X(Mm4, 45, st4, 0, 8) \ +X(Mm5, 46, st5, 0, 8) \ +X(Mm6, 47, st6, 0, 8) \ +X(Mm7, 48, st7, 0, 8) \ +X(Rflags, 49, rflags, 0, 4) \ +X(Es, 50, es, 0, 2) \ +X(Cs, 51, cs, 0, 2) \ +X(Ss, 52, ss, 0, 2) \ +X(Ds, 53, ds, 0, 2) \ +X(Fs, 54, fs, 0, 2) \ +X(Gs, 55, gs, 0, 2) \ +X(FsBase, 58, fsbase, 0, 8) \ +X(GsBase, 59, gsbase, 0, 8) +// privileged registers: +// X(Tr, 62, nil, 0, 0) \ +// X(Ldtr, 63, nil, 0, 0) typedef U32 DW_Reg; diff --git a/src/dwarf/dwarf_coff.c b/src/dwarf/dwarf_coff.c index 3cf7bea3..1ccc2e5b 100644 --- a/src/dwarf/dwarf_coff.c +++ b/src/dwarf/dwarf_coff.c @@ -23,14 +23,14 @@ dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, return is_dwarf_present; } -internal DW_Input +internal DW_Raw dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table) { - DW_Input input = {0}; + DW_Raw input = {0}; B32 sect_status[ArrayCount(input.sec)] = {0}; for (U64 i = 0; i < section_count; ++i) { diff --git a/src/dwarf/dwarf_coff.h b/src/dwarf/dwarf_coff.h index 79cd37c3..797324ef 100644 --- a/src/dwarf/dwarf_coff.h +++ b/src/dwarf/dwarf_coff.h @@ -5,7 +5,7 @@ #define DWARF_COFF_H internal B32 dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, COFF_SectionHeader *section_table); -internal DW_Input dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table); +internal DW_Raw dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table); #endif // DWARF_COFF_H diff --git a/src/dwarf/dwarf_dump.c b/src/dwarf/dwarf_dump.c index 95318987..69b83b23 100644 --- a/src/dwarf/dwarf_dump.c +++ b/src/dwarf/dwarf_dump.c @@ -92,7 +92,7 @@ dw_string_list_from_cfi_program(Arena *arena, { Temp scratch = scratch_begin(&arena, 1); String8List list = {0}; - + U64 reg_max = dw_reg_count_from_arch(arch); U64 pc = pc_begin; for (U64 cursor = 0, inst_size; cursor < program.size; cursor += inst_size) { @@ -104,134 +104,134 @@ dw_string_list_from_cfi_program(Arena *arena, str8_list_pushf(arena, &list, "ERROR: failed to unpack CFA instruction @ 0x%I64", cursor); break; } - + // error check operands DW_CFA_OperandType *operand_types = dw_operand_types_from_cfa_op(inst.opcode); U64 operand_count = dw_operand_count_from_cfa_opcode(inst.opcode); for EachIndex(operand_idx, operand_count) { switch (operand_types[operand_idx]) { - case DW_CFA_OperandType_Null: break; - case DW_CFA_OperandType_Value: break; - case DW_CFA_OperandType_Register: { - if (inst.operands[operand_idx].u64 >= reg_max) { - str8_list_pushf(arena, &list, "ERROR: DW_CFA_%S @ 0x%I64x has an invalid register", - dw_string_from_cfa_opcode(inst.opcode), - cursor); - } - } break; - case DW_CFA_OperandType_Expression: { - DW_Expr expr = dw_expr_from_data(scratch.arena, format, cie->address_size, inst.operands[operand_idx].block); - for EachNode(inst, DW_ExprInst, expr.first) { - if (dw_is_cfa_expr_opcode_invalid(inst->opcode)) { - String8 expr_opcode_str = dw_string_from_expr_op(scratch.arena, ver, ext, inst->opcode); - str8_list_pushf(arena, &list, "ERROR: Exrepssion in DW_CFA_%S @ 0x%I64x has an invalid opcode DW_ExprOp_%S", expr_opcode_str); + case DW_CFA_OperandType_Null: break; + case DW_CFA_OperandType_Value: break; + case DW_CFA_OperandType_Register: { + if (inst.operands[operand_idx].u64 >= reg_max) { + str8_list_pushf(arena, &list, "ERROR: DW_CFA_%S @ 0x%I64x has an invalid register", + dw_string_from_cfa_opcode(inst.opcode), + cursor); } - } - } break; - default: { InvalidPath; } break; + } break; + case DW_CFA_OperandType_Expression: { + DW_Expr expr = dw_expr_from_data(scratch.arena, format, cie->address_size, inst.operands[operand_idx].block); + for EachNode(inst, DW_ExprInst, expr.first) { + if (dw_is_cfa_expr_opcode_invalid(inst->opcode)) { + String8 expr_opcode_str = dw_string_from_expr_op(scratch.arena, ver, ext, inst->opcode); + str8_list_pushf(arena, &list, "ERROR: Exrepssion in DW_CFA_%S @ 0x%I64x has an invalid opcode DW_ExprOp_%S", expr_opcode_str); + } + } + } break; + default: { InvalidPath; } break; } } - + // format operands String8 operand_str = str8_lit("???"); switch (inst.opcode) { - case DW_CFA_Nop: { operand_str = str8_zero(); } break; - case DW_CFA_SetLoc: { - operand_str = str8f(arena, "0x%X", inst.operands[0].u64); - pc = inst.operands[0].u64; - } break; - case DW_CFA_AdvanceLoc1: { - U64 delta = inst.operands[0].u64; - pc += delta; - operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); - } break; - case DW_CFA_AdvanceLoc2: { - U64 delta = inst.operands[0].u64; - pc += delta; - operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); - } break; - case DW_CFA_AdvanceLoc4: { - U64 delta = inst.operands[0].u64; - pc += delta; - operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); - } break; - case DW_CFA_OffsetExt: { - U64 reg = inst.operands[0].u64; - S64 offset = (S64)inst.operands[1].u64; - operand_str = dw_string_from_reg_off(arena, arch, reg, offset); - } break; - case DW_CFA_RestoreExt: { operand_str = str8_zero(); } break; - case DW_CFA_Undefined: { - operand_str = str8f(arena, "%I64u", inst.operands[0].u64); - } break; - case DW_CFA_SameValue: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); - } break; - case DW_CFA_Register: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64); - } break; - case DW_CFA_RememberState: { operand_str = str8_zero(); } break; - case DW_CFA_RestoreState: { operand_str = str8_zero(); } break; - case DW_CFA_DefCfa: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64); - } break; - case DW_CFA_DefCfaRegister: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); - } break; - case DW_CFA_DefCfaOffset: { - operand_str = str8f(arena, "+%I64u", inst.operands[0].u64); - } break; - case DW_CFA_DefCfaExpr: { - operand_str = dw_string_from_expression(arena, inst.operands[0].block, cu_base, cie->address_size, arch, ver, ext, format); - } break; - case DW_CFA_Expr: { - String8 reg_str = dw_string_from_reg_off(scratch.arena, arch, inst.operands[0].u64, 0); - String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format); - operand_str = str8f(arena, "%S expression %S", reg_str, expr_str); - } break; - case DW_CFA_OffsetExtSf: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64); - } break; - case DW_CFA_DefCfaSf: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64); - } break; - case DW_CFA_DefCfaOffsetSf: { operand_str = str8_zero(); } break; - case DW_CFA_ValOffset: { - operand_str = str8f(arena, "value 0x%I64x, offset %+I64d", inst.operands[0].u64, inst.operands[1].u64); - } break; - case DW_CFA_ValOffsetSf: { - operand_str = str8f(arena, "value %I64u, offset %+I64d", inst.operands[0].u64, inst.operands[1].s64); - } break; - case DW_CFA_ValExpr: { - String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format); - operand_str = str8f(arena, "value +%I64u, expression %S", inst.operands[0].u64, expr_str); - } break; - case DW_CFA_AdvanceLoc: { - U64 delta = inst.operands[0].u64; - pc += delta; - operand_str = str8f(arena, "+%I64u `PC 0x%I64x`", delta, pc); - } break; - case DW_CFA_Offset: { - U64 reg = inst.operands[0].u64; - S64 offset = (S64)inst.operands[1].u64; - operand_str = dw_string_from_reg_off(arena, arch, reg, offset); - } break; - case DW_CFA_Restore: { - operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); - } break; - default: { - str8_list_pushf(arena, &list, "ERROR: unknown CFA opcode 0x%I64u", inst.opcode); - } goto exit; + case DW_CFA_Nop: { operand_str = str8_zero(); } break; + case DW_CFA_SetLoc: { + operand_str = str8f(arena, "0x%X", inst.operands[0].u64); + pc = inst.operands[0].u64; + } break; + case DW_CFA_AdvanceLoc1: { + U64 delta = inst.operands[0].u64; + pc += delta; + operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); + } break; + case DW_CFA_AdvanceLoc2: { + U64 delta = inst.operands[0].u64; + pc += delta; + operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); + } break; + case DW_CFA_AdvanceLoc4: { + U64 delta = inst.operands[0].u64; + pc += delta; + operand_str = str8f(arena, "%+u `PC 0x%I64x`", delta, pc); + } break; + case DW_CFA_OffsetExt: { + U64 reg = inst.operands[0].u64; + S64 offset = (S64)inst.operands[1].u64; + operand_str = dw_string_from_reg_off(arena, arch, reg, offset); + } break; + case DW_CFA_RestoreExt: { operand_str = str8_zero(); } break; + case DW_CFA_Undefined: { + operand_str = str8f(arena, "%I64u", inst.operands[0].u64); + } break; + case DW_CFA_SameValue: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); + } break; + case DW_CFA_Register: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64); + } break; + case DW_CFA_RememberState: { operand_str = str8_zero(); } break; + case DW_CFA_RestoreState: { operand_str = str8_zero(); } break; + case DW_CFA_DefCfa: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].u64); + } break; + case DW_CFA_DefCfaRegister: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); + } break; + case DW_CFA_DefCfaOffset: { + operand_str = str8f(arena, "+%I64u", inst.operands[0].u64); + } break; + case DW_CFA_DefCfaExpr: { + operand_str = dw_string_from_expression(arena, inst.operands[0].block, cu_base, cie->address_size, arch, ver, ext, format); + } break; + case DW_CFA_Expr: { + String8 reg_str = dw_string_from_reg_off(scratch.arena, arch, inst.operands[0].u64, 0); + String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format); + operand_str = str8f(arena, "%S expression %S", reg_str, expr_str); + } break; + case DW_CFA_OffsetExtSf: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64); + } break; + case DW_CFA_DefCfaSf: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, inst.operands[1].s64); + } break; + case DW_CFA_DefCfaOffsetSf: { operand_str = str8_zero(); } break; + case DW_CFA_ValOffset: { + operand_str = str8f(arena, "value 0x%I64x, offset %+I64d", inst.operands[0].u64, inst.operands[1].u64); + } break; + case DW_CFA_ValOffsetSf: { + operand_str = str8f(arena, "value %I64u, offset %+I64d", inst.operands[0].u64, inst.operands[1].s64); + } break; + case DW_CFA_ValExpr: { + String8 expr_str = dw_string_from_expression(scratch.arena, inst.operands[1].block, cu_base, cie->address_size, arch, ver, ext, format); + operand_str = str8f(arena, "value +%I64u, expression %S", inst.operands[0].u64, expr_str); + } break; + case DW_CFA_AdvanceLoc: { + U64 delta = inst.operands[0].u64; + pc += delta; + operand_str = str8f(arena, "+%I64u `PC 0x%I64x`", delta, pc); + } break; + case DW_CFA_Offset: { + U64 reg = inst.operands[0].u64; + S64 offset = (S64)inst.operands[1].u64; + operand_str = dw_string_from_reg_off(arena, arch, reg, offset); + } break; + case DW_CFA_Restore: { + operand_str = dw_string_from_reg_off(arena, arch, inst.operands[0].u64, 0); + } break; + default: { + str8_list_pushf(arena, &list, "ERROR: unknown CFA opcode 0x%I64u", inst.opcode); + } goto exit; } - + if (operand_str.size) { str8_list_pushf(arena, &list, "DW_CFA_%S: %S", dw_string_from_cfa_opcode(inst.opcode), operand_str); } else { str8_list_pushf(arena, &list, "DW_CFA_%S", dw_string_from_cfa_opcode(inst.opcode)); } } - -exit:; + + exit:; scratch_end(scratch); return list; } @@ -566,10 +566,10 @@ dw_string_from_cfa(Arena *arena, Arch arch, U64 address_size, DW_Version version { String8 cfa_str = str8_lit("???"); switch (cfa.rule) { - case DW_CFA_Rule_Null: {} break; - case DW_CFA_Rule_RegOff: { cfa_str = dw_string_from_reg_off(arena, arch, cfa.reg, cfa.off); } break; - case DW_CFA_Rule_Expression: { cfa_str = dw_string_from_expression(arena, cfa.expr, max_U64, address_size, arch, version, ext, format); } break; - default: { InvalidPath; } break; + case DW_CFA_Rule_Null: {} break; + case DW_CFA_Rule_RegOff: { cfa_str = dw_string_from_reg_off(arena, arch, cfa.reg, cfa.off); } break; + case DW_CFA_Rule_Expression: { cfa_str = dw_string_from_expression(arena, cfa.expr, max_U64, address_size, arch, version, ext, format); } break; + default: { InvalidPath; } break; } return cfa_str; } @@ -584,40 +584,40 @@ dw_string_from_cfi_row(Arena *arena, Arch arch, U64 address_size, DW_Version ver DW_CFI_Register *cfi_reg = &row->regs[reg_idx]; String8 rule_str = str8_lit("???"); switch (cfi_reg->rule) { - case DW_CFI_RegisterRule_Undefined: { - rule_str = str8f(scratch.arena, "Undefined(%S)", dw_string_from_register(scratch.arena, arch, cfi_reg->n)); - } break; - case DW_CFI_RegisterRule_SameValue: { - rule_str = str8_zero(); - } break; - case DW_CFI_RegisterRule_Offset: { - rule_str = str8f(scratch.arena, "[CFA%+I64d]", cfi_reg->n); - } break; - case DW_CFI_RegisterRule_ValOffset: { - rule_str = str8f(scratch.arena, "Val(CFA%+I64d)", cfi_reg->n); - } break; - case DW_CFI_RegisterRule_Register: { - rule_str = str8f(scratch.arena, "Register(%S)", dw_string_from_register(scratch.arena, arch, cfi_reg->n)); - } break; - case DW_CFI_RegisterRule_Expression: { - rule_str = str8f(scratch.arena, "Expression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format)); - } break; - case DW_CFI_RegisterRule_ValExpression: { - rule_str = str8f(scratch.arena, "ValExpression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format)); - } break; - case DW_CFI_RegisterRule_Architectural: { - rule_str = str8_lit("???"); - } break; - default: { InvalidPath; } break; + case DW_CFI_RegisterRule_Undefined: { + rule_str = str8f(scratch.arena, "Undefined(%S)", dw_string_from_register(scratch.arena, arch, cfi_reg->n)); + } break; + case DW_CFI_RegisterRule_SameValue: { + rule_str = str8_zero(); + } break; + case DW_CFI_RegisterRule_Offset: { + rule_str = str8f(scratch.arena, "[CFA%+I64d]", cfi_reg->n); + } break; + case DW_CFI_RegisterRule_ValOffset: { + rule_str = str8f(scratch.arena, "Val(CFA%+I64d)", cfi_reg->n); + } break; + case DW_CFI_RegisterRule_Register: { + rule_str = str8f(scratch.arena, "Register(%S)", dw_string_from_register(scratch.arena, arch, cfi_reg->n)); + } break; + case DW_CFI_RegisterRule_Expression: { + rule_str = str8f(scratch.arena, "Expression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format)); + } break; + case DW_CFI_RegisterRule_ValExpression: { + rule_str = str8f(scratch.arena, "ValExpression(%S)", dw_string_from_expression(scratch.arena, cfi_reg->expr, max_U64, address_size, arch, version, ext, format)); + } break; + case DW_CFI_RegisterRule_Architectural: { + rule_str = str8_lit("???"); + } break; + default: { InvalidPath; } break; } - + if (rule_str.size) { str8_list_pushf(scratch.arena, &cfi_regs_list, "%S: %S", dw_string_from_register(scratch.arena, arch, reg_idx), rule_str); } } - + String8 string = str8_list_join(arena, &cfi_regs_list, &(StringJoin){.sep=str8_lit(", ")}); - + scratch_end(scratch); return string; } @@ -633,10 +633,10 @@ dw_single_line_string_from_expression(Arena *arena, String8 raw_data, U64 cu_bas } internal String8 -dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib) +dw_string_from_attrib_value(Arena *arena, DW_Raw *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib) { Temp scratch = scratch_begin(&arena, 1); - + String8List attrib_fmt = {0}; // rjf: log attrib's value based on vlass @@ -762,7 +762,7 @@ dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUni enum_info = dw_string_from_attrib_visibility(scratch.arena, vis); }break; } - + if(enum_info.size) { str8_list_pushf(scratch.arena, &attrib_fmt, " `%S`", enum_info); @@ -770,7 +770,7 @@ dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUni } String8 result = str8_list_join(arena, &attrib_fmt, 0); - + scratch_end(scratch); return result; } @@ -778,8 +778,8 @@ dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUni internal DW_PRINTER(dw_print_abbrev) { - DW_Input *input = dumper->input; - + DW_Raw *input = dumper->input; + Temp scratch = scratch_begin(&arena, 1); DW_Section abbrev = input->sec[DW_Section_Abbrev]; S64 depth = 0; @@ -791,13 +791,13 @@ DW_PRINTER(dw_print_abbrev) U64 id = 0; cursor += str8_deserial_read_uleb128(abbrev.data, cursor, &id); if(id == 0) { continue; } - + // rjf: unpack abbrev U64 tag = 0; U8 has_children = 0; cursor += str8_deserial_read_uleb128(abbrev.data, cursor, &tag); cursor += str8_deserial_read_struct(abbrev.data, cursor, &has_children); - + // rjf: log abbrev Temp temp = temp_begin(scratch.arena); dw_printf("abbrev: // abbrev[%I64u] abbrev_off: 0x%I64x \n {\n", idx, id_off); @@ -827,7 +827,7 @@ DW_PRINTER(dw_print_abbrev) if(attrib_id == 0) { break; } String8 attrib_str = dw_string_from_attrib_kind(temp.arena, DW_Version_Last, DW_Ext_All, attrib_id); String8 form_str = dw_string_from_form_kind(temp.arena, DW_Version_Last, form_id); - + String8List fmt = {0}; str8_list_pushf(temp.arena, &fmt, "%S%.*s", attrib_str, attrib_kind_max_size - attrib_str.size, g_spaces); str8_list_pushf(temp.arena, &fmt, "%S%.*s", form_str, form_kind_max_size - form_str.size, g_spaces); @@ -842,13 +842,13 @@ DW_PRINTER(dw_print_abbrev) } internal void -dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_TagNode *root) +dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_TagNode *root) { Temp scratch = scratch_begin(0, 0); - + for (DW_TagNode *n = root; n != 0; n = n->sibling) { DW_Tag *tag = &n->tag; - + // compute columns' max widths U64 attrib_name_max_size = 0, form_kind_max_size = 0, value_max_size = 0; for EachNode(attrib_n, DW_AttribNode, tag->attribs.first) @@ -862,48 +862,48 @@ dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Input attrib_name_max_size = Min(40, attrib_name_max_size); form_kind_max_size = Min(20, form_kind_max_size); value_max_size = Min(80, value_max_size); - + dw_printf("tag: // info_off: 0x%I64x abbrev_id: %I64u\n", tag->info_off, tag->abbrev_id); dw_printf("{\n"); dw_indent(); dw_printf("kind: %S\n", dw_string_from_tag_kind(scratch.arena, tag->kind)); for EachNode(attrib_n, DW_AttribNode, tag->attribs.first) { DW_Attrib *attrib = &attrib_n->v; - + String8 attrib_kind_str = dw_string_from_attrib_kind(scratch.arena, cu->version, cu->ext, attrib->attrib_kind); String8 form_kind_str = dw_string_from_form_kind(scratch.arena, cu->version, attrib->form.kind); String8 value_str = dw_string_from_attrib_value(scratch.arena, input, arch, cu, line_vm, attrib); - + String8List fmt = {0}; str8_list_pushf(scratch.arena, &fmt, "%S%.*s", attrib_kind_str, attrib_kind_str.size <= attrib_name_max_size ? attrib_name_max_size - attrib_kind_str.size : 0, g_spaces); str8_list_pushf(scratch.arena, &fmt, "%S%.*s", form_kind_str, form_kind_str.size <= form_kind_max_size ? form_kind_max_size - form_kind_str.size : 0, g_spaces); str8_list_pushf(scratch.arena, &fmt, "%S%.*s", value_str, value_str.size <= value_max_size ? value_max_size - value_str.size : 0, g_spaces); String8 attrib_str = str8_list_join(scratch.arena, &fmt, &(StringJoin){.sep = str8_lit(" ")}); - + dw_printf("attrib: { %S } // info_off: 0x%I64x\n", attrib_str, attrib->info_off); } - + if (tag->has_children) { dw_print_tag(arena, strings, indent, arch, input, cu, line_vm, n->first_child); } - + dw_unindent(); dw_printf("}\n"); } - + scratch_end(scratch); } internal DW_PRINTER(dw_print_info) { - DW_Input *input = dumper->input; + DW_Raw *input = dumper->input; Arch arch = dumper->arch; HashTable *line_vm_map = dw_get_line_vm_map(dumper); Rng1U64Array cu_ranges = dw_get_info_ranges(dumper); DW_CompUnit *cu_arr = dw_get_cu_arr(dumper); DW_TagTree *tag_trees = dw_get_tag_trees(dumper); - + Temp scratch = scratch_begin(&arena, 1); for EachIndex(cu_idx, cu_ranges.count) { Rng1U64 cu_range = cu_ranges.v[cu_idx]; @@ -911,7 +911,7 @@ DW_PRINTER(dw_print_info) String8 cu_dir = dw_string_from_tag_attrib_kind (input, cu, cu->tag, DW_AttribKind_CompDir ); String8 cu_name = dw_string_from_tag_attrib_kind (input, cu, cu->tag, DW_AttribKind_Name ); String8 stmt_list = dw_line_ptr_from_tag_attrib_kind(input, cu, cu->tag, DW_AttribKind_StmtList); - + DW_LineVM *line_vm = 0; if (stmt_list.str) { line_vm = hash_table_search_raw_raw(line_vm_map, stmt_list.str); @@ -924,7 +924,7 @@ DW_PRINTER(dw_print_info) hash_table_push_raw_raw(scratch.arena, line_vm_map, stmt_list.str, line_vm); } } - + dw_printf("cu: // compile_unit[%I64u] @ %r (%M)\n", cu_idx, cu_range, dim_1u64(cu->info_range)); dw_printf("{\n"); dw_indent(); @@ -941,7 +941,7 @@ DW_PRINTER(dw_print_info) DW_PRINTER(dw_print_line) { - DW_Input *input = dumper->input; + DW_Raw *input = dumper->input; B32 is_verbose = dumper->is_verbose; DW_CompUnit *cu_arr = dw_get_cu_arr(dumper); Temp scratch = scratch_begin(&arena, 1); @@ -949,10 +949,10 @@ DW_PRINTER(dw_print_line) for EachIndex(unit_idx, unit_ranges.count) { Temp unit_temp = temp_begin(scratch.arena); - + DW_CompUnit *cu = &cu_arr[unit_idx]; DW_LineVM *vm = dw_line_vm_init(input, cu); - + // rjf: begin logging line table dw_printf("line_table: // line_table[%I64u]\n", unit_idx); dw_printf("{\n"); @@ -980,7 +980,7 @@ DW_PRINTER(dw_print_line) } dw_unindent(); dw_printf("}\n"); - + // rjf: log directory table dw_printf("directory_table:\n"); dw_printf("{\n"); @@ -995,7 +995,7 @@ DW_PRINTER(dw_print_line) } dw_unindent(); dw_printf("}\n"); - + // rjf: log file table dw_printf("file_table:\n"); dw_printf("{\n"); @@ -1007,18 +1007,18 @@ DW_PRINTER(dw_print_line) { DW_LineFile *file = &vm->header.file_table.v[file_idx]; dw_printf("{ %-4I64u %-8I64u %-8I64u %016I64x-%016I64x %-8I64u %-20S }\n", - file_idx, - file->dir_idx, - file->time_stamp, - file->md5.u64[1], - file->md5.u64[0], - file->size, - file->path); + file_idx, + file->dir_idx, + file->time_stamp, + file->md5.u64[1], + file->md5.u64[0], + file->size, + file->path); } } dw_unindent(); dw_printf("}\n"); - + // rjf: log opcodes dw_printf("line_table:\n"); dw_printf("{\n"); @@ -1027,106 +1027,106 @@ DW_PRINTER(dw_print_line) dw_printf("//\n"); dw_printf("// %-16s %-8s %-4s %-5s %-3s %-7s %-16s\n", "Address", "Line", "Col", "File", "ISA", "Discrim", "Flags"); dw_printf("// ---------------- -------- ---- ----- --- ------- ----------------\n"); - + for(;;) { U64 global_opcode_off = unit_ranges.v[unit_idx].min + vm->cursor; - + if( ! dw_line_vm_step(vm)) { break; } - + Temp opcode_temp = temp_begin(unit_temp.arena); String8List opcode_fmt = {0}; - + // opcode offset str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%08I64x:", global_opcode_off); - + // push opcode id if (vm->opcode != 0) { String8 opcode_str = dw_string_from_std_opcode(opcode_temp.arena, vm->opcode); str8_list_pushf(arena, &opcode_fmt, "%-11S:", opcode_str); } - + // print operands switch(vm->opcode) { - default: - { - if(vm->opcode >= vm->header.opcode_base) + default: { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance line by %I64d, advance address by %I64d", vm->line_advance, vm->addr_advance); - } - else + if(vm->opcode >= vm->header.opcode_base) + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance line by %I64d, advance address by %I64d", vm->line_advance, vm->addr_advance); + } + else + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "skipping %I64x unknown opcodes", vm->header.opcode_lens[vm->opcode - 1]); + } + }break; + case DW_StdOpcode_Copy: { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "skipping %I64x unknown opcodes", vm->header.opcode_lens[vm->opcode - 1]); - } - }break; - case DW_StdOpcode_Copy: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "Line = %I64u, Column = %I64u, Address = %#I64x", vm->state.line, vm->state.column, vm->state.address); - }break; - case DW_StdOpcode_AdvancePc: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance %#I64x ; current address %#I64x", vm->operands[0].u64, vm->state.address); - }break; - case DW_StdOpcode_AdvanceLine: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance %I64d ; current line %I64u", vm->operands[0].s64, vm->state.line); - }break; - case DW_StdOpcode_SetFile: - { - DW_LineFile *file = dw_line_vm_find_file(vm, vm->state.file_index); - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u \"%S\"", vm->state.file_index, dw_path_from_file(opcode_temp.arena, vm->header.dir_table, file)); - }break; - case DW_StdOpcode_SetColumn: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->state.column); - }break; - case DW_StdOpcode_NegateStmt: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "is_stmt = %u", vm->state.is_stmt); - }break; - case DW_StdOpcode_SetBasicBlock: - { - }break; - case DW_StdOpcode_ConstAddPc: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64d ; address %#I64x", vm->advance, vm->state.address); - }break; - case DW_StdOpcode_FixedAdvancePc: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->operands[0].u64); - }break; - case DW_StdOpcode_SetPrologueEnd: - { - }break; - case DW_StdOpcode_SetEpilogueBegin: - { - }break; - case DW_StdOpcode_SetIsa: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->state.isa); - }break; - case DW_StdOpcode_ExtendedOpcode: - { - str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%S*", dw_string_from_ext_opcode(opcode_temp.arena, vm->ext_opcode)); - //str8_list_pushf(opcode_temp.arena, &opcode_fmt, "length: %u", length); - switch(vm->ext_opcode) + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "Line = %I64u, Column = %I64u, Address = %#I64x", vm->state.line, vm->state.column, vm->state.address); + }break; + case DW_StdOpcode_AdvancePc: { - case DW_ExtOpcode_EndSequence: {} break; - case DW_ExtOpcode_SetAddress: { str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%#I64x", vm->operands[0].u64); } break; - case DW_ExtOpcode_DefineFile: { str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%S Dir: %I64u, Time: %I64u, Size: %I64u", - vm->operands[0].string, vm->operands[1].u64, vm->operands[2].u64, vm->operands[3].u64); } break; - case DW_ExtOpcode_SetDiscriminator: { str8_list_pushf(arena, &opcode_fmt, "%I64u", vm->state.discriminator); }break; - } + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance %#I64x ; current address %#I64x", vm->operands[0].u64, vm->state.address); + }break; + case DW_StdOpcode_AdvanceLine: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "advance %I64d ; current line %I64u", vm->operands[0].s64, vm->state.line); + }break; + case DW_StdOpcode_SetFile: + { + DW_LineFile *file = dw_line_vm_find_file(vm, vm->state.file_index); + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u \"%S\"", vm->state.file_index, dw_path_from_file(opcode_temp.arena, vm->header.dir_table, file)); + }break; + case DW_StdOpcode_SetColumn: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->state.column); + }break; + case DW_StdOpcode_NegateStmt: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "is_stmt = %u", vm->state.is_stmt); + }break; + case DW_StdOpcode_SetBasicBlock: + { + }break; + case DW_StdOpcode_ConstAddPc: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64d ; address %#I64x", vm->advance, vm->state.address); + }break; + case DW_StdOpcode_FixedAdvancePc: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->operands[0].u64); + }break; + case DW_StdOpcode_SetPrologueEnd: + { + }break; + case DW_StdOpcode_SetEpilogueBegin: + { + }break; + case DW_StdOpcode_SetIsa: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%I64u", vm->state.isa); + }break; + case DW_StdOpcode_ExtendedOpcode: + { + str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%S*", dw_string_from_ext_opcode(opcode_temp.arena, vm->ext_opcode)); + //str8_list_pushf(opcode_temp.arena, &opcode_fmt, "length: %u", length); + switch(vm->ext_opcode) + { + case DW_ExtOpcode_EndSequence: {} break; + case DW_ExtOpcode_SetAddress: { str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%#I64x", vm->operands[0].u64); } break; + case DW_ExtOpcode_DefineFile: { str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%S Dir: %I64u, Time: %I64u, Size: %I64u", + vm->operands[0].string, vm->operands[1].u64, vm->operands[2].u64, vm->operands[3].u64); } break; + case DW_ExtOpcode_SetDiscriminator: { str8_list_pushf(arena, &opcode_fmt, "%I64u", vm->state.discriminator); }break; + } }break; } - + if(is_verbose) { String8 string = str8_list_join(opcode_temp.arena, &opcode_fmt, &(StringJoin){.sep=str8_lit(" ")}); dw_printf("// %S\n", string); } - + if(vm->new_line) { String8List l = {0}; if(vm->state.is_stmt) @@ -1138,13 +1138,13 @@ DW_PRINTER(dw_print_line) str8_list_pushf(opcode_temp.arena, &l, "end_seq"); } String8 flags = str8_list_join(opcode_temp.arena, &l, &(StringJoin){.sep = str8_lit("|")}); - + dw_printf("{ %#016I64x %8I64u %4I64u %5I64u %3I64u %7I64u %-16S } %s\n", vm->state.address, vm->state.line, vm->state.column, vm->state.file_index, vm->state.isa, vm->state.discriminator, flags, vm->new_seq ? "// new seq" : ""); } - + temp_end(opcode_temp); } - + if(vm->error.size) { dw_printf("ERROR: Line VM failed stepping @ 0x%I64x\n", vm->cursor); @@ -1152,7 +1152,7 @@ DW_PRINTER(dw_print_line) } dw_unindent(); dw_printf("}\n"); - + temp_end(unit_temp); } dw_unindent(); @@ -1163,7 +1163,7 @@ DW_PRINTER(dw_print_line) DW_PRINTER(dw_print_strings) { - DW_Input *input = dumper->input; + DW_Raw *input = dumper->input; String8 data = input->sec[DW_Section_Str].data; for (U64 cursor = 0, read_size = 0; cursor < data.size; cursor += read_size) { String8 string = {0}; @@ -1174,13 +1174,13 @@ DW_PRINTER(dw_print_strings) DW_PRINTER(dw_print_frame) { - DW_Input *input = dumper->input; + DW_Raw *input = dumper->input; Arch arch = dumper->arch; Temp scratch = scratch_begin(&arena, 1); HashTable *cie_ht = hash_table_init(scratch.arena, 0x2000); String8 debug_frame = input->sec[DW_Section_Frame].data; U64 addr_size = byte_size_from_arch(arch); - + // make offset -> CIE hash table for (U64 cursor = 0, desc_size; cursor < debug_frame.size; cursor += desc_size) { DW_DescriptorEntry desc = {0}; @@ -1196,77 +1196,77 @@ DW_PRINTER(dw_print_frame) } } } - + for (U64 cursor = 0, desc_size; cursor < debug_frame.size; cursor += desc_size) { DW_DescriptorEntry desc = {0}; desc_size = dw_parse_descriptor_entry_header(debug_frame, cursor, &desc); String8 raw_desc = str8_substr(debug_frame, desc.entry_range); switch (desc.type) { - case DW_DescriptorEntryType_Null: {} break; - case DW_DescriptorEntryType_CIE: { - DW_CIE cie = {0}; - if (dw_parse_cie(raw_desc, desc.format, arch, &cie)) { - String8List init_insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, DW_Version_5, DW_Ext_All, cie.format, 0, &cie, dw_decode_ptr_debug_frame, &cie, cie.insts); - - dw_printf("CIE: // entry range: %r\n", desc.entry_range); - dw_printf("{\n"); - dw_printf(" Format: %S\n", dw_string_from_format(desc.format)); - dw_printf(" Version: %u\n", cie.version); - dw_printf(" Aug string: \"%S\"\n", cie.aug_string); - dw_printf(" Code align: %I64u\n", cie.code_align_factor); - dw_printf(" Data align: %I64d\n", cie.data_align_factor); - dw_printf(" Return addr reg: %u\n", cie.ret_addr_reg); - if (cie.version > DW_Version_3) { - dw_printf(" Address size: %u\n", cie.address_size); - dw_printf(" Segment selector size: %u\n", cie.segment_selector_size); - } - dw_printf(" Initial Insturction:\n"); - dw_printf(" {\n"); - for EachNode(n, String8Node, init_insts_str_list.first) { dw_printf(" %S\n", n->string); } - dw_printf(" }\n"); - dw_printf("}\n"); - } else { - dw_printf("ERROR: unable to parse CIE @ %I64x\n", desc.entry_range.min); - } - } break; - case DW_DescriptorEntryType_FDE: { - DW_DescriptorEntry cie_desc = {0}; - U64 cie_desc_size = dw_parse_descriptor_entry_header(debug_frame, desc.cie_pointer, &cie_desc); - String8 cie_data = str8_substr(debug_frame, cie_desc.entry_range); - DW_CIE cie = {0}; - dw_parse_cie(cie_data, cie_desc.format, arch, &cie); - - DW_FDE fde = {0}; - if (dw_parse_fde(raw_desc, desc.format, &cie, &fde)) { - DW_Version version = DW_Version_5; - DW_Ext ext = DW_Ext_All; - String8List insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, version, ext, fde.format, fde.pc_range.min, &cie, dw_decode_ptr_debug_frame, &cie, fde.insts); - dw_printf("FDE: // entry range: %r\n", desc.entry_range); - dw_printf("{\n"); - { - dw_printf(" Format: %S\n", dw_string_from_format(fde.format)); - dw_printf(" CIE pointer: 0x%I64x\n", fde.cie_pointer); - dw_printf(" PC range: %r\n", fde.pc_range); - dw_printf(" Instructions:\n"); + case DW_DescriptorEntryType_Null: {} break; + case DW_DescriptorEntryType_CIE: { + DW_CIE cie = {0}; + if (dw_parse_cie(raw_desc, desc.format, arch, &cie)) { + String8List init_insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, DW_Version_5, DW_Ext_All, cie.format, 0, &cie, dw_decode_ptr_debug_frame, &cie, cie.insts); + + dw_printf("CIE: // entry range: %r\n", desc.entry_range); + dw_printf("{\n"); + dw_printf(" Format: %S\n", dw_string_from_format(desc.format)); + dw_printf(" Version: %u\n", cie.version); + dw_printf(" Aug string: \"%S\"\n", cie.aug_string); + dw_printf(" Code align: %I64u\n", cie.code_align_factor); + dw_printf(" Data align: %I64d\n", cie.data_align_factor); + dw_printf(" Return addr reg: %u\n", cie.ret_addr_reg); + if (cie.version > DW_Version_3) { + dw_printf(" Address size: %u\n", cie.address_size); + dw_printf(" Segment selector size: %u\n", cie.segment_selector_size); + } + dw_printf(" Initial Insturction:\n"); dw_printf(" {\n"); - for EachNode(n, String8Node, insts_str_list.first) { dw_printf(" %S\n", n->string); } + for EachNode(n, String8Node, init_insts_str_list.first) { dw_printf(" %S\n", n->string); } dw_printf(" }\n"); + dw_printf("}\n"); + } else { + dw_printf("ERROR: unable to parse CIE @ %I64x\n", desc.entry_range.min); } - dw_printf(" Unwind:\n"); - dw_printf(" {\n"); - DW_CFI_Unwind *cfi_unwind = dw_cfi_unwind_init(scratch.arena, arch, &cie, &fde, dw_decode_ptr_debug_frame, &cie); - do { - String8 cfa_str = dw_string_from_cfa(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row->cfa); - String8 cfi_regs_str = dw_string_from_cfi_row(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row); - dw_printf(" { PC: 0x%I64x, CFA: %-7S, Rules: { %S }\n", cfi_unwind->pc, cfa_str, cfi_regs_str); - } while (dw_cfi_next_row(scratch.arena, cfi_unwind)); - dw_printf(" }\n"); - - dw_printf("}\n"); - } else { - dw_printf("ERROR: unable to parse FDE @ %I64x\n", desc.entry_range.min); - } - } break; + } break; + case DW_DescriptorEntryType_FDE: { + DW_DescriptorEntry cie_desc = {0}; + U64 cie_desc_size = dw_parse_descriptor_entry_header(debug_frame, desc.cie_pointer, &cie_desc); + String8 cie_data = str8_substr(debug_frame, cie_desc.entry_range); + DW_CIE cie = {0}; + dw_parse_cie(cie_data, cie_desc.format, arch, &cie); + + DW_FDE fde = {0}; + if (dw_parse_fde(raw_desc, desc.format, &cie, &fde)) { + DW_Version version = DW_Version_5; + DW_Ext ext = DW_Ext_All; + String8List insts_str_list = dw_string_list_from_cfi_program(scratch.arena, 0, arch, version, ext, fde.format, fde.pc_range.min, &cie, dw_decode_ptr_debug_frame, &cie, fde.insts); + dw_printf("FDE: // entry range: %r\n", desc.entry_range); + dw_printf("{\n"); + { + dw_printf(" Format: %S\n", dw_string_from_format(fde.format)); + dw_printf(" CIE pointer: 0x%I64x\n", fde.cie_pointer); + dw_printf(" PC range: %r\n", fde.pc_range); + dw_printf(" Instructions:\n"); + dw_printf(" {\n"); + for EachNode(n, String8Node, insts_str_list.first) { dw_printf(" %S\n", n->string); } + dw_printf(" }\n"); + } + dw_printf(" Unwind:\n"); + dw_printf(" {\n"); + DW_CFI_Unwind *cfi_unwind = dw_cfi_unwind_init(scratch.arena, arch, &cie, &fde, dw_decode_ptr_debug_frame, &cie); + do { + String8 cfa_str = dw_string_from_cfa(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row->cfa); + String8 cfi_regs_str = dw_string_from_cfi_row(scratch.arena, arch, cie.address_size, version, ext, fde.format, cfi_unwind->row); + dw_printf(" { PC: 0x%I64x, CFA: %-7S, Rules: { %S }\n", cfi_unwind->pc, cfa_str, cfi_regs_str); + } while (dw_cfi_next_row(scratch.arena, cfi_unwind)); + dw_printf(" }\n"); + + dw_printf("}\n"); + } else { + dw_printf("ERROR: unable to parse FDE @ %I64x\n", desc.entry_range.min); + } + } break; } } } @@ -1275,7 +1275,7 @@ DW_PRINTER(dw_print_frame) internal DW_PRINTER(dw_print_debug_loc) { - DW_Input *input = dumper->input; + DW_Raw *input = dumper->input; DW_TagTree *tag_trees = dw_get_tag_trees(dumper); DW_Section info = input->sec[DW_Section_Info]; DW_Section loc = input->sec[DW_Section_Loc]; @@ -1397,7 +1397,7 @@ DW_PRINTER(dw_print_debug_loc) #if 0 internal void -dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed) +dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed) { NotImplemented; #if 0 @@ -1503,7 +1503,7 @@ dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_In } internal void -dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { NotImplemented; #if 0 @@ -1592,7 +1592,7 @@ dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_I } internal void -dw_print_debug_addr(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_addr(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { NotImplemented; #if 0 @@ -1701,7 +1701,7 @@ dw_based_range_read_address(void *base, Rng1U64 range, U64 offset, Rng1U64Array } internal void -dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Rng1U64Array segment_virtual_ranges, Arch arch) +dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Rng1U64Array segment_virtual_ranges, Arch arch) { NotImplemented; #if 0 @@ -1854,7 +1854,7 @@ dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_ } internal void -dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Rng1U64Array segment_ranges) +dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Rng1U64Array segment_ranges) { NotImplemented; #if 0 @@ -1993,7 +1993,7 @@ dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_ } internal void -dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, DW_SectionKind sec) +dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, DW_SectionKind sec) { NotImplemented; #if 0 @@ -2055,19 +2055,19 @@ dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_I } internal void -dw_print_debug_pubnames(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_pubnames(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubNames); } internal void -dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubTypes); } internal void -dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { NotImplemented; #if 0 @@ -2097,7 +2097,7 @@ dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_ } internal void -dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) +dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input) { NotImplemented; #if 0 @@ -2180,7 +2180,7 @@ read_only struct { internal String8List dw_dump_list_from_sections(Arena *arena, - DW_Input *input, + DW_Raw *input, Arch arch, DW_SectionFlags subset_flags, B32 is_verbose) @@ -2188,19 +2188,19 @@ dw_dump_list_from_sections(Arena *arena, Temp scratch = scratch_begin(&arena, 1); String8List *strings = push_array(scratch.arena, String8List, 1); int indent = 0; - + DW_Dumper dumper = {0}; dumper.arena = arena_alloc(); dumper.arch = arch; dumper.is_verbose = is_verbose; dumper.input = input; dumper.is_relaxed = 1; - + for EachElement(i, g_dw_printers) { if (((1 << g_dw_printers[i].kind) & subset_flags) != 0) { String8List s = {0}; g_dw_printers[i].printer(arena, &s, indent + 1, &dumper); - + if (s.total_size > 0) { dw_printf("%S:\n", str8_skip(dw_name_string_from_section_kind(g_dw_printers[i].kind), 1)); dw_printf("{\n"); @@ -2211,7 +2211,7 @@ dw_dump_list_from_sections(Arena *arena, } } } - + String8List result = *strings; arena_release(dumper.arena); scratch_end(scratch); diff --git a/src/dwarf/dwarf_dump.h b/src/dwarf/dwarf_dump.h index eec0d983..6a015952 100644 --- a/src/dwarf/dwarf_dump.h +++ b/src/dwarf/dwarf_dump.h @@ -18,7 +18,7 @@ typedef struct DW_Dumper Arch arch; B32 is_relaxed; B32 is_verbose; - DW_Input *input; + DW_Raw *input; DW_DumperCacheFlags cache_flags; struct { Rng1U64Array info_ranges; @@ -46,28 +46,28 @@ internal String8List dw_string_list_from_cfi_program(Arena *arena, U64 cu_base, internal String8List dw_string_list_from_expression (Arena *arena, String8 raw_data, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format); internal String8 dw_string_from_reg_off (Arena *arena, Arch arch, DW_Reg reg_idx, S64 reg_off); -internal String8 dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib); +internal String8 dw_string_from_attrib_value(Arena *arena, DW_Raw *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib); internal String8 dw_string_from_expression (Arena *arena, String8 expr, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format); internal String8 dw_string_from_cfa (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFA cfa); internal String8 dw_string_from_cfi_row (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFI_Row *row); #if 0 internal void dw_print_eh_frame (Arena *arena, String8List *out, String8 indent, String8 raw_eh_frame, Arch arch, DW_Version ver, DW_Ext ext, EH_PtrCtx *ptr_ctx); -internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); -internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); -internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Input *input); -internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Input *input); -internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges, Arch arch); -internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges); -internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Input *input); -internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Input *input); -internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Input *input); -internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Input *input); +internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); +internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); +internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input); +internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Raw *input); +internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges, Arch arch); +internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges); +internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Raw *input); +internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Raw *input); +internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Raw *input); +internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Raw *input); #endif //////////////////////////////// //~ rjf: Dump Entry Point -internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_SectionFlags dump_sections, B32 is_verbose); +internal String8List dw_dump_list_from_sections(Arena *arena, DW_Raw *input, Arch arch, DW_SectionFlags dump_sections, B32 is_verbose); #endif // DWARF_DUMP_H diff --git a/src/dwarf/dwarf_elf.c b/src/dwarf/dwarf_elf.c index 39884286..63b09dd4 100644 --- a/src/dwarf/dwarf_elf.c +++ b/src/dwarf/dwarf_elf.c @@ -27,10 +27,10 @@ dw_is_dwarf_present_from_elf_bin(String8 data, ELF_Bin *bin) #define SINFL_IMPLEMENTATION #include "third_party/sinfl/sinfl.h" -internal DW_Input +internal DW_Raw dw_input_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin) { - DW_Input result = {0}; + DW_Raw result = {0}; B32 is_section_present[ArrayCount(result.sec)] = {0}; for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1) { diff --git a/src/dwarf/dwarf_elf.h b/src/dwarf/dwarf_elf.h index a9a54f38..5d5965e3 100644 --- a/src/dwarf/dwarf_elf.h +++ b/src/dwarf/dwarf_elf.h @@ -5,6 +5,6 @@ #define DWARF_ELF_H internal B32 dw_is_dwarf_present_from_elf_bin(String8 raw_image, ELF_Bin *bin); -internal DW_Input dw_input_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin); +internal DW_Raw dw_input_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin); #endif // DWARF_ELF_H diff --git a/src/dwarf/dwarf_inc.c b/src/dwarf/dwarf_inc.c index de222b03..e090fb48 100644 --- a/src/dwarf/dwarf_inc.c +++ b/src/dwarf/dwarf_inc.c @@ -10,5 +10,6 @@ #include "dwarf/dwarf_dump.c" #include "dwarf/dwarf_help.c" #include "dwarf/dwarf_writer.c" +#include "dwarf/dwarf_parse_2.c" #include "dwarf/eh_frame.c" #include "dwarf/eh_dump.c" diff --git a/src/dwarf/dwarf_inc.h b/src/dwarf/dwarf_inc.h index aeba7dde..325c6034 100644 --- a/src/dwarf/dwarf_inc.h +++ b/src/dwarf/dwarf_inc.h @@ -13,6 +13,7 @@ #include "dwarf/dwarf_dump.h" #include "dwarf/dwarf_help.h" #include "dwarf/dwarf_writer.h" +#include "dwarf/dwarf_parse_2.h" #include "dwarf/eh_frame.h" #include "dwarf/eh_dump.h" diff --git a/src/dwarf/dwarf_parse.c b/src/dwarf/dwarf_parse.c index bc57b510..d55925d2 100644 --- a/src/dwarf/dwarf_parse.c +++ b/src/dwarf/dwarf_parse.c @@ -199,17 +199,17 @@ dw_unit_ranges_from_data(Arena *arena, String8 data) for (U64 cursor = 0; cursor < data.size; ) { U64 start = cursor; - + // read unit size U64 size; U64 size_size = str8_deserial_read_dwarf_packed_size(data, cursor, &size); if (size_size == 0) { break; } cursor += size_size; - + // is unit size valid? if (cursor + size > data.size) { break; } cursor += size; - + // push unit range if (size > 0) { rng1u64_list_push(arena, &result, rng_1u64(start, cursor)); @@ -274,7 +274,7 @@ internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out) { U64 header_size = 0; - + U32 first_four_bytes = 0; if (str8_deserial_read_struct(unit_data, 0, &first_four_bytes) != sizeof(first_four_bytes)) { goto exit; } DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit; @@ -310,7 +310,7 @@ internal U64 dw_read_list_unit_header_list(String8 unit_data, DW_ListUnit *lu_out) { U64 header_size = 0; - + U32 first_four_bytes = 0; if (str8_deserial_read_struct(unit_data, 0, &first_four_bytes) != sizeof(first_four_bytes)) { goto exit; } DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit; @@ -353,7 +353,7 @@ dw_read_list_unit_header_list(String8 unit_data, DW_ListUnit *lu_out) } internal DW_ListUnitInput -dw_list_unit_input_from_input(Arena *arena, DW_Input *input) +dw_list_unit_input_from_input(Arena *arena, DW_Raw *input) { Temp scratch = scratch_begin(&arena, 1); @@ -465,17 +465,17 @@ dw_read_abbrev_tag(String8 data, U64 offset, DW_Abbrev *out_abbrev) // read tag ID and kind U64 id = 0; TryRead(str8_deserial_read_uleb128(data, cursor, &id), cursor, exit); - + // is this null terminator? if (id == 0) { total_bytes_read = cursor - offset; MemoryZeroStruct(out_abbrev); goto exit; } - + U64 kind = 0; TryRead(str8_deserial_read_uleb128(data, cursor, &kind), cursor, exit); - + // read child flag U8 has_children = 0; if (id != 0) { @@ -491,7 +491,7 @@ dw_read_abbrev_tag(String8 data, U64 offset, DW_Abbrev *out_abbrev) } total_bytes_read = cursor - offset; -exit:; + exit:; return total_bytes_read; } @@ -500,7 +500,7 @@ dw_read_abbrev_attrib(String8 data, U64 offset, DW_Abbrev *out_abbrev) { U64 total_bytes_read = 0; U64 cursor = offset; - + // read id and kind U64 id, kind; TryRead(str8_deserial_read_uleb128(data, cursor, &id), cursor, exit); @@ -522,7 +522,7 @@ dw_read_abbrev_attrib(String8 data, U64 offset, DW_Abbrev *out_abbrev) } total_bytes_read = cursor - offset; -exit:; + exit:; return total_bytes_read; } @@ -532,24 +532,24 @@ dw_make_abbrev_table(Arena *arena, String8 abbrev_data, U64 abbrev_base) Temp temp = temp_begin(arena); DW_AbbrevTable table = {0}; B32 failed_to_make = 1; - + // count abbrev tags for (U64 cursor = abbrev_base; cursor < abbrev_data.size; table.count += 1) { DW_Abbrev tag; TryRead(dw_read_abbrev_tag(abbrev_data, cursor, &tag), cursor, exit); if (tag.id == 0) { break; } - + for (; cursor < abbrev_data.size; ) { DW_Abbrev attrib; TryRead(dw_read_abbrev_attrib(abbrev_data, cursor, &attrib), cursor, exit); if(attrib.id == 0) { break; } } } - + // alloc entries table.entries = push_array(arena, DW_AbbrevTableEntry, table.count); table.count = 0; - + // fill out the table for (U64 cursor = abbrev_base; cursor < abbrev_data.size;) { U64 tag_abbrev_off = cursor; @@ -571,7 +571,7 @@ dw_make_abbrev_table(Arena *arena, String8 abbrev_data, U64 abbrev_base) } failed_to_make = 0; -exit:; + exit:; if (failed_to_make) { MemoryZeroStruct(&table); temp_end(temp); @@ -759,7 +759,7 @@ dw_read_form(String8 data, } break; default: InvalidPath; break; } - + if (form_out) { form.kind = form_kind; *form_out = form; @@ -769,14 +769,14 @@ dw_read_form(String8 data, } is_ok = 1; -exit:; + exit:; Assert(is_ok); return is_ok; } internal U64 dw_read_tag(Arena *arena, - DW_Input *input, + DW_Raw *input, DW_AbbrevTable abbrev_table, DW_Version version, DW_Format format, @@ -786,17 +786,17 @@ dw_read_tag(Arena *arena, DW_Tag *tag_out) { U64 bytes_read = 0; - + String8 info_data = input->sec[DW_Section_Info].data; String8 abbrev_data = input->sec[DW_Section_Abbrev].data; - + String8 tag_data = str8_substr(info_data, cu_info_range); U64 tag_cursor = tag_info_off - cu_info_range.min; // read tag abbrev id U64 tag_abbrev_id = 0; TryRead(str8_deserial_read_uleb128(tag_data, tag_cursor, &tag_abbrev_id), tag_cursor, exit); - + B32 has_children = 0; DW_TagKind tag_kind = DW_TagKind_Null; DW_AttribList attribs = {0}; @@ -804,34 +804,34 @@ dw_read_tag(Arena *arena, // map abbrev id -> .debug_abbrev offset U64 abbrev_cursor = dw_abbrev_offset_from_abbrev_id(abbrev_table, tag_abbrev_id); if (abbrev_cursor >= abbrev_data.size) { log_user_errorf("failed to find abbrev id 0x%I64x for tag 0x%I64x", tag_abbrev_id, tag_info_off); goto exit; } - + // read tag abbrev DW_Abbrev tag_abbrev = {0}; TryRead(dw_read_abbrev_tag(abbrev_data, abbrev_cursor, &tag_abbrev), abbrev_cursor, exit); - + has_children = !!(tag_abbrev.flags & DW_AbbrevFlag_HasChildren); tag_kind = (DW_TagKind)tag_abbrev.sub_kind; - + // read attribs for (; tag_cursor < tag_data.size && abbrev_cursor < abbrev_data.size; ) { U64 attrib_tag_cursor = tag_cursor; U64 attrib_abbrev_off = abbrev_cursor; - + // read attrib abbrev DW_Abbrev attrib_abbrev = {0}; TryRead(dw_read_abbrev_attrib(abbrev_data, abbrev_cursor, &attrib_abbrev), abbrev_cursor, exit); - + DW_AttribKind attrib_kind = (DW_AttribKind)attrib_abbrev.id; DW_FormKind form_kind = (DW_FormKind)attrib_abbrev.sub_kind; - + // is this closing attrib? if (attrib_kind == DW_AttribKind_Null) { break; } - + // special case, allows producer to embed form in .debug_info if (form_kind == DW_Form_Indirect) { TryRead(str8_deserial_read_uleb128(tag_data, tag_cursor, &form_kind), tag_cursor, exit); } - + // read form value DW_Form form = {0}; U64 form_size = 0; @@ -839,7 +839,7 @@ dw_read_tag(Arena *arena, goto exit; } tag_cursor += form_size; - + // fill out node DW_AttribNode *attrib_n = push_array(arena, DW_AttribNode, 1); attrib_n->v.info_off = cu_info_range.min + attrib_tag_cursor; @@ -847,13 +847,13 @@ dw_read_tag(Arena *arena, attrib_n->v.abbrev_id = attrib_abbrev.id; attrib_n->v.attrib_kind = attrib_kind; attrib_n->v.form = form; - + // push node to list SLLQueuePush(attribs.first, attribs.last, attrib_n); attribs.count += 1; } } - + // fill out tag tag_out->abbrev_id = tag_abbrev_id; tag_out->has_children = has_children; @@ -862,12 +862,12 @@ dw_read_tag(Arena *arena, tag_out->info_off = tag_info_off; bytes_read = tag_cursor - (tag_info_off - cu_info_range.min); -exit:; + exit:; return bytes_read; } internal U64 -dw_read_tag_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out) +dw_read_tag_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out) { return dw_read_tag(arena, input, @@ -1025,14 +1025,14 @@ dw_interp_address(U64 address_size, U64 base_addr, DW_ListUnit *addr_lu, DW_Form } internal String8 -dw_interp_block(DW_Input *input, DW_CompUnit *cu, DW_Form form) +dw_interp_block(DW_Raw *input, DW_CompUnit *cu, DW_Form form) { NotImplemented; return str8_zero(); } internal String8 -dw_interp_string(DW_Input *input, +dw_interp_string(DW_Raw *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_Form form) @@ -1070,7 +1070,7 @@ dw_interp_string(DW_Input *input, } internal String8 -dw_interp_line_ptr(DW_Input *input, DW_Form form) +dw_interp_line_ptr(DW_Raw *input, DW_Form form) { String8 result = {0}; if (form.kind == DW_Form_SecOffset) { @@ -1090,7 +1090,7 @@ dw_interp_file(DW_LineVM *line_vm, DW_Form form) } internal DW_Reference -dw_interp_ref(DW_Input *input, DW_CompUnit *cu, DW_Form form) +dw_interp_ref(DW_Raw *input, DW_CompUnit *cu, DW_Form form) { DW_Reference ref = {0}; if (form.kind == DW_Form_Ref1 || form.kind == DW_Form_Ref2 || @@ -1111,7 +1111,7 @@ dw_interp_ref(DW_Input *input, DW_CompUnit *cu, DW_Form form) } internal DW_LocList -dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form) +dw_interp_loclist(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form) { DW_LocList loclist = {0}; @@ -1398,7 +1398,7 @@ dw_interp_flag(DW_Form form) } internal Rng1U64List -dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form) +dw_interp_rnglist(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form) { Rng1U64List rnglist = {0}; @@ -1589,7 +1589,7 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form) } internal String8 -dw_interp_secptr(DW_Input *input, DW_SectionKind section, DW_Form form) +dw_interp_secptr(DW_Raw *input, DW_SectionKind section, DW_Form form) { String8 secptr = {0}; if (form.kind == DW_Form_SecOffset) { @@ -1603,25 +1603,25 @@ dw_interp_secptr(DW_Input *input, DW_SectionKind section, DW_Form form) } internal String8 -dw_interp_addrptr(DW_Input *input, DW_Form form) +dw_interp_addrptr(DW_Raw *input, DW_Form form) { return dw_interp_secptr(input, DW_Section_Addr, form); } internal String8 -dw_interp_str_offsets_ptr(DW_Input *input, DW_Form form) +dw_interp_str_offsets_ptr(DW_Raw *input, DW_Form form) { return dw_interp_secptr(input, DW_Section_StrOffsets, form); } internal String8 -dw_interp_rnglists_ptr(DW_Input *input, DW_Form form) +dw_interp_rnglists_ptr(DW_Raw *input, DW_Form form) { return dw_interp_secptr(input, DW_Section_RngLists, form); } internal String8 -dw_interp_loclists_ptr(DW_Input *input, DW_Form form) +dw_interp_loclists_ptr(DW_Raw *input, DW_Form form) { return dw_interp_secptr(input, DW_Section_LocLists, form); } @@ -1633,7 +1633,7 @@ dw_value_class_from_attrib(DW_CompUnit *cu, DW_Attrib *attrib) } internal String8 -dw_exprloc_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_exprloc_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_ExprLoc || value_class == DW_AttribClass_Block); @@ -1641,7 +1641,7 @@ dw_exprloc_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal U128 -dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_const_u128_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); @@ -1649,7 +1649,7 @@ dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal U64 -dw_const_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_const_u64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); @@ -1657,7 +1657,7 @@ dw_const_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal U32 -dw_const_u32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_const_u32_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); @@ -1665,7 +1665,7 @@ dw_const_u32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal S64 -dw_const_s64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_const_s64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); @@ -1673,7 +1673,7 @@ dw_const_s64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal S32 -dw_const_s32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_const_s32_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); @@ -1681,7 +1681,7 @@ dw_const_s32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal B32 -dw_flag_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_flag_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Flag); @@ -1689,7 +1689,7 @@ dw_flag_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal U64 -dw_address_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_address_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || @@ -1710,7 +1710,7 @@ dw_address_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal String8 -dw_block_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_block_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Block); @@ -1718,7 +1718,7 @@ dw_block_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal String8 -dw_string_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_string_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_String || value_class == DW_AttribClass_StrOffsetsPtr); @@ -1726,7 +1726,7 @@ dw_string_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal String8 -dw_line_ptr_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_line_ptr_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_LinePtr); @@ -1742,7 +1742,7 @@ dw_file_from_attrib(DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib) } internal DW_Reference -dw_ref_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_ref_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Reference); @@ -1750,7 +1750,7 @@ dw_ref_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal DW_LocList -dw_loclist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_loclist_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); AssertAlways(value_class == DW_AttribClass_Null || @@ -1760,7 +1760,7 @@ dw_loclist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib } internal Rng1U64List -dw_rnglist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_rnglist_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { Rng1U64List rnglist = {0}; DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); @@ -1787,7 +1787,7 @@ dw_attrib_from_tag_(DW_Tag tag, DW_AttribKind kind) } internal DW_Attrib * -dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_attrib_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { DW_Attrib *attrib = dw_attrib_from_tag_(tag, kind); @@ -1806,7 +1806,7 @@ dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k } internal B32 -dw_tag_has_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_tag_has_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); B32 has_attrib = attrib->attrib_kind != DW_AttribKind_Null; @@ -1814,85 +1814,85 @@ dw_tag_has_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind ki } internal String8 -dw_exprloc_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_exprloc_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_exprloc_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal String8 -dw_block_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_block_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_block_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal U128 -dw_const_u128_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_const_u128_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_const_u128_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal U64 -dw_const_u64_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_const_u64_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_const_u64_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal U32 -dw_const_u32_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_const_u32_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_const_u32_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal U64 -dw_address_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_address_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_address_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal String8 -dw_string_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_string_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_string_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal String8 -dw_line_ptr_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_line_ptr_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_line_ptr_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal DW_Reference -dw_ref_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_ref_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_ref_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal DW_LocList -dw_loclist_from_tag_attrib_kind(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_loclist_from_tag_attrib_kind(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_loclist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal Rng1U64List -dw_rnglist_from_tag_attrib_kind(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_rnglist_from_tag_attrib_kind(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_rnglist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal B32 -dw_flag_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_flag_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { return dw_flag_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); } internal DW_LineFile * -dw_file_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind) +dw_file_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind) { return dw_file_from_attrib(cu, line_vm, dw_attrib_from_tag(input, cu, tag, kind)); } internal B32 -dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byte_size_out) +dw_try_byte_size_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, U64 *byte_size_out) { B32 has_byte_size = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_ByteSize); B32 has_bit_size = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_BitSize ); @@ -1914,7 +1914,7 @@ dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byt } internal U64 -dw_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) +dw_byte_size_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag) { U64 byte_size = max_U64; dw_try_byte_size_from_tag(input, cu, tag, &byte_size); @@ -1922,7 +1922,7 @@ dw_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) } internal U32 -dw_byte_size_32_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) +dw_byte_size_32_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag) { U32 byte_size32 = 0; U64 byte_size64; @@ -1933,7 +1933,7 @@ dw_byte_size_32_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) } internal U64 -dw_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +dw_u64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { U64 result = 0; DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); @@ -1964,7 +1964,7 @@ dw_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k } internal B32 -dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) +dw_is_attrib_var_ref(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib) { B32 is_var_ref = 0; if (dw_is_form_kind_ref(cu->version, cu->ext, attrib->form.kind)) { @@ -1980,10 +1980,10 @@ dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) } internal DW_CompUnit -dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 cu_header_offset, B32 relaxed) +dw_cu_from_info_off(Arena *arena, DW_Raw *input, DW_ListUnitInput lu_input, U64 cu_header_offset, B32 relaxed) { DW_CompUnit cu = {0}; - + U32 first_four_bytes = 0; if (str8_deserial_read_struct(input->sec[DW_Section_Info].data, 0, &first_four_bytes) != sizeof(first_four_bytes)) { goto exit; } DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit; @@ -2037,7 +2037,7 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6 is_header_ok = 1; } break; } - + U64 header_size = info_cursor; if (is_header_ok) { @@ -2052,13 +2052,13 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6 // TODO: handle these unit types if (cu_tag.kind == DW_TagKind_SkeletonUnit) { log_user_errorf("TODO: Skeleton Unit"); } if (cu_tag.kind == DW_TagKind_TypeUnit) { log_user_errorf("TODO Type Unit"); } - + if (cu_tag.kind != DW_TagKind_CompileUnit && cu_tag.kind != DW_TagKind_PartialUnit) { // unexpected tag, release memory and exit temp_end(temp); goto exit; } - + // fetch attribs for list sections DW_Attrib *addr_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_AttribKind_AddrBase ); DW_Attrib *str_offsets_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_AttribKind_StrOffsetsBase); @@ -2106,12 +2106,12 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6 cu.tag = cu_tag; } -exit:; + exit:; return cu; } internal void -dw_tag_tree_from_data(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_TagNode *parent, U64 *cursor, U64 *tag_count) +dw_tag_tree_from_data(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *parent, U64 *cursor, U64 *tag_count) { while (*cursor < cu->info_range.max) { // read tag @@ -2138,7 +2138,7 @@ dw_tag_tree_from_data(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_TagNode } internal DW_TagTree -dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu) +dw_tag_tree_from_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu) { DW_TagNode root = {0}; U64 cursor = cu->first_tag_info_off; @@ -2206,7 +2206,7 @@ dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off) internal U64 dw_read_line_vm_header(Arena *arena, - DW_Input *input, + DW_Raw *input, String8 cu_stmt_list, String8 cu_dir, String8 cu_name, @@ -2215,12 +2215,12 @@ dw_read_line_vm_header(Arena *arena, DW_LineVMHeader *header_out) { Temp scratch = scratch_begin(&arena, 1); - + U64 cursor = 0; - + U32 first_four_bytes = 0; if (str8_deserial_read_struct(cu_stmt_list, 0, &first_four_bytes) != sizeof(U32)) { goto exit; } - + // read unit length U64 length = 0; U64 length_size = str8_deserial_read_dwarf_packed_size(cu_stmt_list, 0, &length); @@ -2247,7 +2247,7 @@ dw_read_line_vm_header(Arena *arena, // substring header so we dont overread into the line program data = str8_prefix(data, cursor + header_length); - + U8 min_inst_len = 0; TryRead(str8_deserial_read_struct(data, cursor, &min_inst_len), cursor, exit); @@ -2259,16 +2259,16 @@ dw_read_line_vm_header(Arena *arena, U8 default_is_stmt = 0; TryRead(str8_deserial_read_struct(data, cursor, &default_is_stmt), cursor, exit); - + S8 line_base = 0; TryRead(str8_deserial_read_struct(data, cursor, &line_base), cursor, exit); - + U8 line_range = 0; TryRead(str8_deserial_read_struct(data, cursor, &line_range), cursor, exit); - + U8 opcode_base = 0; TryRead(str8_deserial_read_struct(data, cursor, &opcode_base), cursor, exit); - + U64 num_opcode_lens = opcode_base > 0 ? opcode_base - 1 : 0; String8 opcode_lens; TryRead(str8_deserial_read_block(data, cursor, num_opcode_lens * sizeof(U8), &opcode_lens), cursor, exit); @@ -2278,7 +2278,7 @@ dw_read_line_vm_header(Arena *arena, if (version < DW_Version_5) { // read directory table String8List dir_list = {0}; - + // compile directory is always first in the table str8_list_push(scratch.arena, &dir_list, cu_dir); @@ -2305,7 +2305,7 @@ dw_read_line_vm_header(Arena *arena, U8 first_byte = 0; if (str8_deserial_read_struct(data, cursor, &first_byte) == 0) { goto exit; } if (first_byte == 0) { break; } - + DW_LineFile file = {0}; TryRead(str8_deserial_read_cstr (data, cursor, &file.path), cursor, exit); TryRead(str8_deserial_read_uleb128(data, cursor, &file.dir_idx), cursor, exit); @@ -2322,7 +2322,7 @@ dw_read_line_vm_header(Arena *arena, // dir list -> array dir_table = str8_array_from_list(arena, &dir_list); - + // file list -> array file_table.count = 0; file_table.v = push_array(arena, DW_LineFile, file_list.node_count); @@ -2349,7 +2349,7 @@ dw_read_line_vm_header(Arena *arena, // read table count U64 table_count = 0; TryRead(str8_deserial_read_uleb128(data, cursor, &table_count), cursor, exit); - + // validate encoding if (table_count > 0) { if (enc_count != 1) { goto exit; } @@ -2382,31 +2382,31 @@ dw_read_line_vm_header(Arena *arena, // read table count U64 table_count = 0; TryRead(str8_deserial_read_uleb128(data, cursor, &table_count), cursor, exit); - + file_table.count = table_count; file_table.v = push_array(arena, DW_LineFile, table_count); - + for EachIndex(i, table_count) { DW_LineFile *file = &file_table.v[i]; for EachIndex(enc_idx, enc_count) { DW_LNCT lnct = enc_arr[enc_idx*2 + 0]; - + DW_FormKind form_kind = enc_arr[enc_idx*2 + 1]; DW_Form form = {0}; U64 form_size = 0; if (!dw_read_form(str8_skip(data, cursor), version, format, address_size, form_kind, max_U64, &form, &form_size)) { goto exit; } cursor += form_size; - + switch (lnct) { - case DW_LNCT_Path: { file->path = dw_interp_string(input, format, cu_str_offsets, form); } break; - case DW_LNCT_DirectoryIndex: { file->dir_idx = dw_interp_const_u64(form); } break; - case DW_LNCT_TimeStamp: { file->time_stamp = dw_interp_const_u64(form); } break; - case DW_LNCT_Size: { file->size = dw_interp_const_u64(form); } break; - case DW_LNCT_MD5: { file->md5 = dw_interp_const_u128(form); } break; - case DW_LNCT_LLVM_Source: { file->source = dw_interp_string(input, format, cu_str_offsets, form); } break; - default: { - Assert(!"unexpected LNTC encoding"); - } break; + case DW_LNCT_Path: { file->path = dw_interp_string(input, format, cu_str_offsets, form); } break; + case DW_LNCT_DirectoryIndex: { file->dir_idx = dw_interp_const_u64(form); } break; + case DW_LNCT_TimeStamp: { file->time_stamp = dw_interp_const_u64(form); } break; + case DW_LNCT_Size: { file->size = dw_interp_const_u64(form); } break; + case DW_LNCT_MD5: { file->md5 = dw_interp_const_u128(form); } break; + case DW_LNCT_LLVM_Source: { file->source = dw_interp_string(input, format, cu_str_offsets, form); } break; + default: { + Assert(!"unexpected LNTC encoding"); + } break; } } } @@ -2438,16 +2438,16 @@ dw_read_line_vm_header(Arena *arena, } internal DW_LineVM * -dw_line_vm_init(DW_Input *input, DW_CompUnit *cu) +dw_line_vm_init(DW_Raw *input, DW_CompUnit *cu) { DW_LineVM *vm = 0; - + Arena *arena = arena_alloc(.reserve_size = KB(64), .commit_size = KB(1)); - + String8 cu_stmt_list = dw_line_ptr_from_tag_attrib_kind(input, cu, cu->tag, DW_AttribKind_StmtList); String8 cu_dir = dw_string_from_tag_attrib_kind(input, cu, cu->tag, DW_AttribKind_CompDir); String8 cu_name = dw_string_from_tag_attrib_kind(input, cu, cu->tag, DW_AttribKind_Name); - + // read the line table header DW_LineVMHeader header = {0}; if (cu_stmt_list.size) { @@ -2455,7 +2455,7 @@ dw_line_vm_init(DW_Input *input, DW_CompUnit *cu) goto exit; } } - + vm = push_array(arena, DW_LineVM, 1); *vm = (DW_LineVM){ .arena = arena, @@ -2464,7 +2464,7 @@ dw_line_vm_init(DW_Input *input, DW_CompUnit *cu) .header = header, .state.end_sequence = 1, }; - + exit:; if (vm == 0) { arena_release(arena); } return vm; @@ -2489,11 +2489,11 @@ internal B32 dw_line_vm_step(DW_LineVM *vm) { B32 is_ok = 0; - + if (vm->cursor >= vm->program.size) { goto exit; } - + vm->new_line = 0; - + // reset VM state if (vm->state.end_sequence) { vm->state.address = 0; @@ -2509,24 +2509,24 @@ dw_line_vm_step(DW_LineVM *vm) vm->state.isa = 0; vm->state.discriminator = 0; } - + // read opcode TryRead(str8_deserial_read_struct(vm->program, vm->cursor, &vm->opcode), vm->cursor, exit); - + // special opcodes if (vm->opcode >= vm->header.opcode_base) { U32 adjusted_opcode = (U32)(vm->opcode - vm->header.opcode_base); U32 op_advance = adjusted_opcode / vm->header.line_range; S32 line_advance = (S64)vm->header.line_base + ((S64)adjusted_opcode) % (S64)vm->header.line_range; U64 addr_advance = vm->header.min_inst_len * ((vm->state.op_index + op_advance) / vm->header.max_ops_for_inst); - + if (vm->header.line_range > 0 && vm->header.max_ops_for_inst > 0) { adjusted_opcode = (U32)(vm->opcode - vm->header.opcode_base); op_advance = adjusted_opcode / vm->header.line_range; line_advance = (S32)vm->header.line_base + ((S32)adjusted_opcode) % (S32)vm->header.line_range; addr_advance = vm->header.min_inst_len * ((vm->state.op_index+op_advance) / vm->header.max_ops_for_inst); } - + vm->state.address += addr_advance; vm->state.op_index = (vm->state.op_index + op_advance) % vm->header.max_ops_for_inst; vm->state.line = (U64)((S64)vm->state.line + line_advance); @@ -2534,142 +2534,142 @@ dw_line_vm_step(DW_LineVM *vm) vm->state.prologue_end = 0; vm->state.epilogue_begin = 0; vm->state.discriminator = 0; - + vm->line_advance = line_advance; vm->addr_advance = addr_advance; vm->new_line = 1; } else { // standard opcodes switch (vm->opcode) { - case DW_StdOpcode_Copy: { - vm->new_line = 1; - - vm->state.discriminator = 0; - vm->state.basic_block = 0; - vm->state.prologue_end = 0; - vm->state.epilogue_begin = 0; - } break; - - case DW_StdOpcode_AdvancePc: { - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); - dw_line_vm_advance(vm, vm->operands[0].u64); - } break; - - case DW_StdOpcode_AdvanceLine: { - TryRead(str8_deserial_read_sleb128(vm->program, vm->cursor, &vm->operands[0].s64), vm->cursor, exit); - vm->state.line += vm->operands[0].s64; - } break; - - case DW_StdOpcode_SetFile: { - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); - vm->state.file_index = vm->operands[0].u64; - } break; - - case DW_StdOpcode_SetColumn: { - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); - vm->state.column = vm->operands[0].u64; - } break; - - case DW_StdOpcode_NegateStmt: { - vm->state.is_stmt = !vm->state.is_stmt; - } break; - - case DW_StdOpcode_SetBasicBlock: { - vm->state.basic_block = 1; - } break; - - case DW_StdOpcode_ConstAddPc: { - U64 advance = (0xffu - vm->header.opcode_base) / vm->header.line_range; - dw_line_vm_advance(vm, advance); - } break; - - case DW_StdOpcode_FixedAdvancePc: { - U16 fixed_advance = 0; - TryRead(str8_deserial_read_struct(vm->program, vm->cursor, &fixed_advance), vm->cursor, exit); - vm->operands[0].u64 = fixed_advance; - vm->state.address += vm->operands[0].u64; - vm->state.op_index = 0; - } break; - - case DW_StdOpcode_SetPrologueEnd: { - vm->state.prologue_end = 1; - } break; - - case DW_StdOpcode_SetEpilogueBegin: { - vm->state.epilogue_begin = 1; - } break; - - case DW_StdOpcode_SetIsa: { - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); - vm->state.isa = vm->operands[0].u64; - } break; - - // extended opcodes - case DW_StdOpcode_ExtendedOpcode: { - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->ext_length), vm->cursor, exit); - String8 ext_data = str8_substr(vm->program, r1u64(vm->cursor, vm->cursor + vm->ext_length)); - vm->cursor += vm->ext_length; - - U64 ext_cursor = 0; - TryRead(str8_deserial_read_struct(ext_data, ext_cursor, &vm->ext_opcode), ext_cursor, exit); - - switch (vm->ext_opcode) { - case DW_ExtOpcode_EndSequence: { - vm->new_seq = 1; + case DW_StdOpcode_Copy: { vm->new_line = 1; - vm->state.end_sequence = 1; + + vm->state.discriminator = 0; + vm->state.basic_block = 0; + vm->state.prologue_end = 0; + vm->state.epilogue_begin = 0; } break; - - case DW_ExtOpcode_SetAddress: { - TryRead(str8_deserial_read(ext_data, ext_cursor, &vm->operands[0].u64, vm->header.address_size, vm->header.address_size), ext_cursor, exit); - vm->state.address = vm->operands[0].u64; + + case DW_StdOpcode_AdvancePc: { + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); + dw_line_vm_advance(vm, vm->operands[0].u64); + } break; + + case DW_StdOpcode_AdvanceLine: { + TryRead(str8_deserial_read_sleb128(vm->program, vm->cursor, &vm->operands[0].s64), vm->cursor, exit); + vm->state.line += vm->operands[0].s64; + } break; + + case DW_StdOpcode_SetFile: { + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); + vm->state.file_index = vm->operands[0].u64; + } break; + + case DW_StdOpcode_SetColumn: { + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); + vm->state.column = vm->operands[0].u64; + } break; + + case DW_StdOpcode_NegateStmt: { + vm->state.is_stmt = !vm->state.is_stmt; + } break; + + case DW_StdOpcode_SetBasicBlock: { + vm->state.basic_block = 1; + } break; + + case DW_StdOpcode_ConstAddPc: { + U64 advance = (0xffu - vm->header.opcode_base) / vm->header.line_range; + dw_line_vm_advance(vm, advance); + } break; + + case DW_StdOpcode_FixedAdvancePc: { + U16 fixed_advance = 0; + TryRead(str8_deserial_read_struct(vm->program, vm->cursor, &fixed_advance), vm->cursor, exit); + vm->operands[0].u64 = fixed_advance; + vm->state.address += vm->operands[0].u64; vm->state.op_index = 0; } break; - - case DW_ExtOpcode_DefineFile: { - TryRead(str8_deserial_read_cstr (ext_data, ext_cursor, &vm->operands[0].string), ext_cursor, exit); // file name - TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[1].u64), ext_cursor, exit); // dir index - TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[2].u64), ext_cursor, exit); // modify time - TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[3].u64), ext_cursor, exit); // file size - - if (vm->ext_file_ht == 0) { - vm->ext_file_ht = hash_table_init(vm->arena, 512); - } - - DW_LineFile *file = push_array(vm->arena, DW_LineFile, 1); - file->path = vm->operands[0].string; - file->dir_idx = vm->operands[1].u64; - file->time_stamp = vm->operands[2].u64; - file->size = vm->operands[3].u64; - - if (hash_table_search_u64_raw(vm->ext_file_ht, vm->state.file_index) == 0) { - vm->error = push_str8f(vm->arena, "file with index %I64d was already defined", vm->state.file_index); - goto exit; - } - - hash_table_push_u64_raw(vm->arena, vm->ext_file_ht, vm->state.file_index, file); + + case DW_StdOpcode_SetPrologueEnd: { + vm->state.prologue_end = 1; } break; - - case DW_ExtOpcode_SetDiscriminator: { - TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[0].u64), ext_cursor, exit); - vm->state.discriminator = vm->operands[0].u64; + + case DW_StdOpcode_SetEpilogueBegin: { + vm->state.epilogue_begin = 1; + } break; + + case DW_StdOpcode_SetIsa: { + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->operands[0].u64), vm->cursor, exit); + vm->state.isa = vm->operands[0].u64; + } break; + + // extended opcodes + case DW_StdOpcode_ExtendedOpcode: { + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &vm->ext_length), vm->cursor, exit); + String8 ext_data = str8_substr(vm->program, r1u64(vm->cursor, vm->cursor + vm->ext_length)); + vm->cursor += vm->ext_length; + + U64 ext_cursor = 0; + TryRead(str8_deserial_read_struct(ext_data, ext_cursor, &vm->ext_opcode), ext_cursor, exit); + + switch (vm->ext_opcode) { + case DW_ExtOpcode_EndSequence: { + vm->new_seq = 1; + vm->new_line = 1; + vm->state.end_sequence = 1; + } break; + + case DW_ExtOpcode_SetAddress: { + TryRead(str8_deserial_read(ext_data, ext_cursor, &vm->operands[0].u64, vm->header.address_size, vm->header.address_size), ext_cursor, exit); + vm->state.address = vm->operands[0].u64; + vm->state.op_index = 0; + } break; + + case DW_ExtOpcode_DefineFile: { + TryRead(str8_deserial_read_cstr (ext_data, ext_cursor, &vm->operands[0].string), ext_cursor, exit); // file name + TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[1].u64), ext_cursor, exit); // dir index + TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[2].u64), ext_cursor, exit); // modify time + TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[3].u64), ext_cursor, exit); // file size + + if (vm->ext_file_ht == 0) { + vm->ext_file_ht = hash_table_init(vm->arena, 512); + } + + DW_LineFile *file = push_array(vm->arena, DW_LineFile, 1); + file->path = vm->operands[0].string; + file->dir_idx = vm->operands[1].u64; + file->time_stamp = vm->operands[2].u64; + file->size = vm->operands[3].u64; + + if (hash_table_search_u64_raw(vm->ext_file_ht, vm->state.file_index) == 0) { + vm->error = push_str8f(vm->arena, "file with index %I64d was already defined", vm->state.file_index); + goto exit; + } + + hash_table_push_u64_raw(vm->arena, vm->ext_file_ht, vm->state.file_index, file); + } break; + + case DW_ExtOpcode_SetDiscriminator: { + TryRead(str8_deserial_read_uleb128(ext_data, ext_cursor, &vm->operands[0].u64), ext_cursor, exit); + vm->state.discriminator = vm->operands[0].u64; + } break; + + default: { NotImplemented; } break; + } + } break; + + default: { + // skip unknown opcode + if (0 == vm->opcode || vm->opcode > vm->header.num_opcode_lens) { goto exit; } + for EachIndex(i, vm->header.opcode_lens[vm->opcode - 1]) { + U64 v = 0; + TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &v), vm->cursor, exit); + } } break; - - default: { NotImplemented; } break; - } - } break; - - default: { - // skip unknown opcode - if (0 == vm->opcode || vm->opcode > vm->header.num_opcode_lens) { goto exit; } - for EachIndex(i, vm->header.opcode_lens[vm->opcode - 1]) { - U64 v = 0; - TryRead(str8_deserial_read_uleb128(vm->program, vm->cursor, &v), vm->cursor, exit); - } - } break; } } - + is_ok = 1; exit:; return is_ok; @@ -2691,14 +2691,14 @@ internal String8 dw_path_from_file(Arena *arena, String8Array dir_table, DW_LineFile *file) { Temp scratch = scratch_begin(&arena, 1); - + // directory table must contain at least compile unit directory Assert(dir_table.count > 0); - + // find directory and file name associated with the file index String8 dir = dir_table.v[file->dir_idx]; String8 path = file->path; - + // infer path style if directory is empty use file name PathStyle style = path_style_from_str8(dir); if (style == PathStyle_Null || style == PathStyle_Relative) { @@ -2712,18 +2712,18 @@ dw_path_from_file(Arena *arena, String8Array dir_table, DW_LineFile *file) String8List comp_dir = str8_split_path(scratch.arena, dir_table.v[0]); str8_list_concat_in_place(&path_list, &comp_dir); } - + // push directory String8List dir_list = str8_split_path(scratch.arena, dir); str8_list_concat_in_place(&path_list, &dir_list); - + // push file name str8_list_push(scratch.arena, &path_list, file->path); - + // resolve dots in the path str8_path_list_resolve_dots_in_place(&path_list, style); } - + // join path String8 result = str8_path_list_join_by_style(arena, &path_list, style); @@ -2732,7 +2732,7 @@ dw_path_from_file(Arena *arena, String8Array dir_table, DW_LineFile *file) } internal DW_PubStringsTable -dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind) +dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Raw *input, DW_SectionKind section_kind) { Temp scratch = scratch_begin(&arena, 1); @@ -2745,7 +2745,7 @@ dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_Sect U32 first_four_bytes = 0; if (str8_deserial_read_struct(input->sec[DW_Section_Info].data, 0, &first_four_bytes) != sizeof(first_four_bytes)) { break; } DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit; - + U64 unit_length = 0; U64 unit_length_size = str8_deserial_read_dwarf_packed_size(section_data, cursor, &unit_length); if (unit_length_size == 0) { @@ -2823,45 +2823,45 @@ dw_expr_from_data(Arena *arena, DW_Format format, U64 addr_size, String8 data) for EachIndex(operand_idx, operand_count) { U64 operand_size = 0; switch (operand_types[operand_idx]) { - case DW_ExprOperandType_Null: { } break; - case DW_ExprOperandType_U8: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u8); } break; - case DW_ExprOperandType_U16: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u16); } break; - case DW_ExprOperandType_U32: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u32); } break; - case DW_ExprOperandType_U64: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u64); } break; - case DW_ExprOperandType_S8: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s8); } break; - case DW_ExprOperandType_S16: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s16); } break; - case DW_ExprOperandType_S32: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s32); } break; - case DW_ExprOperandType_S64: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s64); } break; - case DW_ExprOperandType_ULEB128: { operand_size = str8_deserial_read_uleb128(data, cursor, &operands[operand_idx].u64); } break; - case DW_ExprOperandType_SLEB128: { operand_size = str8_deserial_read_sleb128(data, cursor, &operands[operand_idx].s64); } break; - case DW_ExprOperandType_Addr: { operand_size = str8_deserial_read(data, cursor, &operands[operand_idx].u64, addr_size, addr_size); } break; - case DW_ExprOperandType_DwarfUInt: { operand_size = str8_deserial_read_dwarf_uint(data, cursor, format, &operands[operand_idx].u64); } break; - case DW_ExprOperandType_Block: { - U8 block_size; - U64 block_size_size = str8_deserial_read_struct(data, cursor, &block_size); - U64 block_read_size = str8_deserial_read_block(data, cursor + block_size_size, block_size, &operands[operand_idx].block); - if(block_read_size == block_size_size) { - operand_size = block_size_size + block_read_size; - } - } break; - default: { InvalidPath; } break; + case DW_ExprOperandType_Null: { } break; + case DW_ExprOperandType_U8: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u8); } break; + case DW_ExprOperandType_U16: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u16); } break; + case DW_ExprOperandType_U32: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u32); } break; + case DW_ExprOperandType_U64: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].u64); } break; + case DW_ExprOperandType_S8: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s8); } break; + case DW_ExprOperandType_S16: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s16); } break; + case DW_ExprOperandType_S32: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s32); } break; + case DW_ExprOperandType_S64: { operand_size = str8_deserial_read_struct(data, cursor, &operands[operand_idx].s64); } break; + case DW_ExprOperandType_ULEB128: { operand_size = str8_deserial_read_uleb128(data, cursor, &operands[operand_idx].u64); } break; + case DW_ExprOperandType_SLEB128: { operand_size = str8_deserial_read_sleb128(data, cursor, &operands[operand_idx].s64); } break; + case DW_ExprOperandType_Addr: { operand_size = str8_deserial_read(data, cursor, &operands[operand_idx].u64, addr_size, addr_size); } break; + case DW_ExprOperandType_DwarfUInt: { operand_size = str8_deserial_read_dwarf_uint(data, cursor, format, &operands[operand_idx].u64); } break; + case DW_ExprOperandType_Block: { + U8 block_size; + U64 block_size_size = str8_deserial_read_struct(data, cursor, &block_size); + U64 block_read_size = str8_deserial_read_block(data, cursor + block_size_size, block_size, &operands[operand_idx].block); + if(block_read_size == block_size_size) { + operand_size = block_size_size + block_read_size; + } + } break; + default: { InvalidPath; } break; } if (operand_size == 0) { goto exit; } cursor += operand_size; } - + // fill out instruction DW_ExprInst *inst = push_array(arena, DW_ExprInst, 1); inst->opcode = opcode; inst->size = cursor - inst_start; inst->operands = operand_count ? push_array(arena, DW_ExprOperand, operand_count) : 0; MemoryCopy(inst->operands, operands, operand_count * sizeof(DW_ExprOperand)); - + // push instruction DLLPushBack(expr.first, expr.last, inst); expr.count += 1; } -exit:; + exit:; return expr; } @@ -2899,25 +2899,25 @@ dw_parse_descriptor_entry_header(String8 data, U64 off, DW_DescriptorEntry *desc U32 first_four_bytes = 0; str8_deserial_read_struct(data, off, &first_four_bytes); DW_Format format = first_four_bytes == max_U32 ? DW_Format_64Bit : DW_Format_32Bit; - + U64 length = 0; U64 length_size = str8_deserial_read_dwarf_packed_size(data, off, &length); if (length_size == 0) { goto exit; } - + Rng1U64 entry_range = rng_1u64(off, off + length_size + length); String8 entry_data = str8_substr(data, entry_range); U64 id = 0; U64 id_size = str8_deserial_read_dwarf_uint(entry_data, length_size, format, &id); if (id_size == 0) { goto exit; } - + U64 id_type = format == DW_Format_32Bit ? max_U32 : max_U64; desc_out->format = format; desc_out->type = (id == id_type) ? DW_DescriptorEntryType_CIE : DW_DescriptorEntryType_FDE; desc_out->entry_range = entry_range; desc_out->cie_pointer = id; desc_out->cie_pointer_off = length_size; - -exit:; + + exit:; return length + length_size; } @@ -2926,16 +2926,16 @@ dw_parse_cie(String8 data, DW_Format format, Arch arch, DW_CIE *cie_out) { B32 is_parsed = 0; U64 cursor = format == DW_Format_32Bit ? 4 : 12; - + U64 cie_id = 0; TryRead(str8_deserial_read_dwarf_uint(data, cursor, format, &cie_id), cursor, exit); - + U8 version = 0; TryRead(str8_deserial_read_struct(data, cursor, &version), cursor, exit); - + String8 aug_string = {0}; TryRead(str8_deserial_read_cstr(data, cursor, &aug_string), cursor, exit); - + U8 address_size = 0; U8 segment_selector_size = 0; if (version >= DW_Version_4) { @@ -2944,20 +2944,20 @@ dw_parse_cie(String8 data, DW_Format format, Arch arch, DW_CIE *cie_out) } else { address_size = byte_size_from_arch(arch); } - + U64 code_align_factor = 0; TryRead(str8_deserial_read_uleb128(data, cursor, &code_align_factor), cursor, exit); - + S64 data_align_factor = 0; TryRead(str8_deserial_read_sleb128(data, cursor, &data_align_factor), cursor, exit); - + U64 ret_addr_reg = 0; U64 ret_addr_reg_size = 0; if (version == DW_Version_1) { TryRead(str8_deserial_read(data, cursor, &ret_addr_reg, sizeof(U8), sizeof(U8)), cursor, exit); } else { TryRead(str8_deserial_read_uleb128(data, cursor, &ret_addr_reg), cursor, exit); } - + if (aug_string.size > 0) { goto exit; } - + cie_out->insts = str8_skip(data, cursor); cie_out->aug_string = aug_string; cie_out->code_align_factor = code_align_factor; @@ -2967,9 +2967,9 @@ dw_parse_cie(String8 data, DW_Format format, Arch arch, DW_CIE *cie_out) cie_out->version = version; cie_out->address_size = address_size; cie_out->segment_selector_size = segment_selector_size; - + is_parsed = 1; -exit:; + exit:; return is_parsed; } @@ -2978,31 +2978,31 @@ dw_parse_fde(String8 data, DW_Format format, DW_CIE *cie, DW_FDE *fde_out) { B32 is_parsed = 0; U64 cursor = format == DW_Format_32Bit ? 4 : 12; - + // extract CIE pointer U64 cie_pointer = 0; TryRead(str8_deserial_read_dwarf_uint(data, cursor, format, &cie_pointer), cursor, exit); - + // extract address of first instruction U64 pc_begin = 0; TryRead(dw_read_debug_frame_ptr(str8_skip(data, cursor), cie, &pc_begin), cursor, exit); - + // extract instruction range size U64 pc_range = 0; TryRead(dw_read_debug_frame_ptr(str8_skip(data, cursor), cie, &pc_range), cursor, exit); - + // parse augmentation data String8 aug_data = str8_substr(data, rng_1u64(cursor, cursor + cie->aug_data.size)); cursor += cie->aug_data.size; - + // commit values to out fde_out->format = format; fde_out->cie_pointer = cie_pointer; fde_out->pc_range = rng_1u64(pc_begin, pc_begin + pc_range); fde_out->insts = str8_skip(data, cursor); - + is_parsed = 1; -exit:; + exit:; return is_parsed; } @@ -3028,28 +3028,28 @@ dw_parse_cfi(String8 data, U64 fde_offset, Arch arch, DW_CIE *cie_out, DW_FDE *f } } } - + return is_parsed; } internal DW_CFA_ParseErrorCode dw_parse_cfa_inst(String8 data, - U64 code_align_factor, - S64 data_align_factor, - DW_DecodePtr *decode_ptr_func, - void *decode_ptr_ud, - U64 *bytes_read_out, - DW_CFA_Inst *inst_out) + U64 code_align_factor, + S64 data_align_factor, + DW_DecodePtr *decode_ptr_func, + void *decode_ptr_ud, + U64 *bytes_read_out, + DW_CFA_Inst *inst_out) { *bytes_read_out = 0; - + DW_CFA_ParseErrorCode error_code = DW_CFA_ParseErrorCode_End; U64 cursor = 0; - + // read opcode DW_CFA_Opcode raw_opcode = 0; TryRead(str8_deserial_read_struct(data, cursor, &raw_opcode), cursor, exit); - + // decode opcode implicit operand U64 opcode = raw_opcode & ~DW_CFA_Mask_OpcodeHi; U64 implicit_operand = 0; @@ -3057,263 +3057,263 @@ dw_parse_cfa_inst(String8 data, opcode = raw_opcode & DW_CFA_Mask_OpcodeHi; implicit_operand = raw_opcode & DW_CFA_Mask_Operand; } - + // decode operands DW_CFA_Operand operands[DW_CFA_OperandMax] = {0}; switch (opcode) { - case DW_CFA_SetLoc: { - U64 address_size = decode_ptr_func(str8_skip(data, cursor), decode_ptr_ud, &operands[0].u64); - if (address_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += address_size; - } break; - case DW_CFA_AdvanceLoc: { - operands[0].u64 = implicit_operand * code_align_factor; - } break; - case DW_CFA_AdvanceLoc1: { - U8 delta = 0; - U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); - if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += delta_size; - operands[0].u64 = delta * code_align_factor; - } break; - case DW_CFA_AdvanceLoc2: { - U16 delta = 0; - U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); - if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += delta_size; - operands[0].u64 = delta * code_align_factor; - } break; - case DW_CFA_AdvanceLoc4: { - U32 delta = 0; - U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); - if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += delta_size; - operands[0].u64 = delta * code_align_factor; - } break; - case DW_CFA_DefCfa: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = reg; - operands[1].u64 = offset; - } break; - case DW_CFA_DefCfaSf: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - S64 offset = 0; - U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = reg; - operands[1].s64 = offset * data_align_factor; - } break; - case DW_CFA_DefCfaRegister: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - operands[0].u64 = reg; - } break; - case DW_CFA_DefCfaOffset: { - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = offset; - } break; - case DW_CFA_DefCfaOffsetSf: { - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = offset * data_align_factor; - } break; - case DW_CFA_DefCfaExpr: { - U64 expr_size = 0; - U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); - if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += expr_size_size; - - if (cursor + expr_size > data.size) { goto exit; } - String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); - - operands[0].block = expr; - cursor += expr_size; - } break; - case DW_CFA_Undefined: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - operands[0].u64 = reg; - } break; - case DW_CFA_SameValue: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - operands[0].u64 = reg; - } break; - case DW_CFA_Offset: { - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = implicit_operand; - operands[1].s64 = (S64)offset * data_align_factor; - } break; - case DW_CFA_OffsetExt: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = reg; - operands[1].u64 = offset * data_align_factor; - } break; - case DW_CFA_OffsetExtSf: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - S64 offset = 0; - U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = reg; - operands[1].s64 = offset * data_align_factor; - } break; - case DW_CFA_ValOffset: { - U64 val = 0; - U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); - if (val_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += val_size; - - U64 offset = 0; - U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = val; - operands[1].u64 = offset * data_align_factor; - } break; - case DW_CFA_ValOffsetSf: { - U64 val = 0; - U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); - if (val_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += val_size; - - S64 offset = 0; - U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); - if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += offset_size; - - operands[0].u64 = val; - operands[1].s64 = offset; - } break; - case DW_CFA_Register: { - U64 dst_reg = 0; - U64 dst_reg_size = str8_deserial_read_uleb128(data, cursor, &dst_reg); - if (dst_reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += dst_reg_size; - - U64 src_reg = 0; - U64 src_reg_size = str8_deserial_read_uleb128(data, cursor, &src_reg); - if (src_reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += src_reg_size; - - operands[0].u64 = dst_reg; - operands[1].u64 = src_reg; - } break; - case DW_CFA_Expr: { - U64 reg = 0; - U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); - if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += reg_size; - - U64 expr_size = 0; - U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); - if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += expr_size_size; - - if (cursor + expr_size > data.size) { goto exit; } - String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); - cursor += expr_size; - - operands[0].u64 = reg; - operands[1].block = expr; - } break; - case DW_CFA_ValExpr: { - U64 val = 0; - U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); - if (val_size == 0) { goto exit; } - cursor += val_size; - - U64 expr_size = 0; - U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); - if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } - cursor += expr_size_size; - - if (cursor + expr_size > data.size) { goto exit; } - String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); - cursor += expr_size; - - operands[0].u64 = val; - operands[1].block = expr; - } break; - case DW_CFA_Restore: { - operands[0].u64 = implicit_operand; - } break; - case DW_CFA_RestoreExt: {} break; - case DW_CFA_RememberState: {} break; - case DW_CFA_RestoreState: {} break; - case DW_CFA_Nop: {} break; - default: { NotImplemented; goto exit; } break; + case DW_CFA_SetLoc: { + U64 address_size = decode_ptr_func(str8_skip(data, cursor), decode_ptr_ud, &operands[0].u64); + if (address_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += address_size; + } break; + case DW_CFA_AdvanceLoc: { + operands[0].u64 = implicit_operand * code_align_factor; + } break; + case DW_CFA_AdvanceLoc1: { + U8 delta = 0; + U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); + if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += delta_size; + operands[0].u64 = delta * code_align_factor; + } break; + case DW_CFA_AdvanceLoc2: { + U16 delta = 0; + U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); + if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += delta_size; + operands[0].u64 = delta * code_align_factor; + } break; + case DW_CFA_AdvanceLoc4: { + U32 delta = 0; + U64 delta_size = str8_deserial_read_struct(data, cursor, &delta); + if (delta_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += delta_size; + operands[0].u64 = delta * code_align_factor; + } break; + case DW_CFA_DefCfa: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = reg; + operands[1].u64 = offset; + } break; + case DW_CFA_DefCfaSf: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + S64 offset = 0; + U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = reg; + operands[1].s64 = offset * data_align_factor; + } break; + case DW_CFA_DefCfaRegister: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + operands[0].u64 = reg; + } break; + case DW_CFA_DefCfaOffset: { + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = offset; + } break; + case DW_CFA_DefCfaOffsetSf: { + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = offset * data_align_factor; + } break; + case DW_CFA_DefCfaExpr: { + U64 expr_size = 0; + U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); + if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += expr_size_size; + + if (cursor + expr_size > data.size) { goto exit; } + String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); + + operands[0].block = expr; + cursor += expr_size; + } break; + case DW_CFA_Undefined: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + operands[0].u64 = reg; + } break; + case DW_CFA_SameValue: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + operands[0].u64 = reg; + } break; + case DW_CFA_Offset: { + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = implicit_operand; + operands[1].s64 = (S64)offset * data_align_factor; + } break; + case DW_CFA_OffsetExt: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = reg; + operands[1].u64 = offset * data_align_factor; + } break; + case DW_CFA_OffsetExtSf: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + S64 offset = 0; + U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = reg; + operands[1].s64 = offset * data_align_factor; + } break; + case DW_CFA_ValOffset: { + U64 val = 0; + U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); + if (val_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += val_size; + + U64 offset = 0; + U64 offset_size = str8_deserial_read_uleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = val; + operands[1].u64 = offset * data_align_factor; + } break; + case DW_CFA_ValOffsetSf: { + U64 val = 0; + U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); + if (val_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += val_size; + + S64 offset = 0; + U64 offset_size = str8_deserial_read_sleb128(data, cursor, &offset); + if (offset_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += offset_size; + + operands[0].u64 = val; + operands[1].s64 = offset; + } break; + case DW_CFA_Register: { + U64 dst_reg = 0; + U64 dst_reg_size = str8_deserial_read_uleb128(data, cursor, &dst_reg); + if (dst_reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += dst_reg_size; + + U64 src_reg = 0; + U64 src_reg_size = str8_deserial_read_uleb128(data, cursor, &src_reg); + if (src_reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += src_reg_size; + + operands[0].u64 = dst_reg; + operands[1].u64 = src_reg; + } break; + case DW_CFA_Expr: { + U64 reg = 0; + U64 reg_size = str8_deserial_read_uleb128(data, cursor, ®); + if (reg_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += reg_size; + + U64 expr_size = 0; + U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); + if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += expr_size_size; + + if (cursor + expr_size > data.size) { goto exit; } + String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); + cursor += expr_size; + + operands[0].u64 = reg; + operands[1].block = expr; + } break; + case DW_CFA_ValExpr: { + U64 val = 0; + U64 val_size = str8_deserial_read_uleb128(data, cursor, &val); + if (val_size == 0) { goto exit; } + cursor += val_size; + + U64 expr_size = 0; + U64 expr_size_size = str8_deserial_read_uleb128(data, cursor, &expr_size); + if (expr_size_size == 0) { error_code = DW_CFA_ParseErrorCode_OutOfData; goto exit; } + cursor += expr_size_size; + + if (cursor + expr_size > data.size) { goto exit; } + String8 expr = str8_prefix(str8_skip(data, cursor), expr_size); + cursor += expr_size; + + operands[0].u64 = val; + operands[1].block = expr; + } break; + case DW_CFA_Restore: { + operands[0].u64 = implicit_operand; + } break; + case DW_CFA_RestoreExt: {} break; + case DW_CFA_RememberState: {} break; + case DW_CFA_RestoreState: {} break; + case DW_CFA_Nop: {} break; + default: { NotImplemented; goto exit; } break; } - + // fill out output inst_out->opcode = opcode; MemoryCopyTyped(&inst_out->operands[0], &operands[0], DW_CFA_OperandMax); - + *bytes_read_out = cursor; - + error_code = DW_CFA_ParseErrorCode_NewInst; - -exit:; + + exit:; return error_code; } internal DW_CFA_InstList dw_parse_cfa_inst_list(Arena *arena, - String8 data, - U64 code_align_factor, - S64 data_align_factor, - DW_DecodePtr *decode_ptr_func, - void *decode_ptr_ud) + String8 data, + U64 code_align_factor, + S64 data_align_factor, + DW_DecodePtr *decode_ptr_func, + void *decode_ptr_ud) { U64 pos = arena_pos(arena); DW_CFA_InstList list = {0}; diff --git a/src/dwarf/dwarf_parse.h b/src/dwarf/dwarf_parse.h index 25efb799..e83fd918 100644 --- a/src/dwarf/dwarf_parse.h +++ b/src/dwarf/dwarf_parse.h @@ -11,11 +11,11 @@ typedef struct DW_Section B32 is_dwo; } DW_Section; -typedef struct DW_Input +typedef struct DW_Raw { - DW_Section sec[DW_Section_Count]; - DW_Section sup[DW_Section_Count]; -} DW_Input; + DW_Section sec[DW_Section_COUNT]; + DW_Section sup[DW_Section_COUNT]; +} DW_Raw; typedef struct DW_ListUnit { @@ -307,12 +307,12 @@ typedef union DW_ExprOperand U16 u16; U32 u32; U64 u64; - + S8 s8; S16 s16; S32 s32; S64 s64; - + String8 block; } DW_ExprOperand; @@ -432,7 +432,7 @@ internal U64 dw_read_list_unit_header_addr (String8 unit_data, DW_ListUnit internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out); internal U64 dw_read_list_unit_header_list (String8 unit_data, DW_ListUnit *lu_out); -internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Input *input); +internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Raw *input); internal U64 dw_offset_from_list_unit(DW_ListUnit *lu, U64 index); internal U64 dw_addr_from_list_unit (DW_ListUnit *lu, U64 index); @@ -448,8 +448,8 @@ internal U64 dw_abbrev_offset_from_abbrev_id(DW_AbbrevTable table, U6 // form and tag internal B32 dw_read_form (String8 data, DW_Version version, DW_Format unit_format, U64 address_size, DW_FormKind form_kind, S64 implicit_const, DW_Form *form_out, U64 *bytes_read_out); -internal U64 dw_read_tag (Arena *arena, DW_Input *input, DW_AbbrevTable abbrev_table, DW_Version version, DW_Format format, U64 address_size, Rng1U64 cu_info_range, U64 tag_info_off, DW_Tag *tag_out); -internal U64 dw_read_tag_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out); +internal U64 dw_read_tag (Arena *arena, DW_Raw *input, DW_AbbrevTable abbrev_table, DW_Version version, DW_Format format, U64 address_size, Rng1U64 cu_info_range, U64 tag_info_off, DW_Tag *tag_out); +internal U64 dw_read_tag_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out); // attrib interp @@ -462,58 +462,58 @@ internal S64 dw_interp_const_s64 (DW_Form form); internal S32 dw_interp_const_s32 (DW_Form form); internal B32 dw_interp_flag (DW_Form form); internal U64 dw_interp_address (U64 address_size, U64 base_addr, DW_ListUnit *addr_xlist, DW_Form form); -internal String8 dw_interp_block (DW_Input *input, DW_CompUnit *cu, DW_Form form); -internal String8 dw_interp_string (DW_Input *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_Form form); -internal String8 dw_interp_line_ptr (DW_Input *input, DW_Form form); +internal String8 dw_interp_block (DW_Raw *input, DW_CompUnit *cu, DW_Form form); +internal String8 dw_interp_string (DW_Raw *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_Form form); +internal String8 dw_interp_line_ptr (DW_Raw *input, DW_Form form); internal DW_LineFile * dw_interp_file (DW_LineVM *line_vm, DW_Form form); -internal DW_Reference dw_interp_ref (DW_Input *input, DW_CompUnit *cu, DW_Form form); -internal DW_LocList dw_interp_loclist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form); -internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form); +internal DW_Reference dw_interp_ref (DW_Raw *input, DW_CompUnit *cu, DW_Form form); +internal DW_LocList dw_interp_loclist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form); +internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form); -internal String8 dw_exprloc_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal U128 dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal U64 dw_const_u64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal U32 dw_const_u32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal S64 dw_const_s64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal S32 dw_const_s32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal B32 dw_flag_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal U64 dw_address_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal String8 dw_block_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal String8 dw_string_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal String8 dw_line_ptr_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal String8 dw_exprloc_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal U128 dw_const_u128_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal U64 dw_const_u64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal U32 dw_const_u32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal S64 dw_const_s64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal S32 dw_const_s32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal B32 dw_flag_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal U64 dw_address_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal String8 dw_block_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal String8 dw_string_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal String8 dw_line_ptr_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); internal DW_LineFile * dw_file_from_attrib (DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib); -internal DW_Reference dw_ref_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal DW_Reference dw_ref_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); -internal String8 dw_exprloc_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal U128 dw_const_u128_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal U64 dw_const_u64_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal U32 dw_const_u32_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal B32 dw_flag_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal U64 dw_address_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal String8 dw_block_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal String8 dw_string_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind); -internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal String8 dw_exprloc_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal U128 dw_const_u128_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal U64 dw_const_u64_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal U32 dw_const_u32_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal B32 dw_flag_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal U64 dw_address_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal String8 dw_block_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal String8 dw_string_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind); +internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); -internal B32 dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); +internal B32 dw_is_attrib_var_ref(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib); // compile unit -internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed); -internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu); +internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Raw *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed); +internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu); internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree); internal DW_TagNode * dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off); // line VM -internal U64 dw_read_line_vm_header(Arena *arena, DW_Input *input, String8 cu_stmt_list, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out); -internal DW_LineVM * dw_line_vm_init(DW_Input *input, DW_CompUnit *cu); +internal U64 dw_read_line_vm_header(Arena *arena, DW_Raw *input, String8 cu_stmt_list, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out); +internal DW_LineVM * dw_line_vm_init(DW_Raw *input, DW_CompUnit *cu); internal void dw_line_vm_release(DW_LineVM *vm); internal void dw_line_vm_advance(DW_LineVM *vm, U64 advance); internal B32 dw_line_vm_step(DW_LineVM *vm); @@ -522,7 +522,7 @@ internal String8 dw_path_from_file(Arena *arena, String8Array dir_table, D // helper for .debug_pubtypes and .debug_pubnames -internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind); +internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Raw *input, DW_SectionKind section_kind); // expression diff --git a/src/dwarf/dwarf_parse_2.c b/src/dwarf/dwarf_parse_2.c index 6da9c57a..9148e40f 100644 --- a/src/dwarf/dwarf_parse_2.c +++ b/src/dwarf/dwarf_parse_2.c @@ -775,6 +775,7 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of case DW_LNCT_TimeStamp: { entry_out->modify_time = form_val.u128.u64[0]; + entry_out->flags |= DW2_LineTableFileFlag_HasModifyTime; }break; case DW_LNCT_Size: { @@ -783,6 +784,7 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of case DW_LNCT_MD5: { entry_out->md5.u128 = form_val.u128; + entry_out->flags |= DW2_LineTableFileFlag_HasMD5; }break; case DW_LNCT_LLVM_Source: { diff --git a/src/dwarf/dwarf_parse_2.h b/src/dwarf/dwarf_parse_2.h index cf69a1fc..8ee995b8 100644 --- a/src/dwarf/dwarf_parse_2.h +++ b/src/dwarf/dwarf_parse_2.h @@ -100,10 +100,18 @@ struct DW2_Tag //////////////////////////////// //~ rjf: Line Info +typedef U32 DW2_LineTableFileFlags; +enum +{ + DW2_LineTableFileFlag_HasMD5 = (1<<0), + DW2_LineTableFileFlag_HasModifyTime = (1<<1), +}; + typedef struct DW2_LineTableFile DW2_LineTableFile; struct DW2_LineTableFile { String8 file_name; + DW2_LineTableFileFlags flags; U64 dir_idx; U64 modify_time; U64 file_size; @@ -154,6 +162,23 @@ struct DW2_LineTableHeader DW2_LineTableFileArray files; }; +typedef struct DW2_LineVMRegs DW2_LineVMRegs; +struct DW2_LineVMRegs +{ + U64 address; + U64 vliw_op_index; + U64 file_index; + U64 line; + U64 column; + B32 is_stmt; + B32 basic_block; + B32 end_sequence; + B32 prologue_end; + B32 epilogue_begin; + U64 isa; + U64 discriminator; +}; + //////////////////////////////// //~ rjf: Globals diff --git a/src/dwarf/dwarf_writer.c b/src/dwarf/dwarf_writer.c index b7de4503..1cb92f71 100644 --- a/src/dwarf/dwarf_writer.c +++ b/src/dwarf/dwarf_writer.c @@ -24,12 +24,12 @@ dw_size_from_sint(S64 v) { DW_IntEnc enc = dw_int_enc_from_sint(v); switch (enc) { - case DW_IntEnc_Null: break; - case DW_IntEnc_1Byte: return 1; - case DW_IntEnc_2Byte: return 2; - case DW_IntEnc_4Byte: return 4; - case DW_IntEnc_LEB128: return dw_size_from_sleb128(v); - default: InvalidPath; break; + case DW_IntEnc_Null: break; + case DW_IntEnc_1Byte: return 1; + case DW_IntEnc_2Byte: return 2; + case DW_IntEnc_4Byte: return 4; + case DW_IntEnc_LEB128: return dw_size_from_sleb128(v); + default: InvalidPath; break; } return 0; } @@ -39,12 +39,12 @@ dw_size_from_uint(U64 v) { DW_IntEnc enc = dw_int_enc_from_uint(v); switch (enc) { - case DW_IntEnc_Null: break; - case DW_IntEnc_1Byte: return 1; - case DW_IntEnc_2Byte: return 2; - case DW_IntEnc_4Byte: return 4; - case DW_IntEnc_LEB128: return dw_size_from_uleb128(v); - default: InvalidPath; break; + case DW_IntEnc_Null: break; + case DW_IntEnc_1Byte: return 1; + case DW_IntEnc_2Byte: return 2; + case DW_IntEnc_4Byte: return 4; + case DW_IntEnc_LEB128: return dw_size_from_uleb128(v); + default: InvalidPath; break; } return 0; } @@ -69,12 +69,12 @@ dw_writer_attrib_chunk_list_push(Arena *arena, DW_WriterAttribChunkList *list, U SLLQueuePush(list->first, list->last, n); list->chunk_count += 1; } - + DW_WriterAttrib *result = &list->last->v[list->last->count++]; MemoryZeroStruct(result); - + list->total_count += 1; - + return result; } @@ -88,12 +88,12 @@ dw_writer_tag_chunk_list_push(Arena *arena, DW_WriterTagChunkList *list, U64 cap SLLQueuePush(list->first, list->last, n); list->chunk_count += 1; } - + DW_WriterTag *result = &list->last->v[list->last->count++]; MemoryZeroStruct(result); - + list->total_count += 1; - + return result; } @@ -121,33 +121,33 @@ dw_writer_begin(DW_Format format, DW_Version version, DW_CompUnitKind cu_kind, A for EachElement(i, writer->sections) { str8_serial_begin(arena, &writer->sections[i].srl); } - + // write info header { String8List *srl = &writer->sections[DW_Section_Info].srl; - + // length writer->sections[DW_Section_Info].length = dw_serial_push_length(writer->arena, srl, writer->format, 0); - + // version str8_serial_push_struct(writer->arena, srl, &writer->version); - + // compile unit kind str8_serial_push_struct(writer->arena, srl, &writer->cu_kind); - + // address size str8_serial_push_u8(writer->arena, srl, (U8)writer->address_size); // reserve 'abbrev_base' writer->abbrev_base_info_off = srl->total_size; dw_serial_push_uint(writer->arena, srl, writer->format, 0); - + if (writer->cu_kind == DW_CompUnitKind_Skeleton) { // TODO: write skeleton id NotImplemented; } } - + return writer; } @@ -163,132 +163,132 @@ dw_serial_push_form(Arena *arena, String8List *srl, DW_Version version, DW_Forma { U64 start_off = srl->total_size; switch (form.reader.kind) { - case DW_Form_Addr: { - str8_serial_push_string(arena, srl, form.reader.addr); - } break; - case DW_Form_Block1: - case DW_Form_Block2: - case DW_Form_Block4: { - str8_serial_push_string(arena, srl, form.reader.block); - } break; - case DW_Form_Data1: - case DW_Form_Data2: - case DW_Form_Data4: - case DW_Form_Data8: { - str8_serial_push_string(arena, srl, form.reader.data); - } break; - case DW_Form_String: { - str8_serial_push_cstr(arena, srl, form.reader.string); - } break; - case DW_Form_Block: { - dw_serial_push_uleb128(arena, srl, form.reader.block.size); - str8_serial_push_string(arena, srl, form.reader.block); - } break; - case DW_Form_Flag: { - str8_serial_push_u8(arena, srl, form.reader.flag); - } break; - case DW_Form_SData: { - dw_serial_push_sleb128(arena, srl, form.reader.sdata); - } break; - case DW_Form_Strp: { - dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); - } break; - case DW_Form_UData: { - dw_serial_push_uleb128(arena, srl, form.reader.udata); - } break; - case DW_Form_RefAddr: { - if (version < DW_Version_3) { - Assert(address_size <= sizeof(form.reader.ref)); - str8_serial_push_string(arena, srl, str8((U8 *)&form.reader.ref, address_size)); - } else { + case DW_Form_Addr: { + str8_serial_push_string(arena, srl, form.reader.addr); + } break; + case DW_Form_Block1: + case DW_Form_Block2: + case DW_Form_Block4: { + str8_serial_push_string(arena, srl, form.reader.block); + } break; + case DW_Form_Data1: + case DW_Form_Data2: + case DW_Form_Data4: + case DW_Form_Data8: { + str8_serial_push_string(arena, srl, form.reader.data); + } break; + case DW_Form_String: { + str8_serial_push_cstr(arena, srl, form.reader.string); + } break; + case DW_Form_Block: { + dw_serial_push_uleb128(arena, srl, form.reader.block.size); + str8_serial_push_string(arena, srl, form.reader.block); + } break; + case DW_Form_Flag: { + str8_serial_push_u8(arena, srl, form.reader.flag); + } break; + case DW_Form_SData: { + dw_serial_push_sleb128(arena, srl, form.reader.sdata); + } break; + case DW_Form_Strp: { + dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); + } break; + case DW_Form_UData: { + dw_serial_push_uleb128(arena, srl, form.reader.udata); + } break; + case DW_Form_RefAddr: { + if (version < DW_Version_3) { + Assert(address_size <= sizeof(form.reader.ref)); + str8_serial_push_string(arena, srl, str8((U8 *)&form.reader.ref, address_size)); + } else { + dw_serial_push_uint(arena, srl, format, form.reader.ref); + } + } break; + case DW_Form_Ref1: { + str8_serial_push_u8(arena, srl, (U8)form.reader.ref); + } break; + case DW_Form_Ref2: { + str8_serial_push_u16(arena, srl, (U16)form.reader.ref); + } break; + case DW_Form_Ref4: { + str8_serial_push_u32(arena, srl, (U32)form.reader.ref); + } break; + case DW_Form_Ref8: { + if (form.writer.ref->info_off == 0) { + // reserve 8 bytes + void *value = str8_serial_push_u64(arena, srl, 0); + + // push fixup + dw_writer_fixup_list_push(arena, fixups, (DW_WriterFixup){ .ptr = value, .tag = form.writer.ref }); + } + } break; + case DW_Form_RefUData: { + dw_serial_push_uleb128(arena, srl, form.reader.ref); + } break; + case DW_Form_Indirect: { + NotImplemented; + } break; + case DW_Form_SecOffset: { + dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); + } break; + case DW_Form_ExprLoc: { + dw_serial_push_uleb128(arena, srl, form.reader.exprloc.size); + str8_serial_push_string(arena, srl, form.reader.exprloc); + } break; + case DW_Form_FlagPresent: { + } break; + case DW_Form_RefSig8: { + NotImplemented; + } break; + case DW_Form_Strx: + case DW_Form_Addrx: + case DW_Form_RngListx: + case DW_Form_LocListx: { + dw_serial_push_uleb128(arena, srl, form.reader.xval); + } break; + case DW_Form_RefSup4: { + NotImplemented; + } break; + case DW_Form_StrpSup: { + dw_serial_push_uint(arena, srl, format, form.reader.strp_sup); + } break; + case DW_Form_Data16: { + str8_serial_push_string(arena, srl, form.reader.data); + } break; + case DW_Form_LineStrp: { + dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); + } break; + case DW_Form_ImplicitConst: { + // value is stored in the abbrev entry + } break; + case DW_Form_RefSup8: { + NotImplemented; + } break; + case DW_Form_Strx1: + case DW_Form_Addrx1: { + str8_serial_push_u8(arena, srl, (U8)form.reader.xval); + } break; + case DW_Form_Strx2: + case DW_Form_Addrx2: { + str8_serial_push_u16(arena, srl, (U16)form.reader.xval); + } break; + case DW_Form_Strx3: + case DW_Form_Addrx3: { + str8_serial_push_string(arena, srl, str8((U8 *)&form.reader.xval, 3)); + } break; + case DW_Form_Strx4: + case DW_Form_Addrx4: { + str8_serial_push_u32(arena, srl, (U32)form.reader.xval); + } break; + + case DW_Form_GNU_StrpAlt: { + dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); + } break; + case DW_Form_GNU_RefAlt: { dw_serial_push_uint(arena, srl, format, form.reader.ref); - } - } break; - case DW_Form_Ref1: { - str8_serial_push_u8(arena, srl, (U8)form.reader.ref); - } break; - case DW_Form_Ref2: { - str8_serial_push_u16(arena, srl, (U16)form.reader.ref); - } break; - case DW_Form_Ref4: { - str8_serial_push_u32(arena, srl, (U32)form.reader.ref); - } break; - case DW_Form_Ref8: { - if (form.writer.ref->info_off == 0) { - // reserve 8 bytes - void *value = str8_serial_push_u64(arena, srl, 0); - - // push fixup - dw_writer_fixup_list_push(arena, fixups, (DW_WriterFixup){ .ptr = value, .tag = form.writer.ref }); - } - } break; - case DW_Form_RefUData: { - dw_serial_push_uleb128(arena, srl, form.reader.ref); - } break; - case DW_Form_Indirect: { - NotImplemented; - } break; - case DW_Form_SecOffset: { - dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); - } break; - case DW_Form_ExprLoc: { - dw_serial_push_uleb128(arena, srl, form.reader.exprloc.size); - str8_serial_push_string(arena, srl, form.reader.exprloc); - } break; - case DW_Form_FlagPresent: { - } break; - case DW_Form_RefSig8: { - NotImplemented; - } break; - case DW_Form_Strx: - case DW_Form_Addrx: - case DW_Form_RngListx: - case DW_Form_LocListx: { - dw_serial_push_uleb128(arena, srl, form.reader.xval); - } break; - case DW_Form_RefSup4: { - NotImplemented; - } break; - case DW_Form_StrpSup: { - dw_serial_push_uint(arena, srl, format, form.reader.strp_sup); - } break; - case DW_Form_Data16: { - str8_serial_push_string(arena, srl, form.reader.data); - } break; - case DW_Form_LineStrp: { - dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); - } break; - case DW_Form_ImplicitConst: { - // value is stored in the abbrev entry - } break; - case DW_Form_RefSup8: { - NotImplemented; - } break; - case DW_Form_Strx1: - case DW_Form_Addrx1: { - str8_serial_push_u8(arena, srl, (U8)form.reader.xval); - } break; - case DW_Form_Strx2: - case DW_Form_Addrx2: { - str8_serial_push_u16(arena, srl, (U16)form.reader.xval); - } break; - case DW_Form_Strx3: - case DW_Form_Addrx3: { - str8_serial_push_string(arena, srl, str8((U8 *)&form.reader.xval, 3)); - } break; - case DW_Form_Strx4: - case DW_Form_Addrx4: { - str8_serial_push_u32(arena, srl, (U32)form.reader.xval); - } break; - - case DW_Form_GNU_StrpAlt: { - dw_serial_push_uint(arena, srl, format, form.reader.sec_offset); - } break; - case DW_Form_GNU_RefAlt: { - dw_serial_push_uint(arena, srl, format, form.reader.ref); - } break; - - default: InvalidPath; break; + } break; + + default: InvalidPath; break; } return srl->total_size - start_off; } @@ -297,15 +297,15 @@ internal String8 dw_make_abbrev_entry(Arena *arena, DW_WriterTag *tag) { Temp scratch = scratch_begin(&arena, 1); - + String8List srl = {0}; str8_serial_begin(scratch.arena, &srl); - + // tag abbrev B8 has_children = tag->first_child != 0; dw_serial_push_uleb128(scratch.arena, &srl, tag->kind); str8_serial_push_string(scratch.arena, &srl, str8_struct(&has_children)); - + // attrib abbrev for EachNode(attrib, DW_WriterAttrib, tag->first_attrib) { dw_serial_push_uleb128(scratch.arena, &srl, attrib->kind); @@ -314,13 +314,13 @@ dw_make_abbrev_entry(Arena *arena, DW_WriterTag *tag) dw_serial_push_sleb128(scratch.arena, &srl, attrib->form.reader.implicit_const); } } - + // closing entry dw_serial_push_uleb128(scratch.arena, &srl, 0); dw_serial_push_uleb128(scratch.arena, &srl, 0); - + String8 tag_abbrev = str8_serial_end(arena, &srl); - + scratch_end(scratch); return tag_abbrev; } @@ -352,7 +352,7 @@ internal void dw_writer_tag_begin_reserved(DW_Writer *writer, DW_WriterTag *tag) { tag->parent = writer->current; - + // add tag to the tree if (writer->current) { SLLQueuePush(writer->current->first_child, writer->current->last_child, tag); @@ -371,31 +371,31 @@ dw_writer_push_attrib(DW_Writer *writer, DW_AttribKind kind, DW_WriterForm form) for (DW_AttribClass f = attrib_class; f != 0; f &= f - 1) { DW_AttribClass v = f & -f; switch (v) { - case DW_AttribClass_Null: { is_enc_legal = (form.kind == DW_WriterFormKind_Null); } break; - case DW_AttribClass_Undefined: { is_enc_legal = 0; } break; - case DW_AttribClass_Address: { is_enc_legal = (form.kind == DW_WriterFormKind_Address); } break; - case DW_AttribClass_Block: { is_enc_legal = (form.kind == DW_WriterFormKind_Block); } break; - case DW_AttribClass_Const: { is_enc_legal = (form.kind == DW_WriterFormKind_SInt || - form.kind == DW_WriterFormKind_UInt || - form.kind == DW_WriterFormKind_Implicit); } break; - case DW_AttribClass_ExprLoc: { is_enc_legal = (form.kind == DW_WriterFormKind_ExprLoc); } break; - case DW_AttribClass_Flag: { is_enc_legal = (form.kind == DW_WriterFormKind_Flag); } break; - case DW_AttribClass_LinePtr: { is_enc_legal = (form.kind == DW_WriterFormKind_LinePtr); } break; - case DW_AttribClass_LocListPtr: { is_enc_legal = 0; /* TODO */ } break; - case DW_AttribClass_MacPtr: { is_enc_legal = (form.kind == DW_WriterFormKind_MacPtr); } break; - case DW_AttribClass_RngListPtr: { is_enc_legal = (form.kind == DW_WriterFormKind_RngListPtr); } break; - case DW_AttribClass_Reference: { is_enc_legal = (form.kind == DW_WriterFormKind_Ref); } break; - case DW_AttribClass_String: { is_enc_legal = (form.kind == DW_WriterFormKind_String); } break; - case DW_AttribClass_LocList: { is_enc_legal = 0; /* TODO */ } break; - case DW_AttribClass_RngList: { is_enc_legal = 0; /* TODO */ } break; - case DW_AttribClass_StrOffsetsPtr: { is_enc_legal = 0; /* TODO */ } break; - case DW_AttribClass_AddrPtr: { is_enc_legal = 0; /* TODO */ } break; - default: { InvalidPath; } break; + case DW_AttribClass_Null: { is_enc_legal = (form.kind == DW_WriterFormKind_Null); } break; + case DW_AttribClass_Undefined: { is_enc_legal = 0; } break; + case DW_AttribClass_Address: { is_enc_legal = (form.kind == DW_WriterFormKind_Address); } break; + case DW_AttribClass_Block: { is_enc_legal = (form.kind == DW_WriterFormKind_Block); } break; + case DW_AttribClass_Const: { is_enc_legal = (form.kind == DW_WriterFormKind_SInt || + form.kind == DW_WriterFormKind_UInt || + form.kind == DW_WriterFormKind_Implicit); } break; + case DW_AttribClass_ExprLoc: { is_enc_legal = (form.kind == DW_WriterFormKind_ExprLoc); } break; + case DW_AttribClass_Flag: { is_enc_legal = (form.kind == DW_WriterFormKind_Flag); } break; + case DW_AttribClass_LinePtr: { is_enc_legal = (form.kind == DW_WriterFormKind_LinePtr); } break; + case DW_AttribClass_LocListPtr: { is_enc_legal = 0; /* TODO */ } break; + case DW_AttribClass_MacPtr: { is_enc_legal = (form.kind == DW_WriterFormKind_MacPtr); } break; + case DW_AttribClass_RngListPtr: { is_enc_legal = (form.kind == DW_WriterFormKind_RngListPtr); } break; + case DW_AttribClass_Reference: { is_enc_legal = (form.kind == DW_WriterFormKind_Ref); } break; + case DW_AttribClass_String: { is_enc_legal = (form.kind == DW_WriterFormKind_String); } break; + case DW_AttribClass_LocList: { is_enc_legal = 0; /* TODO */ } break; + case DW_AttribClass_RngList: { is_enc_legal = 0; /* TODO */ } break; + case DW_AttribClass_StrOffsetsPtr: { is_enc_legal = 0; /* TODO */ } break; + case DW_AttribClass_AddrPtr: { is_enc_legal = 0; /* TODO */ } break; + default: { InvalidPath; } break; } if (is_enc_legal) { break; } } Assert(is_enc_legal); - + DW_WriterAttrib *attrib = dw_writer_attrib_chunk_list_push(writer->arena, &writer->attrib_chunk_list, 512); attrib->kind = kind; attrib->form.writer = form; @@ -527,76 +527,76 @@ dw_data_from_line_insts(Arena *arena, U8 address_size, DW_LineInstList insts) Temp scratch = scratch_begin(&arena, 1); String8List srl = {0}; str8_serial_begin(scratch.arena, &srl); - + for EachNode(inst_n, DW_LineInstNode, insts.first) { DW_LineInst *inst = &inst_n->v; - + str8_serial_push_struct(scratch.arena, &srl, &inst->opcode); switch (inst->opcode) { - case DW_StdOpcode_Copy: {} break; - case DW_StdOpcode_AdvancePc: { - dw_serial_push_uleb128(arena, &srl, inst->advance_pc); - } break; - case DW_StdOpcode_AdvanceLine: { - dw_serial_push_sleb128(arena, &srl, inst->advance_line); - } break; - case DW_StdOpcode_SetFile: { - dw_serial_push_uleb128(arena, &srl, inst->set_file->file_idx); - } break; - case DW_StdOpcode_SetColumn: { - dw_serial_push_uleb128(arena, &srl, inst->set_column); - } break; - case DW_StdOpcode_NegateStmt: {} break; - case DW_StdOpcode_SetBasicBlock: {} break; - case DW_StdOpcode_ConstAddPc: {} break; - case DW_StdOpcode_FixedAdvancePc: { - str8_serial_push_u16(arena, &srl, inst->fixed_advance_pc); - } break; - case DW_StdOpcode_SetPrologueEnd: {} break; - case DW_StdOpcode_SetEpilogueBegin: {} break; - case DW_StdOpcode_SetIsa: { - dw_serial_push_uleb128(arena, &srl, inst->set_isa); - } break; - case DW_StdOpcode_ExtendedOpcode: { - // get ext size - U64 ext_size = 0; - switch (inst->ext) { - case DW_ExtOpcode_EndSequence: { ext_size = 0; } break; - case DW_ExtOpcode_SetAddress: { ext_size = address_size; } break; - case DW_ExtOpcode_DefineFile: { - NotImplemented; + case DW_StdOpcode_Copy: {} break; + case DW_StdOpcode_AdvancePc: { + dw_serial_push_uleb128(arena, &srl, inst->advance_pc); } break; - case DW_ExtOpcode_SetDiscriminator: { - ext_size = dw_size_from_uleb128(inst->set_discriminator); + case DW_StdOpcode_AdvanceLine: { + dw_serial_push_sleb128(arena, &srl, inst->advance_line); } break; - default: { InvalidPath; } break; - } - ext_size += sizeof(DW_ExtOpcode); - - // write ext header - dw_serial_push_uleb128(arena, &srl, ext_size); - str8_serial_push_struct(arena, &srl, &inst->ext); - - // write ext operands - switch (inst->ext) { - case DW_ExtOpcode_EndSequence: {} break; - case DW_ExtOpcode_SetAddress: { - str8_serial_push_string(arena, &srl, str8_copy(arena, str8((U8 *)&inst->set_address, address_size))); + case DW_StdOpcode_SetFile: { + dw_serial_push_uleb128(arena, &srl, inst->set_file->file_idx); } break; - case DW_ExtOpcode_DefineFile: { - NotImplemented; + case DW_StdOpcode_SetColumn: { + dw_serial_push_uleb128(arena, &srl, inst->set_column); } break; - case DW_ExtOpcode_SetDiscriminator: { - dw_serial_push_uleb128(arena, &srl, inst->set_discriminator); + case DW_StdOpcode_NegateStmt: {} break; + case DW_StdOpcode_SetBasicBlock: {} break; + case DW_StdOpcode_ConstAddPc: {} break; + case DW_StdOpcode_FixedAdvancePc: { + str8_serial_push_u16(arena, &srl, inst->fixed_advance_pc); } break; - default: { InvalidPath; } break; - } - } break; - // special opcode - default: { } break; + case DW_StdOpcode_SetPrologueEnd: {} break; + case DW_StdOpcode_SetEpilogueBegin: {} break; + case DW_StdOpcode_SetIsa: { + dw_serial_push_uleb128(arena, &srl, inst->set_isa); + } break; + case DW_StdOpcode_ExtendedOpcode: { + // get ext size + U64 ext_size = 0; + switch (inst->ext) { + case DW_ExtOpcode_EndSequence: { ext_size = 0; } break; + case DW_ExtOpcode_SetAddress: { ext_size = address_size; } break; + case DW_ExtOpcode_DefineFile: { + NotImplemented; + } break; + case DW_ExtOpcode_SetDiscriminator: { + ext_size = dw_size_from_uleb128(inst->set_discriminator); + } break; + default: { InvalidPath; } break; + } + ext_size += sizeof(DW_ExtOpcode); + + // write ext header + dw_serial_push_uleb128(arena, &srl, ext_size); + str8_serial_push_struct(arena, &srl, &inst->ext); + + // write ext operands + switch (inst->ext) { + case DW_ExtOpcode_EndSequence: {} break; + case DW_ExtOpcode_SetAddress: { + str8_serial_push_string(arena, &srl, str8_copy(arena, str8((U8 *)&inst->set_address, address_size))); + } break; + case DW_ExtOpcode_DefineFile: { + NotImplemented; + } break; + case DW_ExtOpcode_SetDiscriminator: { + dw_serial_push_uleb128(arena, &srl, inst->set_discriminator); + } break; + default: { InvalidPath; } break; + } + } break; + // special opcode + default: { } break; } } - + String8 data = str8_serial_end(arena, &srl); scratch_end(scratch); return data; @@ -608,14 +608,14 @@ dw_writer_line_emit(DW_Writer *writer, DW_WriterFile *file, U64 ln, U64 col, U64 if (writer->line.file != file) { dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNS_set_file(file)); } - + S64 col_delta = (S64)col - (S64)writer->line.col; if (col_delta != 0) { dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNS_set_column(col_delta)); } - + Assert(addr <= max_S64); S64 addr_delta = (S64)addr - (S64)writer->line.addr; S64 ln_delta = (S64)ln - (S64)writer->line.ln; - + S64 max_ln_delta = writer->line.line_range + writer->line.line_base; S64 max_addr_delta = (max_U8 - writer->line.opcode_base - (ln_delta - writer->line.line_base)) / writer->line.line_range; if ((ln_delta != 0 || addr_delta != 0) && @@ -630,7 +630,7 @@ dw_writer_line_emit(DW_Writer *writer, DW_WriterFile *file, U64 ln, U64 col, U64 dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNS_copy()); } } - + // update registers writer->line.file = file; writer->line.ln = ln; @@ -683,7 +683,7 @@ dw_writer_new_file(DW_Writer *writer, String8 path) { DW_WriterFile *file = push_array(writer->arena, DW_WriterFile, 1); file->path = path; - + SLLQueuePush(writer->line.first_file, writer->line.last_file, file); writer->line.file_count += 1; return file; @@ -694,104 +694,104 @@ dw_lower_attrib_forms(DW_Writer *writer, DW_WriterTag *tag) { for EachNode(attrib, DW_WriterAttrib, tag->first_attrib) { switch (attrib->form.writer.kind) { - case DW_WriterFormKind_Null: {} break; - case DW_WriterFormKind_Flag: { - attrib->form.reader.kind = DW_Form_Flag; - attrib->form.reader.flag = attrib->form.writer.flag; - } break; - case DW_WriterFormKind_SInt: { - switch (dw_int_enc_from_sint(attrib->form.writer.sint)) { - case DW_IntEnc_Null: attrib->form.reader.kind = 0; break; - case DW_IntEnc_1Byte: { - attrib->form.reader.kind = DW_Form_Data1; - attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(S8)); + case DW_WriterFormKind_Null: {} break; + case DW_WriterFormKind_Flag: { + attrib->form.reader.kind = DW_Form_Flag; + attrib->form.reader.flag = attrib->form.writer.flag; } break; - case DW_IntEnc_2Byte: { - attrib->form.reader.kind = DW_Form_Data2; - attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(S16)); - } break; - case DW_IntEnc_4Byte: { - attrib->form.reader.kind = DW_Form_Data4; - attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(U32)); - } break; - case DW_IntEnc_LEB128: { - attrib->form.reader.kind = DW_Form_SData; - attrib->form.reader.sdata = attrib->form.writer.sint; - } break; - default: InvalidPath; break; - } - } break; - case DW_WriterFormKind_UInt: { - attrib->form.reader.kind = DW_Form_UData; - attrib->form.reader.udata = attrib->form.writer.uint; - } break; - case DW_WriterFormKind_Address: { - Assert(writer->address_size <= sizeof(attrib->form.writer.address)); - attrib->form.reader.kind = DW_Form_Addr; - attrib->form.reader.addr = push_str8_copy(writer->arena, str8((U8 *)&attrib->form.writer.address, writer->address_size)); - } break; - case DW_WriterFormKind_Ref: { - if (attrib->form.writer.ref->info_off == 0) { - attrib->form.reader.kind = DW_Form_Ref8; - } else { - switch (dw_int_enc_from_uint(attrib->form.writer.ref->info_off)) { - case DW_IntEnc_Null: break; - case DW_IntEnc_1Byte: { - attrib->form.reader.kind = DW_Form_Ref1; - attrib->form.reader.ref = (U8)attrib->form.writer.ref->info_off; - } break; - case DW_IntEnc_2Byte: { - attrib->form.reader.kind = DW_Form_Ref2; - attrib->form.reader.ref = (U16)attrib->form.writer.ref->info_off; - } break; - case DW_IntEnc_4Byte: { - attrib->form.reader.kind = DW_Form_Ref4; - attrib->form.reader.ref = (U32)attrib->form.writer.ref->info_off; - } break; - case DW_IntEnc_LEB128: { - attrib->form.reader.kind = DW_Form_RefUData; - attrib->form.reader.ref = attrib->form.writer.ref->info_off; - } break; - default: InvalidPath; break; + case DW_WriterFormKind_SInt: { + switch (dw_int_enc_from_sint(attrib->form.writer.sint)) { + case DW_IntEnc_Null: attrib->form.reader.kind = 0; break; + case DW_IntEnc_1Byte: { + attrib->form.reader.kind = DW_Form_Data1; + attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(S8)); + } break; + case DW_IntEnc_2Byte: { + attrib->form.reader.kind = DW_Form_Data2; + attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(S16)); + } break; + case DW_IntEnc_4Byte: { + attrib->form.reader.kind = DW_Form_Data4; + attrib->form.reader.data = str8((U8 *)&attrib->form.writer.sint, sizeof(U32)); + } break; + case DW_IntEnc_LEB128: { + attrib->form.reader.kind = DW_Form_SData; + attrib->form.reader.sdata = attrib->form.writer.sint; + } break; + default: InvalidPath; break; } - } - } break; - case DW_WriterFormKind_LinePtr: { - attrib->form.reader.kind = DW_Form_SecOffset; - attrib->form.reader.sec_offset = attrib->form.writer.line_ptr; - } break; - case DW_WriterFormKind_MacPtr: { - NotImplemented; - } break; - case DW_WriterFormKind_RngListPtr: { - NotImplemented; - } break; - case DW_WriterFormKind_Data: { - NotImplemented; - } break; - case DW_WriterFormKind_Block: { - attrib->form.reader.block = attrib->form.writer.block; - switch (attrib->form.writer.block.size) { - case 0 : break; - case 1 : attrib->form.reader.kind = DW_Form_Block1; break; - case 2 : attrib->form.reader.kind = DW_Form_Block2; break; - case 4 : attrib->form.reader.kind = DW_Form_Block4; break; - default: attrib->form.reader.kind = DW_Form_Block; break; - } - } break; - case DW_WriterFormKind_String: { - attrib->form.reader.kind = DW_Form_String; - attrib->form.reader.string = attrib->form.writer.string; - } break; - case DW_WriterFormKind_ExprLoc: { - attrib->form.reader.kind = DW_Form_ExprLoc; - attrib->form.reader.exprloc = attrib->form.writer.exprloc; - } break; - case DW_WriterFormKind_Implicit: { - attrib->form.reader.kind = DW_Form_ImplicitConst; - attrib->form.reader.implicit_const = attrib->form.writer.implicit; - } break; - default: { InvalidPath; } break; + } break; + case DW_WriterFormKind_UInt: { + attrib->form.reader.kind = DW_Form_UData; + attrib->form.reader.udata = attrib->form.writer.uint; + } break; + case DW_WriterFormKind_Address: { + Assert(writer->address_size <= sizeof(attrib->form.writer.address)); + attrib->form.reader.kind = DW_Form_Addr; + attrib->form.reader.addr = push_str8_copy(writer->arena, str8((U8 *)&attrib->form.writer.address, writer->address_size)); + } break; + case DW_WriterFormKind_Ref: { + if (attrib->form.writer.ref->info_off == 0) { + attrib->form.reader.kind = DW_Form_Ref8; + } else { + switch (dw_int_enc_from_uint(attrib->form.writer.ref->info_off)) { + case DW_IntEnc_Null: break; + case DW_IntEnc_1Byte: { + attrib->form.reader.kind = DW_Form_Ref1; + attrib->form.reader.ref = (U8)attrib->form.writer.ref->info_off; + } break; + case DW_IntEnc_2Byte: { + attrib->form.reader.kind = DW_Form_Ref2; + attrib->form.reader.ref = (U16)attrib->form.writer.ref->info_off; + } break; + case DW_IntEnc_4Byte: { + attrib->form.reader.kind = DW_Form_Ref4; + attrib->form.reader.ref = (U32)attrib->form.writer.ref->info_off; + } break; + case DW_IntEnc_LEB128: { + attrib->form.reader.kind = DW_Form_RefUData; + attrib->form.reader.ref = attrib->form.writer.ref->info_off; + } break; + default: InvalidPath; break; + } + } + } break; + case DW_WriterFormKind_LinePtr: { + attrib->form.reader.kind = DW_Form_SecOffset; + attrib->form.reader.sec_offset = attrib->form.writer.line_ptr; + } break; + case DW_WriterFormKind_MacPtr: { + NotImplemented; + } break; + case DW_WriterFormKind_RngListPtr: { + NotImplemented; + } break; + case DW_WriterFormKind_Data: { + NotImplemented; + } break; + case DW_WriterFormKind_Block: { + attrib->form.reader.block = attrib->form.writer.block; + switch (attrib->form.writer.block.size) { + case 0 : break; + case 1 : attrib->form.reader.kind = DW_Form_Block1; break; + case 2 : attrib->form.reader.kind = DW_Form_Block2; break; + case 4 : attrib->form.reader.kind = DW_Form_Block4; break; + default: attrib->form.reader.kind = DW_Form_Block; break; + } + } break; + case DW_WriterFormKind_String: { + attrib->form.reader.kind = DW_Form_String; + attrib->form.reader.string = attrib->form.writer.string; + } break; + case DW_WriterFormKind_ExprLoc: { + attrib->form.reader.kind = DW_Form_ExprLoc; + attrib->form.reader.exprloc = attrib->form.writer.exprloc; + } break; + case DW_WriterFormKind_Implicit: { + attrib->form.reader.kind = DW_Form_ImplicitConst; + attrib->form.reader.implicit_const = attrib->form.writer.implicit; + } break; + default: { InvalidPath; } break; } } } @@ -800,20 +800,20 @@ internal void dw_writer_emit_tag(DW_Writer *writer, DW_WriterTag *tag) { Assert(tag->info_off == 0); - + dw_lower_attrib_forms(writer, tag); - + // make abbrev id for the tag U64 abbrev_id; { Temp temp = temp_begin(writer->arena); String8 abbrev_entry = dw_make_abbrev_entry(temp.arena, tag); - + if ( ! hash_table_search_string_u64(writer->abbrev_id_map, abbrev_entry, &abbrev_id)) { abbrev_id = writer->abbrev_id_map->count + 1; - + hash_table_push_string_u64(writer->arena, writer->abbrev_id_map, abbrev_entry, abbrev_id); - + // push abbrev entry dw_serial_push_uleb128(writer->arena, &writer->sections[DW_Section_Abbrev].srl, abbrev_id); str8_serial_push_string(writer->arena, &writer->sections[DW_Section_Abbrev].srl, abbrev_entry); @@ -821,149 +821,149 @@ dw_writer_emit_tag(DW_Writer *writer, DW_WriterTag *tag) temp_end(temp); } } - + tag->abbrev_id = abbrev_id; tag->info_off = writer->sections[DW_Section_Info].srl.total_size; - + // emit tag abbrev id dw_serial_push_uleb128(writer->arena, &writer->sections[DW_Section_Info].srl, tag->abbrev_id); - + // emit attribs { String8List *debug_info = &writer->sections[DW_Section_Info].srl; for EachNode(attrib, DW_WriterAttrib, tag->first_attrib) { switch (attrib->form.reader.kind) { - case DW_Form_Addr: { - str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.addr); - } break; - case DW_Form_Block1: - case DW_Form_Block2: - case DW_Form_Block4: { - str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.block); - } break; - case DW_Form_Data1: - case DW_Form_Data2: - case DW_Form_Data4: - case DW_Form_Data8: { - str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.data); - } break; - case DW_Form_String: { - str8_serial_push_cstr(writer->arena, debug_info, attrib->form.reader.string); - } break; - case DW_Form_Flag: { - str8_serial_push_u8(writer->arena, debug_info, attrib->form.reader.flag); - } break; - case DW_Form_SData: { - dw_serial_push_sleb128(writer->arena, debug_info, attrib->form.reader.sdata); - } break; - case DW_Form_Strp: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); - } break; - case DW_Form_UData: { - dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.udata); - } break; - case DW_Form_RefAddr: { - if (writer->version < DW_Version_3) { - Assert(writer->address_size <= sizeof(attrib->form.reader.ref)); - str8_serial_push_string(writer->arena, debug_info, str8((U8 *)&attrib->form.reader.ref, writer->address_size)); - } else { + case DW_Form_Addr: { + str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.addr); + } break; + case DW_Form_Block1: + case DW_Form_Block2: + case DW_Form_Block4: { + str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.block); + } break; + case DW_Form_Data1: + case DW_Form_Data2: + case DW_Form_Data4: + case DW_Form_Data8: { + str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.data); + } break; + case DW_Form_String: { + str8_serial_push_cstr(writer->arena, debug_info, attrib->form.reader.string); + } break; + case DW_Form_Flag: { + str8_serial_push_u8(writer->arena, debug_info, attrib->form.reader.flag); + } break; + case DW_Form_SData: { + dw_serial_push_sleb128(writer->arena, debug_info, attrib->form.reader.sdata); + } break; + case DW_Form_Strp: { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); + } break; + case DW_Form_UData: { + dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.udata); + } break; + case DW_Form_RefAddr: { + if (writer->version < DW_Version_3) { + Assert(writer->address_size <= sizeof(attrib->form.reader.ref)); + str8_serial_push_string(writer->arena, debug_info, str8((U8 *)&attrib->form.reader.ref, writer->address_size)); + } else { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.ref); + } + } break; + case DW_Form_Ref1: { + str8_serial_push_u8(writer->arena, debug_info, (U8)attrib->form.reader.ref); + } break; + case DW_Form_Ref2: { + str8_serial_push_u16(writer->arena, debug_info, (U16)attrib->form.reader.ref); + } break; + case DW_Form_Ref4: { + str8_serial_push_u32(writer->arena, debug_info, (U32)attrib->form.reader.ref); + } break; + case DW_Form_Ref8: { + if (attrib->form.writer.ref->info_off == 0) { + // reserve 8 bytes + void *value = str8_serial_push_u64(writer->arena, debug_info, 0); + + // push fixup + dw_writer_fixup_list_push(writer->arena, &writer->fixups, (DW_WriterFixup){ .tag = attrib->form.writer.ref, .ptr = value }); + } + } break; + case DW_Form_RefUData: { + dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.ref); + } break; + case DW_Form_Indirect: { + NotImplemented; + } break; + case DW_Form_SecOffset: { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); + } break; + case DW_Form_ExprLoc: { + dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.exprloc.size); + str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.exprloc); + } break; + case DW_Form_FlagPresent: { + } break; + case DW_Form_RefSig8: { + NotImplemented; + } break; + case DW_Form_Strx: + case DW_Form_Addrx: + case DW_Form_RngListx: + case DW_Form_LocListx: { + dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.xval); + } break; + case DW_Form_RefSup4: { + NotImplemented; + } break; + case DW_Form_StrpSup: { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.strp_sup); + } break; + case DW_Form_Data16: { + str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.data); + } break; + case DW_Form_LineStrp: { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); + } break; + case DW_Form_ImplicitConst: { + // value is stored in the abbrev entry + } break; + case DW_Form_RefSup8: { + NotImplemented; + } break; + case DW_Form_Strx1: + case DW_Form_Addrx1: { + str8_serial_push_u8(writer->arena, debug_info, (U8)attrib->form.reader.xval); + } break; + case DW_Form_Strx2: + case DW_Form_Addrx2: { + str8_serial_push_u16(writer->arena, debug_info, (U16)attrib->form.reader.xval); + } break; + case DW_Form_Strx3: + case DW_Form_Addrx3: { + str8_serial_push_string(writer->arena, debug_info, str8((U8 *)&attrib->form.reader.xval, 3)); + } break; + case DW_Form_Strx4: + case DW_Form_Addrx4: { + str8_serial_push_u32(writer->arena, debug_info, (U32)attrib->form.reader.xval); + } break; + + case DW_Form_GNU_StrpAlt: { + dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); + } break; + case DW_Form_GNU_RefAlt: { dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.ref); - } - } break; - case DW_Form_Ref1: { - str8_serial_push_u8(writer->arena, debug_info, (U8)attrib->form.reader.ref); - } break; - case DW_Form_Ref2: { - str8_serial_push_u16(writer->arena, debug_info, (U16)attrib->form.reader.ref); - } break; - case DW_Form_Ref4: { - str8_serial_push_u32(writer->arena, debug_info, (U32)attrib->form.reader.ref); - } break; - case DW_Form_Ref8: { - if (attrib->form.writer.ref->info_off == 0) { - // reserve 8 bytes - void *value = str8_serial_push_u64(writer->arena, debug_info, 0); - - // push fixup - dw_writer_fixup_list_push(writer->arena, &writer->fixups, (DW_WriterFixup){ .tag = attrib->form.writer.ref, .ptr = value }); - } - } break; - case DW_Form_RefUData: { - dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.ref); - } break; - case DW_Form_Indirect: { - NotImplemented; - } break; - case DW_Form_SecOffset: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); - } break; - case DW_Form_ExprLoc: { - dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.exprloc.size); - str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.exprloc); - } break; - case DW_Form_FlagPresent: { - } break; - case DW_Form_RefSig8: { - NotImplemented; - } break; - case DW_Form_Strx: - case DW_Form_Addrx: - case DW_Form_RngListx: - case DW_Form_LocListx: { - dw_serial_push_uleb128(writer->arena, debug_info, attrib->form.reader.xval); - } break; - case DW_Form_RefSup4: { - NotImplemented; - } break; - case DW_Form_StrpSup: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.strp_sup); - } break; - case DW_Form_Data16: { - str8_serial_push_string(writer->arena, debug_info, attrib->form.reader.data); - } break; - case DW_Form_LineStrp: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); - } break; - case DW_Form_ImplicitConst: { - // value is stored in the abbrev entry - } break; - case DW_Form_RefSup8: { - NotImplemented; - } break; - case DW_Form_Strx1: - case DW_Form_Addrx1: { - str8_serial_push_u8(writer->arena, debug_info, (U8)attrib->form.reader.xval); - } break; - case DW_Form_Strx2: - case DW_Form_Addrx2: { - str8_serial_push_u16(writer->arena, debug_info, (U16)attrib->form.reader.xval); - } break; - case DW_Form_Strx3: - case DW_Form_Addrx3: { - str8_serial_push_string(writer->arena, debug_info, str8((U8 *)&attrib->form.reader.xval, 3)); - } break; - case DW_Form_Strx4: - case DW_Form_Addrx4: { - str8_serial_push_u32(writer->arena, debug_info, (U32)attrib->form.reader.xval); - } break; - - case DW_Form_GNU_StrpAlt: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.sec_offset); - } break; - case DW_Form_GNU_RefAlt: { - dw_serial_push_uint(writer->arena, debug_info, writer->format, attrib->form.reader.ref); - } break; - - default: InvalidPath; break; + } break; + + default: InvalidPath; break; } } } - + // write children for EachNode(child, DW_WriterTag, tag->first_child) { dw_writer_emit_tag(writer, child); } - + // close tag if (tag->first_child) { dw_serial_push_uleb128(writer->arena, &writer->sections[DW_Section_Info].srl, 0); @@ -977,7 +977,7 @@ dw_writer_emit(DW_Writer *writer) { // push line table terminator dw_writer_line_end_sequence(writer); - + // find comp dir in the compile unit tag String8 comp_dir = {0}; String8 comp_name = {0}; @@ -991,19 +991,19 @@ dw_writer_emit(DW_Writer *writer) comp_name = attrib->form.writer.string; } } - + String8List dir_table_srl = {0}; str8_serial_begin(writer->arena, &dir_table_srl); { Temp scratch = scratch_begin(0, 0); String8List *srl = &dir_table_srl; - + // (13) directory_entry_format_count str8_serial_push_u8(writer->arena, srl, 1); // (14) directory_entry_format dw_serial_push_uleb128(writer->arena, srl, DW_LNCT_Path); dw_serial_push_uleb128(writer->arena, srl, DW_Form_String); - + // dedup directories String8List dirs = {0}; HashTable *dir_ht = hash_table_init(scratch.arena, writer->line.file_count + 1); @@ -1017,7 +1017,7 @@ dw_writer_emit(DW_Writer *writer) for EachNode(file, DW_WriterFile, writer->line.first_file) { String8 path = str8_chop_last_slash(file->path); if (path.size == 0) { - continue; + continue; } if ( ! hash_table_search_string_u64(dir_ht, path, &file->dir_idx)) { // @dir_idx @@ -1029,24 +1029,24 @@ dw_writer_emit(DW_Writer *writer) } } } - + // (15) directories_count dw_serial_push_uleb128(writer->arena, srl, dirs.node_count); - + // (16) directories for EachNode(dir_n, String8Node, dirs.first) { dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, (DW_WriterXForm) { .reader = { .kind = DW_Form_String, .string = dir_n->string } }); } - + scratch_end(scratch); } - + String8List file_table_srl = {0}; str8_serial_begin(writer->arena, &file_table_srl); { Temp scratch = scratch_begin(0, 0); String8List *srl = &file_table_srl; - + struct { DW_LNCT lnct; DW_FormKind form_kind; } encs[] = { { DW_LNCT_Path, DW_Form_String }, { DW_LNCT_DirectoryIndex, DW_Form_UData }, @@ -1055,10 +1055,10 @@ dw_writer_emit(DW_Writer *writer) { DW_LNCT_MD5, DW_Form_Null }, // DW_Form_Block { DW_LNCT_LLVM_Source, DW_Form_Null } // DW_Form_String }; - + HashTable *encs_ht = hash_table_init(scratch.arena, ArrayCount(encs) * 2); for EachElement(i, encs) { hash_table_push_u64_raw(scratch.arena, encs_ht, encs[i].lnct, &encs[i].form_kind); } - + // enable encodings in use for EachNode(file, DW_WriterFile, writer->line.first_file) { if (file->time_stamp != 0) { *(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_TimeStamp ) = DW_Form_UData; } @@ -1066,24 +1066,24 @@ dw_writer_emit(DW_Writer *writer) if ( ! u128_match(file->md5, u128_zero())) { *(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_MD5 ) = DW_Form_Block; } if (file->source.size != 0) { *(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_LLVM_Source) = DW_Form_String; } } - + // count needed encodings U8 enc_count = 0; for EachElement(i, encs) { if (encs[i].form_kind != DW_Form_Null) { enc_count += 1; } } - + // (17) file_name_entry_format_count str8_serial_push_u8(writer->arena, srl, enc_count); - + // (18) file_name_entry_format for EachElement(i, encs) { if (encs[i].form_kind == DW_Form_Null) { continue; } dw_serial_push_uleb128(writer->arena, srl, encs[i].lnct ); dw_serial_push_uleb128(writer->arena, srl, encs[i].form_kind); } - + // (19) file_names_count dw_serial_push_uleb128(writer->arena, srl, writer->line.file_count); - + // (20) file_names if (comp_name.size) { for (DW_WriterFile *n = writer->line.first_file, *p = 0; n != 0; p = n, n = n->next) { @@ -1109,21 +1109,21 @@ dw_writer_emit(DW_Writer *writer) static DW_WriterXForm null_form_udata = { .reader = { .kind = DW_Form_UData } }; static DW_WriterXForm null_form_string = { .reader = { .kind = DW_Form_String } }; static DW_WriterXForm null_form_block = { .reader = { .kind = DW_Form_Block } }; - + // @file_idx file->file_idx = file_idx++; - + // path Assert(*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_Path) == DW_Form_String); String8 file_name = str8_skip_last_slash(file->path); DW_WriterXForm path_form = { .reader = { .kind = DW_Form_String, .string = file_name } }; dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, path_form); - + // directory index Assert(*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_DirectoryIndex) == DW_Form_UData); DW_WriterXForm dir_idx_form = { .reader = { .kind = DW_Form_UData, .udata = file->dir_idx } }; dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, dir_idx_form); - + // time stamp if (*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_TimeStamp) == DW_Form_UData) { if (file->time_stamp) { @@ -1133,7 +1133,7 @@ dw_writer_emit(DW_Writer *writer) dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, null_form_udata); } } - + // size if (*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_Size) == DW_Form_UData) { if (file->size) { @@ -1143,7 +1143,7 @@ dw_writer_emit(DW_Writer *writer) dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, null_form_udata); } } - + // MD5 if (*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_MD5) == DW_Form_Block) { if ( ! u128_match(file->md5, u128_zero())) { @@ -1153,7 +1153,7 @@ dw_writer_emit(DW_Writer *writer) dw_serial_push_form(writer->arena, srl, writer->version, writer->format, writer->address_size, 0, null_form_block); } } - + // LLVM Source if (*(DW_FormKind *)hash_table_search_u64_raw(encs_ht, DW_LNCT_LLVM_Source) == DW_Form_String) { if (file->source.size) { @@ -1164,10 +1164,10 @@ dw_writer_emit(DW_Writer *writer) } } } - + scratch_end(scratch); } - + { String8List *srl = &writer->sections[DW_Section_Line].srl; // (1) unit_length @@ -1201,25 +1201,25 @@ dw_writer_emit(DW_Writer *writer) str8_list_concat_in_place(srl, &dir_table_srl); // file table str8_list_concat_in_place(srl, &file_table_srl); - + // fixup header length U64 bytes_to_line_program = srl->total_size - header_length_offset; if (writer->format == DW_Format_32Bit) { *(U32 *)header_length_ptr = bytes_to_line_program; } else { *(U64 *)header_length_ptr = bytes_to_line_program; } - + // line program String8 line_program_data = dw_data_from_line_insts(writer->arena, writer->address_size, writer->line.line_insts); str8_serial_push_string(writer->arena, srl, line_program_data); } } - + // info { dw_writer_emit_tag(writer, writer->root); - + // null terminate .debug_abbrev dw_serial_push_uleb128(writer->arena, &writer->sections[DW_Section_Abbrev].srl, 0); - + // fixup units lengths for EachElement(i, writer->sections) { if (writer->sections[i].length) { @@ -1236,7 +1236,7 @@ dw_writer_emit(DW_Writer *writer) } } } - + // fixup forward references in .debug_info for EachNode(fixup_n, DW_WriterFixupNode, writer->fixups.first) { DW_WriterFixup *fixup = &fixup_n->v; @@ -1251,19 +1251,19 @@ internal void dw_writer_emit_to_obj(DW_Writer *writer, OBJ *obj) { dw_writer_emit(writer); - + // push obj sections - OBJ_Section *sections[DW_Section_Count] = {0}; + OBJ_Section *sections[DW_Section_COUNT] = {0}; for EachElement(i, writer->sections) { if (writer->sections[i].srl.total_size) { sections[i] = obj_push_section(obj, dw_name_string_from_section_kind(i), OBJ_SectionFlag_Read|OBJ_SectionFlag_Write); } } - + // push OBJ relocation for 'abbrev base' OBJ_Section *debug_info = sections[DW_Section_Info]; obj_push_reloc(obj, debug_info, OBJ_RelocKind_SecRel, writer->abbrev_base_info_off, sections[DW_Section_Abbrev]->symbol); - + // copy section data from writer to obj for EachElement(i, writer->sections) { if (writer->sections[i].srl.total_size > 0) { @@ -1271,7 +1271,7 @@ dw_writer_emit_to_obj(DW_Writer *writer, OBJ *obj) str8_list_push(obj->arena, §ions[i]->data, data); } } - + // zero out writer sections MemoryZeroArray(writer->sections); } diff --git a/src/dwarf/dwarf_writer.h b/src/dwarf/dwarf_writer.h index eb8a3e84..2e1a8923 100644 --- a/src/dwarf/dwarf_writer.h +++ b/src/dwarf/dwarf_writer.h @@ -201,7 +201,7 @@ typedef struct DW_WriterSection typedef struct DW_Writer { Arena *arena; - + // Compile Unit Arch arch; DW_Version version; @@ -209,15 +209,15 @@ typedef struct DW_Writer DW_CompUnitKind cu_kind; U8 address_size; U8 segsel_size; - + // Abbrev U64 abbrev_base_info_off; HashTable *abbrev_id_map; - + // Info DW_WriterTag *root; DW_WriterTag *current; - + // Line struct { U8 min_inst_len; @@ -227,20 +227,20 @@ typedef struct DW_Writer U8 line_range; U8 opcode_base; DW_LineInstList line_insts; - + DW_WriterFile *file; U64 ln; U64 col; U64 addr; - + U64 file_count; DW_WriterFile *first_file; DW_WriterFile *last_file; } line; - + // Emit DW_WriterFixupList fixups; - DW_WriterSection sections[DW_Section_Count]; + DW_WriterSection sections[DW_Section_COUNT]; DW_WriterAttribChunkList attrib_chunk_list; DW_WriterTagChunkList tag_chunk_list; } DW_Writer; diff --git a/src/lib_rdi/rdi.c b/src/lib_rdi/rdi.c index eadf21dd..9463e4aa 100644 --- a/src/lib_rdi/rdi.c +++ b/src/lib_rdi/rdi.c @@ -285,6 +285,7 @@ switch(arch) { default:{}break; case RDI_Arch_X64:{result = 8;}break; +case RDI_Arch_X86:{result = 4;}break; } return result; } diff --git a/src/lib_rdi/rdi.h b/src/lib_rdi/rdi.h index d870dd2b..aadf6729 100644 --- a/src/lib_rdi/rdi.h +++ b/src/lib_rdi/rdi.h @@ -133,6 +133,7 @@ typedef enum RDI_ArchEnum { RDI_Arch_NULL = 0, RDI_Arch_X64 = 1, +RDI_Arch_X86 = 2, } RDI_ArchEnum; typedef RDI_U8 RDI_RegCode; @@ -578,6 +579,7 @@ X(RDI_U64, idx)\ #define RDI_Arch_XList \ X(NULL)\ X(X64)\ +X(X86)\ #define RDI_RegCodeX64_XList \ X(nil, 0)\ diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index 3b8af5f6..53e8ec44 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -77,7 +77,14 @@ rb_thread_entry_point(void *p) ////////////////////////// //- rjf: possibly relative -> absolute path // - String8 input_file_path = path_normalized_from_string(arena, str8f(arena, "%S/%S", working_directory, n->string)); + String8 input_file_path = n->string; + { + PathStyle path_style = path_style_from_str8(n->string); + if(path_style == PathStyle_Relative) + { + input_file_path = path_normalized_from_string(arena, str8f(arena, "%S/%S", working_directory, n->string)); + } + } ////////////////////////// //- rjf: do thin analysis of file @@ -654,6 +661,7 @@ rb_thread_entry_point(void *p) B32 convert_done = 0; RDIM_BakeParams pdb_bake_params = {0}; RDIM_BakeParams dwarf_bake_params = {0}; + RDIM_BakeParams dwarf_bake_params_2 = {0}; typedef struct RDIM_BakeParamsNode RDIM_BakeParamsNode; struct RDIM_BakeParamsNode { @@ -756,6 +764,124 @@ rb_thread_entry_point(void *p) convert_params.is_parse_relaxed = 1; // TODO: switch } ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params); + + // rjf: convert [2] + D2R2_ConvertParams convert_params_2 = {0}; + { + B32 got_exe = 0; + B32 got_dbg = 0; + String8 exe_name = {0}; + String8 exe_data = {0}; + ExecutableImageKind exe_kind = ExecutableImageKind_Null; + String8 dbg_name = {0}; + String8 dbg_data = {0}; + if(!got_exe && !got_dbg) + { + for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_PE].first; n != 0; n = n->next) + { + if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) + { + got_exe = 1; + got_dbg = 1; + dbg_name = n->v->path; + dbg_data = n->v->data; + exe_name = n->v->path; + exe_data = n->v->data; + exe_kind = ExecutableImageKind_CoffPe; + break; + } + } + } + if(!got_exe) + { + for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next) + { + got_exe = 1; + exe_name = n->v->path; + exe_data = n->v->data; + exe_kind = ExecutableImageKind_Elf32; + if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF)) + { + break; + } + } + } + if(!got_exe) + { + for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next) + { + got_exe = 1; + exe_name = n->v->path; + exe_data = n->v->data; + exe_kind = ExecutableImageKind_Elf64; + if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF)) + { + break; + } + } + } + if(!got_dbg) + { + for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next) + { + if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) + { + got_dbg = 1; + dbg_name = n->v->path; + dbg_data = n->v->data; + break; + } + } + } + if(!got_dbg) + { + for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next) + { + if(n->v->format_flags & RB_FileFormatFlag_HasDWARF) + { + got_dbg = 1; + dbg_name = n->v->path; + dbg_data = n->v->data; + break; + } + } + } + switch(exe_kind) + { + default:{}break; + case ExecutableImageKind_CoffPe: + { + Temp scratch = scratch_begin(&arena, 1); + PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, exe_data); + String8 raw_sections = str8_substr(exe_data, pe.section_table_range); + COFF_SectionHeader *section_table = str8_deserial_get_raw_ptr(raw_sections, 0, sizeof(COFF_SectionHeader) * pe.section_count); + String8 string_table = str8_substr(exe_data, pe.string_table_range); + convert_params_2.arch = pe.arch; + convert_params_2.base_vaddr = pe.image_base; + convert_params_2.raw = dw_input_from_coff_section_table(scratch.arena, exe_data, string_table, pe.section_count, section_table); + convert_params_2.path_style = PathStyle_WindowsAbsolute; + convert_params_2.binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, exe_data, string_table, pe.section_count, section_table); + scratch_end(scratch); + }break; + case ExecutableImageKind_Elf32: + case ExecutableImageKind_Elf64: + { + Temp scratch = scratch_begin(&arena, 1); + ELF_Bin bin = elf_bin_from_data(scratch.arena, dbg_data); + convert_params_2.arch = arch_from_elf_machine(bin.hdr.e_machine); + convert_params_2.base_vaddr = elf_base_addr_from_bin(&bin); + convert_params_2.raw = dw_input_from_elf_bin(scratch.arena, dbg_data, &bin); + convert_params_2.path_style = PathStyle_UnixAbsolute; + convert_params_2.binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, bin.shdrs); + scratch_end(scratch); + } break; + } + convert_params_2.exe_name = exe_name; + convert_params_2.exe_data = exe_data; + convert_params_2.subset_flags = subset_flags; + convert_params_2.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic")); + } + ProfScope("convert [2]") dwarf_bake_params_2 = d2r2_convert(arena, &convert_params_2); } //- rjf: PDB inputs => PDB -> RDI conversion @@ -1277,7 +1403,7 @@ rb_thread_entry_point(void *p) PE_BinInfo pe = {0}; ELF_Bin elf = {0}; COFF_FileHeaderInfo coff_obj = {0}; - DW_Input dw = {0}; + DW_Raw dw = {0}; U64 eh_frame_hdr_vaddr = 0; U64 eh_frame_vaddr = 0; String8 eh_frame_hdr = {0}; diff --git a/src/radbin/radbin_main.c b/src/radbin/radbin_main.c index b87e6502..7d6db3f5 100644 --- a/src/radbin/radbin_main.c +++ b/src/radbin/radbin_main.c @@ -37,6 +37,7 @@ #include "rdi_from_elf/rdi_from_elf.h" #include "rdi_from_pdb/rdi_from_pdb.h" #include "rdi_from_dwarf/rdi_from_dwarf.h" +#include "rdi_from_dwarf/rdi_from_dwarf_2.h" #include "radbin/radbin.h" //- rjf: [c] @@ -66,6 +67,7 @@ #include "rdi_from_elf/rdi_from_elf.c" #include "rdi_from_pdb/rdi_from_pdb.c" #include "rdi_from_dwarf/rdi_from_dwarf.c" +#include "rdi_from_dwarf/rdi_from_dwarf_2.c" #include "radbin/radbin.c" //////////////////////////////// diff --git a/src/rdi/rdi.mdesk b/src/rdi/rdi.mdesk index b98f8e6c..6b16333b 100644 --- a/src/rdi/rdi.mdesk +++ b/src/rdi/rdi.mdesk @@ -309,6 +309,7 @@ RDI_ArchTable: { {NULL 0 0} {X64 1 8} + {X86 2 4} } @table(name value) diff --git a/src/rdi_from_dwarf/rdi_from_dwarf.c b/src/rdi_from_dwarf/rdi_from_dwarf.c index 5433129e..3592a309 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf.c +++ b/src/rdi_from_dwarf/rdi_from_dwarf.c @@ -717,7 +717,7 @@ d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecod internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, - DW_Input *input, + DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, @@ -1312,7 +1312,7 @@ d2r_bytecode_from_expression(Arena *arena, } internal RDIM_Location -d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr) +d2r_transpile_expression(Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr) { RDIM_Location loc = {0}; if (expr.size) { @@ -1325,7 +1325,7 @@ d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arc } internal RDIM_Location -d2r_location_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind) +d2r_location_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind) { String8 expr = dw_exprloc_from_tag_attrib_kind(input, cu, tag, kind); RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr); @@ -1336,7 +1336,7 @@ internal RDIM_LocationCaseList d2r_locset_from_attrib(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, - DW_Input *input, + DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, @@ -1383,7 +1383,7 @@ internal RDIM_LocationCaseList d2r_var_locset_from_tag(Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, - DW_Input *input, + DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, @@ -1450,7 +1450,7 @@ d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off) } internal RDIM_Type * -d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) +d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) { RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void]; @@ -1559,7 +1559,7 @@ d2r_is_type_tag_converted(DW_TagNode *tag_node) } internal RDIM_Type * -d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind) +d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind) { RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void]; @@ -1604,7 +1604,7 @@ d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *inpu internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, - DW_Input *input, + DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, @@ -2088,7 +2088,7 @@ d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, R internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, - DW_Input *input, + DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, DW_TagNode *root) @@ -2205,7 +2205,7 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D } internal RDIM_Type ** -d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out) +d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out) { Temp scratch = scratch_begin(&arena, 1); @@ -2238,7 +2238,7 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input } internal Rng1U64List -d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag) +d2r_range_list_from_tag(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag) { // collect non-contiguous range Rng1U64List raw_ranges = dw_rnglist_from_tag_attrib_kind(arena, input, cu, tag, DW_AttribKind_Ranges); @@ -2296,7 +2296,7 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, - DW_Input *input, + DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, U64 image_base, @@ -2620,7 +2620,7 @@ d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, void *b)) } internal D2R_CompUnitContribMap -d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) +d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Raw *input, U64 image_base) { Temp scratch = scratch_begin(&arena, 1); Temp temp = temp_begin(arena); @@ -2726,7 +2726,7 @@ d2r_convert(Arena *arena, D2R_ConvertParams *params) Arch arch = Arch_Null; U64 image_base = 0; - DW_Input input = {0}; + DW_Raw input = {0}; PathStyle path_style = PathStyle_Null; switch (params->exe_kind) { diff --git a/src/rdi_from_dwarf/rdi_from_dwarf.h b/src/rdi_from_dwarf/rdi_from_dwarf.h index 20941dee..c2569b14 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf.h +++ b/src/rdi_from_dwarf/rdi_from_dwarf.h @@ -207,11 +207,11 @@ internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack * //////////////////////////////// //~ Expression Conversion -internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out); -internal RDIM_Location d2r_transpile_expression (Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr); -internal RDIM_Location d2r_location_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); -internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); -internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag); +internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out); +internal RDIM_Location d2r_transpile_expression (Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr); +internal RDIM_Location d2r_location_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); +internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); +internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag); //////////////////////////////// //~ Type Table @@ -219,7 +219,7 @@ internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_S internal RDIM_Type * d2r_create_type (Arena *arena, D2R_TypeTable *type_table); internal RDIM_Type * d2r_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off); internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off); -internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); +internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); //////////////////////////////// //~ Tag Iterator @@ -235,8 +235,8 @@ internal DW_Tag d2r_tag_iterator_parent_tag (D2R_TagIterator *ite internal void d2r_flag_converted_tag(DW_TagNode *tag_node); internal B8 d2r_is_tag_converted (DW_TagNode *tag_node); -internal RDIM_Type * d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind); -internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_TagNode *root); +internal RDIM_Type * d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind); +internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_TagNode *root); //////////////////////////////// //~ UDT Conversion @@ -244,15 +244,15 @@ internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, internal B8 d2r_is_udt_tag_converted (DW_TagNode *tag_node); internal void d2r_flag_converted_udt_tag(DW_TagNode *tag_node); internal void d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, RDIM_UDT *udt); -internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, DW_TagNode *root); +internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, DW_TagNode *root); //////////////////////////////// //~ Symbol Conversion internal RDIM_Scope * d2r_push_scope (Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D2R_TagFrame *tag_stack, Rng1U64List ranges); -internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out); -internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag); -internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 image_base, Arch arch, DW_TagNode *root, RDIM_Unit *unit_rdi); +internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out); +internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag); +internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, U64 image_base, Arch arch, DW_TagNode *root, RDIM_Unit *unit_rdi); //////////////////////////////// //~ Line Table Conversion @@ -263,7 +263,7 @@ internal void d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, v //////////////////////////////// //~ Contrib Map -internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base); +internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Raw *input, U64 image_base); internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off); //////////////////////////////// diff --git a/src/rdi_from_dwarf/rdi_from_dwarf_2.c b/src/rdi_from_dwarf/rdi_from_dwarf_2.c index 17939b5a..4bc80fe0 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf_2.c +++ b/src/rdi_from_dwarf/rdi_from_dwarf_2.c @@ -299,9 +299,19 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params) lane_sync(); //////////////////////////// - //- rjf: parse each unit's line table + //- rjf: parse each unit's line table header // + DW2_LineTableHeader *unit_line_table_headers = 0; + U64 *unit_line_table_header_sizes = 0; + ProfScope("parse each unit's line table header") { + if(lane_idx() == 0) + { + unit_line_table_headers = push_array(scratch.arena, DW2_LineTableHeader, unit_count); + unit_line_table_header_sizes = push_array(scratch.arena, U64, unit_count); + } + lane_sync_u64(&unit_line_table_headers, 0); + lane_sync_u64(&unit_line_table_header_sizes, 0); U64 unit_take_idx = 0; U64 *unit_take_idx_ptr = &unit_take_idx; lane_sync_u64(&unit_take_idx_ptr, 0); @@ -316,13 +326,173 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params) DW2_Tag *unit_root_tag = &unit_root_tags[unit_idx]; DW2_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList); U64 line_info_off = stmt_list->val.u128.u64[0]; - DW2_LineTableHeader line_table_header = {0}; String8 line_info_data = raw->sec[DW_Section_Line].data; - dw2_read_line_table_header(scratch.arena, ctx, line_info_data, line_info_off, &line_table_header); + unit_line_table_header_sizes[unit_idx] = dw2_read_line_table_header(scratch.arena, ctx, line_info_data, line_info_off, &unit_line_table_headers[unit_idx]); } } lane_sync(); + //////////////////////////// + //- rjf: deduplicate all source files + // + typedef struct UnitSrcFileMap UnitSrcFileMap; + struct UnitSrcFileMap + { + RDIM_SrcFile **v; + }; + RDIM_SrcFileChunkList *all_src_files = 0; + UnitSrcFileMap *unit_src_file_maps = 0; + ProfScope("deduplicate all source files") if(lane_idx() == 0) + { + Temp scratch2 = scratch_begin(&scratch.arena, 1); + + //- rjf: count all files in all units + U64 total_file_count = 0; + for EachIndex(unit_idx, unit_count) + { + total_file_count += unit_line_table_headers[unit_idx].files.count; + } + + //- rjf: set up path -> src file map + typedef struct SrcFileNode SrcFileNode; + struct SrcFileNode + { + SrcFileNode *next; + String8 full_path; + RDIM_SrcFile *src_file; + }; + all_src_files = push_array(scratch.arena, RDIM_SrcFileChunkList, 1); + U64 slots_count = 1 + (total_file_count * 3) / 4; + SrcFileNode **slots = push_array(scratch2.arena, SrcFileNode *, slots_count); + + //- rjf: set up unit -> src file maps + unit_src_file_maps = push_array(scratch.arena, UnitSrcFileMap, unit_count); + for EachIndex(unit_idx, unit_count) + { + unit_src_file_maps[unit_idx].v = push_array(scratch.arena, RDIM_SrcFile *, unit_line_table_headers[unit_idx].files.count); + } + + //- rjf: build path -> src file map + for EachIndex(unit_idx, unit_count) + { + DW2_LineTableHeader *hdr = &unit_line_table_headers[unit_idx]; + for EachIndex(file_idx, hdr->files.count) + { + DW2_LineTableFile *f = &hdr->files.v[file_idx]; + DW2_LineTableFile *dir = &hdr->dirs.v[f->dir_idx]; + String8 full_file_path = str8f(scratch2.arena, "%S/%S", dir->file_name, f->file_name); + U64 hash = u64_hash_from_str8(full_file_path); + U64 slot_idx = hash%slots_count; + SrcFileNode *node = 0; + for(SrcFileNode *n = slots[slot_idx]; n != 0; n = n->next) + { + if(str8_match(n->full_path, full_file_path, 0)) + { + node = n; + break; + } + } + if(!node) + { + node = push_array(scratch2.arena, SrcFileNode, 1); + node->full_path = full_file_path; + node->src_file = rdim_src_file_chunk_list_push(arena, all_src_files, slots_count); + node->src_file->path = str8_copy(arena, full_file_path); + if(f->flags & DW2_LineTableFileFlag_HasMD5) + { + node->src_file->checksum_kind = RDI_ChecksumKind_MD5; + node->src_file->checksum = str8_copy(arena, str8_struct(&f->md5)); + } + else if(f->flags & DW2_LineTableFileFlag_HasModifyTime) + { + node->src_file->checksum_kind = RDI_ChecksumKind_Timestamp; + node->src_file->checksum = str8_copy(arena, str8_struct(&f->modify_time)); + } + } + unit_src_file_maps[unit_idx].v[file_idx] = node->src_file; + } + } + scratch_end(scratch2); + } + lane_sync_u64(&all_src_files, 0); + + //////////////////////////// + //- rjf: parse each unit's line info; produce line tables + // + RDIM_LineTableChunkList *all_line_tables = 0; + RDIM_LineTable **unit_line_tables = 0; + ProfScope("parse each unit's line info; produce line tables") + { + //- rjf: prep all per-unit line tables + if(lane_idx() == 0) + { + all_line_tables = push_array(scratch.arena, RDIM_LineTableChunkList, 1); + unit_line_tables = push_array(scratch.arena, RDIM_LineTable *, unit_count); + for EachIndex(unit_idx, unit_count) + { + unit_line_tables[unit_idx] = rdim_line_table_chunk_list_push(arena, all_line_tables, unit_count); + } + } + lane_sync_u64(&all_line_tables, 0); + lane_sync_u64(&unit_line_tables, 0); + + U64 unit_take_idx = 0; + U64 *unit_take_idx_ptr = &unit_take_idx; + lane_sync_u64(&unit_take_idx_ptr, 0); + for(;;) + { + //- rjf: take unit + U64 unit_idx = ins_atomic_u64_inc_eval(unit_take_idx_ptr) - 1; + if(unit_idx >= unit_count) + { + break; + } + + //- rjf: unpack unit info + DW2_LineTableHeader *line_table_header = &unit_line_table_headers[unit_idx]; + RDIM_LineTable *dst_line_table = unit_line_tables[unit_idx]; + DW2_Tag *unit_root_tag = &unit_root_tags[unit_idx]; + DW2_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList); + U64 line_info_off = stmt_list->val.u128.u64[0]; + String8 all_line_info_data = raw->sec[DW_Section_Line].data; + String8 unit_line_table_data = str8_substr(all_line_info_data, r1u64(line_info_off + unit_line_table_header_sizes[unit_idx], line_info_off + line_table_header->unit_length)); + + //- rjf: set up vm registers + DW2_LineVMRegs vm_regs = {0}; + { + vm_regs.file_index = 1; + vm_regs.line = 1; + vm_regs.is_stmt = line_table_header->default_is_stmt; + } + + //- rjf: run the line opcode program + for(U64 off = 0, next_off = 0; off < unit_line_table_data.size; off = next_off) + { + next_off = unit_line_table_data.size; + + //- rjf: read next opcode + U8 opcode = 0; + str8_deserial_read_struct(unit_line_table_data, off, &opcode); + + //- rjf: apply "special opcodes" (DWARF v5 6.2.5.1) + if(opcode >= line_table_header->opcode_base) + { + U32 adjusted_opcode = (U32)(opcode - line_table_header->opcode_base); + U32 op_advance = adjusted_opcode / line_table_header->line_range; + S64 line_advance = (S64)line_table_header->line_base + (S64)adjusted_opcode%(S64)line_table_header->line_range; + U64 addr_advance = line_table_header->min_inst_length + (vm_regs.vliw_op_index + op_advance) / line_table_header->max_ops_per_inst; + vm_regs.address += addr_advance; + vm_regs.vliw_op_index = (vm_regs.vliw_op_index + op_advance) % line_table_header->max_ops_per_inst; + vm_regs.line += line_advance; + vm_regs.basic_block = 0; + vm_regs.prologue_end = 0; + vm_regs.epilogue_begin = 0; + vm_regs.discriminator = 0; + } + } + } + } + //////////////////////////// //- rjf: fill result // diff --git a/src/rdi_from_dwarf/rdi_from_dwarf_2.h b/src/rdi_from_dwarf/rdi_from_dwarf_2.h index b25d3d57..91253e18 100644 --- a/src/rdi_from_dwarf/rdi_from_dwarf_2.h +++ b/src/rdi_from_dwarf/rdi_from_dwarf_2.h @@ -16,6 +16,7 @@ struct D2R2_ConvertParams U64 base_vaddr; RDIM_BinarySectionList binary_sections; DW_Raw raw; + PathStyle path_style; RDIM_SubsetFlags subset_flags; B32 deterministic; }; diff --git a/src/torture/torture_dwarf.c b/src/torture/torture_dwarf.c index 0cf63150..e9eebf2d 100644 --- a/src/torture/torture_dwarf.c +++ b/src/torture/torture_dwarf.c @@ -103,7 +103,7 @@ dwt_tags_must_match(DW_WriterTag *writer_tag, DW_TagNode *reader_tag) return is_match; } -internal DW_Input +internal DW_Raw dw_input_from_writer(Arena *arena, DW_Writer *writer) { Temp scratch = scratch_begin(&arena, 1); @@ -127,7 +127,7 @@ dw_input_from_writer(Arena *arena, DW_Writer *writer) PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, exe); COFF_SectionHeader *section_table = (COFF_SectionHeader *)(exe.str + pe.section_table_range.min); String8 string_table = str8_substr(exe, pe.string_table_range); - DW_Input input = dw_input_from_coff_section_table(arena, exe, string_table, pe.section_count, section_table); + DW_Raw input = dw_input_from_coff_section_table(arena, exe, string_table, pe.section_count, section_table); obj_release(&obj); scratch_end(scratch); @@ -141,7 +141,7 @@ TEST(dwarf_32bit) dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER")); dw_writer_tag_end(writer); - DW_Input input = dw_input_from_writer(arena, writer); + DW_Raw input = dw_input_from_writer(arena, writer); for EachElement(sec_idx, input.sec) { if (sec_idx == DW_Section_Abbrev) continue; @@ -169,7 +169,7 @@ TEST(dwarf_64bit) dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER")); dw_writer_tag_end(writer); - DW_Input input = dw_input_from_writer(arena, writer); + DW_Raw input = dw_input_from_writer(arena, writer); for EachElement(sec_idx, input.sec) { if (sec_idx == DW_Section_Abbrev) continue; @@ -235,7 +235,7 @@ TEST(dwarf_line_opcodes) dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_set_discriminator(2)); dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_end_sequence()); - DW_Input input = dw_input_from_writer(arena, writer); + DW_Raw input = dw_input_from_writer(arena, writer); Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0); DW_LineVM *line_vm = dw_line_vm_init(&input, &cu); @@ -411,7 +411,7 @@ TEST(dwarf_line_emit) } } - DW_Input input = dw_input_from_writer(arena, writer); + DW_Raw input = dw_input_from_writer(arena, writer); Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0); DW_LineVM *line_vm = dw_line_vm_init(&input, &cu); @@ -621,7 +621,7 @@ TEST(dwarf_writer) dw_writer_tag_end(writer); } - DW_Input input = dw_input_from_writer(arena, writer); + DW_Raw input = dw_input_from_writer(arena, writer); DW_ListUnitInput lu_input = dw_list_unit_input_from_input(arena, &input); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, lu_input, 0, 1); DW_TagTree tag_tree = dw_tag_tree_from_cu(arena, &input, &cu);