pass over DWARF dumper

This commit is contained in:
Nikita Smith
2026-02-11 00:00:43 -08:00
parent 031e24e1aa
commit aaa5b0cb59
4 changed files with 1066 additions and 1230 deletions
+1014 -1156
View File
File diff suppressed because it is too large Load Diff
+39 -56
View File
@@ -4,69 +4,52 @@
#ifndef DWARF_DUMP_H #ifndef DWARF_DUMP_H
#define DWARF_DUMP_H #define DWARF_DUMP_H
typedef enum
{
DW_DumperCacheFlag_InfoRanges = (1 << 0),
DW_DumperCacheFlag_CuArr = (1 << 1),
DW_DumperCacheFlag_LineVmMap = (1 << 2),
DW_DumperCacheFlag_TagTrees = (1 << 3),
} DW_DumperCacheFlags;
typedef struct DW_Dumper
{
Arena *arena;
Arch arch;
B32 is_relaxed;
B32 is_verbose;
DW_Input *input;
DW_DumperCacheFlags cache_flags;
struct {
Rng1U64Array info_ranges;
DW_CompUnit *cu_arr;
HashTable *line_vm_map;
DW_TagTree *tag_trees;
} cache;
} DW_Dumper;
#define DW_PRINTER(name) void name(Arena *arena, String8List *strings, int indent, DW_Dumper *dumper)
typedef DW_PRINTER(DW_Printer);
//////////////////////////////// ////////////////////////////////
//~ rjf: Dump Subset Types
#define DW_DumpSubset_XList \ // cache
X(DebugInfo, debug_info, "DEBUG INFO") \ internal Rng1U64Array dw_get_info_ranges(DW_Dumper *dumper);
X(DebugAbbrev, debug_abbrev, "DEBUG ABBREV") \ internal DW_CompUnit * dw_get_cu_arr(DW_Dumper *dumper);
X(DebugLine, debug_line, "DEBUG LINE") \ internal HashTable * dw_get_line_vm_map(DW_Dumper *dumper);
X(DebugStr, debug_str, "DEBUG STR") \ internal DW_TagTree * dw_get_tag_trees(DW_Dumper *dumper);
X(DebugLoc, debug_loc, "DEBUG LOC") \
X(DebugRanges, debug_ranges, "DEBUG RANGES") \
X(DebugARanges, debug_aranges, "DEBUG ARANGES") \
X(DebugAddr, debug_addr, "DEBUG ADDR") \
X(DebugLocLists, debug_loclists, "DEBUG LOCLISTS") \
X(DebugRngLists, debug_rnglists, "DEBUG RNGLISTS") \
X(DebugPubNames, debug_pubnames, "DEBUG PUBNAMES") \
X(DebugPubTypes, debug_pubtypes, "DEBUG PUBTYPES") \
X(DebugLineStr, debug_linestr, "DEBUG LINESTR") \
X(DebugStrOffsets, debug_stroff, "DEBUG STROFF") \
X(DebugFrame, debug_frame, "DEBUG FRAME") \
typedef enum DW_DumpSubset
{
#define X(name, name_lower, title) DW_DumpSubset_##name,
DW_DumpSubset_XList
#undef X
}
DW_DumpSubset;
typedef U32 DW_DumpSubsetFlags;
enum
{
#define X(name, name_lower, title) DW_DumpSubsetFlag_##name = (1<<DW_DumpSubset_##name),
DW_DumpSubset_XList
#undef X
DW_DumpSubsetFlag_All = 0xffffffffu,
};
read_only global String8 dw_name_lowercase_from_dump_subset_table[] =
{
#define X(name, name_lower, title) str8_lit_comp(#name_lower),
DW_DumpSubset_XList
#undef X
};
read_only global String8 dw_name_title_from_dump_subset_table[] =
{
#define X(name, name_lower, title) str8_lit_comp(title),
DW_DumpSubset_XList
#undef X
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Stringification Helpers //~ rjf: Stringification Helpers
internal String8 dw_string_from_reg_off(Arena *arena, Arch arch, DW_Reg reg_idx, S64 reg_off);
internal String8 dw_string_from_reg(Arena *arena, Arch arch, DW_Reg reg_idx);
internal String8List dw_string_list_from_expression(Arena *arena, String8 raw_data, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format);
internal String8 dw_string_from_expression(Arena *arena, String8 expr, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format);
internal String8List dw_string_list_from_cfi_program(Arena *arena, U64 cu_base, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format, U64 pc_begin, DW_CIE *cie, DW_DecodePtr *decode_ptr_func, void *deocde_ptr_ud, String8 program); internal String8List dw_string_list_from_cfi_program(Arena *arena, U64 cu_base, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format, U64 pc_begin, DW_CIE *cie, DW_DecodePtr *decode_ptr_func, void *deocde_ptr_ud, String8 program);
internal String8List dw_string_list_from_expression (Arena *arena, String8 raw_data, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format);
internal String8 dw_string_from_cfa(Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFA cfa); internal String8 dw_string_from_reg_off (Arena *arena, Arch arch, DW_Reg reg_idx, S64 reg_off);
internal String8 dw_string_from_cfi_row(Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFI_Row *row); internal String8 dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib);
internal String8 dw_string_from_expression (Arena *arena, String8 expr, U64 cu_base, U64 addr_size, Arch arch, DW_Version ver, DW_Ext ext, DW_Format format);
internal String8 dw_string_from_cfa (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFA cfa);
internal String8 dw_string_from_cfi_row (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFI_Row *row);
#if 0 #if 0
internal void dw_print_eh_frame (Arena *arena, String8List *out, String8 indent, String8 raw_eh_frame, Arch arch, DW_Version ver, DW_Ext ext, EH_PtrCtx *ptr_ctx); internal void dw_print_eh_frame (Arena *arena, String8List *out, String8 indent, String8 raw_eh_frame, Arch arch, DW_Version ver, DW_Ext ext, EH_PtrCtx *ptr_ctx);
@@ -85,6 +68,6 @@ internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8
//////////////////////////////// ////////////////////////////////
//~ rjf: Dump Entry Point //~ rjf: Dump Entry Point
internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_DumpSubsetFlags subset_flags, B32 verbose); internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_SectionFlags dump_sections, B32 is_verbose);
#endif // DWARF_DUMP_H #endif // DWARF_DUMP_H
+11 -16
View File
@@ -1025,7 +1025,7 @@ rb_thread_entry_point(void *p)
fprintf(stderr, "-------------------------------------------------------------------------------\n\n"); fprintf(stderr, "-------------------------------------------------------------------------------\n\n");
fprintf(stderr, "RAD DEBUG INFO SUBSET NAMES\n\n"); fprintf(stderr, "RDI Sections:\n");
#define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n"); #define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n");
RDI_DumpSubset_XList RDI_DumpSubset_XList
#undef X #undef X
@@ -1033,9 +1033,9 @@ rb_thread_entry_point(void *p)
fprintf(stderr, "-------------------------------------------------------------------------------\n\n"); fprintf(stderr, "-------------------------------------------------------------------------------\n\n");
fprintf(stderr, "DWARF INFO SUBSET NAMES\n\n"); fprintf(stderr, "DWARF Sections:\n");
#define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n"); #define X(_N, _L, ...) fprintf(stderr, _L "\n");
DW_DumpSubset_XList DW_SectionKind_XList
#undef X #undef X
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
@@ -1044,7 +1044,7 @@ rb_thread_entry_point(void *p)
//- rjf: unpack dump subset flags //- rjf: unpack dump subset flags
RDI_DumpSubsetFlags rdi_dump_subset_flags = RDI_DumpSubsetFlag_All; RDI_DumpSubsetFlags rdi_dump_subset_flags = RDI_DumpSubsetFlag_All;
DW_DumpSubsetFlags dw_dump_subset_flags = DW_DumpSubsetFlag_All; DW_SectionFlags dw_dump_subset_flags = DW_SectionFlag_All;
EH_DumpSubsetFlags eh_dump_subset_flags = EH_DumpSubsetFlag_All; EH_DumpSubsetFlags eh_dump_subset_flags = EH_DumpSubsetFlag_All;
ELF_DumpSubsetFlags elf_dump_subset_flags = ELF_DumpSubsetFlag_All; ELF_DumpSubsetFlags elf_dump_subset_flags = ELF_DumpSubsetFlag_All;
{ {
@@ -1061,8 +1061,8 @@ rb_thread_entry_point(void *p)
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { rdi_dump_subset_flags |= RDI_DumpSubsetFlag_##name; } #define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { rdi_dump_subset_flags |= RDI_DumpSubsetFlag_##name; }
RDI_DumpSubset_XList RDI_DumpSubset_XList
#undef X #undef X
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { dw_dump_subset_flags |= DW_DumpSubsetFlag_##name; } #define X(_N, _L, ...) else if(str8_match(n->string, str8_skip(str8_lit(_L), 1), 0)) { dw_dump_subset_flags |= DW_SectionFlag_##_N; }
DW_DumpSubset_XList DW_SectionKind_XList
#undef X #undef X
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { eh_dump_subset_flags |= EH_DumpSubsetFlag_##name; } #define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { eh_dump_subset_flags |= EH_DumpSubsetFlag_##name; }
EH_DumpSubset_XList EH_DumpSubset_XList
@@ -1078,8 +1078,8 @@ rb_thread_entry_point(void *p)
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { rdi_dump_subset_flags &= ~RDI_DumpSubsetFlag_##name; } #define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { rdi_dump_subset_flags &= ~RDI_DumpSubsetFlag_##name; }
RDI_DumpSubset_XList RDI_DumpSubset_XList
#undef X #undef X
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { dw_dump_subset_flags &= ~DW_DumpSubsetFlag_##name; } #define X(_N, _L, ...) else if(str8_match(n->string, str8_skip(str8_lit(_L), 1), 0)) { dw_dump_subset_flags &= ~DW_SectionFlag_##_N; }
DW_DumpSubset_XList DW_SectionKind_XList
#undef X #undef X
#define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { eh_dump_subset_flags &= ~EH_DumpSubsetFlag_##name; } #define X(name, name_lower, title) else if(str8_match(n->string, str8_lit(#name_lower), 0)) { eh_dump_subset_flags &= ~EH_DumpSubsetFlag_##name; }
EH_DumpSubset_XList EH_DumpSubset_XList
@@ -1236,15 +1236,10 @@ rb_thread_entry_point(void *p)
if(lane_idx() == 0) if(lane_idx() == 0)
{ {
str8_list_pushf(arena, &output_blobs, "// %S (%S) (DWARF)\n\n", deterministic ? str8_skip_last_slash(f->path) : f->path, f->format ? rb_file_format_display_name_table[f->format] : str8_lit("Unsupported format")); str8_list_pushf(arena, &output_blobs, "// %S (%S) (DWARF)\n\n", deterministic ? str8_skip_last_slash(f->path) : f->path, f->format ? rb_file_format_display_name_table[f->format] : str8_lit("Unsupported format"));
String8List dump = dw_dump_list_from_sections(arena, &dw, arch, dw_dump_subset_flags, verbose);
str8_list_concat_in_place(&output_blobs, &dump);
} }
lane_sync(); lane_sync();
{
String8List dump = dw_dump_list_from_sections(arena, &dw, arch, dw_dump_subset_flags, verbose);
if(lane_idx() == 0)
{
str8_list_concat_in_place(&output_blobs, &dump);
}
}
} }
if(eh_dump_subset_flags) if(eh_dump_subset_flags)
+2 -2
View File
@@ -354,12 +354,12 @@ t_entry_point(CmdLine *cmdline)
crash_count += 1; crash_count += 1;
} }
if (result.status != T_RunStatus_Pass) { if (result.status == T_RunStatus_Fail) {
fprintf(stdout, " ERROR: %s:%d: condition: \"%s\"\n", result.fail_file, result.fail_line, result.fail_cond); fprintf(stdout, " ERROR: %s:%d: condition: \"%s\"\n", result.fail_file, result.fail_line, result.fail_cond);
} }
} }
fprintf(stdout, "---- Passed: %I64u, Failed: %I64u, Crashed: %I64u ----\n", pass_count, fail_count, crash_count); fprintf(stdout, "*** Passed: %I64u, Failed: %I64u, Crashed: %I64u ***\n", pass_count, fail_count, crash_count);
if (fail_count + crash_count != 0) { if (fail_count + crash_count != 0) {
fflush(stdout); fflush(stdout);