mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 05:18:40 +00:00
copyright year
This commit is contained in:
+90
-90
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
internal U64
|
||||
@@ -49,10 +49,10 @@ internal U64
|
||||
dw_reg_size_from_code(Arch arch, DW_Reg reg_code)
|
||||
{
|
||||
switch (arch) {
|
||||
case Arch_Null: break;
|
||||
case Arch_x86: return dw_reg_size_from_code_x86(reg_code);
|
||||
case Arch_x64: return dw_reg_size_from_code_x64(reg_code);
|
||||
default: NotImplemented; break;
|
||||
case Arch_Null: break;
|
||||
case Arch_x86: return dw_reg_size_from_code_x86(reg_code);
|
||||
case Arch_x64: return dw_reg_size_from_code_x64(reg_code);
|
||||
default: NotImplemented; break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -61,10 +61,10 @@ internal U64
|
||||
dw_reg_pos_from_code(Arch arch, DW_Reg reg_code)
|
||||
{
|
||||
switch (arch) {
|
||||
case Arch_Null: break;
|
||||
case Arch_x86: return dw_reg_pos_from_code_x86(reg_code);
|
||||
case Arch_x64: return dw_reg_pos_from_code_x64(reg_code);
|
||||
default: NotImplemented; break;
|
||||
case Arch_Null: break;
|
||||
case Arch_x86: return dw_reg_pos_from_code_x86(reg_code);
|
||||
case Arch_x64: return dw_reg_pos_from_code_x64(reg_code);
|
||||
default: NotImplemented; break;
|
||||
}
|
||||
return max_U64;
|
||||
}
|
||||
@@ -73,9 +73,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v2(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V2_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -84,9 +84,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v3(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V3_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -95,9 +95,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v4(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V4_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -106,9 +106,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_v5(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_V5_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -117,9 +117,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_gnu(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_GNU_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -128,9 +128,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_llvm(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_LLVM_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -139,9 +139,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_apple(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_APPLE_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -150,9 +150,9 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind_mips(DW_AttribKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
#define X(_N,_C) case DW_Attrib_##_N: return _C;
|
||||
DW_AttribKind_ClassFlags_MIPS_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ internal DW_AttribClass
|
||||
dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
{
|
||||
DW_AttribClass result = DW_AttribClass_Null;
|
||||
|
||||
|
||||
while (ext) {
|
||||
U64 z = 64-clz64(ext);
|
||||
if (z == 0) {
|
||||
@@ -169,7 +169,7 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
}
|
||||
U64 flag = 1 << (z-1);
|
||||
ext &= ~flag;
|
||||
|
||||
|
||||
switch (flag) {
|
||||
case DW_Ext_Null: break;
|
||||
case DW_Ext_GNU: result = dw_attrib_class_from_attrib_kind_gnu(k); break;
|
||||
@@ -178,12 +178,12 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
case DW_Ext_MIPS: result = dw_attrib_class_from_attrib_kind_mips(k); break;
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
|
||||
|
||||
if (result != DW_AttribClass_Null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result == DW_AttribClass_Null) {
|
||||
switch (ver) {
|
||||
case DW_Version_Null: break;
|
||||
@@ -195,19 +195,19 @@ dw_attrib_class_from_attrib_kind(DW_Version ver, DW_Ext ext, DW_AttribKind k)
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
internal DW_AttribClass
|
||||
dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k)
|
||||
{
|
||||
#define X(_N,_C) case DW_Form_##_N: return _C;
|
||||
|
||||
#define X(_N,_C) case DW_Form_##_N: return _C;
|
||||
|
||||
switch (k) {
|
||||
DW_Form_AttribClass_GNU_XList(X)
|
||||
}
|
||||
|
||||
|
||||
switch (ver) {
|
||||
case DW_Version_5: {
|
||||
switch (k) {
|
||||
@@ -233,8 +233,8 @@ dw_attrib_class_from_form_kind(DW_Version ver, DW_FormKind k)
|
||||
} break;
|
||||
case DW_Version_Null: break;
|
||||
}
|
||||
#undef X
|
||||
|
||||
#undef X
|
||||
|
||||
return DW_AttribClass_Null;
|
||||
}
|
||||
|
||||
@@ -250,9 +250,9 @@ internal String8
|
||||
dw_name_string_from_section_kind(DW_SectionKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_L);
|
||||
DW_SectionKind_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return str8_zero();
|
||||
}
|
||||
@@ -261,9 +261,9 @@ internal String8
|
||||
dw_mach_name_string_from_section_kind(DW_SectionKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_M);
|
||||
DW_SectionKind_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return str8_zero();
|
||||
}
|
||||
@@ -272,9 +272,9 @@ internal String8
|
||||
dw_dwo_name_string_from_section_kind(DW_SectionKind k)
|
||||
{
|
||||
switch (k) {
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
|
||||
#define X(_N,_L,_M,_D) case DW_Section_##_N: return str8_lit(_D);
|
||||
DW_SectionKind_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return str8_zero();
|
||||
}
|
||||
@@ -301,10 +301,10 @@ 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 form_class = dw_attrib_class_from_form_kind(ver, form_kind);
|
||||
|
||||
|
||||
if(relaxed)
|
||||
{
|
||||
if(attrib_class == DW_AttribClass_Null || form_class == DW_AttribClass_Null)
|
||||
@@ -313,12 +313,12 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin
|
||||
form_class = dw_attrib_class_from_form_kind(DW_Version_Last, form_kind);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DW_AttribClass result = DW_AttribClass_Null;
|
||||
if(attrib_class != DW_AttribClass_Null && form_class != DW_AttribClass_Null)
|
||||
{
|
||||
result = DW_AttribClass_Undefined;
|
||||
|
||||
|
||||
for(U32 i = 0; i < 32; ++i)
|
||||
{
|
||||
U32 n = 1u << i;
|
||||
@@ -329,7 +329,7 @@ dw_pick_attrib_value_class(DW_Version ver, DW_Ext ext, B32 relaxed, DW_AttribKin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -338,50 +338,50 @@ dw_pick_default_lower_bound(DW_Language lang)
|
||||
{
|
||||
U64 lower_bound = max_U64;
|
||||
switch (lang) {
|
||||
case DW_Language_Null: break;
|
||||
case DW_Language_C89:
|
||||
case DW_Language_C:
|
||||
case DW_Language_CPlusPlus:
|
||||
case DW_Language_C99:
|
||||
case DW_Language_CPlusPlus03:
|
||||
case DW_Language_CPlusPlus11:
|
||||
case DW_Language_C11:
|
||||
case DW_Language_CPlusPlus14:
|
||||
case DW_Language_Java:
|
||||
case DW_Language_ObjC:
|
||||
case DW_Language_ObjCPlusPlus:
|
||||
case DW_Language_UPC:
|
||||
case DW_Language_D:
|
||||
case DW_Language_Python:
|
||||
case DW_Language_OpenCL:
|
||||
case DW_Language_Go:
|
||||
case DW_Language_Haskell:
|
||||
case DW_Language_OCaml:
|
||||
case DW_Language_Rust:
|
||||
case DW_Language_Swift:
|
||||
case DW_Language_Dylan:
|
||||
case DW_Language_RenderScript:
|
||||
case DW_Language_BLISS:
|
||||
lower_bound = 0;
|
||||
break;
|
||||
case DW_Language_Ada83:
|
||||
case DW_Language_Cobol74:
|
||||
case DW_Language_Cobol85:
|
||||
case DW_Language_Fortran77:
|
||||
case DW_Language_Fortran90:
|
||||
case DW_Language_Pascal83:
|
||||
case DW_Language_Modula2:
|
||||
case DW_Language_Ada95:
|
||||
case DW_Language_Fortran95:
|
||||
case DW_Language_PLI:
|
||||
case DW_Language_Modula3:
|
||||
case DW_Language_Julia:
|
||||
case DW_Language_Fortran03:
|
||||
case DW_Language_Fortran08:
|
||||
lower_bound = 1;
|
||||
default:
|
||||
NotImplemented;
|
||||
break;
|
||||
case DW_Language_Null: break;
|
||||
case DW_Language_C89:
|
||||
case DW_Language_C:
|
||||
case DW_Language_CPlusPlus:
|
||||
case DW_Language_C99:
|
||||
case DW_Language_CPlusPlus03:
|
||||
case DW_Language_CPlusPlus11:
|
||||
case DW_Language_C11:
|
||||
case DW_Language_CPlusPlus14:
|
||||
case DW_Language_Java:
|
||||
case DW_Language_ObjC:
|
||||
case DW_Language_ObjCPlusPlus:
|
||||
case DW_Language_UPC:
|
||||
case DW_Language_D:
|
||||
case DW_Language_Python:
|
||||
case DW_Language_OpenCL:
|
||||
case DW_Language_Go:
|
||||
case DW_Language_Haskell:
|
||||
case DW_Language_OCaml:
|
||||
case DW_Language_Rust:
|
||||
case DW_Language_Swift:
|
||||
case DW_Language_Dylan:
|
||||
case DW_Language_RenderScript:
|
||||
case DW_Language_BLISS:
|
||||
lower_bound = 0;
|
||||
break;
|
||||
case DW_Language_Ada83:
|
||||
case DW_Language_Cobol74:
|
||||
case DW_Language_Cobol85:
|
||||
case DW_Language_Fortran77:
|
||||
case DW_Language_Fortran90:
|
||||
case DW_Language_Pascal83:
|
||||
case DW_Language_Modula2:
|
||||
case DW_Language_Ada95:
|
||||
case DW_Language_Fortran95:
|
||||
case DW_Language_PLI:
|
||||
case DW_Language_Modula3:
|
||||
case DW_Language_Julia:
|
||||
case DW_Language_Fortran03:
|
||||
case DW_Language_Fortran08:
|
||||
lower_bound = 1;
|
||||
default:
|
||||
NotImplemented;
|
||||
break;
|
||||
}
|
||||
return lower_bound;
|
||||
}
|
||||
|
||||
+1356
-1356
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
internal B32
|
||||
@@ -8,22 +8,22 @@ dw_is_dwarf_present_coff_section_table(String8 raw_image,
|
||||
COFF_SectionHeader *section_table)
|
||||
{
|
||||
B32 is_dwarf_present = 0;
|
||||
|
||||
|
||||
for (U64 i = 0; i < section_count; ++i) {
|
||||
COFF_SectionHeader *header = §ion_table[i];
|
||||
String8 name = coff_name_from_section_header(string_table, header);
|
||||
|
||||
|
||||
DW_SectionKind s = dw_section_kind_from_string(name);
|
||||
if (s == DW_Section_Null) {
|
||||
s = dw_section_dwo_kind_from_string(name);
|
||||
}
|
||||
|
||||
|
||||
is_dwarf_present = s != DW_Section_Null;
|
||||
if (is_dwarf_present) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return is_dwarf_present;
|
||||
}
|
||||
|
||||
@@ -36,19 +36,19 @@ dw_input_from_coff_section_table(Arena *arena,
|
||||
{
|
||||
DW_Input input = {0};
|
||||
B32 sect_status[ArrayCount(input.sec)] = {0};
|
||||
|
||||
|
||||
for (U64 i = 0; i < section_count; ++i) {
|
||||
COFF_SectionHeader *header = §ion_table[i];
|
||||
Rng1U64 raw_data_range = rng_1u64(header->foff, header->foff + header->fsize);
|
||||
String8 name = coff_name_from_section_header(string_table, header);
|
||||
|
||||
|
||||
DW_SectionKind s = dw_section_kind_from_string(name);
|
||||
B32 is_dwo = 0;
|
||||
if (s == DW_Section_Null) {
|
||||
s = dw_section_dwo_kind_from_string(name);
|
||||
is_dwo = 1;
|
||||
}
|
||||
|
||||
|
||||
if (s != DW_Section_Null) {
|
||||
if (sect_status[s]) {
|
||||
Assert(!"too many debug sections with identical name, picking first");
|
||||
@@ -61,7 +61,7 @@ dw_input_from_coff_section_table(Arena *arena,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef DWARF_COFF_H
|
||||
|
||||
+32
-32
@@ -1,18 +1,18 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
internal String8
|
||||
dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op)
|
||||
{
|
||||
String8 result = {0};
|
||||
|
||||
#define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit;
|
||||
|
||||
#define X(_N,...) case DW_ExprOp_##_N: result = str8_lit(Stringify(_N)); goto exit;
|
||||
if (ext & DW_Ext_GNU) {
|
||||
switch (op) {
|
||||
DW_Expr_GNU_XList(X);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (ver) {
|
||||
case DW_Version_5: {
|
||||
switch (op) {
|
||||
@@ -32,13 +32,13 @@ dw_string_from_expr_op(Arena *arena, DW_Version ver, DW_Ext ext, DW_ExprOp op)
|
||||
case DW_Version_2:
|
||||
case DW_Version_1:
|
||||
case DW_Version_Null:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
#undef X
|
||||
|
||||
#undef X
|
||||
|
||||
result = push_str8f(arena, "%x", op);
|
||||
|
||||
exit:;
|
||||
|
||||
exit:;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -46,12 +46,12 @@ 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));
|
||||
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)
|
||||
#undef X
|
||||
DW_Tag_V5_XList(X)
|
||||
DW_Tag_GNU_XList(X)
|
||||
#undef X
|
||||
}
|
||||
return push_str8f(arena, "%llx", kind);
|
||||
}
|
||||
@@ -59,8 +59,8 @@ 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_Attrib_##_N: return str8_lit(Stringify(_N));
|
||||
|
||||
while (ext) {
|
||||
U64 z = 64-clz64(ext);
|
||||
if (z == 0) {
|
||||
@@ -68,7 +68,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
|
||||
}
|
||||
U64 flag = 1 << (z-1);
|
||||
ext &= ~flag;
|
||||
|
||||
|
||||
switch (flag) {
|
||||
case DW_Ext_Null: break;
|
||||
case DW_Ext_GNU: switch (kind) { DW_AttribKind_GNU_XList(X) } break;
|
||||
@@ -78,7 +78,7 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (ver) {
|
||||
case DW_Version_5: {
|
||||
switch (kind) {
|
||||
@@ -104,15 +104,15 @@ dw_string_from_attrib_kind(Arena *arena, DW_Version ver, DW_Ext ext, DW_AttribKi
|
||||
} // fall-through
|
||||
case DW_Version_Null: break;
|
||||
}
|
||||
#undef X
|
||||
|
||||
#undef X
|
||||
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
internal String8
|
||||
dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind)
|
||||
{
|
||||
#define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N));
|
||||
#define X(_N,...) case DW_Form_##_N: return str8_lit(Stringify(_N));
|
||||
switch (ver) {
|
||||
case DW_Version_5: {
|
||||
switch (kind) {
|
||||
@@ -132,7 +132,7 @@ dw_string_from_form_kind(Arena *arena, DW_Version ver, DW_FormKind kind)
|
||||
} // fall-through
|
||||
case DW_Version_Null: break;
|
||||
}
|
||||
#undef X
|
||||
#undef X
|
||||
String8 result = push_str8f(arena, "%x", kind);
|
||||
return result;
|
||||
}
|
||||
@@ -141,9 +141,9 @@ internal String8
|
||||
dw_string_from_language(Arena *arena, DW_Language kind)
|
||||
{
|
||||
switch (kind) {
|
||||
#define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N));
|
||||
#define X(_N,_ID) case DW_Language_##_N: return str8_lit(Stringify(_N));
|
||||
DW_Language_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return push_str8f(arena, "%x", kind);
|
||||
}
|
||||
@@ -196,9 +196,9 @@ internal String8
|
||||
dw_string_from_std_opcode(Arena *arena, DW_StdOpcode kind)
|
||||
{
|
||||
switch (kind) {
|
||||
#define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N));
|
||||
#define X(_N,_ID) case DW_StdOpcode_##_N: return str8_lit(Stringify(_N));
|
||||
DW_StdOpcode_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
return push_str8f(arena, "%x", kind);
|
||||
}
|
||||
@@ -207,9 +207,9 @@ internal String8
|
||||
dw_string_from_ext_opcode(Arena *arena, DW_ExtOpcode kind)
|
||||
{
|
||||
switch (kind) {
|
||||
#define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N));
|
||||
#define X(_N,_ID) case DW_ExtOpcode_##_N: return str8_lit(Stringify(_N));
|
||||
DW_ExtOpcode_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
default: InvalidPath; break;
|
||||
}
|
||||
return push_str8f(arena, "%x", kind);
|
||||
@@ -244,16 +244,16 @@ dw_string_from_register(Arena *arena, Arch arch, U64 reg_id)
|
||||
case Arch_Null: break;
|
||||
case Arch_x86: {
|
||||
switch (reg_id) {
|
||||
#define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break;
|
||||
#define X(_N, _ID, ...) case DW_RegX86_##_N: reg_str = str8_lit(Stringify(_N)); break;
|
||||
DW_Regs_X86_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
} break;
|
||||
case Arch_x64: {
|
||||
switch (reg_id) {
|
||||
#define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break;
|
||||
#define X(_N, _ID, ...) case DW_RegX64_##_N: reg_str = str8_lit(Stringify(_N)); break;
|
||||
DW_Regs_X64_XList(X)
|
||||
#undef X
|
||||
#undef X
|
||||
}
|
||||
} break;
|
||||
case Arch_arm32: NotImplemented; break;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef DWARF_ENUM_H
|
||||
|
||||
+16
-16
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
//- analyzers
|
||||
@@ -10,7 +10,7 @@ dw_expr__analyze_fast(void *base, Rng1U64 range, U64 text_section_base)
|
||||
DW_SimpleLoc result = {DW_SimpleLocKind_Empty};
|
||||
|
||||
String8 expr_data = str8((U8*)data+range.min, (U8*)data+range.max);
|
||||
|
||||
|
||||
U8 op = 0;
|
||||
if (str8_deserial_read_struct(expr_data, 0, &op)) {
|
||||
// step params
|
||||
@@ -52,11 +52,11 @@ dw_expr__analyze_fast(void *base, Rng1U64 range, U64 text_section_base)
|
||||
{
|
||||
U64 x = 0;
|
||||
step_cursor += dw_based_range_read(base, range, step_cursor, size_param, &x);
|
||||
|
||||
|
||||
if (is_signed) {
|
||||
x = extend_sign64(x, size_param);
|
||||
}
|
||||
|
||||
|
||||
result.kind = DW_SimpleLocKind_Address;
|
||||
result.addr = x;
|
||||
} break;
|
||||
@@ -180,7 +180,7 @@ internal DW_ExprAnalysis
|
||||
dw_expr__analyze_details(void *in_base, Rng1U64 in_range, DW_ExprMachineCallConfig *call_config)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
|
||||
DW_ExprAnalysis result = {0};
|
||||
|
||||
// are we resolving calls?
|
||||
@@ -560,7 +560,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
{
|
||||
#if 0
|
||||
Temp scratch = scratch_begin(&arena_optional, 1);
|
||||
|
||||
|
||||
DW_Location result = {0};
|
||||
|
||||
// setup stack
|
||||
@@ -655,7 +655,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
{
|
||||
U64 offset = 0;
|
||||
step_cursor += dw_based_range_read(base, range, step_cursor, 8, &offset);
|
||||
|
||||
|
||||
// earlier versions of GCC emit TLS offset with DW_ExprOp_Addr.
|
||||
B32 is_text_relative;
|
||||
{
|
||||
@@ -663,9 +663,9 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
dw_based_range_read_struct(base, range, step_cursor, &next_op);
|
||||
is_text_relative = (next_op != DW_ExprOp_GNU_PushTlsAddress);
|
||||
}
|
||||
|
||||
|
||||
U64 addr = offset;
|
||||
|
||||
|
||||
if (is_text_relative) {
|
||||
if (config->text_section_base != 0) {
|
||||
addr += *config->text_section_base;
|
||||
@@ -675,7 +675,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
goto finish;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dw_expr__stack_push(scratch.arena, &stack, addr);
|
||||
} break;
|
||||
|
||||
@@ -748,7 +748,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
U64 reg_idx = 0; S64 offset = 0;
|
||||
step_cursor += dw_based_range_read_uleb128(base, range, step_cursor, ®_idx);
|
||||
step_cursor += dw_based_range_read_sleb128(base, range, step_cursor, &offset);
|
||||
|
||||
|
||||
DW_RegsX64 *regs = config->regs;
|
||||
if (regs != 0) {
|
||||
if (reg_idx < ArrayCount(regs->r)) {
|
||||
@@ -816,7 +816,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
case DW_ExprOp_Deref:
|
||||
{
|
||||
U64 addr = dw_expr__stack_pop(&stack);
|
||||
|
||||
|
||||
B32 read_success = 0;
|
||||
if (config->read_memory) {
|
||||
U64 x = 0;
|
||||
@@ -825,7 +825,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
read_success = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!read_success) {
|
||||
stashed_loc.kind = DW_SimpleLocKind_Fail;
|
||||
stashed_loc.fail_kind = DW_LocFailKind_MissingMemory;
|
||||
@@ -838,10 +838,10 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
{
|
||||
U64 raw_size = 0;
|
||||
step_cursor += dw_based_range_read(base, range, step_cursor, 1, &raw_size);
|
||||
|
||||
|
||||
U64 size = ClampTop(raw_size, 8);
|
||||
U64 addr = dw_expr__stack_pop(&stack);
|
||||
|
||||
|
||||
B32 read_success = 0;
|
||||
if (config->read_memory) {
|
||||
U64 x = 0;
|
||||
@@ -883,7 +883,7 @@ dw_expr__eval(Arena *arena_optional, void *expr_base, Rng1U64 expr_range, DW_Exp
|
||||
case DW_ExprOp_FormTlsAddress:
|
||||
{
|
||||
S64 s = (S64)dw_expr__stack_pop(&stack);
|
||||
|
||||
|
||||
if (config->tls_address != 0) {
|
||||
U64 x = *config->tls_address + s;
|
||||
dw_expr__stack_push(scratch.arena, &stack, x);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef DWARF_EXPR_H
|
||||
|
||||
+872
-872
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef DWARF_PARSE_H
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
internal U64 dw_based_range_read(void *base, Rng1U64 range, U64 off, U64 size, void *out) { return 0; }
|
||||
@@ -25,9 +25,9 @@ dw_unwind_x64(String8 raw_text,
|
||||
{
|
||||
// TODO: What if ELF has two sections with instructions and pointer is ecnoded relative to .text2?
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
|
||||
DW_UnwindResult result = {0};
|
||||
|
||||
|
||||
dw_unwind_init_x64();
|
||||
|
||||
// rebase
|
||||
@@ -46,7 +46,7 @@ dw_unwind_x64(String8 raw_text,
|
||||
//- get frame info range
|
||||
void *frame_base = raw_eh_frame.str;
|
||||
Rng1U64 frame_range = rng_1u64(0, raw_eh_frame.size);
|
||||
|
||||
|
||||
//- section vaddrs
|
||||
U64 text_base_vaddr = text_vrange.min + rebase_voff_to_vaddr;
|
||||
U64 frame_base_voff = text_vrange.min;
|
||||
@@ -113,7 +113,7 @@ dw_unwind_x64(String8 raw_text,
|
||||
result.is_invalid = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// apply main row to modify the registers
|
||||
if (main_row != 0) {
|
||||
result = dw_unwind_x64__apply_frame_rules(raw_eh_frame, main_row, text_base_vaddr, read_memory, read_memory_ud, stack_pointer, regs);
|
||||
@@ -133,7 +133,7 @@ dw_unwind_x64__apply_frame_rules(String8 raw_eh_frame,
|
||||
DW_RegsX64 *regs)
|
||||
{
|
||||
DW_UnwindResult result = {0};
|
||||
|
||||
|
||||
U64 missed_read_addr = 0;
|
||||
|
||||
//- setup a dwarf expression machine
|
||||
@@ -375,7 +375,7 @@ dw_unwind_parse_pointer_x64(void *frame_base, Rng1U64 frame_range, DW_EhPtrCtx *
|
||||
case DW_EhPtrEnc_SLEB128:
|
||||
{
|
||||
U64 size = dw_based_range_read_sleb128(frame_base, frame_range, pointer_off,
|
||||
(S64*)&raw_pointer);
|
||||
(S64*)&raw_pointer);
|
||||
after_pointer_off = pointer_off + size;
|
||||
} break;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ internal DW_CFIRecords
|
||||
dw_unwind_eh_frame_cfi_from_ip_slow_x64(String8 raw_eh_frame, DW_EhPtrCtx *ptr_ctx, U64 ip_voff)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
|
||||
DW_CFIRecords result = {0};
|
||||
|
||||
DW_CIEUnpackedNode *cie_first = 0;
|
||||
@@ -622,7 +622,7 @@ dw_unwind_eh_frame_cfi_from_ip_slow_x64(String8 raw_eh_frame, DW_EhPtrCtx *ptr_c
|
||||
Rng1U64 rec_range = rng_1u64(rec_off, rec_opl);
|
||||
String8 raw_rec = str8_substr(raw_eh_frame, rec_range);
|
||||
|
||||
|
||||
|
||||
// discriminator
|
||||
U64 discrim_off = after_rec_size_off;
|
||||
U32 discrim = 0;
|
||||
@@ -839,7 +839,7 @@ internal B32
|
||||
dw_unwind_machine_run_to_ip_x64(void *base, Rng1U64 range, DW_CFIMachine *machine, U64 target_ip, DW_CFIRow *row)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
|
||||
B32 result = 0;
|
||||
|
||||
// pull out machine's equipment
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2024 Epic Games Tools
|
||||
// Copyright (c) Epic Games Tools
|
||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||
|
||||
#ifndef DWARF_UNWIND_H
|
||||
|
||||
Reference in New Issue
Block a user