mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 05:48:40 +00:00
plug in dwarf dumping to radbin
This commit is contained in:
@@ -1545,7 +1545,7 @@ dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_In
|
|||||||
//~ rjf: Dump Entry Point
|
//~ rjf: Dump Entry Point
|
||||||
|
|
||||||
internal String8List
|
internal String8List
|
||||||
dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags)
|
dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_DumpSubsetFlags subset_flags)
|
||||||
{
|
{
|
||||||
String8List strings = {0};
|
String8List strings = {0};
|
||||||
String8 indent = str8_lit(" ");
|
String8 indent = str8_lit(" ");
|
||||||
@@ -1805,7 +1805,7 @@ dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, ExecutableI
|
|||||||
if(attrib_id == 0) { break; }
|
if(attrib_id == 0) { break; }
|
||||||
String8 attrib_str = dw_string_from_attrib_kind(temp.arena, DW_Version_Last, DW_Ext_All, attrib_id);
|
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);
|
String8 form_str = dw_string_from_form_kind(temp.arena, DW_Version_Last, form_id);
|
||||||
rd_printf(" attrib: { offset: 0x%I64x, kind: %S, form_kind: %S }\n", attrib_off, attrib_str, form_str);
|
dumpf(" attrib: { offset: 0x%I64x, kind: %S, form_kind: %S }\n", attrib_off, attrib_str, form_str);
|
||||||
}
|
}
|
||||||
dumpf("}\n");
|
dumpf("}\n");
|
||||||
temp_end(temp);
|
temp_end(temp);
|
||||||
|
|||||||
@@ -78,6 +78,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, ExecutableImageKind image_type, DW_DumpSubsetFlags subset_flags);
|
internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_DumpSubsetFlags subset_flags);
|
||||||
|
|
||||||
#endif // DWARF_DUMP_H
|
#endif // DWARF_DUMP_H
|
||||||
|
|||||||
+39
-6
@@ -845,6 +845,7 @@ rb_entry_point(CmdLine *cmdline)
|
|||||||
#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
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
|
||||||
fprintf(stderr, "-------------------------------------------------------------------------------\n\n");
|
fprintf(stderr, "-------------------------------------------------------------------------------\n\n");
|
||||||
|
|
||||||
@@ -852,6 +853,7 @@ rb_entry_point(CmdLine *cmdline)
|
|||||||
#define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n");
|
#define X(name, name_lower, title) fprintf(stderr, " - " #name_lower "\n");
|
||||||
DW_DumpSubset_XList
|
DW_DumpSubset_XList
|
||||||
#undef X
|
#undef X
|
||||||
|
fprintf(stderr, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: unpack dump subset flags
|
//- rjf: unpack dump subset flags
|
||||||
@@ -888,12 +890,46 @@ rb_entry_point(CmdLine *cmdline)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: dump input files in order
|
//- rjf: dump input files in order
|
||||||
String8List dump = {0};
|
|
||||||
for(RB_FileNode *n = input_files.first; n != 0; n = n->next)
|
for(RB_FileNode *n = input_files.first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
RB_File *f = n->v;
|
RB_File *f = n->v;
|
||||||
str8_list_pushf(arena, &output_blobs, "// %S (%S)\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)\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"));
|
||||||
|
|
||||||
|
//- rjf: unpack file parses
|
||||||
|
Arch arch = Arch_Null;
|
||||||
|
PE_BinInfo pe = {0};
|
||||||
|
ELF_BinInfo elf = {0};
|
||||||
|
DW_Input dw = {0};
|
||||||
|
{
|
||||||
|
if(f->format == RB_FileFormat_PE)
|
||||||
|
{
|
||||||
|
pe = pe_bin_info_from_data(arena, f->data);
|
||||||
|
arch = pe.arch;
|
||||||
|
}
|
||||||
|
if(f->format == RB_FileFormat_ELF32 ||
|
||||||
|
f->format == RB_FileFormat_ELF64)
|
||||||
|
{
|
||||||
|
elf = elf_bin_from_data(f->data);
|
||||||
|
arch = arch_from_elf_machine(elf.hdr.e_machine);
|
||||||
|
}
|
||||||
|
if(f->format_flags & RB_FileFormatFlag_HasDWARF)
|
||||||
|
{
|
||||||
|
if(f->format == RB_FileFormat_PE)
|
||||||
|
{
|
||||||
|
String8 raw_sections = str8_substr(f->data, pe.section_table_range);
|
||||||
|
U64 section_count = raw_sections.size / sizeof(COFF_SectionHeader);
|
||||||
|
COFF_SectionHeader *section_table = (COFF_SectionHeader *)raw_sections.str;
|
||||||
|
String8 string_table = str8_substr(f->data, pe.string_table_range);
|
||||||
|
dw = dw_input_from_coff_section_table(arena, f->data, string_table, section_count, section_table);
|
||||||
|
}
|
||||||
|
else if(f->format == RB_FileFormat_ELF32 ||
|
||||||
|
f->format == RB_FileFormat_ELF64)
|
||||||
|
{
|
||||||
|
dw = dw_input_from_elf_section_table(arena, f->data, &elf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//- rjf: dump file info based on format
|
//- rjf: dump file info based on format
|
||||||
switch(f->format)
|
switch(f->format)
|
||||||
{
|
{
|
||||||
@@ -964,14 +1000,11 @@ rb_entry_point(CmdLine *cmdline)
|
|||||||
{
|
{
|
||||||
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);
|
||||||
String8List dump = dw_dump_list_from_sections();
|
str8_list_concat_in_place(&output_blobs, &dump);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: join with output
|
|
||||||
str8_list_concat_in_place(&output_blobs, &dump);
|
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user