mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
consistency pass over dwarf layer
This commit is contained in:
+33
-33
@@ -70,10 +70,10 @@ dw_reg_pos_from_code(Arch arch, DW_Reg reg_code)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_v2(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V2_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -81,10 +81,10 @@ dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_v3(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V3_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -92,10 +92,10 @@ dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_v4(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V4_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -103,10 +103,10 @@ dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_v5(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V5_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -114,10 +114,10 @@ dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_gnu(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_GNU_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -125,10 +125,10 @@ dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_llvm(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_LLVM_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -136,10 +136,10 @@ dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_apple(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_APPLE_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -147,10 +147,10 @@ dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib_mips(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_AttribKind_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_MIPS_XList(X)
|
||||
#undef X
|
||||
}
|
||||
@@ -158,7 +158,7 @@ dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k)
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
dw_attrib_class_from_attrib(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
{
|
||||
DW_AttribClass result = DW_AttribClass_Null;
|
||||
|
||||
@@ -172,10 +172,10 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
|
||||
switch (flag) {
|
||||
case DW_Ext_Null: break;
|
||||
case DW_Ext_GNU: result = dw_attrib_class_from_attrib_kind_gnu(k); break;
|
||||
case DW_Ext_LLVM: result = dw_attrib_class_from_attrib_kind_llvm(k); break;
|
||||
case DW_Ext_APPLE: result = dw_attrib_class_from_attrib_kind_apple(k); break;
|
||||
case DW_Ext_MIPS: result = dw_attrib_class_from_attrib_kind_mips(k); break;
|
||||
case DW_Ext_GNU: result = dw_attrib_class_from_attrib_gnu(k); break;
|
||||
case DW_Ext_LLVM: result = dw_attrib_class_from_attrib_llvm(k); break;
|
||||
case DW_Ext_APPLE: result = dw_attrib_class_from_attrib_apple(k); break;
|
||||
case DW_Ext_MIPS: result = dw_attrib_class_from_attrib_mips(k); break;
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
|
||||
@@ -188,10 +188,10 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
switch (ver) {
|
||||
case DW_Version_Null: break;
|
||||
case DW_Version_1: AssertAlways(!"DWARF V1 is not supported"); break;
|
||||
case DW_Version_2: result = dw_attrib_class_from_attrib_kind_v2(k); break;
|
||||
case DW_Version_3: result = dw_attrib_class_from_attrib_kind_v3(k); break;
|
||||
case DW_Version_4: result = dw_attrib_class_from_attrib_kind_v4(k); break;
|
||||
case DW_Version_5: result = dw_attrib_class_from_attrib_kind_v5(k); break;
|
||||
case DW_Version_2: result = dw_attrib_class_from_attrib_v2(k); break;
|
||||
case DW_Version_3: result = dw_attrib_class_from_attrib_v3(k); break;
|
||||
case DW_Version_4: result = dw_attrib_class_from_attrib_v4(k); break;
|
||||
case DW_Version_5: result = dw_attrib_class_from_attrib_v5(k); break;
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
}
|
||||
@@ -302,14 +302,14 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin
|
||||
// This function's purpose is to find the overlapping class between an
|
||||
// DW_AttribKind and DW_FormKind.
|
||||
|
||||
DW_AttribClass attrib_class = dw_attrib_class_from_attrib_kind(ver, ext, attrib_kind);
|
||||
DW_AttribClass attrib_class = dw_attrib_class_from_attrib(ver, ext, attrib_kind);
|
||||
DW_AttribClass form_class = dw_attrib_class_from_form_kind(ver, form_kind);
|
||||
|
||||
if(relaxed)
|
||||
{
|
||||
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
|
||||
{
|
||||
attrib_class = dw_attrib_class_from_attrib_kind(DW_Version_Last, ext, attrib_kind);
|
||||
attrib_class = dw_attrib_class_from_attrib(DW_Version_Last, ext, attrib_kind);
|
||||
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
|
||||
}
|
||||
}
|
||||
@@ -434,11 +434,11 @@ internal String8
|
||||
dw_string_from_tag_kind(Arena *arena, DW_TagKind kind)
|
||||
{
|
||||
switch (kind) {
|
||||
case DW_Tag_Null: return str8_lit("Null");
|
||||
#define X(_N,_ID) case DW_Tag_##_N: return str8_lit(Stringify(_N));
|
||||
DW_Tag_V3_XList(X)
|
||||
DW_Tag_V5_XList(X)
|
||||
DW_Tag_GNU_XList(X)
|
||||
case DW_TagKind_Null: return str8_lit("Null");
|
||||
#define X(_N,_ID) case DW_TagKind_##_N: return str8_lit(Stringify(_N));
|
||||
DW_TagKind_V3_XList(X)
|
||||
DW_TagKind_V5_XList(X)
|
||||
DW_TagKind_GNU_XList(X)
|
||||
#undef X
|
||||
}
|
||||
return push_str8f(arena, "%llx", kind);
|
||||
@@ -447,7 +447,7 @@ dw_string_from_tag_kind(Arena *arena, DW_TagKind kind)
|
||||
internal String8
|
||||
dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKind kind)
|
||||
{
|
||||
#define X(_N,...) case DW_Attrib_##_N: return str8_lit(Stringify(_N));
|
||||
#define X(_N,...) case DW_AttribKind_##_N: return str8_lit(Stringify(_N));
|
||||
|
||||
while (ext) {
|
||||
U64 z = 64-clz64(ext);
|
||||
|
||||
+24
-24
@@ -188,7 +188,7 @@ typedef enum DW_IDCaseKindEnum
|
||||
#undef X
|
||||
} DW_IDCaseKindEnum;
|
||||
|
||||
#define DW_Tag_V3_XList(X) \
|
||||
#define DW_TagKind_V3_XList(X) \
|
||||
X(ArrayType, 0x01) \
|
||||
X(ClassType, 0x02) \
|
||||
X(EntryPoint, 0x03) \
|
||||
@@ -247,7 +247,7 @@ X(ImportedUnit, 0x3d) \
|
||||
X(Condition, 0x3f) \
|
||||
X(SharedType, 0x40)
|
||||
|
||||
#define DW_Tag_V5_XList(X) \
|
||||
#define DW_TagKind_V5_XList(X) \
|
||||
X(TypeUnit, 0x41) \
|
||||
X(RValueReferenceType, 0x42) \
|
||||
X(TemplateAlias, 0x43) \
|
||||
@@ -260,21 +260,21 @@ X(CallSiteParameter, 0x49) \
|
||||
X(SkeletonUnit, 0x4A) \
|
||||
X(ImmutableType, 0x4B)
|
||||
|
||||
#define DW_Tag_GNU_XList(X) \
|
||||
#define DW_TagKind_GNU_XList(X) \
|
||||
X(GNU_CallSite, 0x4109) \
|
||||
X(GNU_CallSiteParameter, 0x410a)
|
||||
|
||||
typedef U64 DW_TagKind;
|
||||
typedef enum DW_TagKindEnum
|
||||
{
|
||||
DW_Tag_Null,
|
||||
#define X(_N,_ID) DW_Tag_##_N = _ID,
|
||||
DW_Tag_V3_XList(X)
|
||||
DW_Tag_V5_XList(X)
|
||||
DW_Tag_GNU_XList(X)
|
||||
DW_TagKind_Null,
|
||||
#define X(_N,_ID) DW_TagKind_##_N = _ID,
|
||||
DW_TagKind_V3_XList(X)
|
||||
DW_TagKind_V5_XList(X)
|
||||
DW_TagKind_GNU_XList(X)
|
||||
#undef X
|
||||
DW_Tag_UserLo = 0x4080,
|
||||
DW_Tag_UserHi = 0xffff
|
||||
DW_TagKind_UserLo = 0x4080,
|
||||
DW_TagKind_UserHi = 0xffff
|
||||
} DW_TagKindEnum;
|
||||
|
||||
//- Attrib Class Encodings
|
||||
@@ -581,7 +581,7 @@ 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_Attrib_stride_size*/ \
|
||||
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) \
|
||||
@@ -1159,8 +1159,8 @@ X(MIPS_AssumedSize, DW_AttribClass_Reference)
|
||||
typedef U32 DW_AttribKind;
|
||||
typedef enum DW_AttribKindEnum
|
||||
{
|
||||
DW_Attrib_Null,
|
||||
#define X(_N,_ID,...) DW_Attrib_##_N = _ID,
|
||||
DW_AttribKind_Null,
|
||||
#define X(_N,_ID,...) DW_AttribKind_##_N = _ID,
|
||||
DW_AttribKind_V2_XList(X)
|
||||
DW_AttribKind_V3_XList(X)
|
||||
DW_AttribKind_V4_XList(X)
|
||||
@@ -1170,8 +1170,8 @@ typedef enum DW_AttribKindEnum
|
||||
DW_AttribKind_APPLE_XList(X)
|
||||
DW_AttribKind_MIPS_XList(X)
|
||||
#undef X
|
||||
DW_Attrib_UserLo = 0x2000,
|
||||
DW_Attrib_UserHi = 0x3fff
|
||||
DW_AttribKind_UserLo = 0x2000,
|
||||
DW_AttribKind_UserHi = 0x3fff
|
||||
} DW_AttribKindEnum;
|
||||
|
||||
#define DW_ATE_XList(X) \
|
||||
@@ -1744,18 +1744,18 @@ internal U64 dw_reg_pos_from_code(Arch arch, DW_Reg reg_code);
|
||||
//- Attrib Class Encodings
|
||||
|
||||
// Speced Encodings
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_v2(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_v3(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_v4(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_v5(DW_AttribKind k);
|
||||
|
||||
// Extensions
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_gnu (DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_llvm (DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind_mips (DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_gnu (DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_llvm (DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_apple(DW_AttribKind k);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_mips (DW_AttribKind k);
|
||||
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind v);
|
||||
internal DW_AttribClass dw_attrib_class_from_attrib(DW_Version ver, DW_Ext ext, DW_AttribKind v);
|
||||
|
||||
//- Form Class Encodings
|
||||
|
||||
|
||||
+345
-287
@@ -628,260 +628,7 @@ dw_print_eh_frame(Arena *arena, String8List *out, String8 indent, String8 raw_eh
|
||||
internal void
|
||||
dw_print_debug_info(Arena *arena, String8List *out, String8 indent, DW_Input *input, DW_ListUnitInput lu_input, Arch arch, B32 relaxed)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
Rng1U64List cu_ranges = dw_unit_ranges_from_data(scratch.arena, input->sec[DW_Section_Info].data);
|
||||
|
||||
if (cu_ranges.count > 0) {
|
||||
rd_printf("# %S", input->sec[DW_Section_Info].name);
|
||||
rd_indent();
|
||||
}
|
||||
|
||||
U64 comp_idx = 0;
|
||||
for (Rng1U64Node *cu_range_n = cu_ranges.first; cu_range_n != 0; cu_range_n = cu_range_n->next, ++comp_idx) {
|
||||
Temp comp_temp = temp_begin(scratch.arena);
|
||||
|
||||
U64 cu_base = cu_range_n->v.min;
|
||||
Rng1U64 cu_range = cu_range_n->v;
|
||||
DW_CompUnit cu = dw_cu_from_info_off(comp_temp.arena, input, lu_input, cu_range.min, relaxed);
|
||||
|
||||
String8 cu_dir = dw_string_from_attrib (input, &cu, cu.tag, DW_Attrib_CompDir );
|
||||
String8 cu_name = dw_string_from_attrib (input, &cu, cu.tag, DW_Attrib_Name );
|
||||
String8 stmt_list = dw_line_ptr_from_attrib(input, &cu, cu.tag, DW_Attrib_StmtList);
|
||||
|
||||
DW_LineVMHeader line_vm = {0};
|
||||
dw_read_line_vm_header(comp_temp.arena, stmt_list, 0, input, cu_dir, cu_name, cu.address_size, cu.str_offsets_lu, &line_vm);
|
||||
|
||||
// print comp info
|
||||
rd_printf("Compilation Unit #%u", comp_idx);
|
||||
rd_indent();
|
||||
rd_printf("Version: %u", cu.version);
|
||||
rd_printf("Address Size: %llu", cu.address_size);
|
||||
rd_printf("Abbrev Offset: %#llx", cu.abbrev_off);
|
||||
rd_printf("Info Range: %#llx-%#llx (%M)", cu.info_range.min, cu.info_range.max, dim_1u64(cu.info_range));
|
||||
rd_newline();
|
||||
|
||||
// prase tags
|
||||
U32 tag_depth = 0;
|
||||
for (U64 info_off = cu.first_tag_info_off; info_off < cu.info_range.max; ) {
|
||||
Temp tag_temp = temp_begin(scratch.arena);
|
||||
|
||||
U64 tag_info_off = info_off;
|
||||
DW_Tag tag = {0};
|
||||
info_off += dw_read_tag_cu(tag_temp.arena, input, &cu, tag_info_off, &tag);
|
||||
|
||||
String8 tag_str = dw_string_from_tag_kind(tag_temp.arena, tag.kind);
|
||||
rd_printf("<%x><%llx> DW_Tag_%S (Abbrev Number: %llu)", tag_depth, tag_info_off, tag_str, tag.abbrev_id);
|
||||
rd_indent();
|
||||
|
||||
// parse attributes
|
||||
for (DW_AttribNode *attrib_n = tag.attribs.first; attrib_n != 0; attrib_n = attrib_n->next) {
|
||||
Temp attrib_temp = temp_begin(tag_temp.arena);
|
||||
|
||||
DW_Attrib *attrib = &attrib_n->v;
|
||||
|
||||
String8List attrib_list = {0};
|
||||
|
||||
// attribute .debug_info offset
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "<%llx> ", attrib->info_off);
|
||||
|
||||
// attribute kind
|
||||
String8 attrib_kind_str = dw_string_from_attrib_kind(attrib_temp.arena, cu.version, cu.ext, attrib->attrib_kind);
|
||||
if (attrib_kind_str.size == 0) {
|
||||
if (relaxed) {
|
||||
attrib_kind_str = dw_string_from_attrib_kind(attrib_temp.arena, DW_Version_Last, cu.ext, attrib->attrib_kind);
|
||||
}
|
||||
}
|
||||
if (attrib_kind_str.size == 0) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "Unknown(%#x) ", attrib->attrib_kind);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "DW_Attrib_%-20S ", attrib_kind_str);
|
||||
}
|
||||
|
||||
// form kind
|
||||
String8 form_kind_str = dw_string_from_form_kind(scratch.arena, cu.version, attrib->form_kind);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "DW_Form_%-15S", form_kind_str);
|
||||
|
||||
DW_AttribClass value_class = dw_value_class_from_attrib(&cu, attrib);
|
||||
switch (value_class) {
|
||||
default: {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unknown value class");
|
||||
} break;
|
||||
case DW_AttribClass_Undefined: {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: undefined value class");
|
||||
} break;
|
||||
case DW_AttribClass_Address: {
|
||||
U64 address = dw_address_from_attrib_ptr(input, &cu, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", address);
|
||||
} break;
|
||||
case DW_AttribClass_Block: {
|
||||
String8 block = dw_block_from_attrib_ptr(input, &cu, attrib);
|
||||
String8List block_strs = numeric_str8_list_from_data(attrib_temp.arena, 16, block, 1);
|
||||
String8 block_str = str8_list_join(attrib_temp.arena, &block_strs, &(StringJoin){.sep = str8_lit(", ")});
|
||||
str8_list_push(attrib_temp.arena, &attrib_list, block_str);
|
||||
} break;
|
||||
case DW_AttribClass_Const: {
|
||||
U64 constant = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", constant);
|
||||
} break;
|
||||
case DW_AttribClass_ExprLoc: {
|
||||
String8 exprloc = dw_exprloc_from_attrib_ptr(input, &cu, attrib);
|
||||
String8 exprloc_str = dw_format_expression_single_line(attrib_temp.arena, exprloc, cu_base, cu.address_size, arch, cu.version, cu.ext, cu.format);
|
||||
str8_list_push(attrib_temp.arena, &attrib_list, exprloc_str);
|
||||
} break;
|
||||
case DW_AttribClass_Flag: {
|
||||
B32 flag = dw_flag_from_attrib_ptr(input, &cu, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%llu (%s)", flag, flag == 0 ? "false" : "true");
|
||||
} break;
|
||||
case DW_AttribClass_LinePtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, cu.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_LocListPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, cu.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_MacPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_RngListPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_RngList: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_Reference: {
|
||||
if (attrib->form_kind == DW_Form_Ref1 ||
|
||||
attrib->form_kind == DW_Form_Ref2 ||
|
||||
attrib->form_kind == DW_Form_Ref4 ||
|
||||
attrib->form_kind == DW_Form_Ref8 ||
|
||||
attrib->form_kind == DW_Form_RefUData) {
|
||||
U64 info_off = cu.info_range.min + attrib->form.ref;
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "<%llx>", info_off);
|
||||
if (!contains_1u64(cu.info_range, attrib->form.ref)) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(ERROR: out of bounds reference)");
|
||||
}
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.ref);
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_String: {
|
||||
if (attrib->form_kind == DW_Form_Strp) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
}
|
||||
String8 string = dw_string_from_attrib_ptr(input, &cu, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(%S)", string);
|
||||
} break;
|
||||
case DW_AttribClass_StrOffsetsPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, cu.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_AddrPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, cu.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
String8 attrib_str = {0};
|
||||
switch (attrib->attrib_kind) {
|
||||
case DW_Attrib_Language: {
|
||||
DW_Language lang = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = dw_string_from_language(attrib_temp.arena, lang);
|
||||
} break;
|
||||
case DW_Attrib_DeclFile: {
|
||||
U64 file_idx = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
DW_LineFile *file = dw_file_from_attrib_ptr(&cu, &line_vm, attrib);
|
||||
attrib_str = str8_lit("\?\?\?");
|
||||
if (file) {
|
||||
attrib_str = dw_path_from_file(attrib_temp.arena, &line_vm, file);
|
||||
}
|
||||
} break;
|
||||
case DW_Attrib_DeclLine: {
|
||||
U64 line = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = push_str8f(attrib_temp.arena, "%llu", line);
|
||||
} break;
|
||||
case DW_Attrib_Inline: {
|
||||
DW_InlKind inl = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = dw_string_from_inl(attrib_temp.arena, inl);
|
||||
} break;
|
||||
case DW_Attrib_Accessibility: {
|
||||
DW_AccessKind access = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = dw_string_from_access_kind(attrib_temp.arena, access);
|
||||
} break;
|
||||
case DW_Attrib_CallingConvention: {
|
||||
DW_CallingConventionKind calling_convetion = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = dw_string_from_calling_convetion(attrib_temp.arena, calling_convetion);
|
||||
} break;
|
||||
case DW_Attrib_Encoding: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib_ptr(input, &cu, attrib);
|
||||
attrib_str = dw_string_from_attrib_type_encoding(attrib_temp.arena, encoding);
|
||||
} break;
|
||||
}
|
||||
|
||||
if (attrib_str.size) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(%S)", attrib_str);
|
||||
}
|
||||
String8 print = str8_list_join(attrib_temp.arena, &attrib_list, &(StringJoin){.sep=str8_lit(" ")});
|
||||
rd_printf("%S", print);
|
||||
|
||||
temp_end(attrib_temp);
|
||||
}
|
||||
|
||||
B32 is_ender_tag = tag.abbrev_id == 0;
|
||||
if (tag.has_children) {
|
||||
if (is_ender_tag) {
|
||||
rd_errorf("null-tag cannot have children");
|
||||
}
|
||||
rd_indent();
|
||||
tag_depth += 1;
|
||||
}
|
||||
if (is_ender_tag) {
|
||||
if (tag_depth == 0) {
|
||||
rd_errorf("malformed data detected, too many null tags");
|
||||
} else {
|
||||
rd_unindent();
|
||||
tag_depth -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
rd_unindent();
|
||||
temp_end(tag_temp);
|
||||
}
|
||||
temp_end(comp_temp);
|
||||
|
||||
rd_unindent();
|
||||
rd_newline();
|
||||
}
|
||||
|
||||
if (cu_ranges.count > 0) {
|
||||
rd_unindent();
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
}
|
||||
|
||||
internal void
|
||||
@@ -914,7 +661,7 @@ dw_print_debug_abbrev(Arena *arena, String8List *out, String8 indent, DW_Input *
|
||||
cursor += str8_deserial_read_uleb128(raw_abbrev, cursor, &tag);
|
||||
cursor += str8_deserial_read_struct(raw_abbrev, cursor, &has_children);
|
||||
|
||||
rd_printf("<%llx> %llu DW_Tag_%S %s", id_off, id, dw_string_from_tag_kind(temp.arena, tag), has_children ? "[has children]" : "[no children]");
|
||||
rd_printf("<%llx> %llu DW_TagKind_%S %s", id_off, id, dw_string_from_tag_kind(temp.arena, tag), has_children ? "[has children]" : "[no children]");
|
||||
rd_indent();
|
||||
for (;;) {
|
||||
U64 attrib_off = cursor;
|
||||
@@ -927,7 +674,7 @@ dw_print_debug_abbrev(Arena *arena, String8List *out, String8 indent, DW_Input *
|
||||
}
|
||||
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);
|
||||
rd_printf("<%llx> DW_Attrib_%-20S DW_Form_%S", attrib_off, attrib_str, form_str);
|
||||
rd_printf("<%llx> DW_AttribKind_%-20S DW_Form_%S", attrib_off, attrib_str, form_str);
|
||||
}
|
||||
rd_unindent();
|
||||
|
||||
@@ -2146,58 +1893,369 @@ dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_In
|
||||
#endif
|
||||
}
|
||||
|
||||
internal void
|
||||
dw_format(Arena *arena, String8List *out, String8 indent, DW_DumpSubsetFlags subset_flags, DW_Input *input, Arch arch, ExecutableImageKind image_type)
|
||||
internal String8List
|
||||
dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags)
|
||||
{
|
||||
String8List strings = {0};
|
||||
String8 indent = str8_lit(" ");
|
||||
#define dump(str) str8_list_push(arena, &strings, (str))
|
||||
#define dumpf(...) str8_list_pushf(arena, &strings, __VA_ARGS__)
|
||||
#define DumpSubset(name) if(subset_flags & DW_DumpSubsetFlag_##name) DeferLoop(dumpf("# %S\n\n", dw_name_title_from_dump_subset_table[DW_DumpSubset_##name]), dump(str8_lit("\n")))
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
Rng1U64Array segment_vranges = {0};
|
||||
|
||||
DW_ListUnitInput lu_input = dw_list_unit_input_from_input(scratch.arena, input);
|
||||
Rng1U64List unit_ranges_list = dw_unit_ranges_from_data(scratch.arena, input->sec[DW_Section_Info].data);
|
||||
Rng1U64Array unit_ranges = rng1u64_array_from_list(scratch.arena, &unit_ranges_list);
|
||||
B32 relaxed = 1;
|
||||
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugInfo) {
|
||||
dw_print_debug_info(arena, out, indent, input, lu_input, arch, relaxed);
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_info
|
||||
//
|
||||
DumpSubset(DebugInfo)
|
||||
{
|
||||
for EachIndex(unit_idx, unit_ranges.count)
|
||||
{
|
||||
Temp unit_temp = temp_begin(scratch.arena);
|
||||
|
||||
//- rjf: unpack unit
|
||||
Rng1U64 unit_range = unit_ranges.v[unit_idx];
|
||||
DW_CompUnit unit = dw_cu_from_info_off(unit_temp.arena, input, lu_input, unit_range.min, relaxed);
|
||||
String8 unit_dir = dw_string_from_attrib(input, &unit, unit.tag, DW_AttribKind_CompDir );
|
||||
String8 unit_name = dw_string_from_attrib(input, &unit, unit.tag, DW_AttribKind_Name );
|
||||
String8 stmt_list = dw_line_ptr_from_attrib(input, &unit, unit.tag, DW_AttribKind_StmtList);
|
||||
DW_LineVMHeader line_vm = {0};
|
||||
dw_read_line_vm_header(unit_temp.arena, stmt_list, 0, input, unit_dir, unit_name, unit.address_size, unit.str_offsets_lu, &line_vm);
|
||||
|
||||
//- rjf: log top-level unit info
|
||||
dumpf("unit: // compile_unit[%u]\n{\n", unit_idx);
|
||||
dumpf(" version: %u\n", unit.version);
|
||||
dumpf(" address_size: %I64u\n", unit.address_size);
|
||||
dumpf(" abbrev_off: 0x%I64x\n", unit.abbrev_off);
|
||||
dumpf(" info_range: [0x%I64x, 0x%I64x) // (%M)\n", unit.info_range.min, unit.info_range.max, dim_1u64(unit.info_range));
|
||||
|
||||
//- rjf: log tags
|
||||
S64 tag_depth = 0;
|
||||
for(U64 info_off = unit.first_tag_info_off; info_off < unit.info_range.max;)
|
||||
{
|
||||
// rjf: unpack tag
|
||||
Temp tag_temp = temp_begin(scratch.arena);
|
||||
U64 tag_info_off = info_off;
|
||||
DW_Tag tag = {0};
|
||||
info_off += dw_read_tag_cu(tag_temp.arena, input, &unit, tag_info_off, &tag);
|
||||
|
||||
String8 tag_str = dw_string_from_tag_kind(tag_temp.arena, tag.kind);
|
||||
rd_printf("<%x><%llx> DW_TagKind_%S (Abbrev Number: %llu)", tag_depth, tag_info_off, tag_str, tag.abbrev_id);
|
||||
rd_indent();
|
||||
|
||||
// parse attributes
|
||||
for (DW_AttribNode *attrib_n = tag.attribs.first; attrib_n != 0; attrib_n = attrib_n->next) {
|
||||
Temp attrib_temp = temp_begin(tag_temp.arena);
|
||||
|
||||
DW_Attrib *attrib = &attrib_n->v;
|
||||
|
||||
String8List attrib_list = {0};
|
||||
|
||||
// attribute .debug_info offset
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "<%llx> ", attrib->info_off);
|
||||
|
||||
// attribute kind
|
||||
String8 attrib_kind_str = dw_string_from_attrib_kind(attrib_temp.arena, unit.version, unit.ext, attrib->attrib_kind);
|
||||
if (attrib_kind_str.size == 0) {
|
||||
if (relaxed) {
|
||||
attrib_kind_str = dw_string_from_attrib_kind(attrib_temp.arena, DW_Version_Last, unit.ext, attrib->attrib_kind);
|
||||
}
|
||||
}
|
||||
if (attrib_kind_str.size == 0) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "Unknown(%#x) ", attrib->attrib_kind);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "DW_AttribKind_%-20S ", attrib_kind_str);
|
||||
}
|
||||
|
||||
// form kind
|
||||
String8 form_kind_str = dw_string_from_form_kind(scratch.arena, unit.version, attrib->form_kind);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "DW_Form_%-15S", form_kind_str);
|
||||
|
||||
DW_AttribClass value_class = dw_value_class_from_attrib(&unit, attrib);
|
||||
switch (value_class) {
|
||||
default: {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unknown value class");
|
||||
} break;
|
||||
case DW_AttribClass_Undefined: {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: undefined value class");
|
||||
} break;
|
||||
case DW_AttribClass_Address: {
|
||||
U64 address = dw_address_from_attrib_ptr(input, &unit, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", address);
|
||||
} break;
|
||||
case DW_AttribClass_Block: {
|
||||
String8 block = dw_block_from_attrib_ptr(input, &unit, attrib);
|
||||
String8List block_strs = numeric_str8_list_from_data(attrib_temp.arena, 16, block, 1);
|
||||
String8 block_str = str8_list_join(attrib_temp.arena, &block_strs, &(StringJoin){.sep = str8_lit(", ")});
|
||||
str8_list_push(attrib_temp.arena, &attrib_list, block_str);
|
||||
} break;
|
||||
case DW_AttribClass_Const: {
|
||||
U64 constant = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", constant);
|
||||
} break;
|
||||
case DW_AttribClass_ExprLoc: {
|
||||
String8 exprloc = dw_exprloc_from_attrib_ptr(input, &unit, attrib);
|
||||
String8 exprloc_str = dw_format_expression_single_line(attrib_temp.arena, exprloc, unit_range.min, unit.address_size, arch, unit.version, unit.ext, unit.format);
|
||||
str8_list_push(attrib_temp.arena, &attrib_list, exprloc_str);
|
||||
} break;
|
||||
case DW_AttribClass_Flag: {
|
||||
B32 flag = dw_flag_from_attrib_ptr(input, &unit, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%llu (%s)", flag, flag == 0 ? "false" : "true");
|
||||
} break;
|
||||
case DW_AttribClass_LinePtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, unit.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_LocListPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, unit.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_MacPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_RngListPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_RngList: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "\?\?\?");
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_Reference: {
|
||||
if (attrib->form_kind == DW_Form_Ref1 ||
|
||||
attrib->form_kind == DW_Form_Ref2 ||
|
||||
attrib->form_kind == DW_Form_Ref4 ||
|
||||
attrib->form_kind == DW_Form_Ref8 ||
|
||||
attrib->form_kind == DW_Form_RefUData) {
|
||||
U64 info_off = unit.info_range.min + attrib->form.ref;
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "<%llx>", info_off);
|
||||
if (!contains_1u64(unit.info_range, attrib->form.ref)) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(ERROR: out of bounds reference)");
|
||||
}
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.ref);
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_String: {
|
||||
if (attrib->form_kind == DW_Form_Strp) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
}
|
||||
String8 string = dw_string_from_attrib_ptr(input, &unit, attrib);
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(%S)", string);
|
||||
} break;
|
||||
case DW_AttribClass_StrOffsetsPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, unit.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
case DW_AttribClass_AddrPtr: {
|
||||
if (attrib->form_kind == DW_Form_SecOffset) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "%#llx", attrib->form.sec_offset);
|
||||
} else {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "ERROR: unexpected form %S", dw_string_from_form_kind(attrib_temp.arena, unit.version, attrib->form_kind));
|
||||
}
|
||||
} break;
|
||||
}
|
||||
|
||||
String8 attrib_str = {0};
|
||||
switch (attrib->attrib_kind) {
|
||||
case DW_AttribKind_Language: {
|
||||
DW_Language lang = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = dw_string_from_language(attrib_temp.arena, lang);
|
||||
} break;
|
||||
case DW_AttribKind_DeclFile: {
|
||||
U64 file_idx = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
DW_LineFile *file = dw_file_from_attrib_ptr(&unit, &line_vm, attrib);
|
||||
attrib_str = str8_lit("\?\?\?");
|
||||
if (file) {
|
||||
attrib_str = dw_path_from_file(attrib_temp.arena, &line_vm, file);
|
||||
}
|
||||
} break;
|
||||
case DW_AttribKind_DeclLine: {
|
||||
U64 line = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = push_str8f(attrib_temp.arena, "%llu", line);
|
||||
} break;
|
||||
case DW_AttribKind_Inline: {
|
||||
DW_InlKind inl = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = dw_string_from_inl(attrib_temp.arena, inl);
|
||||
} break;
|
||||
case DW_AttribKind_Accessibility: {
|
||||
DW_AccessKind access = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = dw_string_from_access_kind(attrib_temp.arena, access);
|
||||
} break;
|
||||
case DW_AttribKind_CallingConvention: {
|
||||
DW_CallingConventionKind calling_convetion = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = dw_string_from_calling_convetion(attrib_temp.arena, calling_convetion);
|
||||
} break;
|
||||
case DW_AttribKind_Encoding: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib_ptr(input, &unit, attrib);
|
||||
attrib_str = dw_string_from_attrib_type_encoding(attrib_temp.arena, encoding);
|
||||
} break;
|
||||
}
|
||||
|
||||
if (attrib_str.size) {
|
||||
str8_list_pushf(attrib_temp.arena, &attrib_list, "(%S)", attrib_str);
|
||||
}
|
||||
String8 print = str8_list_join(attrib_temp.arena, &attrib_list, &(StringJoin){.sep=str8_lit(" ")});
|
||||
rd_printf("%S", print);
|
||||
|
||||
temp_end(attrib_temp);
|
||||
}
|
||||
|
||||
B32 is_ender_tag = tag.abbrev_id == 0;
|
||||
if (tag.has_children) {
|
||||
if (is_ender_tag) {
|
||||
rd_errorf("null-tag cannot have children");
|
||||
}
|
||||
rd_indent();
|
||||
tag_depth += 1;
|
||||
}
|
||||
if (is_ender_tag) {
|
||||
if (tag_depth == 0) {
|
||||
rd_errorf("malformed data detected, too many null tags");
|
||||
} else {
|
||||
rd_unindent();
|
||||
tag_depth -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
rd_unindent();
|
||||
temp_end(tag_temp);
|
||||
}
|
||||
temp_end(unit_temp);
|
||||
dumpf("} // compile_unit[/%u]\n\n", unit_idx);
|
||||
}
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugAbbrev) {
|
||||
dw_print_debug_abbrev(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_abbrev
|
||||
//
|
||||
DumpSubset(DebugAbbrev)
|
||||
{
|
||||
// dw_print_debug_abbrev(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugLine) {
|
||||
dw_print_debug_line(arena, out, indent, input, lu_input, relaxed);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_line
|
||||
//
|
||||
DumpSubset(DebugLine)
|
||||
{
|
||||
// dw_print_debug_line(arena, out, indent, input, lu_input, relaxed);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugStr) {
|
||||
dw_print_debug_str(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_str
|
||||
//
|
||||
DumpSubset(DebugStr)
|
||||
{
|
||||
// dw_print_debug_str(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugLoc) {
|
||||
dw_print_debug_loc(arena, out, indent, input, arch, image_type, relaxed);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_loc
|
||||
//
|
||||
DumpSubset(DebugLoc)
|
||||
{
|
||||
// dw_print_debug_loc(arena, out, indent, input, arch, image_type, relaxed);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugRanges) {
|
||||
dw_print_debug_ranges(arena, out, indent, input, arch, image_type, relaxed);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_ranges
|
||||
//
|
||||
DumpSubset(DebugRanges)
|
||||
{
|
||||
// dw_print_debug_ranges(arena, out, indent, input, arch, image_type, relaxed);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugARanges) {
|
||||
dw_print_debug_aranges(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_aranges
|
||||
//
|
||||
DumpSubset(DebugARanges)
|
||||
{
|
||||
// dw_print_debug_aranges(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugAddr) {
|
||||
dw_print_debug_addr(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_addr
|
||||
//
|
||||
DumpSubset(DebugAddr)
|
||||
{
|
||||
// dw_print_debug_addr(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugLocLists) {
|
||||
dw_print_debug_loclists(arena, out, indent, input, segment_vranges, arch);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_loclists
|
||||
//
|
||||
DumpSubset(DebugLocLists)
|
||||
{
|
||||
// dw_print_debug_loclists(arena, out, indent, input, segment_vranges, arch);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugRngLists) {
|
||||
dw_print_debug_rnglists(arena, out, indent, input, segment_vranges);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_rnglists
|
||||
//
|
||||
DumpSubset(DebugRngLists)
|
||||
{
|
||||
// dw_print_debug_rnglists(arena, out, indent, input, segment_vranges);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugPubNames) {
|
||||
dw_print_debug_pubnames(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_pubnames
|
||||
//
|
||||
DumpSubset(DebugPubNames)
|
||||
{
|
||||
// dw_print_debug_pubnames(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugPubTypes) {
|
||||
dw_print_debug_pubtypes(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_pubtypes
|
||||
//
|
||||
DumpSubset(DebugPubTypes)
|
||||
{
|
||||
// dw_print_debug_pubtypes(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugLineStr) {
|
||||
dw_print_debug_line_str(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_linestr
|
||||
//
|
||||
DumpSubset(DebugLineStr)
|
||||
{
|
||||
// dw_print_debug_line_str(arena, out, indent, input);
|
||||
}
|
||||
if (subset_flags & DW_DumpSubsetFlag_DebugStrOffsets) {
|
||||
dw_print_debug_str_offsets(arena, out, indent, input);
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: dump .debug_stroffs
|
||||
//
|
||||
DumpSubset(DebugStrOffsets)
|
||||
{
|
||||
// dw_print_debug_str_offsets(arena, out, indent, input);
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
#undef DumpSubset
|
||||
#undef dumpf
|
||||
#undef dump
|
||||
return strings;
|
||||
}
|
||||
|
||||
@@ -72,6 +72,6 @@ internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8
|
||||
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_format(Arena *arena, String8List *out, String8 indent, DW_DumpSubsetFlags subset_flags, DW_Input *input, Arch arch, ExecutableImageKind image_type);
|
||||
internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags);
|
||||
|
||||
#endif // DWARF_DUMP_H
|
||||
|
||||
+20
-20
@@ -1837,10 +1837,10 @@ dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k
|
||||
{
|
||||
DW_Attrib *attrib = dw_attrib_from_tag_(tag, kind);
|
||||
|
||||
if (attrib->attrib_kind == DW_Attrib_Null) {
|
||||
if (attrib->attrib_kind == DW_AttribKind_Null) {
|
||||
if (cu && cu->tag_ht) {
|
||||
DW_Attrib *ao_attrib = dw_attrib_from_tag_(tag, DW_Attrib_AbstractOrigin);
|
||||
if (ao_attrib->attrib_kind == DW_Attrib_AbstractOrigin) {
|
||||
DW_Attrib *ao_attrib = dw_attrib_from_tag_(tag, DW_AttribKind_AbstractOrigin);
|
||||
if (ao_attrib->attrib_kind == DW_AttribKind_AbstractOrigin) {
|
||||
DW_Reference ref = dw_interp_ref(input, cu, ao_attrib->form_kind, ao_attrib->form);
|
||||
DW_TagNode *ref_tag = dw_tag_node_from_info_off(ref.cu, ref.info_off);
|
||||
attrib = dw_attrib_from_tag_(ref_tag->tag, kind);
|
||||
@@ -1855,7 +1855,7 @@ internal B32
|
||||
dw_tag_has_attrib(DW_Input *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_Attrib_Null;
|
||||
B32 has_attrib = attrib->attrib_kind != DW_AttribKind_Null;
|
||||
return has_attrib;
|
||||
}
|
||||
|
||||
@@ -1940,18 +1940,18 @@ dw_file_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_LineVMHeader *line_vm,
|
||||
internal B32
|
||||
dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byte_size_out)
|
||||
{
|
||||
B32 has_byte_size = dw_tag_has_attrib(input, cu, tag, DW_Attrib_ByteSize);
|
||||
B32 has_bit_size = dw_tag_has_attrib(input, cu, tag, DW_Attrib_BitSize );
|
||||
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 );
|
||||
|
||||
if (has_byte_size && has_bit_size) {
|
||||
Assert(!"ill formated byte size");
|
||||
}
|
||||
|
||||
if (has_byte_size) {
|
||||
*byte_size_out = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize);
|
||||
*byte_size_out = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_ByteSize);
|
||||
return 1;
|
||||
} else if (has_bit_size) {
|
||||
U64 bit_size = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_BitSize);
|
||||
U64 bit_size = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_BitSize);
|
||||
*byte_size_out = bit_size / 8;
|
||||
return 1;
|
||||
}
|
||||
@@ -1985,13 +1985,13 @@ dw_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k
|
||||
DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind);
|
||||
DW_AttribClass attrib_class = dw_value_class_from_attrib(cu, attrib);
|
||||
if (attrib_class == DW_AttribClass_Const || attrib_class == DW_AttribClass_Block) {
|
||||
if (dw_tag_has_attrib(input, cu, tag, DW_Attrib_Type)) {
|
||||
if (dw_tag_has_attrib(input, cu, tag, DW_AttribKind_Type)) {
|
||||
Temp scratch = scratch_begin(0,0);
|
||||
DW_Reference type_ref = dw_ref_from_attrib(input, cu, tag, DW_Attrib_Type);
|
||||
DW_Reference type_ref = dw_ref_from_attrib(input, cu, tag, DW_AttribKind_Type);
|
||||
DW_Tag type_tag = {0};
|
||||
dw_read_tag_cu(scratch.arena, input, type_ref.cu, type_ref.info_off, &type_tag);
|
||||
U64 type_byte_size = dw_byte_size_from_tag(input, cu, type_tag);
|
||||
DW_ATE type_encoding = dw_const_u64_from_attrib(input, type_ref.cu, type_tag, DW_Attrib_Encoding);
|
||||
DW_ATE type_encoding = dw_const_u64_from_attrib(input, type_ref.cu, type_tag, DW_AttribKind_Encoding);
|
||||
if (type_encoding == DW_ATE_Unsigned || type_encoding == DW_ATE_UnsignedChar) {
|
||||
result = dw_interp_const64(type_byte_size, type_encoding, attrib->form_kind, attrib->form);
|
||||
}
|
||||
@@ -2121,15 +2121,15 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6
|
||||
dw_read_tag(arena, data, cursor, range.min, abbrev_table, abbrev_data, version, format, address_size, &cu_tag);
|
||||
|
||||
// TODO: handle these unit types
|
||||
Assert(cu_tag.kind != DW_Tag_SkeletonUnit);
|
||||
Assert(cu_tag.kind != DW_Tag_TypeUnit);
|
||||
Assert(cu_tag.kind != DW_TagKind_SkeletonUnit);
|
||||
Assert(cu_tag.kind != DW_TagKind_TypeUnit);
|
||||
|
||||
if (cu_tag.kind == DW_Tag_CompileUnit || cu_tag.kind == DW_Tag_PartialUnit) {
|
||||
if (cu_tag.kind == DW_TagKind_CompileUnit || cu_tag.kind == DW_TagKind_PartialUnit) {
|
||||
// fetch attribs for list sections
|
||||
DW_Attrib *addr_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_AddrBase );
|
||||
DW_Attrib *str_offsets_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_StrOffsetsBase);
|
||||
DW_Attrib *rnglists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_RngListsBase );
|
||||
DW_Attrib *loclists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_LocListsBase );
|
||||
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);
|
||||
DW_Attrib *rnglists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_AttribKind_RngListsBase );
|
||||
DW_Attrib *loclists_base_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_AttribKind_LocListsBase );
|
||||
|
||||
// interp attribs as section offsets
|
||||
U64 addr_sec_off = dw_interp_sec_offset(addr_base_attrib->form_kind, addr_base_attrib->form );
|
||||
@@ -2150,7 +2150,7 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6
|
||||
DW_ListUnit *loclists_lu = loclists_lu_idx < lu_input.loclist_count ? &lu_input.loclists[loclists_lu_idx] : 0;
|
||||
|
||||
// find compile unit base address
|
||||
DW_Attrib *low_pc_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_Attrib_LowPc);
|
||||
DW_Attrib *low_pc_attrib = dw_attrib_from_tag(0, 0, cu_tag, DW_AttribKind_LowPc);
|
||||
U64 low_pc = dw_interp_address(address_size, max_U64, addr_lu, low_pc_attrib->form_kind, low_pc_attrib->form);
|
||||
|
||||
// fill out compile unit
|
||||
@@ -2195,7 +2195,7 @@ dw_tag_tree_from_data(Arena *arena, String8 info_data, String8 abbrev_data, DW_C
|
||||
*cursor += tag_size;
|
||||
|
||||
// is this sentinel tag?
|
||||
if (tag.kind == DW_Tag_Null) {
|
||||
if (tag.kind == DW_TagKind_Null) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
+149
-149
@@ -78,7 +78,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D
|
||||
|
||||
if (value_class == DW_AttribClass_Reference) {
|
||||
// resolve reference
|
||||
DW_Reference ref = dw_ref_from_attrib_ptr(input, cu, attrib);
|
||||
DW_Reference ref = dw_ref_from_attrib(input, cu, attrib);
|
||||
|
||||
// TODO: support for external compile unit references
|
||||
AssertAlways(ref.cu == cu);
|
||||
@@ -88,7 +88,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D
|
||||
} else {
|
||||
Assert(!"unexpected attrib class");
|
||||
}
|
||||
} else if (attrib->attrib_kind == DW_Attrib_Null) {
|
||||
} else if (attrib->attrib_kind == DW_AttribKind_Null) {
|
||||
type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ internal Rng1U64List
|
||||
d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag)
|
||||
{
|
||||
// collect non-contiguous range
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_Attrib_Ranges);
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_AttribKind_Ranges);
|
||||
|
||||
// debase ranges
|
||||
for (Rng1U64Node *range_n = ranges.first; range_n != 0; range_n = range_n->next) {
|
||||
@@ -111,17 +111,17 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag
|
||||
}
|
||||
|
||||
// collect contiguous range
|
||||
DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_LowPc);
|
||||
DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_HighPc);
|
||||
if (lo_pc_attrib->attrib_kind != DW_Attrib_Null && hi_pc_attrib->attrib_kind != DW_Attrib_Null) {
|
||||
U64 lo_pc = dw_address_from_attrib_ptr(input, cu, lo_pc_attrib);
|
||||
DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_AttribKind_LowPc);
|
||||
DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_AttribKind_HighPc);
|
||||
if (lo_pc_attrib->attrib_kind != DW_AttribKind_Null && hi_pc_attrib->attrib_kind != DW_AttribKind_Null) {
|
||||
U64 lo_pc = dw_address_from_attrib(input, cu, lo_pc_attrib);
|
||||
|
||||
U64 hi_pc;
|
||||
DW_AttribClass hi_pc_class = dw_value_class_from_attrib(cu, hi_pc_attrib);
|
||||
if (hi_pc_class == DW_AttribClass_Address) {
|
||||
hi_pc = dw_address_from_attrib_ptr(input, cu, hi_pc_attrib);
|
||||
hi_pc = dw_address_from_attrib(input, cu, hi_pc_attrib);
|
||||
} else if (hi_pc_class == DW_AttribClass_Const) {
|
||||
hi_pc = dw_const_u64_from_attrib_ptr(input, cu, hi_pc_attrib);
|
||||
hi_pc = dw_const_u64_from_attrib(input, cu, hi_pc_attrib);
|
||||
hi_pc += lo_pc;
|
||||
} else {
|
||||
AssertAlways(!"undefined attrib encoding");
|
||||
@@ -148,12 +148,12 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input
|
||||
RDIM_TypeList list = {0};
|
||||
B32 has_vargs = 0;
|
||||
for (DW_TagNode *i = cur_node->first_child; i != 0; i = i->sibling) {
|
||||
if (i->tag.kind == DW_Tag_FormalParameter) {
|
||||
if (i->tag.kind == DW_TagKind_FormalParameter) {
|
||||
RDIM_TypeNode *n = push_array(scratch.arena, RDIM_TypeNode, 1);
|
||||
n->v = d2r_type_from_attrib(arena, type_table, input, cu, i->tag, DW_Attrib_Type);
|
||||
n->v = d2r_type_from_attrib(arena, type_table, input, cu, i->tag, DW_AttribKind_Type);
|
||||
SLLQueuePush(list.first, list.last, n);
|
||||
++list.count;
|
||||
} else if (i->tag.kind == DW_Tag_UnspecifiedParameters) {
|
||||
} else if (i->tag.kind == DW_TagKind_UnspecifiedParameters) {
|
||||
has_vargs = 1;
|
||||
}
|
||||
}
|
||||
@@ -590,9 +590,9 @@ SLLStackPush(stack, f); \
|
||||
// find ref tag
|
||||
DW_TagNode *tag_node = dw_tag_node_from_info_off(cu, type_info_off);
|
||||
DW_Tag tag = tag_node->tag;
|
||||
if (tag.kind == DW_Tag_BaseType) {
|
||||
if (tag.kind == DW_TagKind_BaseType) {
|
||||
// extract encoding attribute
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_Encoding);
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_Encoding);
|
||||
|
||||
// DW_ATE -> RDI_EvalTypeGroup
|
||||
switch (encoding) {
|
||||
@@ -601,7 +601,7 @@ SLLStackPush(stack, f); \
|
||||
case DW_ATE_UnsignedChar:
|
||||
case DW_ATE_Unsigned: out = RDI_EvalTypeGroup_U; break;
|
||||
case DW_ATE_Float: {
|
||||
U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize);
|
||||
U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_ByteSize);
|
||||
switch (byte_size) {
|
||||
case 4: out = RDI_EvalTypeGroup_F32; break;
|
||||
case 8: out = RDI_EvalTypeGroup_F64; break;
|
||||
@@ -864,7 +864,7 @@ d2r_locset_from_attrib(Arena *arena,
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
// extract location list from attrib
|
||||
DW_LocList loclist = dw_loclist_from_attrib_ptr(scratch.arena, input, cu, attrib);
|
||||
DW_LocList loclist = dw_loclist_from_attrib(scratch.arena, input, cu, attrib);
|
||||
|
||||
// convert location list to RDIM location set
|
||||
for (DW_LocNode *loc_n = loclist.first; loc_n != 0; loc_n = loc_n->next) {
|
||||
@@ -876,7 +876,7 @@ d2r_locset_from_attrib(Arena *arena,
|
||||
scratch_end(scratch);
|
||||
} else if (attrib_class == DW_AttribClass_ExprLoc) {
|
||||
// extract expression from attrib
|
||||
String8 expr = dw_exprloc_from_attrib_ptr(input, cu, attrib);
|
||||
String8 expr = dw_exprloc_from_attrib(input, cu, attrib);
|
||||
|
||||
// convert expression and inherit life-time ranges from enclosed scope
|
||||
RDIM_Location *location = d2r_transpile_expression(arena, input, image_base, cu->address_size, arch, cu->addr_lu, cu, expr);
|
||||
@@ -902,8 +902,8 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
{
|
||||
RDIM_LocationSet locset = {0};
|
||||
|
||||
B32 has_const_value = dw_tag_has_attrib(input, cu, tag, DW_Attrib_ConstValue);
|
||||
B32 has_location = dw_tag_has_attrib(input, cu, tag, DW_Attrib_Location);
|
||||
B32 has_const_value = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_ConstValue);
|
||||
B32 has_location = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_Location);
|
||||
|
||||
if (has_const_value && has_location) {
|
||||
// TODO: error handling
|
||||
@@ -912,7 +912,7 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
|
||||
if (has_const_value) {
|
||||
// extract const value
|
||||
U64 const_value = dw_u64_from_attrib(input, cu, tag, DW_Attrib_ConstValue);
|
||||
U64 const_value = dw_u64_from_attrib(input, cu, tag, DW_AttribKind_ConstValue);
|
||||
|
||||
// make value byte code
|
||||
RDIM_EvalBytecode bc = {0};
|
||||
@@ -928,7 +928,7 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
rdim_location_set_push_case(arena, scopes, &locset, range_n->v, loc);
|
||||
}
|
||||
} else if (has_location) {
|
||||
locset = d2r_locset_from_attrib(arena, input, cu, scopes, curr_scope, image_base, arch, tag, DW_Attrib_Location);
|
||||
locset = d2r_locset_from_attrib(arena, input, cu, scopes, curr_scope, image_base, arch, tag, DW_AttribKind_Location);
|
||||
}
|
||||
|
||||
return locset;
|
||||
@@ -1058,7 +1058,7 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D
|
||||
|
||||
// update scope hierarchy
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine || parent_tag_kind == DW_Tag_LexicalBlock) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram || parent_tag_kind == DW_TagKind_InlinedSubroutine || parent_tag_kind == DW_TagKind_LexicalBlock) {
|
||||
RDIM_Scope *parent = tag_stack->next->scope;
|
||||
|
||||
scope->parent_scope = parent;
|
||||
@@ -1202,9 +1202,9 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
DW_LineTableParseResult *cu_line_tables = push_array(scratch.arena, DW_LineTableParseResult, cu_ranges.count);
|
||||
for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) {
|
||||
DW_CompUnit *cu = &cu_arr[cu_idx];
|
||||
String8 cu_stmt_list = dw_line_ptr_from_attrib(&input, cu, cu->tag, DW_Attrib_StmtList);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name);
|
||||
String8 cu_stmt_list = dw_line_ptr_from_attrib(&input, cu, cu->tag, DW_AttribKind_StmtList);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_CompDir);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Name);
|
||||
cu_line_tables[cu_idx] = dw_parsed_line_table_from_data(scratch.arena, cu_stmt_list, &input, cu_dir, cu_name, cu->address_size, cu->str_offsets_lu);
|
||||
}
|
||||
ProfEnd();
|
||||
@@ -1327,8 +1327,8 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
// build tag hash table for abstract origin resolution
|
||||
cu->tag_ht = dw_make_tag_hash_table(comp_temp.arena, tag_tree);
|
||||
|
||||
String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_DwoName);
|
||||
String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_GNU_DwoName);
|
||||
String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_DwoName);
|
||||
String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_GNU_DwoName);
|
||||
if (dwo_name.size || gnu_dwo_name.size || cu->dwo_id) {
|
||||
// TODO: report that we dont support DWO
|
||||
continue;
|
||||
@@ -1337,10 +1337,10 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
// get unit's contribution ranges
|
||||
RDIM_Rng1U64List cu_voff_ranges = d2r_voff_ranges_from_cu_info_off(cu_contrib_map, cu_ranges.v[cu_idx].min);
|
||||
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir);
|
||||
String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Producer);
|
||||
DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_Attrib_Language);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Name);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_CompDir);
|
||||
String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Producer);
|
||||
DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_AttribKind_Language);
|
||||
|
||||
RDIM_Unit *unit = rdim_unit_chunk_list_push(arena, &units, UNIT_CHUNK_CAP);
|
||||
unit->unit_name = cu_name;
|
||||
@@ -1371,14 +1371,14 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
B32 visit_children = 1;
|
||||
|
||||
switch (tag.kind) {
|
||||
case DW_Tag_Null: {
|
||||
case DW_TagKind_Null: {
|
||||
InvalidPath;
|
||||
} break;
|
||||
case DW_Tag_ClassType: {
|
||||
case DW_TagKind_ClassType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteClass;
|
||||
|
||||
@@ -1391,16 +1391,16 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
type->kind = RDI_TypeKind_Class;
|
||||
type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag);
|
||||
type->udt = udt;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_StructureType: {
|
||||
case DW_TagKind_StructureType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteStruct;
|
||||
|
||||
@@ -1418,11 +1418,11 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_UnionType: {
|
||||
case DW_TagKind_UnionType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteUnion;
|
||||
|
||||
@@ -1440,11 +1440,11 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_EnumerationType: {
|
||||
case DW_TagKind_EnumerationType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteEnum;
|
||||
|
||||
@@ -1462,14 +1462,14 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_SubroutineType: {
|
||||
case DW_TagKind_SubroutineType: {
|
||||
// collect parameters
|
||||
RDIM_TypeList param_list = {0};
|
||||
for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) {
|
||||
if (n->tag.kind == DW_Tag_FormalParameter) {
|
||||
RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type);
|
||||
if (n->tag.kind == DW_TagKind_FormalParameter) {
|
||||
RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_AttribKind_Type);
|
||||
rdim_type_list_push(comp_temp.arena, ¶m_list, param_type);
|
||||
} else if (n->tag.kind == DW_Tag_UnspecifiedParameters) {
|
||||
} else if (n->tag.kind == DW_TagKind_UnspecifiedParameters) {
|
||||
rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type);
|
||||
} else {
|
||||
// TODO: error handling
|
||||
@@ -1478,7 +1478,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
}
|
||||
|
||||
// init proceudre type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Function;
|
||||
type->byte_size = arch_addr_size;
|
||||
@@ -1488,14 +1488,14 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
|
||||
visit_children = 0;
|
||||
} break;
|
||||
case DW_Tag_Typedef: {
|
||||
case DW_TagKind_Typedef: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Alias;
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_BaseType: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding);
|
||||
case DW_TagKind_BaseType: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_Encoding);
|
||||
U64 byte_size = dw_byte_size_from_tag(&input, cu, tag);
|
||||
|
||||
// convert base type encoding to RDI version
|
||||
@@ -1602,18 +1602,18 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Alias;
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
type->direct_type = base_type;
|
||||
} break;
|
||||
case DW_Tag_PointerType: {
|
||||
RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
case DW_TagKind_PointerType: {
|
||||
RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Allocated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Associated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_AddressClass));
|
||||
|
||||
U64 byte_size = arch_addr_size;
|
||||
if (cu->version == DW_Version_5 || cu->relaxed) {
|
||||
@@ -1625,39 +1625,39 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
type->byte_size = byte_size;
|
||||
type->direct_type = direct_type;
|
||||
} break;
|
||||
case DW_Tag_RestrictType: {
|
||||
case DW_TagKind_RestrictType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Restrict;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_VolatileType: {
|
||||
case DW_TagKind_VolatileType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Volatile;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_ConstType: {
|
||||
case DW_TagKind_ConstType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Const;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_ArrayType: {
|
||||
case DW_TagKind_ArrayType: {
|
||||
// * DWARF vs RDI Array Type Graph *
|
||||
//
|
||||
// For example lets take following decl:
|
||||
@@ -1668,7 +1668,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
//
|
||||
// foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2]
|
||||
// \
|
||||
// -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4]
|
||||
// -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_TagKind_Subrange [4]
|
||||
// \
|
||||
// -> (B1) DW_TAG_BaseType (int)
|
||||
//
|
||||
@@ -1688,7 +1688,7 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
U64 subrange_count = 0;
|
||||
RDIM_Type *t = type;
|
||||
for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) {
|
||||
if (n->tag.kind != DW_Tag_SubrangeType) {
|
||||
if (n->tag.kind != DW_TagKind_SubrangeType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected tag");
|
||||
continue;
|
||||
@@ -1707,19 +1707,19 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
|
||||
// resolve array lower bound
|
||||
U64 lower_bound = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) {
|
||||
lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound);
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_LowerBound)) {
|
||||
lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_LowerBound);
|
||||
} else {
|
||||
lower_bound = dw_pick_default_lower_bound(cu_lang);
|
||||
}
|
||||
|
||||
// resolve array upper bound
|
||||
U64 upper_bound = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) {
|
||||
U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count);
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_Count)) {
|
||||
U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_Count);
|
||||
upper_bound = lower_bound + count;
|
||||
} else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) {
|
||||
upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound);
|
||||
} else if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_UpperBound)) {
|
||||
upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_UpperBound);
|
||||
// turn upper bound into exclusive range
|
||||
upper_bound += 1;
|
||||
} else {
|
||||
@@ -1731,18 +1731,18 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
}
|
||||
|
||||
Assert(t->direct_type == 0);
|
||||
t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
visit_children = 0;
|
||||
} break;
|
||||
case DW_Tag_SubrangeType: {
|
||||
case DW_TagKind_SubrangeType: {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected tag");
|
||||
} break;
|
||||
case DW_Tag_Inheritance: {
|
||||
case DW_TagKind_Inheritance: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_StructureType &&
|
||||
parent_node->tag.kind != DW_Tag_ClassType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_StructureType &&
|
||||
parent_node->tag.kind != DW_TagKind_ClassType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
@@ -1750,32 +1750,32 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
RDIM_Type *parent = tag_stack->next->type;
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt);
|
||||
member->kind = RDI_MemberKind_Base;
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation));
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_AttribKind_DataMemberLocation));
|
||||
} break;
|
||||
case DW_Tag_Enumerator: {
|
||||
case DW_TagKind_Enumerator: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_EnumerationType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_EnumerationType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
|
||||
RDIM_Type *type = tag_stack->next->type;
|
||||
RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_ConstValue);
|
||||
} break;
|
||||
case DW_Tag_Member: {
|
||||
case DW_TagKind_Member: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_StructureType &&
|
||||
parent_node->tag.kind != DW_Tag_ClassType &&
|
||||
parent_node->tag.kind != DW_Tag_UnionType &&
|
||||
parent_node->tag.kind != DW_Tag_EnumerationType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_StructureType &&
|
||||
parent_node->tag.kind != DW_TagKind_ClassType &&
|
||||
parent_node->tag.kind != DW_TagKind_UnionType &&
|
||||
parent_node->tag.kind != DW_TagKind_EnumerationType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
|
||||
DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation);
|
||||
DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_AttribKind_DataMemberLocation);
|
||||
DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location);
|
||||
if (data_member_location_class == DW_AttribClass_LocList) {
|
||||
AssertAlways(!"UDT member with multiple locations are not supported");
|
||||
@@ -1784,19 +1784,19 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
RDIM_Type *type = tag_stack->next->type;
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt);
|
||||
member->kind = RDI_MemberKind_DataField;
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_DataMemberLocation);
|
||||
} break;
|
||||
case DW_Tag_SubProgram: {
|
||||
DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline);
|
||||
case DW_TagKind_SubProgram: {
|
||||
DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_AttribKind_Inline);
|
||||
switch (inl) {
|
||||
case DW_Inl_NotInlined: {
|
||||
U64 param_count = 0;
|
||||
RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count);
|
||||
|
||||
// get return type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// fill out proc type
|
||||
RDIM_Type *proc_type = d2r_create_type(arena, type_table);
|
||||
@@ -1808,12 +1808,12 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
|
||||
// get container type
|
||||
RDIM_Type *container_type = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) {
|
||||
container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType);
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_ContainingType)) {
|
||||
container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_ContainingType);
|
||||
}
|
||||
|
||||
// get frame base expression
|
||||
String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase);
|
||||
String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_AttribKind_FrameBase);
|
||||
|
||||
// get proc container symbol
|
||||
RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP );
|
||||
@@ -1824,20 +1824,20 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
root_scope->symbol = proc;
|
||||
|
||||
// fill out proc
|
||||
proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External);
|
||||
proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName);
|
||||
proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_External);
|
||||
proc->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_LinkageName);
|
||||
proc->type = proc_type;
|
||||
proc->container_symbol = 0;
|
||||
proc->container_type = container_type;
|
||||
proc->root_scope = root_scope;
|
||||
proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_Attrib_FrameBase);
|
||||
proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_AttribKind_FrameBase);
|
||||
|
||||
// sub program with user-defined parent tag is a method
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) {
|
||||
if (parent_tag_kind == DW_TagKind_ClassType || parent_tag_kind == DW_TagKind_StructureType) {
|
||||
RDI_MemberKind member_kind = RDI_MemberKind_NULL;
|
||||
DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality);
|
||||
DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_Virtuality);
|
||||
switch (virtuality) {
|
||||
case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break;
|
||||
case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break;
|
||||
@@ -1849,8 +1849,8 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt);
|
||||
member->kind = member_kind;
|
||||
member->type = type;
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
} else if (parent_tag_kind != DW_Tag_CompileUnit) {
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
} else if (parent_tag_kind != DW_TagKind_CompileUnit) {
|
||||
//AssertAlways(!"unexpected tag");
|
||||
}
|
||||
|
||||
@@ -1864,12 +1864,12 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_InlinedSubroutine: {
|
||||
case DW_TagKind_InlinedSubroutine: {
|
||||
U64 param_count = 0;
|
||||
RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count);
|
||||
|
||||
// get return type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// fill out proc type
|
||||
RDIM_Type *proc_type = d2r_create_type(arena, type_table);
|
||||
@@ -1881,13 +1881,13 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
|
||||
// get container type
|
||||
RDIM_Type *owner = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) {
|
||||
owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType);
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_ContainingType)) {
|
||||
owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_ContainingType);
|
||||
}
|
||||
|
||||
// fill out inline site
|
||||
RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP);
|
||||
inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
inline_site->type = proc_type;
|
||||
inline_site->owner = owner;
|
||||
inline_site->line_table = 0;
|
||||
@@ -1897,14 +1897,14 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges);
|
||||
root_scope->inline_site = inline_site;
|
||||
} break;
|
||||
case DW_Tag_Variable: {
|
||||
String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
case DW_TagKind_Variable: {
|
||||
String8 name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram ||
|
||||
parent_tag_kind == DW_Tag_InlinedSubroutine ||
|
||||
parent_tag_kind == DW_Tag_LexicalBlock) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram ||
|
||||
parent_tag_kind == DW_TagKind_InlinedSubroutine ||
|
||||
parent_tag_kind == DW_TagKind_LexicalBlock) {
|
||||
RDIM_Scope *scope = tag_stack->next->scope;
|
||||
RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope);
|
||||
local->kind = RDI_LocalKind_Variable;
|
||||
@@ -1920,52 +1920,52 @@ d2r_convert(Arena *arena, RDIM_LocalState *local_state, RC_Context *in)
|
||||
}
|
||||
|
||||
RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP);
|
||||
gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External);
|
||||
gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_External);
|
||||
gvar->name = name;
|
||||
gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName);
|
||||
gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_LinkageName);
|
||||
gvar->type = type;
|
||||
//gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_Attrib_Location);
|
||||
//gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_AttribKind_Location);
|
||||
gvar->container_symbol = 0;
|
||||
gvar->container_type = 0; // TODO: NotImplemented;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_FormalParameter: {
|
||||
case DW_TagKind_FormalParameter: {
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram || parent_tag_kind == DW_TagKind_InlinedSubroutine) {
|
||||
RDIM_Scope *scope = tag_stack->next->scope;
|
||||
RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope);
|
||||
param->kind = RDI_LocalKind_Parameter;
|
||||
param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
param->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
param->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag);
|
||||
} else {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"this is a local variable");
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_LexicalBlock: {
|
||||
if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) {
|
||||
case DW_TagKind_LexicalBlock: {
|
||||
if (tag_stack->next->cur_node->tag.kind == DW_TagKind_SubProgram ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_TagKind_InlinedSubroutine ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_TagKind_LexicalBlock) {
|
||||
Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag);
|
||||
d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges);
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_CallSite: {
|
||||
case DW_TagKind_CallSite: {
|
||||
// TODO
|
||||
} break;
|
||||
case DW_Tag_CallSiteParameter: {
|
||||
case DW_TagKind_CallSiteParameter: {
|
||||
// TODO
|
||||
} break;
|
||||
case DW_Tag_Label:
|
||||
case DW_Tag_CompileUnit:
|
||||
case DW_Tag_UnspecifiedParameters:
|
||||
case DW_TagKind_Label:
|
||||
case DW_TagKind_CompileUnit:
|
||||
case DW_TagKind_UnspecifiedParameters:
|
||||
break;
|
||||
case DW_Tag_Namespace: break;
|
||||
case DW_Tag_ImportedDeclaration: break;
|
||||
case DW_Tag_PtrToMemberType: break;
|
||||
case DW_Tag_TemplateTypeParameter: break;
|
||||
case DW_Tag_ReferenceType: break;
|
||||
case DW_TagKind_Namespace: break;
|
||||
case DW_TagKind_ImportedDeclaration: break;
|
||||
case DW_TagKind_PtrToMemberType: break;
|
||||
case DW_TagKind_TemplateTypeParameter: break;
|
||||
case DW_TagKind_ReferenceType: break;
|
||||
default: NotImplemented; break;
|
||||
}
|
||||
|
||||
|
||||
+14
-14
@@ -4934,29 +4934,29 @@ elf_print_dwarf_expressions(Arena *arena, String8List *out, String8 indent, Stri
|
||||
SLLStackPush(tag_stack, n);
|
||||
}
|
||||
|
||||
if (tag.kind == DW_Tag_Null) {
|
||||
if (tag.kind == DW_TagKind_Null) {
|
||||
if (tag_stack) {
|
||||
struct TagNode *n = tag_stack;
|
||||
if ((n->tag.kind == DW_Tag_SubProgram || n->tag.kind == DW_Tag_LexicalBlock)) {
|
||||
if ((n->tag.kind == DW_TagKind_SubProgram || n->tag.kind == DW_TagKind_LexicalBlock)) {
|
||||
Assert(lexical_block_depth > 0);
|
||||
--lexical_block_depth;
|
||||
}
|
||||
SLLStackPop(tag_stack);
|
||||
SLLStackPush(free_tags, n);
|
||||
}
|
||||
} else if (tag.kind == DW_Tag_LexicalBlock || tag.kind == DW_Tag_SubProgram) {
|
||||
} else if (tag.kind == DW_TagKind_LexicalBlock || tag.kind == DW_TagKind_SubProgram) {
|
||||
++lexical_block_depth;
|
||||
if (tag.kind == DW_Tag_SubProgram) {
|
||||
String8 expr = dw_exprloc_from_attrib(&dwarf_input, &cu, tag, DW_Attrib_FrameBase);
|
||||
if (tag.kind == DW_TagKind_SubProgram) {
|
||||
String8 expr = dw_exprloc_from_attrib(&dwarf_input, &cu, tag, DW_AttribKind_FrameBase);
|
||||
if (expr.size > 0) {
|
||||
String8 expr_str = dw_format_expression_single_line(comp_temp.arena, expr, cu_base, cu.address_size, arch, cu.version, cu.ext, cu.format);
|
||||
}
|
||||
}
|
||||
} else if (tag.kind == DW_Tag_Variable || tag.kind == DW_Tag_FormalParameter) {
|
||||
} else if (tag.kind == DW_Tag_VariaKindble || tag.kind == DW_Tag_FormalParameter) {
|
||||
#if 0
|
||||
local_persist B32 is_global_var = 0;
|
||||
String8 name = dw_string_from_attrib(&dwarf_input, &cu, tag, DW_Attrib_Name);
|
||||
DW_Attrib *location_attrib = dw_attrib_from_tag(&dwarf_input, &cu, tag, DW_Attrib_Location);
|
||||
String8 name = dw_string_from_attrib(&dwarf_input, &cu, tag, DW_AttribKind_Name);
|
||||
DW_Attrib *location_attrib = dw_attrib_from_tag(&dwarf_input, &cu, tag, DW_AttribKind_Location);
|
||||
DW_AttribClass value_class = dw_value_class_from_attrib(&cu, location_attrib);
|
||||
if (value_class != DW_AttribClass_Null) {
|
||||
if (lexical_block_depth == 0) {
|
||||
@@ -4969,13 +4969,13 @@ elf_print_dwarf_expressions(Arena *arena, String8List *out, String8 indent, Stri
|
||||
|
||||
rd_indent();
|
||||
if (value_class == DW_AttribClass_LocListPtr || value_class == DW_AttribClass_LocList) {
|
||||
DW_LocList location = dw_loclist_from_attrib_ptr(comp_temp.arena, &dwarf_input, &cu, location_attrib);
|
||||
DW_LocList location = dw_loclist_from_attrib(comp_temp.arena, &dwarf_input, &cu, location_attrib);
|
||||
for (DW_LocNode *loc_n = location.first; loc_n != 0; loc_n = loc_n->next) {
|
||||
String8 expr_str = dw_format_expression_single_line(comp_temp.arena, loc_n->v.expr, cu_base, cu.address_size, arch, cu.version, cu.ext, cu.format);
|
||||
rd_printf("[%llx-%llx] %S", loc_n->v.range.min, loc_n->v.range.max, expr_str);
|
||||
}
|
||||
} else if (value_class == DW_AttribClass_ExprLoc) {
|
||||
String8 expr = dw_exprloc_from_attrib_ptr(&dwarf_input, &cu, location_attrib);
|
||||
String8 expr = dw_exprloc_from_attrib(&dwarf_input, &cu, location_attrib);
|
||||
String8 expr_str = dw_format_expression_single_line(comp_temp.arena, expr, cu_base, cu.address_size, arch, cu.version, cu.ext, cu.format);
|
||||
rd_printf("%S", expr_str);
|
||||
}
|
||||
@@ -4985,11 +4985,11 @@ elf_print_dwarf_expressions(Arena *arena, String8List *out, String8 indent, Stri
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (tag.kind == DW_Tag_LexicalBlock || tag.kind == DW_Tag_CompileUnit || tag.kind == DW_Tag_InlinedSubroutine || tag.kind == DW_Tag_SubProgram) {
|
||||
if (tag.kind == DW_TagKind_LexicalBlock || tag.kind == DW_TagKind_CompileUnit || tag.kind == DW_TagKind_InlinedSubroutine || tag.kind == DW_TagKind_SubProgram) {
|
||||
Temp temp = temp_begin(comp_temp.arena);
|
||||
DW_Attrib *ranges_attrib = dw_attrib_from_tag(&dwarf_input, &cu, tag, DW_Attrib_Ranges);
|
||||
if (ranges_attrib->attrib_kind == DW_Attrib_Ranges) {
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib_ptr(temp.arena, &dwarf_input, &cu, ranges_attrib);
|
||||
DW_Attrib *ranges_attrib = dw_attrib_from_tag(&dwarf_input, &cu, tag, DW_AttribKind_Ranges);
|
||||
if (ranges_attrib->attrib_kind == DW_AttribKind_Ranges) {
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib(temp.arena, &dwarf_input, &cu, ranges_attrib);
|
||||
}
|
||||
temp_end(temp);
|
||||
}
|
||||
|
||||
+143
-143
@@ -88,7 +88,7 @@ d2r_type_from_attrib(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, D
|
||||
} else {
|
||||
Assert(!"unexpected attrib class");
|
||||
}
|
||||
} else if (attrib->attrib_kind == DW_Attrib_Null) {
|
||||
} else if (attrib->attrib_kind == DW_AttribKind_Null) {
|
||||
type = rdim_builtin_type_from_kind(*type_table->types, RDI_TypeKind_NULL);
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ internal Rng1U64List
|
||||
d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag)
|
||||
{
|
||||
// collect non-contiguous range
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_Attrib_Ranges);
|
||||
Rng1U64List ranges = dw_rnglist_from_attrib(arena, input, cu, tag, DW_AttribKind_Ranges);
|
||||
|
||||
// debase ranges
|
||||
for (Rng1U64Node *range_n = ranges.first; range_n != 0; range_n = range_n->next) {
|
||||
@@ -111,9 +111,9 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag
|
||||
}
|
||||
|
||||
// collect contiguous range
|
||||
DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_LowPc);
|
||||
DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_Attrib_HighPc);
|
||||
if (lo_pc_attrib->attrib_kind != DW_Attrib_Null && hi_pc_attrib->attrib_kind != DW_Attrib_Null) {
|
||||
DW_Attrib *lo_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_AttribKind_LowPc);
|
||||
DW_Attrib *hi_pc_attrib = dw_attrib_from_tag(input, cu, tag, DW_AttribKind_HighPc);
|
||||
if (lo_pc_attrib->attrib_kind != DW_AttribKind_Null && hi_pc_attrib->attrib_kind != DW_AttribKind_Null) {
|
||||
U64 lo_pc = dw_address_from_attrib_ptr(input, cu, lo_pc_attrib);
|
||||
|
||||
U64 hi_pc;
|
||||
@@ -148,12 +148,12 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input
|
||||
RDIM_TypeList list = {0};
|
||||
B32 has_vargs = 0;
|
||||
for (DW_TagNode *i = cur_node->first_child; i != 0; i = i->sibling) {
|
||||
if (i->tag.kind == DW_Tag_FormalParameter) {
|
||||
if (i->tag.kind == DW_TagKind_FormalParameter) {
|
||||
RDIM_TypeNode *n = push_array(scratch.arena, RDIM_TypeNode, 1);
|
||||
n->v = d2r_type_from_attrib(arena, type_table, input, cu, i->tag, DW_Attrib_Type);
|
||||
n->v = d2r_type_from_attrib(arena, type_table, input, cu, i->tag, DW_AttribKind_Type);
|
||||
SLLQueuePush(list.first, list.last, n);
|
||||
++list.count;
|
||||
} else if (i->tag.kind == DW_Tag_UnspecifiedParameters) {
|
||||
} else if (i->tag.kind == DW_TagKind_UnspecifiedParameters) {
|
||||
has_vargs = 1;
|
||||
}
|
||||
}
|
||||
@@ -590,9 +590,9 @@ SLLStackPush(stack, f); \
|
||||
// find ref tag
|
||||
DW_TagNode *tag_node = dw_tag_node_from_info_off(cu, type_info_off);
|
||||
DW_Tag tag = tag_node->tag;
|
||||
if (tag.kind == DW_Tag_BaseType) {
|
||||
if (tag.kind == DW_TagKind_BaseType) {
|
||||
// extract encoding attribute
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_Encoding);
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_Encoding);
|
||||
|
||||
// DW_ATE -> RDI_EvalTypeGroup
|
||||
switch (encoding) {
|
||||
@@ -601,7 +601,7 @@ SLLStackPush(stack, f); \
|
||||
case DW_ATE_UnsignedChar:
|
||||
case DW_ATE_Unsigned: out = RDI_EvalTypeGroup_U; break;
|
||||
case DW_ATE_Float: {
|
||||
U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_Attrib_ByteSize);
|
||||
U64 byte_size = dw_const_u64_from_attrib(input, cu, tag, DW_AttribKind_ByteSize);
|
||||
switch (byte_size) {
|
||||
case 4: out = RDI_EvalTypeGroup_F32; break;
|
||||
case 8: out = RDI_EvalTypeGroup_F64; break;
|
||||
@@ -902,8 +902,8 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
{
|
||||
RDIM_LocationSet locset = {0};
|
||||
|
||||
B32 has_const_value = dw_tag_has_attrib(input, cu, tag, DW_Attrib_ConstValue);
|
||||
B32 has_location = dw_tag_has_attrib(input, cu, tag, DW_Attrib_Location);
|
||||
B32 has_const_value = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_ConstValue);
|
||||
B32 has_location = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_Location);
|
||||
|
||||
if (has_const_value && has_location) {
|
||||
// TODO: error handling
|
||||
@@ -912,7 +912,7 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
|
||||
if (has_const_value) {
|
||||
// extract const value
|
||||
U64 const_value = dw_u64_from_attrib(input, cu, tag, DW_Attrib_ConstValue);
|
||||
U64 const_value = dw_u64_from_attrib(input, cu, tag, DW_AttribKind_ConstValue);
|
||||
|
||||
// make value byte code
|
||||
RDIM_EvalBytecode bc = {0};
|
||||
@@ -928,7 +928,7 @@ d2r_var_locset_from_tag(Arena *arena,
|
||||
rdim_location_set_push_case(arena, scopes, &locset, range_n->v, loc);
|
||||
}
|
||||
} else if (has_location) {
|
||||
locset = d2r_locset_from_attrib(arena, input, cu, scopes, curr_scope, image_base, arch, tag, DW_Attrib_Location);
|
||||
locset = d2r_locset_from_attrib(arena, input, cu, scopes, curr_scope, image_base, arch, tag, DW_AttribKind_Location);
|
||||
}
|
||||
|
||||
return locset;
|
||||
@@ -1058,7 +1058,7 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D
|
||||
|
||||
// update scope hierarchy
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine || parent_tag_kind == DW_Tag_LexicalBlock) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram || parent_tag_kind == DW_TagKind_InlinedSubroutine || parent_tag_kind == DW_TagKind_LexicalBlock) {
|
||||
RDIM_Scope *parent = tag_stack->next->scope;
|
||||
|
||||
scope->parent_scope = parent;
|
||||
@@ -1211,9 +1211,9 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
DW_LineTableParseResult *cu_line_tables = push_array(scratch.arena, DW_LineTableParseResult, cu_ranges.count);
|
||||
for (U64 cu_idx = 0; cu_idx < cu_ranges.count; ++cu_idx) {
|
||||
DW_CompUnit *cu = &cu_arr[cu_idx];
|
||||
String8 cu_stmt_list = dw_line_ptr_from_attrib(&input, cu, cu->tag, DW_Attrib_StmtList);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name);
|
||||
String8 cu_stmt_list = dw_line_ptr_from_attrib(&input, cu, cu->tag, DW_AttribKind_StmtList);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_CompDir);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Name);
|
||||
cu_line_tables[cu_idx] = dw_parsed_line_table_from_data(scratch.arena, cu_stmt_list, &input, cu_dir, cu_name, cu->address_size, cu->str_offsets_lu);
|
||||
}
|
||||
ProfEnd();
|
||||
@@ -1336,8 +1336,8 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
// build tag hash table for abstract origin resolution
|
||||
cu->tag_ht = dw_make_tag_hash_table(comp_temp.arena, tag_tree);
|
||||
|
||||
String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_DwoName);
|
||||
String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_GNU_DwoName);
|
||||
String8 dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_DwoName);
|
||||
String8 gnu_dwo_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_GNU_DwoName);
|
||||
if (dwo_name.size || gnu_dwo_name.size || cu->dwo_id) {
|
||||
// TODO: report that we dont support DWO
|
||||
continue;
|
||||
@@ -1346,10 +1346,10 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
// get unit's contribution ranges
|
||||
RDIM_Rng1U64ChunkList cu_voff_ranges = d2r_voff_ranges_from_cu_info_off(cu_contrib_map, cu_ranges.v[cu_idx].min);
|
||||
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Name);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_CompDir);
|
||||
String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_Attrib_Producer);
|
||||
DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_Attrib_Language);
|
||||
String8 cu_name = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Name);
|
||||
String8 cu_dir = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_CompDir);
|
||||
String8 cu_prod = dw_string_from_attrib(&input, cu, cu->tag, DW_AttribKind_Producer);
|
||||
DW_Language cu_lang = dw_const_u64_from_attrib(&input, cu, cu->tag, DW_AttribKind_Language);
|
||||
|
||||
RDIM_Unit *unit = rdim_unit_chunk_list_push(arena, &units, UNIT_CHUNK_CAP);
|
||||
unit->unit_name = cu_name;
|
||||
@@ -1380,14 +1380,14 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
B32 visit_children = 1;
|
||||
|
||||
switch (tag.kind) {
|
||||
case DW_Tag_Null: {
|
||||
case DW_TagKind_Null: {
|
||||
InvalidPath;
|
||||
} break;
|
||||
case DW_Tag_ClassType: {
|
||||
case DW_TagKind_ClassType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteClass;
|
||||
|
||||
@@ -1400,16 +1400,16 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
type->kind = RDI_TypeKind_Class;
|
||||
type->byte_size = dw_byte_size_32_from_tag(&input, cu, tag);
|
||||
type->udt = udt;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_StructureType: {
|
||||
case DW_TagKind_StructureType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteStruct;
|
||||
|
||||
@@ -1427,11 +1427,11 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_UnionType: {
|
||||
case DW_TagKind_UnionType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteUnion;
|
||||
|
||||
@@ -1449,11 +1449,11 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_EnumerationType: {
|
||||
case DW_TagKind_EnumerationType: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_Declaration);
|
||||
B32 is_decl = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_Declaration);
|
||||
if (is_decl) {
|
||||
type->kind = RDI_TypeKind_IncompleteEnum;
|
||||
|
||||
@@ -1471,14 +1471,14 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
tag_stack->type = type;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_SubroutineType: {
|
||||
case DW_TagKind_SubroutineType: {
|
||||
// collect parameters
|
||||
RDIM_TypeList param_list = {0};
|
||||
for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) {
|
||||
if (n->tag.kind == DW_Tag_FormalParameter) {
|
||||
RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_Attrib_Type);
|
||||
if (n->tag.kind == DW_TagKind_FormalParameter) {
|
||||
RDIM_Type *param_type = d2r_type_from_attrib(arena, type_table, &input, cu, n->tag, DW_AttribKind_Type);
|
||||
rdim_type_list_push(comp_temp.arena, ¶m_list, param_type);
|
||||
} else if (n->tag.kind == DW_Tag_UnspecifiedParameters) {
|
||||
} else if (n->tag.kind == DW_TagKind_UnspecifiedParameters) {
|
||||
rdim_type_list_push(comp_temp.arena, ¶m_list, type_table->varg_type);
|
||||
} else {
|
||||
// TODO: error handling
|
||||
@@ -1487,7 +1487,7 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
}
|
||||
|
||||
// init proceudre type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Function;
|
||||
type->byte_size = arch_addr_size;
|
||||
@@ -1497,14 +1497,14 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
visit_children = 0;
|
||||
} break;
|
||||
case DW_Tag_Typedef: {
|
||||
case DW_TagKind_Typedef: {
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Alias;
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_BaseType: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Encoding);
|
||||
case DW_TagKind_BaseType: {
|
||||
DW_ATE encoding = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_Encoding);
|
||||
U64 byte_size = dw_byte_size_from_tag(&input, cu, tag);
|
||||
|
||||
// convert base type encoding to RDI version
|
||||
@@ -1611,18 +1611,18 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Alias;
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
type->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
type->direct_type = base_type;
|
||||
} break;
|
||||
case DW_Tag_PointerType: {
|
||||
RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
case DW_TagKind_PointerType: {
|
||||
RDIM_Type *direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Allocated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Associated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_AddressClass));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Allocated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Associated));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_AddressClass));
|
||||
|
||||
U64 byte_size = arch_addr_size;
|
||||
if (cu->version == DW_Version_5 || cu->relaxed) {
|
||||
@@ -1634,39 +1634,39 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
type->byte_size = byte_size;
|
||||
type->direct_type = direct_type;
|
||||
} break;
|
||||
case DW_Tag_RestrictType: {
|
||||
case DW_TagKind_RestrictType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Restrict;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_VolatileType: {
|
||||
case DW_TagKind_VolatileType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Volatile;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_ConstType: {
|
||||
case DW_TagKind_ConstType: {
|
||||
// TODO:
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_Attrib_Alignment));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Name));
|
||||
Assert(!dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_Alignment));
|
||||
|
||||
RDIM_Type *type = d2r_find_or_create_type_from_offset(arena, type_table, tag.info_off);
|
||||
type->kind = RDI_TypeKind_Modifier;
|
||||
type->byte_size = arch_addr_size;
|
||||
type->flags = RDI_TypeModifierFlag_Const;
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
type->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
} break;
|
||||
case DW_Tag_ArrayType: {
|
||||
case DW_TagKind_ArrayType: {
|
||||
// * DWARF vs RDI Array Type Graph *
|
||||
//
|
||||
// For example lets take following decl:
|
||||
@@ -1677,7 +1677,7 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
//
|
||||
// foo -> DW_TAG_ArrayType -> (A0) DW_TAG_Subrange [2]
|
||||
// \
|
||||
// -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_Tag_Subrange [4]
|
||||
// -> (B0) DW_TAG_PointerType -> (A1) DW_TAG_ArrayType -> DW_TAG_Subrange [3] -> DW_TagKind_Subrange [4]
|
||||
// \
|
||||
// -> (B1) DW_TAG_BaseType (int)
|
||||
//
|
||||
@@ -1697,7 +1697,7 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
U64 subrange_count = 0;
|
||||
RDIM_Type *t = type;
|
||||
for (DW_TagNode *n = cur_node->first_child; n != 0; n = n->sibling) {
|
||||
if (n->tag.kind != DW_Tag_SubrangeType) {
|
||||
if (n->tag.kind != DW_TagKind_SubrangeType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected tag");
|
||||
continue;
|
||||
@@ -1716,19 +1716,19 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
// resolve array lower bound
|
||||
U64 lower_bound = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_LowerBound)) {
|
||||
lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_LowerBound);
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_LowerBound)) {
|
||||
lower_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_LowerBound);
|
||||
} else {
|
||||
lower_bound = dw_pick_default_lower_bound(cu_lang);
|
||||
}
|
||||
|
||||
// resolve array upper bound
|
||||
U64 upper_bound = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_Count)) {
|
||||
U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_Count);
|
||||
if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_Count)) {
|
||||
U64 count = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_Count);
|
||||
upper_bound = lower_bound + count;
|
||||
} else if (dw_tag_has_attrib(&input, cu, n->tag, DW_Attrib_UpperBound)) {
|
||||
upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_Attrib_UpperBound);
|
||||
} else if (dw_tag_has_attrib(&input, cu, n->tag, DW_AttribKind_UpperBound)) {
|
||||
upper_bound = dw_u64_from_attrib(&input, cu, n->tag, DW_AttribKind_UpperBound);
|
||||
// turn upper bound into exclusive range
|
||||
upper_bound += 1;
|
||||
} else {
|
||||
@@ -1740,18 +1740,18 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
}
|
||||
|
||||
Assert(t->direct_type == 0);
|
||||
t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
t->direct_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
visit_children = 0;
|
||||
} break;
|
||||
case DW_Tag_SubrangeType: {
|
||||
case DW_TagKind_SubrangeType: {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected tag");
|
||||
} break;
|
||||
case DW_Tag_Inheritance: {
|
||||
case DW_TagKind_Inheritance: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_StructureType &&
|
||||
parent_node->tag.kind != DW_Tag_ClassType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_StructureType &&
|
||||
parent_node->tag.kind != DW_TagKind_ClassType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
@@ -1759,32 +1759,32 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
RDIM_Type *parent = tag_stack->next->type;
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, parent->udt);
|
||||
member->kind = RDI_MemberKind_Base;
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation));
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
member->off = safe_cast_u32(dw_const_u32_from_attrib(&input, cu, tag, DW_AttribKind_DataMemberLocation));
|
||||
} break;
|
||||
case DW_Tag_Enumerator: {
|
||||
case DW_TagKind_Enumerator: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_EnumerationType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_EnumerationType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
|
||||
RDIM_Type *type = tag_stack->next->type;
|
||||
RDIM_UDTEnumVal *member = rdim_udt_push_enum_val(arena, &udts, type->udt);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_ConstValue);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
member->val = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_ConstValue);
|
||||
} break;
|
||||
case DW_Tag_Member: {
|
||||
case DW_TagKind_Member: {
|
||||
DW_TagNode *parent_node = tag_stack->next->cur_node;
|
||||
if (parent_node->tag.kind != DW_Tag_StructureType &&
|
||||
parent_node->tag.kind != DW_Tag_ClassType &&
|
||||
parent_node->tag.kind != DW_Tag_UnionType &&
|
||||
parent_node->tag.kind != DW_Tag_EnumerationType) {
|
||||
if (parent_node->tag.kind != DW_TagKind_StructureType &&
|
||||
parent_node->tag.kind != DW_TagKind_ClassType &&
|
||||
parent_node->tag.kind != DW_TagKind_UnionType &&
|
||||
parent_node->tag.kind != DW_TagKind_EnumerationType) {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"unexpected parent tag");
|
||||
}
|
||||
|
||||
DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_Attrib_DataMemberLocation);
|
||||
DW_Attrib *data_member_location = dw_attrib_from_tag(&input, cu, tag, DW_AttribKind_DataMemberLocation);
|
||||
DW_AttribClass data_member_location_class = dw_value_class_from_attrib(cu, data_member_location);
|
||||
if (data_member_location_class == DW_AttribClass_LocList) {
|
||||
AssertAlways(!"UDT member with multiple locations are not supported");
|
||||
@@ -1793,19 +1793,19 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
RDIM_Type *type = tag_stack->next->type;
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt);
|
||||
member->kind = RDI_MemberKind_DataField;
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_DataMemberLocation);
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
member->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
member->off = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_DataMemberLocation);
|
||||
} break;
|
||||
case DW_Tag_SubProgram: {
|
||||
DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_Attrib_Inline);
|
||||
case DW_TagKind_SubProgram: {
|
||||
DW_InlKind inl = dw_u64_from_attrib(&input, cu, tag, DW_AttribKind_Inline);
|
||||
switch (inl) {
|
||||
case DW_Inl_NotInlined: {
|
||||
U64 param_count = 0;
|
||||
RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, cur_node, ¶m_count);
|
||||
|
||||
// get return type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// fill out proc type
|
||||
RDIM_Type *proc_type = d2r_create_type(arena, type_table);
|
||||
@@ -1817,12 +1817,12 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
// get container type
|
||||
RDIM_Type *container_type = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) {
|
||||
container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType);
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_ContainingType)) {
|
||||
container_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_ContainingType);
|
||||
}
|
||||
|
||||
// get frame base expression
|
||||
String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_Attrib_FrameBase);
|
||||
String8 frame_base_expr = dw_exprloc_from_attrib(&input, cu, tag, DW_AttribKind_FrameBase);
|
||||
|
||||
// get proc container symbol
|
||||
RDIM_Symbol *proc = rdim_symbol_chunk_list_push(arena, &procs, PROC_CHUNK_CAP );
|
||||
@@ -1833,20 +1833,20 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
root_scope->symbol = proc;
|
||||
|
||||
// fill out proc
|
||||
proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External);
|
||||
proc->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName);
|
||||
proc->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_External);
|
||||
proc->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
proc->link_name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_LinkageName);
|
||||
proc->type = proc_type;
|
||||
proc->container_symbol = 0;
|
||||
proc->container_type = container_type;
|
||||
proc->root_scope = root_scope;
|
||||
proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_Attrib_FrameBase);
|
||||
proc->frame_base = d2r_locset_from_attrib(arena, &input, cu, &scopes, root_scope, image_base, arch, tag, DW_AttribKind_FrameBase);
|
||||
|
||||
// sub program with user-defined parent tag is a method
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_ClassType || parent_tag_kind == DW_Tag_StructureType) {
|
||||
if (parent_tag_kind == DW_TagKind_ClassType || parent_tag_kind == DW_TagKind_StructureType) {
|
||||
RDI_MemberKind member_kind = RDI_MemberKind_NULL;
|
||||
DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_Attrib_Virtuality);
|
||||
DW_VirtualityKind virtuality = dw_const_u64_from_attrib(&input, cu, tag, DW_AttribKind_Virtuality);
|
||||
switch (virtuality) {
|
||||
case DW_VirtualityKind_None: member_kind = RDI_MemberKind_Method; break;
|
||||
case DW_VirtualityKind_Virtual: member_kind = RDI_MemberKind_VirtualMethod; break;
|
||||
@@ -1858,8 +1858,8 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
RDIM_UDTMember *member = rdim_udt_push_member(arena, &udts, type->udt);
|
||||
member->kind = member_kind;
|
||||
member->type = type;
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
} else if (parent_tag_kind != DW_Tag_CompileUnit) {
|
||||
member->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
} else if (parent_tag_kind != DW_TagKind_CompileUnit) {
|
||||
//AssertAlways(!"unexpected tag");
|
||||
}
|
||||
|
||||
@@ -1873,12 +1873,12 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_InlinedSubroutine: {
|
||||
case DW_TagKind_InlinedSubroutine: {
|
||||
U64 param_count = 0;
|
||||
RDIM_Type **params = d2r_collect_proc_params(arena, type_table, &input, cu, tag_stack->cur_node, ¶m_count);
|
||||
|
||||
// get return type
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
RDIM_Type *ret_type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
// fill out proc type
|
||||
RDIM_Type *proc_type = d2r_create_type(arena, type_table);
|
||||
@@ -1890,13 +1890,13 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
|
||||
// get container type
|
||||
RDIM_Type *owner = 0;
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_Attrib_ContainingType)) {
|
||||
owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_ContainingType);
|
||||
if (dw_tag_has_attrib(&input, cu, tag, DW_AttribKind_ContainingType)) {
|
||||
owner = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_ContainingType);
|
||||
}
|
||||
|
||||
// fill out inline site
|
||||
RDIM_InlineSite *inline_site = rdim_inline_site_chunk_list_push(arena, &inline_sites, INLINE_SITE_CHUNK_CAP);
|
||||
inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
inline_site->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
inline_site->type = proc_type;
|
||||
inline_site->owner = owner;
|
||||
inline_site->line_table = 0;
|
||||
@@ -1906,14 +1906,14 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
RDIM_Scope *root_scope = d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges);
|
||||
root_scope->inline_site = inline_site;
|
||||
} break;
|
||||
case DW_Tag_Variable: {
|
||||
String8 name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
case DW_TagKind_Variable: {
|
||||
String8 name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
RDIM_Type *type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram ||
|
||||
parent_tag_kind == DW_Tag_InlinedSubroutine ||
|
||||
parent_tag_kind == DW_Tag_LexicalBlock) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram ||
|
||||
parent_tag_kind == DW_TagKind_InlinedSubroutine ||
|
||||
parent_tag_kind == DW_TagKind_LexicalBlock) {
|
||||
RDIM_Scope *scope = tag_stack->next->scope;
|
||||
RDIM_Local *local = rdim_scope_push_local(arena, &scopes, tag_stack->next->scope);
|
||||
local->kind = RDI_LocalKind_Variable;
|
||||
@@ -1929,52 +1929,52 @@ d2r_convert(Arena *arena, ASYNC_Root *async_root, D2R_ConvertParams *params)
|
||||
}
|
||||
|
||||
RDIM_Symbol *gvar = rdim_symbol_chunk_list_push(arena, &gvars, GVAR_CHUNK_CAP);
|
||||
gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_Attrib_External);
|
||||
gvar->is_extern = dw_flag_from_attrib(&input, cu, tag, DW_AttribKind_External);
|
||||
gvar->name = name;
|
||||
gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_LinkageName);
|
||||
gvar->link_name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_LinkageName);
|
||||
gvar->type = type;
|
||||
//gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_Attrib_Location);
|
||||
//gvar->locset = d2r_locset_from_attrib(arena, &input, cu, &scopes, global_scope, image_base, arch, tag, DW_AttribKind_Location);
|
||||
gvar->container_symbol = 0;
|
||||
gvar->container_type = 0; // TODO: NotImplemented;
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_FormalParameter: {
|
||||
case DW_TagKind_FormalParameter: {
|
||||
DW_TagKind parent_tag_kind = tag_stack->next->cur_node->tag.kind;
|
||||
if (parent_tag_kind == DW_Tag_SubProgram || parent_tag_kind == DW_Tag_InlinedSubroutine) {
|
||||
if (parent_tag_kind == DW_TagKind_SubProgram || parent_tag_kind == DW_TagKind_InlinedSubroutine) {
|
||||
RDIM_Scope *scope = tag_stack->next->scope;
|
||||
RDIM_Local *param = rdim_scope_push_local(arena, &scopes, scope);
|
||||
param->kind = RDI_LocalKind_Parameter;
|
||||
param->name = dw_string_from_attrib(&input, cu, tag, DW_Attrib_Name);
|
||||
param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_Attrib_Type);
|
||||
param->name = dw_string_from_attrib(&input, cu, tag, DW_AttribKind_Name);
|
||||
param->type = d2r_type_from_attrib(arena, type_table, &input, cu, tag, DW_AttribKind_Type);
|
||||
param->locset = d2r_var_locset_from_tag(arena, &input, cu, &scopes, scope, image_base, arch, tag);
|
||||
} else {
|
||||
// TODO: error handling
|
||||
AssertAlways(!"this is a local variable");
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_LexicalBlock: {
|
||||
if (tag_stack->next->cur_node->tag.kind == DW_Tag_SubProgram ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_Tag_InlinedSubroutine ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_Tag_LexicalBlock) {
|
||||
case DW_TagKind_LexicalBlock: {
|
||||
if (tag_stack->next->cur_node->tag.kind == DW_TagKind_SubProgram ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_TagKind_InlinedSubroutine ||
|
||||
tag_stack->next->cur_node->tag.kind == DW_TagKind_LexicalBlock) {
|
||||
Rng1U64List ranges = d2r_range_list_from_tag(comp_temp.arena, &input, cu, image_base, tag);
|
||||
d2r_push_scope(arena, &scopes, SCOPE_CHUNK_CAP, tag_stack, ranges);
|
||||
}
|
||||
} break;
|
||||
case DW_Tag_CallSite: {
|
||||
case DW_TagKind_CallSite: {
|
||||
// TODO
|
||||
} break;
|
||||
case DW_Tag_CallSiteParameter: {
|
||||
case DW_TagKind_CallSiteParameter: {
|
||||
// TODO
|
||||
} break;
|
||||
case DW_Tag_Label:
|
||||
case DW_Tag_CompileUnit:
|
||||
case DW_Tag_UnspecifiedParameters:
|
||||
case DW_TagKind_Label:
|
||||
case DW_TagKind_CompileUnit:
|
||||
case DW_TagKind_UnspecifiedParameters:
|
||||
break;
|
||||
case DW_Tag_Namespace: break;
|
||||
case DW_Tag_ImportedDeclaration: break;
|
||||
case DW_Tag_PtrToMemberType: break;
|
||||
case DW_Tag_TemplateTypeParameter: break;
|
||||
case DW_Tag_ReferenceType: break;
|
||||
case DW_TagKind_Namespace: break;
|
||||
case DW_TagKind_ImportedDeclaration: break;
|
||||
case DW_TagKind_PtrToMemberType: break;
|
||||
case DW_TagKind_TemplateTypeParameter: break;
|
||||
case DW_TagKind_ReferenceType: break;
|
||||
default: NotImplemented; break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user