mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
minor fixes and improvements for DWARF dumper
This commit is contained in:
+1
-1
@@ -158,7 +158,7 @@ typedef enum DW_InlKindEnum
|
|||||||
X(FixedAdvancePc, 0x09) \
|
X(FixedAdvancePc, 0x09) \
|
||||||
X(SetPrologueEnd, 0x0A) \
|
X(SetPrologueEnd, 0x0A) \
|
||||||
X(SetEpilogueBegin, 0x0B) \
|
X(SetEpilogueBegin, 0x0B) \
|
||||||
X(SetIsa, 0x0C) \
|
X(SetIsa, 0x0C)
|
||||||
|
|
||||||
typedef U8 DW_StdOpcode;
|
typedef U8 DW_StdOpcode;
|
||||||
typedef enum DW_StdOpcodeEnum
|
typedef enum DW_StdOpcodeEnum
|
||||||
|
|||||||
+24
-24
@@ -960,18 +960,18 @@ DW_PRINTER(dw_print_line)
|
|||||||
{
|
{
|
||||||
String8List opcode_length_strings = numeric_str8_list_from_data(unit_temp.arena, 16, str8(vm->header.opcode_lens, vm->header.num_opcode_lens), 1);
|
String8List opcode_length_strings = numeric_str8_list_from_data(unit_temp.arena, 16, str8(vm->header.opcode_lens, vm->header.num_opcode_lens), 1);
|
||||||
String8 opcode_lengths_string = str8_list_join(arena, &opcode_length_strings, &(StringJoin){.sep = str8_lit(", ")});
|
String8 opcode_lengths_string = str8_list_join(arena, &opcode_length_strings, &(StringJoin){.sep = str8_lit(", ")});
|
||||||
dw_printf("version: %u\n", vm->header.version );
|
dw_printf("version: %u\n", vm->header.version );
|
||||||
dw_printf("line_table_size: %I64u\n", vm->header.unit_length );
|
dw_printf("line_table_size: %I64u\n", vm->header.unit_length );
|
||||||
dw_printf("address_size: %u\n", vm->header.address_size );
|
dw_printf("address_size: %u\n", vm->header.address_size );
|
||||||
dw_printf("segment_selector_size: %u\n", vm->header.segment_selector_size);
|
dw_printf("segment_selector_size: %u\n", vm->header.segment_selector_size);
|
||||||
dw_printf("header_length: %I64u\n", vm->header.header_length );
|
dw_printf("header_length: %I64u\n", vm->header.header_length );
|
||||||
dw_printf("min_instruction_length: %u\n", vm->header.min_inst_len );
|
dw_printf("min_instruction_length: %u\n", vm->header.min_inst_len );
|
||||||
dw_printf("max_ops_for_instruction: %u\n", vm->header.max_ops_for_inst );
|
dw_printf("max_ops_for_instruction: %u\n", vm->header.max_ops_for_inst );
|
||||||
dw_printf("default_is_stmt: %u\n", vm->header.default_is_stmt );
|
dw_printf("default_is_stmt: %u\n", vm->header.default_is_stmt );
|
||||||
dw_printf("line_base: %d\n", vm->header.line_base );
|
dw_printf("line_base: %d\n", vm->header.line_base );
|
||||||
dw_printf("line_range: %u\n", vm->header.line_range );
|
dw_printf("line_range: %u\n", vm->header.line_range );
|
||||||
dw_printf("opcode_base: %u\n", vm->header.opcode_base );
|
dw_printf("opcode_base: %u\n", vm->header.opcode_base );
|
||||||
dw_printf("opcode_lengths: { %S }\n", opcode_lengths_string );
|
dw_printf("opcode_lengths: { %S }\n", opcode_lengths_string );
|
||||||
}
|
}
|
||||||
dw_unindent();
|
dw_unindent();
|
||||||
dw_printf("}\n");
|
dw_printf("}\n");
|
||||||
@@ -983,11 +983,9 @@ DW_PRINTER(dw_print_line)
|
|||||||
{
|
{
|
||||||
dw_printf("// %-4s %-30s\n", "No.", "Name");
|
dw_printf("// %-4s %-30s\n", "No.", "Name");
|
||||||
dw_printf("// ---- ------------------------------\n");
|
dw_printf("// ---- ------------------------------\n");
|
||||||
String8 cu_comp_dir = dw_string_from_tag_attrib_kind(input, cu, cu->tag, DW_AttribKind_CompDir);
|
|
||||||
dw_printf("{ %-4I64u %-30S }\n", 0, cu_comp_dir);
|
|
||||||
for EachIndex(dir_idx, vm->header.dir_table.count)
|
for EachIndex(dir_idx, vm->header.dir_table.count)
|
||||||
{
|
{
|
||||||
dw_printf("{ %-4I64u %-30S }\n", dir_idx+1, vm->header.dir_table.v[dir_idx]);
|
dw_printf("{ %-4I64u %-30S }\n", dir_idx, vm->header.dir_table.v[dir_idx]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dw_unindent();
|
dw_unindent();
|
||||||
@@ -998,7 +996,7 @@ DW_PRINTER(dw_print_line)
|
|||||||
dw_printf("{\n");
|
dw_printf("{\n");
|
||||||
dw_indent();
|
dw_indent();
|
||||||
{
|
{
|
||||||
dw_printf("// %-4s %-8s %-8s %-33s %-8s %-20s\n", "No.", "Dir No.", "Time", "MD5", "Size", "Name");
|
dw_printf("// %-4s %-8s %-8s %-33s %-8s %-20s\n", "No.", "Dir No.", "Time", "MD5", "Size", "Path");
|
||||||
dw_printf("// ---- -------- -------- --------------------------------- -------- --------------------\n");
|
dw_printf("// ---- -------- -------- --------------------------------- -------- --------------------\n");
|
||||||
for EachIndex(file_idx, vm->header.file_table.count)
|
for EachIndex(file_idx, vm->header.file_table.count)
|
||||||
{
|
{
|
||||||
@@ -1006,11 +1004,11 @@ DW_PRINTER(dw_print_line)
|
|||||||
dw_printf("{ %-4I64u %-8I64u %-8I64u %016I64x-%016I64x %-8I64u %-20S }\n",
|
dw_printf("{ %-4I64u %-8I64u %-8I64u %016I64x-%016I64x %-8I64u %-20S }\n",
|
||||||
file_idx,
|
file_idx,
|
||||||
file->dir_idx,
|
file->dir_idx,
|
||||||
file->modify_time,
|
file->time_stamp,
|
||||||
file->md5_digest.u64[1],
|
file->md5.u64[1],
|
||||||
file->md5_digest.u64[0],
|
file->md5.u64[0],
|
||||||
file->file_size,
|
file->size,
|
||||||
file->file_name);
|
file->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dw_unindent();
|
dw_unindent();
|
||||||
@@ -1038,8 +1036,10 @@ DW_PRINTER(dw_print_line)
|
|||||||
str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%08I64x:", global_opcode_off);
|
str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%08I64x:", global_opcode_off);
|
||||||
|
|
||||||
// push opcode id
|
// push opcode id
|
||||||
String8 opcode_str = dw_string_from_std_opcode(opcode_temp.arena, vm->opcode);
|
if (vm->opcode != 0) {
|
||||||
str8_list_push(arena, &opcode_fmt, opcode_str);
|
String8 opcode_str = dw_string_from_std_opcode(opcode_temp.arena, vm->opcode);
|
||||||
|
str8_list_pushf(arena, &opcode_fmt, "%-11S:", opcode_str);
|
||||||
|
}
|
||||||
|
|
||||||
// print operands
|
// print operands
|
||||||
switch(vm->opcode)
|
switch(vm->opcode)
|
||||||
@@ -1103,7 +1103,7 @@ DW_PRINTER(dw_print_line)
|
|||||||
}break;
|
}break;
|
||||||
case DW_StdOpcode_ExtendedOpcode:
|
case DW_StdOpcode_ExtendedOpcode:
|
||||||
{
|
{
|
||||||
str8_list_push(opcode_temp.arena, &opcode_fmt, dw_string_from_ext_opcode(opcode_temp.arena, vm->ext_opcode));
|
str8_list_pushf(opcode_temp.arena, &opcode_fmt, "%S*", dw_string_from_ext_opcode(opcode_temp.arena, vm->ext_opcode));
|
||||||
//str8_list_pushf(opcode_temp.arena, &opcode_fmt, "length: %u", length);
|
//str8_list_pushf(opcode_temp.arena, &opcode_fmt, "length: %u", length);
|
||||||
switch(vm->ext_opcode)
|
switch(vm->ext_opcode)
|
||||||
{
|
{
|
||||||
|
|||||||
+34
-11
@@ -341,6 +341,21 @@ rb_thread_entry_point(void *p)
|
|||||||
}
|
}
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(file_format == RB_FileFormat_COFF_OBJ || file_format == RB_FileFormat_COFF_BigOBJ)
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
COFF_FileHeaderInfo coff_obj = coff_file_header_info_from_data(file_data);
|
||||||
|
String8 string_table = str8_substr(file_data, coff_obj.string_table_range);
|
||||||
|
U64 section_count = coff_obj.section_count_no_null;
|
||||||
|
COFF_SectionHeader *section_table = (COFF_SectionHeader *)str8_substr(file_data, coff_obj.section_table_range).str;
|
||||||
|
if(dw_is_dwarf_present_coff_section_table(string_table, section_count, section_table))
|
||||||
|
{
|
||||||
|
log_infof("DWARF data detected in %S (%S)\n", n->string, rb_file_format_display_name_table[file_format]);
|
||||||
|
file_format_flags |= RB_FileFormatFlag_HasDWARF;
|
||||||
|
}
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
//- rjf: ELF => check if contains DWARF
|
//- rjf: ELF => check if contains DWARF
|
||||||
@@ -1101,22 +1116,30 @@ rb_thread_entry_point(void *p)
|
|||||||
lane_sync();
|
lane_sync();
|
||||||
|
|
||||||
//- rjf: unpack file parses
|
//- rjf: unpack file parses
|
||||||
Arch arch = Arch_Null;
|
Arch arch = Arch_Null;
|
||||||
PE_BinInfo pe = {0};
|
PE_BinInfo pe = {0};
|
||||||
ELF_Bin elf = {0};
|
ELF_Bin elf = {0};
|
||||||
DW_Input dw = {0};
|
COFF_FileHeaderInfo coff_obj = {0};
|
||||||
U64 eh_frame_hdr_vaddr = 0;
|
DW_Input dw = {0};
|
||||||
U64 eh_frame_vaddr = 0;
|
U64 eh_frame_hdr_vaddr = 0;
|
||||||
String8 eh_frame_hdr = {0};
|
U64 eh_frame_vaddr = 0;
|
||||||
String8 eh_frame = {0};
|
String8 eh_frame_hdr = {0};
|
||||||
|
String8 eh_frame = {0};
|
||||||
{
|
{
|
||||||
if(f->format == RB_FileFormat_PE)
|
if(f->format == RB_FileFormat_PE)
|
||||||
{
|
{
|
||||||
pe = pe_bin_info_from_data(arena, f->data);
|
pe = pe_bin_info_from_data(arena, f->data);
|
||||||
arch = pe.arch;
|
arch = pe.arch;
|
||||||
}
|
}
|
||||||
if(f->format == RB_FileFormat_ELF32 ||
|
else if(f->format == RB_FileFormat_COFF_OBJ || f->format == RB_FileFormat_COFF_BigOBJ)
|
||||||
f->format == RB_FileFormat_ELF64)
|
{
|
||||||
|
coff_obj = coff_file_header_info_from_data(f->data);
|
||||||
|
String8 string_table = str8_substr(f->data, coff_obj.string_table_range);
|
||||||
|
U64 section_count = coff_obj.section_count_no_null;
|
||||||
|
COFF_SectionHeader *section_table = (COFF_SectionHeader *)str8_substr(f->data, coff_obj.section_table_range).str;
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
elf = elf_bin_from_data(arena, f->data);
|
elf = elf_bin_from_data(arena, f->data);
|
||||||
arch = arch_from_elf_machine(elf.hdr.e_machine);
|
arch = arch_from_elf_machine(elf.hdr.e_machine);
|
||||||
|
|||||||
Reference in New Issue
Block a user