WIP DWARF expression eval

- fixup jump offsets after expression is serialized
- use generalized machine ops for register reads
- add option to limit number of executed opcodes
This commit is contained in:
Nikita Smith
2025-12-16 11:12:43 -08:00
parent 44123e9712
commit 2b4e0f8b77
6 changed files with 1338 additions and 1326 deletions
+43 -43
View File
@@ -6,7 +6,7 @@ dw_reg_size_from_code_x64(DW_Reg reg_code)
{ {
switch (reg_code) { switch (reg_code) {
#define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX64_##reg_name_dw: return reg_size; #define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX64_##reg_name_dw: return reg_size;
DW_Regs_X64_XList(X) DW_Regs_X64_XList
#undef X #undef X
} }
return 0; return 0;
@@ -17,7 +17,7 @@ dw_reg_pos_from_code_x64(DW_Reg reg_code)
{ {
switch (reg_code) { switch (reg_code) {
#define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX64_##reg_name_dw: return reg_pos; #define X(reg_name_dw, reg_code_dw, reg_name_rdi, reg_pos, reg_size) case DW_RegX64_##reg_name_dw: return reg_pos;
DW_Regs_X64_XList(X) DW_Regs_X64_XList
#undef X #undef X
} }
return max_U64; return max_U64;
@@ -84,7 +84,7 @@ dw_attrib_class_from_attrib_v2(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_V2_XList(X) DW_AttribKind_ClassFlags_V2_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -95,7 +95,7 @@ dw_attrib_class_from_attrib_v3(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_V3_XList(X) DW_AttribKind_ClassFlags_V3_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -106,7 +106,7 @@ dw_attrib_class_from_attrib_v4(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_V4_XList(X) DW_AttribKind_ClassFlags_V4_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -117,7 +117,7 @@ dw_attrib_class_from_attrib_v5(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_V5_XList(X) DW_AttribKind_ClassFlags_V5_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -128,7 +128,7 @@ dw_attrib_class_from_attrib_gnu(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_GNU_XList(X) DW_AttribKind_ClassFlags_GNU_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -139,7 +139,7 @@ dw_attrib_class_from_attrib_llvm(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_LLVM_XList(X) DW_AttribKind_ClassFlags_LLVM_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -150,7 +150,7 @@ dw_attrib_class_from_attrib_apple(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_APPLE_XList(X) DW_AttribKind_ClassFlags_APPLE_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -161,7 +161,7 @@ dw_attrib_class_from_attrib_mips(DW_AttribKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_C) case DW_AttribKind_##_N: return _C; #define X(_N,_C) case DW_AttribKind_##_N: return _C;
DW_AttribKind_ClassFlags_MIPS_XList(X) DW_AttribKind_ClassFlags_MIPS_XList
#undef X #undef X
} }
return DW_AttribClass_Null; return DW_AttribClass_Null;
@@ -215,28 +215,28 @@ dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k)
#define X(_N,_C) case DW_Form_##_N: return _C; #define X(_N,_C) case DW_Form_##_N: return _C;
switch (k) { switch (k) {
DW_Form_AttribClass_GNU_XList(X) DW_Form_AttribClass_GNU_XList
} }
switch (ver) { switch (ver) {
case DW_Version_5: { case DW_Version_5: {
switch (k) { switch (k) {
DW_Form_AttribClass_V5_XList(X) DW_Form_AttribClass_V5_XList
} }
} break; } break;
case DW_Version_4: { case DW_Version_4: {
switch (k) { switch (k) {
DW_Form_AttribClass_V4_XList(X) DW_Form_AttribClass_V4_XList
} }
} break; } break;
case DW_Version_3: { case DW_Version_3: {
switch (k) { switch (k) {
DW_Form_AttribClass_V2_XList(X) DW_Form_AttribClass_V2_XList
} }
} break; } break;
case DW_Version_2: { case DW_Version_2: {
switch (k) { switch (k) {
DW_Form_AttribClass_V2_XList(X) DW_Form_AttribClass_V2_XList
} }
} break; } break;
case DW_Version_1: { case DW_Version_1: {
@@ -261,7 +261,7 @@ dw_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
} }
return str8_zero(); return str8_zero();
@@ -272,7 +272,7 @@ dw_mach_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
} }
return str8_zero(); return str8_zero();
@@ -283,7 +283,7 @@ dw_dwo_name_string_from_section_kind(DW_SectionKind k)
{ {
switch (k) { switch (k) {
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D); #define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
} }
return str8_zero(); return str8_zero();
@@ -460,7 +460,7 @@ dw_operand_count_from_cfa_opcode(DW_CFA_Opcode opcode)
{ {
switch (opcode) { switch (opcode) {
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return ArrayCount(t)-1; } #define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return ArrayCount(t)-1; }
DW_CFA_Kind_XList(X) DW_CFA_Kind_XList
#undef X #undef X
default: { NotImplemented; } break; default: { NotImplemented; } break;
} }
@@ -513,7 +513,7 @@ dw_operand_types_from_cfa_op(DW_CFA_Opcode opcode)
{ {
switch (opcode) { switch (opcode) {
#define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return &t[0] + 1; } #define X(_N, _ID, ...) case _ID: { local_persist DW_CFA_OperandType t[] = { DW_CFA_OperandType_Null, __VA_ARGS__ }; return &t[0] + 1; }
DW_CFA_Kind_XList(X) DW_CFA_Kind_XList
#undef X #undef X
default: { NotImplemented; } break; default: { NotImplemented; } break;
} }
@@ -581,9 +581,9 @@ dw_string_from_tag_kind(Arena *arena, DW_TagKind kind)
switch (kind) { switch (kind) {
case DW_TagKind_Null: return str8_lit("Null"); case DW_TagKind_Null: return str8_lit("Null");
#define X(_N,_ID) case DW_TagKind_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_TagKind_##_N: return str8_lit(Stringify(_N));
DW_TagKind_V3_XList(X) DW_TagKind_V3_XList
DW_TagKind_V5_XList(X) DW_TagKind_V5_XList
DW_TagKind_GNU_XList(X) DW_TagKind_GNU_XList
#undef X #undef X
} }
return push_str8f(arena, "%llx", kind); return push_str8f(arena, "%llx", kind);
@@ -611,10 +611,10 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
{ {
default:{}break; default:{}break;
case DW_Ext_Null: break; case DW_Ext_Null: break;
case DW_Ext_GNU: switch (kind) { DW_AttribKind_GNU_XList(X) } break; case DW_Ext_GNU: switch (kind) { DW_AttribKind_GNU_XList } break;
case DW_Ext_LLVM: switch (kind) { DW_AttribKind_LLVM_XList(X) } break; case DW_Ext_LLVM: switch (kind) { DW_AttribKind_LLVM_XList } break;
case DW_Ext_APPLE: switch (kind) { DW_AttribKind_APPLE_XList(X) } break; case DW_Ext_APPLE: switch (kind) { DW_AttribKind_APPLE_XList } break;
case DW_Ext_MIPS: switch (kind) { DW_AttribKind_MIPS_XList(X) } break; case DW_Ext_MIPS: switch (kind) { DW_AttribKind_MIPS_XList } break;
} }
} }
} }
@@ -627,10 +627,10 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
DW_Version version = retry ? DW_Version_5 : ver; DW_Version version = retry ? DW_Version_5 : ver;
switch(version) switch(version)
{ {
case DW_Version_5: { switch(kind) { DW_AttribKind_V5_XList(X) } } // fall-through case DW_Version_5: { switch(kind) { DW_AttribKind_V5_XList } } // fall-through
case DW_Version_4: { switch(kind) { DW_AttribKind_V4_XList(X) } } // fall-through case DW_Version_4: { switch(kind) { DW_AttribKind_V4_XList } } // fall-through
case DW_Version_3: { switch(kind) { DW_AttribKind_V3_XList(X) } } // fall-through case DW_Version_3: { switch(kind) { DW_AttribKind_V3_XList } } // fall-through
case DW_Version_2: { switch(kind) { DW_AttribKind_V2_XList(X) } } // fall-through case DW_Version_2: { switch(kind) { DW_AttribKind_V2_XList } } // fall-through
case DW_Version_1: {}break; case DW_Version_1: {}break;
case DW_Version_Null:{}break; case DW_Version_Null:{}break;
default:{}break; default:{}break;
@@ -655,18 +655,18 @@ dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind)
switch (ver) { switch (ver) {
case DW_Version_5: { case DW_Version_5: {
switch (kind) { switch (kind) {
DW_Form_V5_XList(X) DW_Form_V5_XList
} }
} // fall-through } // fall-through
case DW_Version_4: { case DW_Version_4: {
switch (kind) { switch (kind) {
DW_Form_V4_XList(X) DW_Form_V4_XList
} }
} // fall-through } // fall-through
case DW_Version_3: case DW_Version_3:
case DW_Version_2: { case DW_Version_2: {
switch (kind) { switch (kind) {
DW_Form_V2_XList(X) DW_Form_V2_XList
} }
} // fall-through } // fall-through
case DW_Version_Null: break; case DW_Version_Null: break;
@@ -681,7 +681,7 @@ dw_string_from_language(Arena *arena, DW_Language kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N));
DW_Language_XList(X) DW_Language_XList
#undef X #undef X
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
@@ -692,7 +692,7 @@ dw_string_from_inl(Arena *arena, DW_InlKind kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case _ID: return str8_lit(Stringify(_N)); #define X(_N,_ID) case _ID: return str8_lit(Stringify(_N));
DW_Inl_XList(X) DW_Inl_XList
#undef X #undef X
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
@@ -703,7 +703,7 @@ dw_string_from_access_kind(Arena *arena, DW_AccessKind kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case _ID: return str8_lit(Stringify(_N)); #define X(_N,_ID) case _ID: return str8_lit(Stringify(_N));
DW_AccessKind_XList(X) DW_AccessKind_XList
#undef X #undef X
} }
return push_str8f(arena, "%llx", kind); return push_str8f(arena, "%llx", kind);
@@ -714,7 +714,7 @@ dw_string_from_calling_convetion(Arena *arena, DW_CallingConventionKind kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case _ID: return str8_lit(Stringify(_N)); #define X(_N,_ID) case _ID: return str8_lit(Stringify(_N));
DW_CallingConventionKind_XList(X) DW_CallingConventionKind_XList
#undef X #undef X
} }
return push_str8f(arena, "%llx", kind); return push_str8f(arena, "%llx", kind);
@@ -725,7 +725,7 @@ dw_string_from_attrib_type_encoding(Arena *arena, DW_ATE kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case _ID: return str8_lit(Stringify(_N)); #define X(_N,_ID) case _ID: return str8_lit(Stringify(_N));
DW_ATE_XList(X) DW_ATE_XList
#undef X #undef X
} }
return push_str8f(arena, "%llx", kind); return push_str8f(arena, "%llx", kind);
@@ -736,7 +736,7 @@ dw_string_from_std_opcode(Arena *arena, DW_StdOpcode kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N));
DW_StdOpcode_XList(X) DW_StdOpcode_XList
#undef X #undef X
} }
return push_str8f(arena, "%x", kind); return push_str8f(arena, "%x", kind);
@@ -747,7 +747,7 @@ dw_string_from_ext_opcode(Arena *arena, DW_ExtOpcode kind)
{ {
switch (kind) { switch (kind) {
#define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N)); #define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N));
DW_ExtOpcode_XList(X) DW_ExtOpcode_XList
#undef X #undef X
default: InvalidPath; break; default: InvalidPath; break;
} }
@@ -784,7 +784,7 @@ dw_string_from_register(Arena *arena, Arch arch, U64 reg_id)
case Arch_x64: { case Arch_x64: {
switch (reg_id) { switch (reg_id) {
#define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break; #define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break;
DW_Regs_X64_XList(X) DW_Regs_X64_XList
#undef X #undef X
} }
} break; } break;
@@ -804,7 +804,7 @@ dw_string_from_cfa_opcode(DW_CFA_Opcode opcode)
{ {
switch (opcode) { switch (opcode) {
#define X(_NAME, _ID, ...) case _ID: return str8_lit(Stringify(_NAME)); #define X(_NAME, _ID, ...) case _ID: return str8_lit(Stringify(_NAME));
DW_CFA_Kind_XList(X) DW_CFA_Kind_XList
#undef X #undef X
default: InvalidPath; break; default: InvalidPath; break;
} }
+84 -107
View File
@@ -39,7 +39,7 @@ typedef enum DW_Format
#define DW_SentinelFromSize(address_size) ((address_size) == 4 ? max_U32 : (address_size) == 8 ? max_U64 : 0) #define DW_SentinelFromSize(address_size) ((address_size) == 4 ? max_U32 : (address_size) == 8 ? max_U64 : 0)
#define DW_SectionKind_XList(X )\ #define DW_SectionKind_XList \
X(Null, "", "", "" ) \ X(Null, "", "", "" ) \
X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" ) \ X(Abbrev, ".debug_abbrev", "__debug_abbrev", ".debug_abbrev.dwo" ) \
X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" ) \ X(ARanges, ".debug_aranges", "__debug_aranges", ".debug_aranges.dwo" ) \
@@ -63,12 +63,12 @@ typedef U64 DW_SectionKind;
typedef enum DW_SectionKindEnum typedef enum DW_SectionKindEnum
{ {
#define X(_N,...) DW_Section_##_N, #define X(_N,...) DW_Section_##_N,
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
DW_Section_Count DW_Section_Count
} DW_SectionKindEnum; } DW_SectionKindEnum;
#define DW_Language_XList(X) \ #define DW_Language_XList \
X(Null, 0x00) \ X(Null, 0x00) \
X(C89, 0x01) \ X(C89, 0x01) \
X(C, 0x02) \ X(C, 0x02) \
@@ -116,13 +116,13 @@ typedef U32 DW_Language;
typedef enum DW_LanguageEnum typedef enum DW_LanguageEnum
{ {
#define X(_N, _ID) DW_Language_##_N = _ID, #define X(_N, _ID) DW_Language_##_N = _ID,
DW_Language_XList(X) DW_Language_XList
#undef X #undef X
DW_Language_UserLo = 0x8000, DW_Language_UserLo = 0x8000,
DW_Language_UserHi = 0xffff, DW_Language_UserHi = 0xffff,
} DW_LanguageEnum; } DW_LanguageEnum;
#define DW_Inl_XList(X) \ #define DW_Inl_XList \
X(NotInlined, 0) \ X(NotInlined, 0) \
X(Inlined, 1) \ X(Inlined, 1) \
X(DeclaredNotInlined, 2) \ X(DeclaredNotInlined, 2) \
@@ -132,11 +132,11 @@ typedef U32 DW_InlKind;
typedef enum DW_InlKindEnum typedef enum DW_InlKindEnum
{ {
#define X(_N,_ID) DW_Inl_##_N = _ID, #define X(_N,_ID) DW_Inl_##_N = _ID,
DW_Inl_XList(X) DW_Inl_XList
#undef X #undef X
} DW_InlKindEnum; } DW_InlKindEnum;
#define DW_StdOpcode_XList(X) \ #define DW_StdOpcode_XList \
X(ExtendedOpcode, 0x00) \ X(ExtendedOpcode, 0x00) \
X(Copy, 0x01) \ X(Copy, 0x01) \
X(AdvancePc, 0x02) \ X(AdvancePc, 0x02) \
@@ -154,11 +154,11 @@ X(SetIsa, 0x0C) \
typedef enum DW_StdOpcode typedef enum DW_StdOpcode
{ {
#define X(_N,_ID) DW_StdOpcode_##_N = _ID, #define X(_N,_ID) DW_StdOpcode_##_N = _ID,
DW_StdOpcode_XList(X) DW_StdOpcode_XList
#undef X #undef X
} DW_StdOpcode; } DW_StdOpcode;
#define DW_ExtOpcode_XList(X) \ #define DW_ExtOpcode_XList \
X(Undefined, 0x00) \ X(Undefined, 0x00) \
X(EndSequence, 0x01) \ X(EndSequence, 0x01) \
X(SetAddress, 0x02) \ X(SetAddress, 0x02) \
@@ -170,11 +170,11 @@ X(UserHi, 0xff)
typedef enum DW_ExtOpcode typedef enum DW_ExtOpcode
{ {
#define X(_N,_ID) DW_ExtOpcode_##_N = _ID, #define X(_N,_ID) DW_ExtOpcode_##_N = _ID,
DW_ExtOpcode_XList(X) DW_ExtOpcode_XList
#undef X #undef X
} DW_ExtOpcode; } DW_ExtOpcode;
#define DW_IDCaseKind_XList(X) \ #define DW_IDCaseKind_XList \
X(CaseSensitive, 0x00) \ X(CaseSensitive, 0x00) \
X(UpCase, 0x01) \ X(UpCase, 0x01) \
X(DownCase, 0x02) \ X(DownCase, 0x02) \
@@ -184,11 +184,11 @@ typedef U64 DW_IDCaseKind;
typedef enum DW_IDCaseKindEnum typedef enum DW_IDCaseKindEnum
{ {
#define X(_N,_ID) DW_IDCase_##_N = _ID, #define X(_N,_ID) DW_IDCase_##_N = _ID,
DW_IDCaseKind_XList(X) DW_IDCaseKind_XList
#undef X #undef X
} DW_IDCaseKindEnum; } DW_IDCaseKindEnum;
#define DW_TagKind_V3_XList(X) \ #define DW_TagKind_V3_XList \
X(ArrayType, 0x01) \ X(ArrayType, 0x01) \
X(ClassType, 0x02) \ X(ClassType, 0x02) \
X(EntryPoint, 0x03) \ X(EntryPoint, 0x03) \
@@ -247,7 +247,7 @@ X(ImportedUnit, 0x3d) \
X(Condition, 0x3f) \ X(Condition, 0x3f) \
X(SharedType, 0x40) X(SharedType, 0x40)
#define DW_TagKind_V5_XList(X) \ #define DW_TagKind_V5_XList \
X(TypeUnit, 0x41) \ X(TypeUnit, 0x41) \
X(RValueReferenceType, 0x42) \ X(RValueReferenceType, 0x42) \
X(TemplateAlias, 0x43) \ X(TemplateAlias, 0x43) \
@@ -260,7 +260,7 @@ X(CallSiteParameter, 0x49) \
X(SkeletonUnit, 0x4A) \ X(SkeletonUnit, 0x4A) \
X(ImmutableType, 0x4B) X(ImmutableType, 0x4B)
#define DW_TagKind_GNU_XList(X) \ #define DW_TagKind_GNU_XList \
X(GNU_CallSite, 0x4109) \ X(GNU_CallSite, 0x4109) \
X(GNU_CallSiteParameter, 0x410a) X(GNU_CallSiteParameter, 0x410a)
@@ -269,9 +269,9 @@ typedef enum DW_TagKindEnum
{ {
DW_TagKind_Null, DW_TagKind_Null,
#define X(_N,_ID) DW_TagKind_##_N = _ID, #define X(_N,_ID) DW_TagKind_##_N = _ID,
DW_TagKind_V3_XList(X) DW_TagKind_V3_XList
DW_TagKind_V5_XList(X) DW_TagKind_V5_XList
DW_TagKind_GNU_XList(X) DW_TagKind_GNU_XList
#undef X #undef X
DW_TagKind_UserLo = 0x4080, DW_TagKind_UserLo = 0x4080,
DW_TagKind_UserHi = 0xffff DW_TagKind_UserHi = 0xffff
@@ -279,7 +279,7 @@ typedef enum DW_TagKindEnum
//- Attrib Class Encodings //- Attrib Class Encodings
#define DW_AttribClass_V3_XList(X) \ #define DW_AttribClass_V3_XList \
X(Null, 0) \ X(Null, 0) \
X(Undefined, 1) \ X(Undefined, 1) \
X(Address, 2) \ X(Address, 2) \
@@ -294,11 +294,11 @@ X(RngListPtr, 10) \
X(Reference, 11) \ X(Reference, 11) \
X(String, 12) X(String, 12)
#define DW_AttribClass_V4_XList(X) \ #define DW_AttribClass_V4_XList \
X(LocList, 13) \ X(LocList, 13) \
X(RngList, 14) X(RngList, 14)
#define DW_AttribClass_V5_XList(X) \ #define DW_AttribClass_V5_XList \
X(StrOffsetsPtr, 15) \ X(StrOffsetsPtr, 15) \
X(AddrPtr, 16) X(AddrPtr, 16)
@@ -306,15 +306,16 @@ typedef U32 DW_AttribClass;
typedef enum DW_AttribClassEnum typedef enum DW_AttribClassEnum
{ {
#define X(_N,_ID) DW_AttribClass_##_N = (1 << _ID), #define X(_N,_ID) DW_AttribClass_##_N = (1 << _ID),
DW_AttribClass_V3_XList(X) DW_AttribClass_V3_XList
DW_AttribClass_V4_XList(X) DW_AttribClass_V4_XList
DW_AttribClass_V5_XList(X) DW_AttribClass_V5_XList
#undef X #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; } DW_AttribClassEnum;
//- Form Encodings //- Form Encodings
#define DW_Form_V2_XList(X) \ #define DW_Form_V2_XList \
X(Addr, 0x1) \ X(Addr, 0x1) \
X(Block2, 0x3) \ X(Block2, 0x3) \
X(Block4, 0x4) \ X(Block4, 0x4) \
@@ -337,7 +338,7 @@ X(Ref8, 0x14) \
X(RefUData, 0x15) \ X(RefUData, 0x15) \
X(Indirect, 0x16) X(Indirect, 0x16)
#define DW_Form_AttribClass_V2_XList(X) \ #define DW_Form_AttribClass_V2_XList \
X(Addr, DW_AttribClass_Address) \ X(Addr, DW_AttribClass_Address) \
X(Block2, DW_AttribClass_Block) \ X(Block2, DW_AttribClass_Block) \
X(Block4, DW_AttribClass_Block) \ X(Block4, DW_AttribClass_Block) \
@@ -360,13 +361,13 @@ X(Ref8, DW_AttribClass_Reference) \
X(RefUData, DW_AttribClass_Reference) \ X(RefUData, DW_AttribClass_Reference) \
X(Indirect, DW_AttribClass_Null) X(Indirect, DW_AttribClass_Null)
#define DW_Form_V4_XList(X) \ #define DW_Form_V4_XList \
X(SecOffset, 0x17) \ X(SecOffset, 0x17) \
X(ExprLoc, 0x18) \ X(ExprLoc, 0x18) \
X(FlagPresent, 0x19) \ X(FlagPresent, 0x19) \
X(RefSig8, 0x20) X(RefSig8, 0x20)
#define DW_Form_AttribClass_V4_XList(X) \ #define DW_Form_AttribClass_V4_XList \
X(Addr, DW_AttribClass_Address) \ X(Addr, DW_AttribClass_Address) \
X(Block2, DW_AttribClass_Block) \ X(Block2, DW_AttribClass_Block) \
X(Block4, DW_AttribClass_Block) \ X(Block4, DW_AttribClass_Block) \
@@ -393,7 +394,7 @@ X(ExprLoc, DW_AttribClass_ExprLoc) \
X(FlagPresent, DW_AttribClass_Flag) \ X(FlagPresent, DW_AttribClass_Flag) \
X(RefSig8, DW_AttribClass_Reference) X(RefSig8, DW_AttribClass_Reference)
#define DW_Form_V5_XList(X) \ #define DW_Form_V5_XList \
X(Strx, 0x1a) \ X(Strx, 0x1a) \
X(Addrx, 0x1b) \ X(Addrx, 0x1b) \
X(RefSup4, 0x1c) \ X(RefSup4, 0x1c) \
@@ -413,7 +414,7 @@ X(Addrx2, 0x2a) \
X(Addrx3, 0x2b) \ X(Addrx3, 0x2b) \
X(Addrx4, 0x2c) X(Addrx4, 0x2c)
#define DW_Form_AttribClass_V5_XList(X) \ #define DW_Form_AttribClass_V5_XList \
X(Addr, DW_AttribClass_Address) \ X(Addr, DW_AttribClass_Address) \
X(Block2, DW_AttribClass_Block) \ X(Block2, DW_AttribClass_Block) \
X(Block4, DW_AttribClass_Block) \ X(Block4, DW_AttribClass_Block) \
@@ -435,14 +436,7 @@ X(Ref4, DW_AttribClass_Reference) \
X(Ref8, DW_AttribClass_Reference) \ X(Ref8, DW_AttribClass_Reference) \
X(RefUData, DW_AttribClass_Reference) \ X(RefUData, DW_AttribClass_Reference) \
X(Indirect, DW_AttribClass_Null) \ X(Indirect, DW_AttribClass_Null) \
X(SecOffset, DW_AttribClass_AddrPtr| \ X(SecOffset, DW_AttribClass_AllPtrs) \
DW_AttribClass_LinePtr| \
DW_AttribClass_LocList| \
DW_AttribClass_LocListPtr| \
DW_AttribClass_MacPtr| \
DW_AttribClass_RngList| \
DW_AttribClass_RngListPtr| \
DW_AttribClass_StrOffsetsPtr) \
X(ExprLoc, DW_AttribClass_ExprLoc) \ X(ExprLoc, DW_AttribClass_ExprLoc) \
X(FlagPresent, DW_AttribClass_Flag) \ X(FlagPresent, DW_AttribClass_Flag) \
X(RefSig8, DW_AttribClass_Reference) \ X(RefSig8, DW_AttribClass_Reference) \
@@ -465,13 +459,13 @@ X(Addrx2, DW_AttribClass_Address) \
X(Addrx3, DW_AttribClass_Address) \ X(Addrx3, DW_AttribClass_Address) \
X(Addrx4, DW_AttribClass_Address) X(Addrx4, DW_AttribClass_Address)
#define DW_Form_GNU_XList(X) \ #define DW_Form_GNU_XList \
X(GNU_AddrIndex, 0x1f01) \ X(GNU_AddrIndex, 0x1f01) \
X(GNU_StrIndex, 0x1f02) \ X(GNU_StrIndex, 0x1f02) \
X(GNU_RefAlt, 0x1f20) \ X(GNU_RefAlt, 0x1f20) \
X(GNU_StrpAlt, 0x1f21) X(GNU_StrpAlt, 0x1f21)
#define DW_Form_AttribClass_GNU_XList(X) \ #define DW_Form_AttribClass_GNU_XList \
X(GNU_AddrIndex, DW_AttribClass_Undefined) \ X(GNU_AddrIndex, DW_AttribClass_Undefined) \
X(GNU_StrIndex, DW_AttribClass_Undefined) \ X(GNU_StrIndex, DW_AttribClass_Undefined) \
X(GNU_RefAlt, DW_AttribClass_Undefined) \ X(GNU_RefAlt, DW_AttribClass_Undefined) \
@@ -482,16 +476,16 @@ typedef enum DW_FormEnum
{ {
DW_Form_Null, DW_Form_Null,
#define X(_N, _ID) DW_Form_##_N = _ID, #define X(_N, _ID) DW_Form_##_N = _ID,
DW_Form_V2_XList(X) DW_Form_V2_XList
DW_Form_V4_XList(X) DW_Form_V4_XList
DW_Form_V5_XList(X) DW_Form_V5_XList
DW_Form_GNU_XList(X) DW_Form_GNU_XList
#undef X #undef X
} DW_FormEnum; } DW_FormEnum;
//- Attributes DWARF2 //- Attributes DWARF2
#define DW_AttribKind_V2_XList(X) \ #define DW_AttribKind_V2_XList \
X(Sibling, 0x1) \ X(Sibling, 0x1) \
X(Location, 0x2) \ X(Location, 0x2) \
X(Name, 0x3) \ X(Name, 0x3) \
@@ -552,7 +546,7 @@ X(VariableParameter, 0x4b) \
X(Virtuality, 0x4c) \ X(Virtuality, 0x4c) \
X(VTableElemLocation, 0x4d) X(VTableElemLocation, 0x4d)
#define DW_AttribKind_ClassFlags_V2_XList(X) \ #define DW_AttribKind_ClassFlags_V2_XList \
X(Sibling, DW_AttribClass_Reference) \ X(Sibling, DW_AttribClass_Reference) \
X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \
X(Name, DW_AttribClass_String) \ X(Name, DW_AttribClass_String) \
@@ -615,7 +609,7 @@ X(VTableElemLocation, DW_AttribClass_Block|DW_AttribClass_Reference)
//- Attributes DWARF3 //- Attributes DWARF3
#define DW_AttribKind_V3_XList(X) \ #define DW_AttribKind_V3_XList \
X(Allocated, 0x4e) \ X(Allocated, 0x4e) \
X(Associated, 0x4f) \ X(Associated, 0x4f) \
X(DataLocation, 0x50) \ X(DataLocation, 0x50) \
@@ -644,7 +638,7 @@ X(Elemental, 0x66) \
X(Pure, 0x67) \ X(Pure, 0x67) \
X(Recursive, 0x68) X(Recursive, 0x68)
#define DW_AttribKind_ClassFlags_V3_XList(X) \ #define DW_AttribKind_ClassFlags_V3_XList \
X(Sibling, DW_AttribClass_Reference) \ X(Sibling, DW_AttribClass_Reference) \
X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \ X(Location, DW_AttribClass_Block|DW_AttribClass_LocListPtr) \
X(Name, DW_AttribClass_String) \ X(Name, DW_AttribClass_String) \
@@ -734,7 +728,7 @@ X(Recursive, DW_AttribClass_Flag)
//- Attributes DWARF4 //- Attributes DWARF4
#define DW_AttribKind_V4_XList(X) \ #define DW_AttribKind_V4_XList \
X(Signature, 0x69) \ X(Signature, 0x69) \
X(MainSubProgram, 0x6a) \ X(MainSubProgram, 0x6a) \
X(DataBitOffset, 0x6b) \ X(DataBitOffset, 0x6b) \
@@ -742,7 +736,7 @@ X(ConstExpr, 0x6c) \
X(EnumClass, 0x6d) \ X(EnumClass, 0x6d) \
X(LinkageName, 0x6e) X(LinkageName, 0x6e)
#define DW_AttribKind_ClassFlags_V4_XList(X) \ #define DW_AttribKind_ClassFlags_V4_XList \
X(Sibling, DW_AttribClass_Reference) \ X(Sibling, DW_AttribClass_Reference) \
X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \
X(Name, DW_AttribClass_String) \ X(Name, DW_AttribClass_String) \
@@ -838,7 +832,7 @@ X(LinkageName, DW_AttribClass_String)
//- Attributes DWARF5 //- Attributes DWARF5
#define DW_AttribKind_V5_XList(X) \ #define DW_AttribKind_V5_XList \
X(StringLengthBitSize, 0x6f) \ X(StringLengthBitSize, 0x6f) \
X(StringLengthByteSize, 0x70) \ X(StringLengthByteSize, 0x70) \
X(Rank, 0x71) \ X(Rank, 0x71) \
@@ -869,7 +863,7 @@ X(Deleted, 0x8a) \
X(Defaulted, 0x8b) \ X(Defaulted, 0x8b) \
X(LocListsBase, 0x8c) X(LocListsBase, 0x8c)
#define DW_AttribKind_ClassFlags_V5_XList(X) \ #define DW_AttribKind_ClassFlags_V5_XList \
X(Sibling, DW_AttribClass_Reference) \ X(Sibling, DW_AttribClass_Reference) \
X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \ X(Location, DW_AttribClass_ExprLoc|DW_AttribClass_LocListPtr) \
X(Name, DW_AttribClass_String) \ X(Name, DW_AttribClass_String) \
@@ -994,7 +988,7 @@ X(LocListsBase, DW_AttribClass_LocListPtr)
//- Attributes GNU //- Attributes GNU
#define DW_AttribKind_GNU_XList(X) \ #define DW_AttribKind_GNU_XList \
X(GNU_Vector, 0x2107) \ X(GNU_Vector, 0x2107) \
X(GNU_GuardedBy, 0x2108) \ X(GNU_GuardedBy, 0x2108) \
X(GNU_PtGuardedBy, 0x2109) \ X(GNU_PtGuardedBy, 0x2109) \
@@ -1029,7 +1023,7 @@ X(GNU_Numerator, 0x2303) \
X(GNU_Denominator, 0x2304) \ X(GNU_Denominator, 0x2304) \
X(GNU_Bias, 0x2305) X(GNU_Bias, 0x2305)
#define DW_AttribKind_ClassFlags_GNU_XList(X) \ #define DW_AttribKind_ClassFlags_GNU_XList \
X(GNU_Vector, DW_AttribClass_Flag) \ X(GNU_Vector, DW_AttribClass_Flag) \
X(GNU_GuardedBy, DW_AttribClass_Undefined) \ X(GNU_GuardedBy, DW_AttribClass_Undefined) \
X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \ X(GNU_PtGuardedBy, DW_AttribClass_Undefined) \
@@ -1066,14 +1060,14 @@ X(GNU_Bias, DW_AttribClass_Undefined)
//- Attributes LLVM //- Attributes LLVM
#define DW_AttribKind_LLVM_XList(X) \ #define DW_AttribKind_LLVM_XList \
X(LLVM_IncludePath, 0x3e00) \ X(LLVM_IncludePath, 0x3e00) \
X(LLVM_ConfigMacros, 0x3e01) \ X(LLVM_ConfigMacros, 0x3e01) \
X(LLVM_SysRoot, 0x3e02) \ X(LLVM_SysRoot, 0x3e02) \
X(LLVM_TagOffset, 0x3e03) \ X(LLVM_TagOffset, 0x3e03) \
X(LLVM_ApiNotes, 0x3e07) X(LLVM_ApiNotes, 0x3e07)
#define DW_AttribKind_ClassFlags_LLVM_XList(X) \ #define DW_AttribKind_ClassFlags_LLVM_XList \
X(LLVM_IncludePath, DW_AttribClass_String) \ X(LLVM_IncludePath, DW_AttribClass_String) \
X(LLVM_ConfigMacros, DW_AttribClass_String) \ X(LLVM_ConfigMacros, DW_AttribClass_String) \
X(LLVM_SysRoot, DW_AttribClass_String) \ X(LLVM_SysRoot, DW_AttribClass_String) \
@@ -1082,7 +1076,7 @@ X(LLVM_ApiNotes, DW_AttribClass_String)
//- Attributes Apple //- Attributes Apple
#define DW_AttribKind_APPLE_XList(X) \ #define DW_AttribKind_APPLE_XList \
X(APPLE_Optimized, 0x3fe1) \ X(APPLE_Optimized, 0x3fe1) \
X(APPLE_Flags, 0x3fe2) \ X(APPLE_Flags, 0x3fe2) \
X(APPLE_Isa, 0x3fe3) \ X(APPLE_Isa, 0x3fe3) \
@@ -1099,7 +1093,7 @@ X(APPLE_Property, 0x3fed) \
X(APPLE_ObjDirect, 0x3fee) \ X(APPLE_ObjDirect, 0x3fee) \
X(APPLE_Sdk, 0x3fef) X(APPLE_Sdk, 0x3fef)
#define DW_AttribKind_ClassFlags_APPLE_XList(X) \ #define DW_AttribKind_ClassFlags_APPLE_XList \
X(APPLE_Optimized, DW_AttribClass_Flag) \ X(APPLE_Optimized, DW_AttribClass_Flag) \
X(APPLE_Flags, DW_AttribClass_Flag) \ X(APPLE_Flags, DW_AttribClass_Flag) \
X(APPLE_Isa, DW_AttribClass_Flag) \ X(APPLE_Isa, DW_AttribClass_Flag) \
@@ -1118,7 +1112,7 @@ X(APPLE_Sdk, DW_AttribClass_String)
//- Attributes MIPS //- Attributes MIPS
#define DW_AttribKind_MIPS_XList(X) \ #define DW_AttribKind_MIPS_XList \
X(MIPS_Fde, 0x2001) \ X(MIPS_Fde, 0x2001) \
X(MIPS_LoopBegin, 0x2002) \ X(MIPS_LoopBegin, 0x2002) \
X(MIPS_TailLoopBegin, 0x2003) \ X(MIPS_TailLoopBegin, 0x2003) \
@@ -1137,7 +1131,7 @@ X(MIPS_AllocatableDopeType, 0x200f) \
X(MIPS_AssumedShapeDopeType, 0x2010) \ X(MIPS_AssumedShapeDopeType, 0x2010) \
X(MIPS_AssumedSize, 0x2011) X(MIPS_AssumedSize, 0x2011)
#define DW_AttribKind_ClassFlags_MIPS_XList(X) \ #define DW_AttribKind_ClassFlags_MIPS_XList \
X(MIPS_Fde, DW_AttribClass_Block) \ X(MIPS_Fde, DW_AttribClass_Block) \
X(MIPS_LoopBegin, DW_AttribClass_Block) \ X(MIPS_LoopBegin, DW_AttribClass_Block) \
X(MIPS_TailLoopBegin, DW_AttribClass_Block) \ X(MIPS_TailLoopBegin, DW_AttribClass_Block) \
@@ -1161,20 +1155,20 @@ typedef enum DW_AttribKindEnum
{ {
DW_AttribKind_Null, DW_AttribKind_Null,
#define X(_N,_ID,...) DW_AttribKind_##_N = _ID, #define X(_N,_ID,...) DW_AttribKind_##_N = _ID,
DW_AttribKind_V2_XList(X) DW_AttribKind_V2_XList
DW_AttribKind_V3_XList(X) DW_AttribKind_V3_XList
DW_AttribKind_V4_XList(X) DW_AttribKind_V4_XList
DW_AttribKind_V5_XList(X) DW_AttribKind_V5_XList
DW_AttribKind_GNU_XList(X) DW_AttribKind_GNU_XList
DW_AttribKind_LLVM_XList(X) DW_AttribKind_LLVM_XList
DW_AttribKind_APPLE_XList(X) DW_AttribKind_APPLE_XList
DW_AttribKind_MIPS_XList(X) DW_AttribKind_MIPS_XList
#undef X #undef X
DW_AttribKind_UserLo = 0x2000, DW_AttribKind_UserLo = 0x2000,
DW_AttribKind_UserHi = 0x3fff DW_AttribKind_UserHi = 0x3fff
} DW_AttribKindEnum; } DW_AttribKindEnum;
#define DW_ATE_XList(X) \ #define DW_ATE_XList \
X(Null, 0x00) \ X(Null, 0x00) \
X(Address, 0x01) \ X(Address, 0x01) \
X(Boolean, 0x02) \ X(Boolean, 0x02) \
@@ -1199,11 +1193,11 @@ typedef U64 DW_ATE;
typedef enum DW_ATEEnum typedef enum DW_ATEEnum
{ {
#define X(_N,_ID) DW_ATE_##_N = _ID, #define X(_N,_ID) DW_ATE_##_N = _ID,
DW_ATE_XList(X) DW_ATE_XList
#undef X #undef X
} DW_ATEnum; } DW_ATEnum;
#define DW_CallingConventionKind_XList(X) \ #define DW_CallingConventionKind_XList \
X(Normal, 0x0) \ X(Normal, 0x0) \
X(Program, 0x1) \ X(Program, 0x1) \
X(NoCall, 0x3) \ X(NoCall, 0x3) \
@@ -1214,11 +1208,11 @@ typedef U64 DW_CallingConventionKind;
typedef enum DW_CallingConventionKindEnum typedef enum DW_CallingConventionKindEnum
{ {
#define X(_N,_ID) DW_CallingConventionKind_##_N = _ID, #define X(_N,_ID) DW_CallingConventionKind_##_N = _ID,
DW_CallingConventionKind_XList(X) DW_CallingConventionKind_XList
#undef X #undef X
} DW_CallingConventionKindEnum; } DW_CallingConventionKindEnum;
#define DW_AccessKind_XList(X) \ #define DW_AccessKind_XList \
X(Public, 0x00) \ X(Public, 0x00) \
X(Private, 0x01) \ X(Private, 0x01) \
X(Protected, 0x02) X(Protected, 0x02)
@@ -1227,11 +1221,11 @@ typedef U64 DW_AccessKind;
typedef enum DW_AccessKindEnum typedef enum DW_AccessKindEnum
{ {
#define X(_N,_ID) DW_AccessKind_##_N = _ID, #define X(_N,_ID) DW_AccessKind_##_N = _ID,
DW_AccessKind_XList(X) DW_AccessKind_XList
#undef X #undef X
} DW_AccessKindEnum; } DW_AccessKindEnum;
#define DW_VirtualityKind_XList(X) \ #define DW_VirtualityKind_XList \
X(None, 0x00) \ X(None, 0x00) \
X(Virtual, 0x01) \ X(Virtual, 0x01) \
X(PureVirtual, 0x02) X(PureVirtual, 0x02)
@@ -1240,11 +1234,11 @@ typedef U64 DW_VirtualityKind;
typedef enum DW_VirtualityEnum typedef enum DW_VirtualityEnum
{ {
#define X(_N,_ID) DW_VirtualityKind_##_N = _ID, #define X(_N,_ID) DW_VirtualityKind_##_N = _ID,
DW_VirtualityKind_XList(X) DW_VirtualityKind_XList
#undef X #undef X
} DW_VirtualityEnum; } DW_VirtualityEnum;
#define DW_RngListEntryKind(X) \ #define DW_RngListEntryKind \
X(EndOfList, 0x00) \ X(EndOfList, 0x00) \
X(BaseAddressx, 0x01) \ X(BaseAddressx, 0x01) \
X(StartxEndx, 0x02) \ X(StartxEndx, 0x02) \
@@ -1258,11 +1252,11 @@ typedef U8 DW_RLE;
typedef enum DW_RLE_Enum typedef enum DW_RLE_Enum
{ {
#define X(_N,_ID) DW_RLE_##_N = _ID, #define X(_N,_ID) DW_RLE_##_N = _ID,
DW_RngListEntryKind(X) DW_RngListEntryKind
#undef X #undef X
} DW_RLE_Enum; } DW_RLE_Enum;
#define DW_LocListEntry_XList(X) \ #define DW_LocListEntry_XList \
X(EndOfList, 0x00) \ X(EndOfList, 0x00) \
X(BaseAddressx, 0x01) \ X(BaseAddressx, 0x01) \
X(StartxEndx, 0x02) \ X(StartxEndx, 0x02) \
@@ -1280,11 +1274,11 @@ typedef U8 DW_LLE;
typedef enum DW_LLE_Enum typedef enum DW_LLE_Enum
{ {
#define X(_N,_ID) DW_LLE_##_N = _ID, #define X(_N,_ID) DW_LLE_##_N = _ID,
DW_LocListEntry_XList(X) DW_LocListEntry_XList
#undef X #undef X
} DW_LLEEnum; } DW_LLEEnum;
#define DW_AddrClass_XList(X) \ #define DW_AddrClass_XList \
X(None, 0) \ X(None, 0) \
X(Near16, 1) \ X(Near16, 1) \
X(Far16, 2) \ X(Far16, 2) \
@@ -1296,11 +1290,11 @@ typedef U64 DW_AddrClass;
typedef enum DW_AddrClassEnum typedef enum DW_AddrClassEnum
{ {
#define X(_N, _ID) DW_AddrClassKind_##_N = _ID, #define X(_N, _ID) DW_AddrClassKind_##_N = _ID,
DW_AddrClass_XList(X) DW_AddrClass_XList
#undef X #undef X
} DW_AddrClassEnum; } DW_AddrClassEnum;
#define DW_CompUnitKind_XList(X) \ #define DW_CompUnitKind_XList \
X(Reserved, 0) \ X(Reserved, 0) \
X(Compile, 1) \ X(Compile, 1) \
X(Type, 2) \ X(Type, 2) \
@@ -1313,13 +1307,13 @@ typedef U8 DW_CompUnitKind;
typedef enum DW_CompUnitKindEnum typedef enum DW_CompUnitKindEnum
{ {
#define X(_N, _ID) DW_CompUnitKind_##_N = _ID, #define X(_N, _ID) DW_CompUnitKind_##_N = _ID,
DW_CompUnitKind_XList(X) DW_CompUnitKind_XList
#undef X #undef X
DW_CompUnitKind_UserLo = 0x80, DW_CompUnitKind_UserLo = 0x80,
DW_CompUnitKind_UserHi = 0xff DW_CompUnitKind_UserHi = 0xff
} DW_CompUnitKindEnum; } DW_CompUnitKindEnum;
#define DW_LNCT_XList(X) \ #define DW_LNCT_XList \
X(Path, 0x1) \ X(Path, 0x1) \
X(DirectoryIndex, 0x2) \ X(DirectoryIndex, 0x2) \
X(TimeStamp, 0x3) \ X(TimeStamp, 0x3) \
@@ -1331,7 +1325,7 @@ typedef U64 DW_LNCT;
typedef enum DW_LNCTEnum typedef enum DW_LNCTEnum
{ {
#define X(_N, _ID) DW_LNCT_##_N = _ID, #define X(_N, _ID) DW_LNCT_##_N = _ID,
DW_LNCT_XList(X) DW_LNCT_XList
#undef X #undef X
DW_LNCT_UserLo = 0x2000, DW_LNCT_UserLo = 0x2000,
DW_LNCT_UserHi = 0x3fff DW_LNCT_UserHi = 0x3fff
@@ -1349,7 +1343,7 @@ typedef enum
} DW_CFA_OperandType; } DW_CFA_OperandType;
// (opcode name, opcode id, operand count, operand types) // (opcode name, opcode id, operand count, operand types)
#define DW_CFA_Kind_XList(X) \ #define DW_CFA_Kind_XList \
X(Nop, 0x0) \ X(Nop, 0x0) \
X(SetLoc, 0x1, DW_CFA_OperandType_Value) \ X(SetLoc, 0x1, DW_CFA_OperandType_Value) \
X(AdvanceLoc1, 0x2, DW_CFA_OperandType_Value) \ X(AdvanceLoc1, 0x2, DW_CFA_OperandType_Value) \
@@ -1385,7 +1379,7 @@ typedef U8 DW_CFA_Opcode;
typedef enum DW_CFA_Enum typedef enum DW_CFA_Enum
{ {
#define X(_N, _ID, ...) DW_CFA_##_N = _ID, #define X(_N, _ID, ...) DW_CFA_##_N = _ID,
DW_CFA_Kind_XList(X) DW_CFA_Kind_XList
#undef X #undef X
} DW_CFA_Enum; } DW_CFA_Enum;
@@ -1608,7 +1602,7 @@ typedef enum DW_ExprOpEnum
//- Regs //- Regs
#define DW_Regs_X64_XList(X) \ #define DW_Regs_X64_XList \
X(Rax, 0, rax, 0, 8) \ X(Rax, 0, rax, 0, 8) \
X(Rdx, 1, rdx, 0, 8) \ X(Rdx, 1, rdx, 0, 8) \
X(Rcx, 2, rcx, 0, 8) \ X(Rcx, 2, rcx, 0, 8) \
@@ -1693,30 +1687,13 @@ typedef DW_Reg DW_RegX64;
typedef enum DW_RegX64Enum typedef enum DW_RegX64Enum
{ {
#define X(_N,_ID,...) DW_RegX64_##_N = _ID, #define X(_N,_ID,...) DW_RegX64_##_N = _ID,
DW_Regs_X64_XList(X) DW_Regs_X64_XList
#undef X #undef X
DW_RegX64_Last DW_RegX64_Last
} DW_RegX64Enum; } DW_RegX64Enum;
//////////////////////////////// ////////////////////////////////
typedef enum {
DW_UnwindStatus_Ok,
DW_UnwindStatus_Fail,
DW_UnwindStatus_Maybe
} DW_UnwindStatus;
#define DW_REG_READ(name) DW_UnwindStatus name(DW_Reg reg_id, void *buffer, U64 buffer_max, void *ud)
typedef DW_REG_READ(DW_RegRead);
#define DW_REG_WRITE(name) DW_UnwindStatus name(DW_Reg reg_id, void *value, U64 value_size, void *ud)
typedef DW_REG_WRITE(DW_RegWrite);
#define DW_MEM_READ(name) DW_UnwindStatus name(U64 addr, U64 size, void *buffer, void *ud)
typedef DW_MEM_READ(DW_MemRead);
////////////////////////////////
internal U64 dw_reg_size_from_code_x64(DW_Reg reg_code); internal U64 dw_reg_size_from_code_x64(DW_Reg reg_code);
internal U64 dw_reg_pos_from_code_x64(DW_Reg reg_code); internal U64 dw_reg_pos_from_code_x64(DW_Reg reg_code);
internal U64 dw_reg_size_from_code(Arch arch, DW_Reg reg_code); internal U64 dw_reg_size_from_code(Arch arch, DW_Reg reg_code);
+70 -35
View File
@@ -1127,23 +1127,30 @@ dw_expr_inst_from_delta(DW_ExprInst *inst, S16 delta)
return i; return i;
} }
internal DW_UnwindStatus internal DW_ExprEvalResult
dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_read, void *reg_read_ud, DW_ExprValue *value_out) dw_eval_expr(Arena *arena, Arch arch, DW_Format format, U64 cfa, U64 tls, U64 exec_op_limit, DW_Expr expr, MachineOp_RegRead *reg_read, void *reg_read_ud, DW_ExprValue *value_out)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
DW_UnwindStatus result = DW_UnwindStatus_Ok;
DW_ExprEvalResult result = DW_ExprEvalResult_Fail;
DW_PieceList pieces = {0}; DW_PieceList pieces = {0};
DW_ExprStack *stack = push_array(scratch.arena, DW_ExprStack, 1); DW_ExprStack *stack = push_array(scratch.arena, DW_ExprStack, 1);
B32 is_ok = 1; U64 exec_op_count = 0;
for EachNode(inst, DW_ExprInst, expr.first) { for EachNode(inst, DW_ExprInst, expr.first) {
again:; again:;
exec_op_count += 1;
if (exec_op_count > exec_op_limit) {
Assert(0 && "reached opcode exec limit on the expression");
result = DW_ExprEvalResult_ExecOpLimitReached;
goto exit;
}
U64 pop_count = dw_pop_count_from_expr_op(inst->opcode); U64 pop_count = dw_pop_count_from_expr_op(inst->opcode);
if (pop_count >= stack->count) { if (pop_count > stack->count) {
Assert(0 && "not enough values on the stack to evaluate the instruction"); Assert(0 && "not enough values on the stack to evaluate the instruction");
is_ok = 0; goto exit;
break;
} }
switch (inst->opcode) { switch (inst->opcode) {
@@ -1187,18 +1194,18 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29: case DW_ExprOp_Reg27: case DW_ExprOp_Reg28: case DW_ExprOp_Reg29:
case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: { case DW_ExprOp_Reg30: case DW_ExprOp_Reg31: {
DW_Reg reg_id = inst->opcode - DW_ExprOp_Reg0; DW_Reg reg_id = inst->opcode - DW_ExprOp_Reg0;
U64 reg_size = dw_reg_size_from_code(ctx->arch, reg_id); U64 reg_size = dw_reg_size_from_code(arch, reg_id);
U8 *reg_value = push_array(scratch.arena, U8, reg_size); U8 *reg_value = push_array(scratch.arena, U8, reg_size);
result = reg_read(reg_id, reg_value, reg_size, reg_read_ud); MachineOpResult reg_read_result = reg_read(reg_id, reg_value, reg_size, reg_read_ud);
if (result != DW_UnwindStatus_Ok) { goto exit; } if (reg_read_result != MachineOpResult_Ok) { goto exit; }
dw_expr_stack_push_unsigned(scratch.arena, stack, reg_value, reg_size); dw_expr_stack_push_unsigned(scratch.arena, stack, reg_value, reg_size);
} break; } break;
case DW_ExprOp_RegX: { case DW_ExprOp_RegX: {
U64 reg_size = dw_reg_size_from_code(ctx->arch, inst->operands[0].u64); U64 reg_size = dw_reg_size_from_code(arch, inst->operands[0].u64);
U8 *reg_value = push_array(scratch.arena, U8, reg_size); U8 *reg_value = push_array(scratch.arena, U8, reg_size);
result = reg_read(inst->operands[0].u64, reg_value, reg_size, reg_read_ud); MachineOpResult reg_read_result = reg_read(inst->operands[0].u64, reg_value, reg_size, reg_read_ud);
if (result != DW_UnwindStatus_Ok) { goto exit; } if (reg_read_result != MachineOpResult_Ok) { goto exit; }
dw_expr_stack_push_unsigned(scratch.arena, stack, reg_value, reg_size); dw_expr_stack_push_unsigned(scratch.arena, stack, reg_value, reg_size);
} break; } break;
@@ -1212,12 +1219,12 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
case DW_ExprOp_Piece: { case DW_ExprOp_Piece: {
if (stack->count) { if (stack->count) {
String8 value = dw_string_from_expr_value(arena, ctx->arch, dw_expr_stack_pop(stack)); String8 value = dw_string_from_expr_value(arena, arch, dw_expr_stack_pop(stack));
if (inst->operands[0].u64 <= value.size) { if (inst->operands[0].u64 <= value.size) {
dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Value, .value = { .ptr = value.str, .bit_size = inst->operands[0].u64 * 8 }}); dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Value, .value = { .ptr = value.str, .bit_size = inst->operands[0].u64 * 8 }});
} else { } else {
Assert(0 && "out of bounds size in the piece opcode"); Assert(0 && "out of bounds size in the piece opcode");
result = DW_UnwindStatus_Fail; goto exit;
} }
} else { } else {
dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Undefined, .undef_bit_size = inst->operands[0].u64 * 8 }); dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Undefined, .undef_bit_size = inst->operands[0].u64 * 8 });
@@ -1225,12 +1232,12 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
} break; } break;
case DW_ExprOp_BitPiece: { case DW_ExprOp_BitPiece: {
if (stack->count) { if (stack->count) {
String8 value = dw_string_from_expr_value(arena, ctx->arch, dw_expr_stack_pop(stack)); String8 value = dw_string_from_expr_value(arena, arch, dw_expr_stack_pop(stack));
if (inst->operands[0].u64 <= value.size * 8) { if (inst->operands[0].u64 <= value.size * 8) {
dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Value, .value = { .ptr = value.str, .bit_size = inst->operands[0].u64 }}); dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Value, .value = { .ptr = value.str, .bit_size = inst->operands[0].u64 }});
} else { } else {
Assert(0 && "out of bounds size in the bit piece opcode"); Assert(0 && "out of bounds size in the bit piece opcode");
result = DW_UnwindStatus_Fail; goto exit;
} }
} else { } else {
dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Undefined, .undef_bit_size = inst->operands[0].u64 }); dw_piece_list_push(arena, &pieces, (DW_Piece){ .kind = DW_PieceKind_Undefined, .undef_bit_size = inst->operands[0].u64 });
@@ -1243,7 +1250,7 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
dw_expr_stack_push(scratch.arena, stack, src->v); dw_expr_stack_push(scratch.arena, stack, src->v);
} else { } else {
Assert(0 && "out of bounds stack index"); Assert(0 && "out of bounds stack index");
result = DW_UnwindStatus_Fail; goto exit;
} }
} break; } break;
@@ -1253,7 +1260,7 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
dw_expr_stack_push(scratch.arena, stack, src->v); dw_expr_stack_push(scratch.arena, stack, src->v);
} else { } else {
Assert(0 && "out of bounds stack index"); Assert(0 && "out of bounds stack index");
result = DW_UnwindStatus_Fail; goto exit;
} }
} break; } break;
@@ -1269,8 +1276,7 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
if (i == 0) { if (i == 0) {
Assert(0 && "seeking to an invalid offset"); Assert(0 && "seeking to an invalid offset");
result = DW_UnwindStatus_Fail; goto exit;
break;
} }
inst = i; inst = i;
@@ -1282,16 +1288,14 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
if (cond.type != DW_ExprValueType_S16) { if (cond.type != DW_ExprValueType_S16) {
Assert(0 && "unexpected value"); Assert(0 && "unexpected value");
result = DW_UnwindStatus_Fail; goto exit;
break;
} }
DW_ExprInst *i = dw_expr_inst_from_delta(inst, inst->operands[0].s16); DW_ExprInst *i = dw_expr_inst_from_delta(inst, inst->operands[0].s16);
if (i == 0) { if (i == 0) {
Assert(0 && "seeking to an invalid offset"); Assert(0 && "seeking to an invalid offset");
result = DW_UnwindStatus_Fail; goto exit;
break;
} }
inst = i; inst = i;
@@ -1334,18 +1338,17 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
case DW_ExprOp_EntryValue: case DW_ExprOp_EntryValue:
case DW_ExprOp_GNU_EntryValue: { case DW_ExprOp_GNU_EntryValue: {
DW_Expr entry_value_expr = dw_expr_from_data(scratch.arena, ctx->format, byte_size_from_arch(ctx->arch), inst->operands[0].block); DW_Expr entry_value_expr = dw_expr_from_data(scratch.arena, format, byte_size_from_arch(arch), inst->operands[0].block);
DW_ExprValue entry_value; DW_ExprValue entry_value;
result = dw_eval_expr(scratch.arena, ctx, entry_value_expr, reg_read, reg_read_ud, &entry_value); result = dw_eval_expr(scratch.arena, arch, format, cfa, tls, exec_op_limit, entry_value_expr, reg_read, reg_read_ud, &entry_value);
if (result == DW_UnwindStatus_Ok) { if (result != DW_ExprEvalResult_Ok) { goto exit; }
dw_expr_stack_push(scratch.arena, stack, entry_value); dw_expr_stack_push(scratch.arena, stack, entry_value);
}
} break; } break;
case DW_ExprOp_Addrx: { NotImplemented; } break; case DW_ExprOp_Addrx: { NotImplemented; } break;
case DW_ExprOp_CallFrameCfa: { case DW_ExprOp_CallFrameCfa: {
dw_expr_stack_push(scratch.arena, stack, (DW_ExprValue){ .type = DW_ExprValueType_U64, .u64 = ctx->cfa }); dw_expr_stack_push(scratch.arena, stack, (DW_ExprValue){ .type = DW_ExprValueType_U64, .u64 = cfa });
} break; } break;
case DW_ExprOp_PushObjectAddress: { NotImplemented; } break; case DW_ExprOp_PushObjectAddress: { NotImplemented; } break;
@@ -1399,35 +1402,43 @@ dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_re
} break; } break;
case DW_ExprOp_StackValue: { case DW_ExprOp_StackValue: {
stack->top->v.type = dw_expr_unsigned_value_type_from_bit_size(byte_size_from_arch(ctx->arch) * 8); stack->top->v.type = dw_expr_unsigned_value_type_from_bit_size(bit_size_from_arch(arch));
} break; } break;
case DW_ExprOp_GNU_PushTlsAddress: case DW_ExprOp_GNU_PushTlsAddress:
case DW_ExprOp_FormTlsAddress: { case DW_ExprOp_FormTlsAddress: {
DW_ExprValue tls_off = dw_expr_stack_pop(stack); DW_ExprValue tls_off = dw_expr_stack_pop(stack);
DW_ExprValue tls_base = { .type = DW_ExprValueType_Addr, .addr = ctx->tls_base }; DW_ExprValue tls_base = { .type = DW_ExprValueType_Addr, .addr = tls };
DW_ExprValue tls_addr = dw_expr_add(tls_base, tls_off); DW_ExprValue tls_addr = dw_expr_add(tls_base, tls_off);
dw_expr_stack_push(scratch.arena, stack, tls_addr); dw_expr_stack_push(scratch.arena, stack, tls_addr);
} break; } break;
} }
} }
result = DW_ExprEvalResult_Ok;
exit:; exit:;
scratch_end(scratch); scratch_end(scratch);
return result; return result;
} }
internal String8 internal String8
dw_encode_expr(Arena *arena, DW_Format format, U64 addr_size, DW_ExprEnc *encs, U64 encs_count) dw_encode_expr(Arena *arena, Arch arch, DW_Format format, DW_ExprEnc *encs, U64 encs_count)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
String8List *srl = push_array(scratch.arena, String8List, 1); String8List *srl = push_array(scratch.arena, String8List, 1);
str8_serial_begin(scratch.arena, srl); str8_serial_begin(scratch.arena, srl);
HashTable *label_map = hash_table_init(scratch.arena, 128);
struct Fixup { U64 offset; String8 label; struct Fixup *next; };
struct Fixup *first_fixup = 0, *last_fixup = 0;
for EachIndex(i, encs_count) { for EachIndex(i, encs_count) {
DW_ExprEnc *e = &encs[i]; DW_ExprEnc *e = &encs[i];
switch (e->type) { switch (e->type) {
case DW_ExprEncType_Null: {} break;
case DW_ExprEncType_Op: { case DW_ExprEncType_Op: {
str8_serial_push_struct(scratch.arena, srl, &e->op); str8_serial_push_struct(scratch.arena, srl, &e->op);
} break; } break;
@@ -1487,6 +1498,7 @@ dw_encode_expr(Arena *arena, DW_Format format, U64 addr_size, DW_ExprEnc *encs,
str8_serial_push_string(scratch.arena, srl, str8(buffer, buffer_size)); str8_serial_push_string(scratch.arena, srl, str8(buffer, buffer_size));
} break; } break;
case DW_ExprEncType_Addr: { case DW_ExprEncType_Addr: {
U64 addr_size = byte_size_from_arch(arch);
Assert(addr_size <= sizeof(e->addr)); Assert(addr_size <= sizeof(e->addr));
str8_serial_push_string(scratch.arena, srl, str8((U8 *)&e->addr, addr_size)); str8_serial_push_string(scratch.arena, srl, str8((U8 *)&e->addr, addr_size));
} break; } break;
@@ -1504,16 +1516,39 @@ dw_encode_expr(Arena *arena, DW_Format format, U64 addr_size, DW_ExprEnc *encs,
} }
} break; } break;
case DW_ExprEncType_Label: { case DW_ExprEncType_Label: {
// TODO: struct Fixup *fixup = push_array(scratch.arena, struct Fixup, 1);
fixup->offset = srl->total_size;
fixup->label = e->label;
SLLQueuePush(first_fixup, last_fixup, fixup);
S16 delta_placeholder = 0;
str8_serial_push_struct(scratch.arena, srl, &delta_placeholder);
} break; } break;
case DW_ExprEncType_DeclLabel: { case DW_ExprEncType_DeclLabel: {
// TODO: hash_table_push_string_u64(scratch.arena, label_map, e->label, srl->total_size);
} break; } break;
default: { InvalidPath; } break; default: { InvalidPath; } break;
} }
} }
// finalize expression
String8 expr = str8_serial_end(arena, srl); String8 expr = str8_serial_end(arena, srl);
// apply fixups
for EachNode(fixup, struct Fixup, first_fixup) {
U64 label_offset;
if (!hash_table_search_string_u64(label_map, fixup->label, &label_offset)) {
Assert(0 && "undefined label");
continue;
}
S64 delta = (S64)label_offset - (S64)fixup->offset;
AssertAlways(min_S16 <= delta && delta <= max_S16);
S16 *delta_ptr = (S16 *)(expr.str + fixup->offset);
*delta_ptr = delta;
}
scratch_end(scratch); scratch_end(scratch);
return expr; return expr;
} }
+19 -19
View File
@@ -7,14 +7,6 @@
//////////////////////////////// ////////////////////////////////
// evaluator // evaluator
typedef struct DW_ExprContext
{
Arch arch;
DW_Format format;
U64 cfa;
U64 tls_base;
} DW_ExprContext;
#define DW_ExprValueType_IsSigned(x) ((x) == DW_ExprValueType_S8 || (x) == DW_ExprValueType_S16 || (x) == DW_ExprValueType_S32 || (x) == DW_ExprValueType_S64 || (x) == DW_ExprValueType_S128 || (x) == DW_ExprValueType_S256 || (x) == DW_ExprValueType_S512) #define DW_ExprValueType_IsSigned(x) ((x) == DW_ExprValueType_S8 || (x) == DW_ExprValueType_S16 || (x) == DW_ExprValueType_S32 || (x) == DW_ExprValueType_S64 || (x) == DW_ExprValueType_S128 || (x) == DW_ExprValueType_S256 || (x) == DW_ExprValueType_S512)
#define DW_ExprValueType_IsUnsigned(x) ((x) == DW_ExprValueType_U8 || (x) == DW_ExprValueType_U16 || (x) == DW_ExprValueType_U32 || (x) == DW_ExprValueType_U64 || (x) == DW_ExprValueType_U128 || (x) == DW_ExprValueType_U256 || (x) == DW_ExprValueType_U512) #define DW_ExprValueType_IsUnsigned(x) ((x) == DW_ExprValueType_U8 || (x) == DW_ExprValueType_U16 || (x) == DW_ExprValueType_U32 || (x) == DW_ExprValueType_U64 || (x) == DW_ExprValueType_U128 || (x) == DW_ExprValueType_U256 || (x) == DW_ExprValueType_U512)
#define DW_ExprValueType_IsFloat(x) ((x) == DW_ExprValueType_F32 || (x) == DW_ExprValueType_F64) #define DW_ExprValueType_IsFloat(x) ((x) == DW_ExprValueType_F32 || (x) == DW_ExprValueType_F64)
@@ -75,12 +67,6 @@ typedef struct DW_ExprValueNode
struct DW_ExprValueNode *next; struct DW_ExprValueNode *next;
} DW_ExprValueNode; } DW_ExprValueNode;
typedef struct DW_ExprStack
{
U64 count;
DW_ExprValueNode *top;
} DW_ExprStack;
typedef enum typedef enum
{ {
DW_PieceKind_Null, DW_PieceKind_Null,
@@ -113,11 +99,25 @@ typedef struct DW_PieceList
DW_PieceNode *last; DW_PieceNode *last;
} DW_PieceList; } DW_PieceList;
typedef struct DW_ExprStack
{
U64 count;
DW_ExprValueNode *top;
} DW_ExprStack;
typedef struct DW_ExprResult typedef struct DW_ExprResult
{ {
int x; int x;
} DW_ExprResult; } DW_ExprResult;
typedef enum
{
DW_ExprEvalResult_Fail,
DW_ExprEvalResult_Ok,
DW_ExprEvalResult_Maybe,
DW_ExprEvalResult_ExecOpLimitReached,
} DW_ExprEvalResult;
//////////////////////////////// ////////////////////////////////
// encoder // encoder
@@ -157,7 +157,7 @@ typedef struct DW_ExprEnc
S64 s64; S64 s64;
U64 addr; U64 addr;
String8 block; String8 block;
char *label; String8 label;
}; };
} DW_ExprEnc; } DW_ExprEnc;
@@ -175,8 +175,8 @@ typedef struct DW_ExprEnc
#define DW_ExprEnc_Addr(v) { .type = DW_ExprEncType_Addr, .addr = v } #define DW_ExprEnc_Addr(v) { .type = DW_ExprEncType_Addr, .addr = v }
#define DW_ExprEnc_Block(v) { .type = DW_ExprEncType_Block, .block = v } #define DW_ExprEnc_Block(v) { .type = DW_ExprEncType_Block, .block = v }
#define DW_ExprEnc_UInt(v) { .type = DW_ExprEncType_DwarfUInt, .u64 = v } #define DW_ExprEnc_UInt(v) { .type = DW_ExprEncType_DwarfUInt, .u64 = v }
#define DW_ExprEnc_Label(v) { .type = DW_ExprEncType_Label, .label = v } #define DW_ExprEnc_Label(v) { .type = DW_ExprEncType_Label, .label = str8_lit_comp(v) }
#define DW_ExprEnc_DeclLabel(v) { .type = DW_ExprEncType_DeclLabel, .label = v } #define DW_ExprEnc_DeclLabel(v) { .type = DW_ExprEncType_DeclLabel, .label = str8_lit_comp(v) }
//////////////////////////////// ////////////////////////////////
@@ -235,10 +235,10 @@ internal DW_ExprValueNode * dw_expr_stack_pick(DW_ExprStack *stack, U64 idx);
internal String8 dw_string_from_expr_value(Arena *arena, U64 addr_size, DW_ExprValue v); internal String8 dw_string_from_expr_value(Arena *arena, U64 addr_size, DW_ExprValue v);
// evaluator // evaluator
internal DW_UnwindStatus dw_eval_expr(Arena *arena, DW_ExprContext *ctx, DW_Expr expr, DW_RegRead *reg_read, void *reg_read_ud, DW_ExprValue *value_out); internal DW_ExprEvalResult dw_eval_expr(Arena *arena, Arch arch, DW_Format format, U64 cfa, U64 tls_base, U64 op_limit, DW_Expr expr, MachineOp_RegRead *reg_read, void *reg_read_ud, DW_ExprValue *value_out);
// encoder // encoder
internal String8 dw_encode_expr(Arena *arena, DW_Format format, U64 addr_size, DW_ExprEnc *encs, U64 encs_count); internal String8 dw_encode_expr(Arena *arena, Arch arch, DW_Format format, DW_ExprEnc *encs, U64 encs_count);
#endif //DWARF_EXPR_H #endif //DWARF_EXPR_H
+2 -2
View File
@@ -176,7 +176,7 @@ dw_section_kind_from_string(String8 string)
#define X(_K,_L,_M,_W) \ #define X(_K,_L,_M,_W) \
if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \ if (str8_match_lit(_L, string, 0)) { s = DW_Section_##_K; } \
if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; } if (str8_match_lit(_M, string, 0)) { s = DW_Section_##_K; }
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
return s; return s;
} }
@@ -187,7 +187,7 @@ dw_section_dwo_kind_from_string(String8 string)
DW_SectionKind s = DW_Section_Null; DW_SectionKind s = DW_Section_Null;
#define X(_K,_L,_M,_W) \ #define X(_K,_L,_M,_W) \
if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; } if (str8_match_lit(_W, string, 0)) { s = DW_Section_##_K; }
DW_SectionKind_XList(X) DW_SectionKind_XList
#undef X #undef X
return s; return s;
} }
+1 -1
View File
@@ -73,7 +73,7 @@ d2r_rdi_reg_code_from_dw_reg_x64(DW_RegX64 v)
{ {
default:{}break; default:{}break;
#define X(reg_dw, val_dw, reg_rdi, off, size) case DW_RegX64_##reg_dw:{result = RDI_RegCodeX64_##reg_rdi;}break; #define X(reg_dw, val_dw, reg_rdi, off, size) case DW_RegX64_##reg_dw:{result = RDI_RegCodeX64_##reg_rdi;}break;
DW_Regs_X64_XList(X) DW_Regs_X64_XList
#undef X #undef X
} }
return result; return result;