checkpoint on multi-lane / simplified dwarf parsing/conversion; fix incorrect assumption of relative in radbin

This commit is contained in:
Ryan Fleury
2026-04-23 14:25:50 -07:00
parent 6f624c10ad
commit 2623141fd4
25 changed files with 3154 additions and 2822 deletions
+3 -3
View File
@@ -64,7 +64,7 @@ typedef enum DW_SectionKindEnum
#define X(_N,...) DW_Section_##_N, #define X(_N,...) DW_Section_##_N,
DW_SectionKind_XList DW_SectionKind_XList
#undef X #undef X
DW_Section_Count DW_Section_COUNT
} DW_SectionKindEnum; } DW_SectionKindEnum;
typedef U32 DW_SectionFlags; typedef U32 DW_SectionFlags;
@@ -494,7 +494,7 @@ typedef enum DW_AttribClassEnum
X(GNU_StrpAlt, DW_AttribClass_String) X(GNU_StrpAlt, DW_AttribClass_String)
typedef U64 DW_FormKind; typedef U64 DW_FormKind;
typedef enum DW_FormEnum typedef enum DW_FormKindEnum
{ {
DW_Form_Null, DW_Form_Null,
#define X(_N, _ID) DW_Form_##_N = _ID, #define X(_N, _ID) DW_Form_##_N = _ID,
@@ -503,7 +503,7 @@ typedef enum DW_FormEnum
DW_Form_V5_XList DW_Form_V5_XList
DW_Form_GNU_XList DW_Form_GNU_XList
#undef X #undef X
} DW_FormEnum; } DW_FormKindEnum;
typedef struct DW_Form typedef struct DW_Form
{ {
+2 -2
View File
@@ -23,14 +23,14 @@ dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count,
return is_dwarf_present; return is_dwarf_present;
} }
internal DW_Input internal DW_Raw
dw_input_from_coff_section_table(Arena *arena, dw_input_from_coff_section_table(Arena *arena,
String8 raw_image, String8 raw_image,
String8 string_table, String8 string_table,
U64 section_count, U64 section_count,
COFF_SectionHeader *section_table) COFF_SectionHeader *section_table)
{ {
DW_Input input = {0}; DW_Raw input = {0};
B32 sect_status[ArrayCount(input.sec)] = {0}; B32 sect_status[ArrayCount(input.sec)] = {0};
for (U64 i = 0; i < section_count; ++i) { for (U64 i = 0; i < section_count; ++i) {
+1 -1
View File
@@ -5,7 +5,7 @@
#define DWARF_COFF_H #define DWARF_COFF_H
internal B32 dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, COFF_SectionHeader *section_table); internal B32 dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
internal DW_Input dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table); internal DW_Raw dw_input_from_coff_section_table(Arena *arena, String8 raw_image, String8 string_table, U64 section_count, COFF_SectionHeader *section_table);
#endif // DWARF_COFF_H #endif // DWARF_COFF_H
+19 -19
View File
@@ -633,7 +633,7 @@ dw_single_line_string_from_expression(Arena *arena, String8 raw_data, U64 cu_bas
} }
internal String8 internal String8
dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib) dw_string_from_attrib_value(Arena *arena, DW_Raw *input, Arch arch, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
@@ -778,7 +778,7 @@ dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUni
internal internal
DW_PRINTER(dw_print_abbrev) DW_PRINTER(dw_print_abbrev)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
DW_Section abbrev = input->sec[DW_Section_Abbrev]; DW_Section abbrev = input->sec[DW_Section_Abbrev];
@@ -842,7 +842,7 @@ DW_PRINTER(dw_print_abbrev)
} }
internal void internal void
dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_TagNode *root) dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_TagNode *root)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
@@ -897,7 +897,7 @@ dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Input
internal internal
DW_PRINTER(dw_print_info) DW_PRINTER(dw_print_info)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
Arch arch = dumper->arch; Arch arch = dumper->arch;
HashTable *line_vm_map = dw_get_line_vm_map(dumper); HashTable *line_vm_map = dw_get_line_vm_map(dumper);
Rng1U64Array cu_ranges = dw_get_info_ranges(dumper); Rng1U64Array cu_ranges = dw_get_info_ranges(dumper);
@@ -941,7 +941,7 @@ DW_PRINTER(dw_print_info)
DW_PRINTER(dw_print_line) DW_PRINTER(dw_print_line)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
B32 is_verbose = dumper->is_verbose; B32 is_verbose = dumper->is_verbose;
DW_CompUnit *cu_arr = dw_get_cu_arr(dumper); DW_CompUnit *cu_arr = dw_get_cu_arr(dumper);
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
@@ -1163,7 +1163,7 @@ DW_PRINTER(dw_print_line)
DW_PRINTER(dw_print_strings) DW_PRINTER(dw_print_strings)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
String8 data = input->sec[DW_Section_Str].data; String8 data = input->sec[DW_Section_Str].data;
for (U64 cursor = 0, read_size = 0; cursor < data.size; cursor += read_size) { for (U64 cursor = 0, read_size = 0; cursor < data.size; cursor += read_size) {
String8 string = {0}; String8 string = {0};
@@ -1174,7 +1174,7 @@ DW_PRINTER(dw_print_strings)
DW_PRINTER(dw_print_frame) DW_PRINTER(dw_print_frame)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
Arch arch = dumper->arch; Arch arch = dumper->arch;
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
HashTable *cie_ht = hash_table_init(scratch.arena, 0x2000); HashTable *cie_ht = hash_table_init(scratch.arena, 0x2000);
@@ -1275,7 +1275,7 @@ DW_PRINTER(dw_print_frame)
internal internal
DW_PRINTER(dw_print_debug_loc) DW_PRINTER(dw_print_debug_loc)
{ {
DW_Input *input = dumper->input; DW_Raw *input = dumper->input;
DW_TagTree *tag_trees = dw_get_tag_trees(dumper); DW_TagTree *tag_trees = dw_get_tag_trees(dumper);
DW_Section info = input->sec[DW_Section_Info]; DW_Section info = input->sec[DW_Section_Info];
DW_Section loc = input->sec[DW_Section_Loc]; DW_Section loc = input->sec[DW_Section_Loc];
@@ -1397,7 +1397,7 @@ DW_PRINTER(dw_print_debug_loc)
#if 0 #if 0
internal void internal void
dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed) dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -1503,7 +1503,7 @@ dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_In
} }
internal void internal void
dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -1592,7 +1592,7 @@ dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_I
} }
internal void internal void
dw_print_debug_addr(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_addr(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -1701,7 +1701,7 @@ dw_based_range_read_address(void *base, Rng1U64 range, U64 offset, Rng1U64Array
} }
internal void internal void
dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Rng1U64Array segment_virtual_ranges, Arch arch) dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Rng1U64Array segment_virtual_ranges, Arch arch)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -1854,7 +1854,7 @@ dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_
} }
internal void internal void
dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, Rng1U64Array segment_ranges) dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, Rng1U64Array segment_ranges)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -1993,7 +1993,7 @@ dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_
} }
internal void internal void
dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input, DW_SectionKind sec) dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input, DW_SectionKind sec)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -2055,19 +2055,19 @@ dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_I
} }
internal void internal void
dw_print_debug_pubnames(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_pubnames(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubNames); dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubNames);
} }
internal void internal void
dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_pubtypes(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubTypes); dw_format_string_table(arena, out, g_dw_indent, input, DW_Section_PubTypes);
} }
internal void internal void
dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -2097,7 +2097,7 @@ dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_
} }
internal void internal void
dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 g_dw_indent, DW_Input *input) dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 g_dw_indent, DW_Raw *input)
{ {
NotImplemented; NotImplemented;
#if 0 #if 0
@@ -2180,7 +2180,7 @@ read_only struct {
internal String8List internal String8List
dw_dump_list_from_sections(Arena *arena, dw_dump_list_from_sections(Arena *arena,
DW_Input *input, DW_Raw *input,
Arch arch, Arch arch,
DW_SectionFlags subset_flags, DW_SectionFlags subset_flags,
B32 is_verbose) B32 is_verbose)
+13 -13
View File
@@ -18,7 +18,7 @@ typedef struct DW_Dumper
Arch arch; Arch arch;
B32 is_relaxed; B32 is_relaxed;
B32 is_verbose; B32 is_verbose;
DW_Input *input; DW_Raw *input;
DW_DumperCacheFlags cache_flags; DW_DumperCacheFlags cache_flags;
struct { struct {
Rng1U64Array info_ranges; Rng1U64Array info_ranges;
@@ -46,28 +46,28 @@ internal String8List dw_string_list_from_cfi_program(Arena *arena, U64 cu_base,
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 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_reg_off (Arena *arena, Arch arch, DW_Reg reg_idx, S64 reg_off); internal String8 dw_string_from_reg_off (Arena *arena, Arch arch, DW_Reg reg_idx, S64 reg_off);
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_attrib_value(Arena *arena, DW_Raw *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_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_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); 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);
internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); internal void dw_print_debug_loc (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Input *input, Arch arch, ExecutableImageKind image_type, B32 relaxed); internal void dw_print_debug_ranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_aranges (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_addr (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges, Arch arch); internal void dw_print_debug_loclists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges, Arch arch);
internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges); internal void dw_print_debug_rnglists (Arena *arena, String8List *out, String8 indent, DW_Raw *input, Rng1U64Array segment_vranges);
internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Raw *input);
internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Input *input); internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Raw *input);
#endif #endif
//////////////////////////////// ////////////////////////////////
//~ rjf: Dump Entry Point //~ rjf: Dump Entry Point
internal String8List dw_dump_list_from_sections(Arena *arena, DW_Input *input, Arch arch, DW_SectionFlags dump_sections, B32 is_verbose); internal String8List dw_dump_list_from_sections(Arena *arena, DW_Raw *input, Arch arch, DW_SectionFlags dump_sections, B32 is_verbose);
#endif // DWARF_DUMP_H #endif // DWARF_DUMP_H
+2 -2
View File
@@ -27,10 +27,10 @@ dw_is_dwarf_present_from_elf_bin(String8 data, ELF_Bin *bin)
#define SINFL_IMPLEMENTATION #define SINFL_IMPLEMENTATION
#include "third_party/sinfl/sinfl.h" #include "third_party/sinfl/sinfl.h"
internal DW_Input internal DW_Raw
dw_input_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin) dw_input_from_elf_bin(Arena *arena, String8 data, ELF_Bin *bin)
{ {
DW_Input result = {0}; DW_Raw result = {0};
B32 is_section_present[ArrayCount(result.sec)] = {0}; B32 is_section_present[ArrayCount(result.sec)] = {0};
for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1) for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1)
{ {
+1 -1
View File
@@ -5,6 +5,6 @@
#define DWARF_ELF_H #define DWARF_ELF_H
internal B32 dw_is_dwarf_present_from_elf_bin(String8 raw_image, ELF_Bin *bin); internal B32 dw_is_dwarf_present_from_elf_bin(String8 raw_image, ELF_Bin *bin);
internal DW_Input dw_input_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin); internal DW_Raw dw_input_from_elf_bin(Arena *arena, String8 raw_image, ELF_Bin *bin);
#endif // DWARF_ELF_H #endif // DWARF_ELF_H
+1
View File
@@ -10,5 +10,6 @@
#include "dwarf/dwarf_dump.c" #include "dwarf/dwarf_dump.c"
#include "dwarf/dwarf_help.c" #include "dwarf/dwarf_help.c"
#include "dwarf/dwarf_writer.c" #include "dwarf/dwarf_writer.c"
#include "dwarf/dwarf_parse_2.c"
#include "dwarf/eh_frame.c" #include "dwarf/eh_frame.c"
#include "dwarf/eh_dump.c" #include "dwarf/eh_dump.c"
+1
View File
@@ -13,6 +13,7 @@
#include "dwarf/dwarf_dump.h" #include "dwarf/dwarf_dump.h"
#include "dwarf/dwarf_help.h" #include "dwarf/dwarf_help.h"
#include "dwarf/dwarf_writer.h" #include "dwarf/dwarf_writer.h"
#include "dwarf/dwarf_parse_2.h"
#include "dwarf/eh_frame.h" #include "dwarf/eh_frame.h"
#include "dwarf/eh_dump.h" #include "dwarf/eh_dump.h"
+54 -54
View File
@@ -353,7 +353,7 @@ dw_read_list_unit_header_list(String8 unit_data, DW_ListUnit *lu_out)
} }
internal DW_ListUnitInput internal DW_ListUnitInput
dw_list_unit_input_from_input(Arena *arena, DW_Input *input) dw_list_unit_input_from_input(Arena *arena, DW_Raw *input)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
@@ -776,7 +776,7 @@ exit:;
internal U64 internal U64
dw_read_tag(Arena *arena, dw_read_tag(Arena *arena,
DW_Input *input, DW_Raw *input,
DW_AbbrevTable abbrev_table, DW_AbbrevTable abbrev_table,
DW_Version version, DW_Version version,
DW_Format format, DW_Format format,
@@ -867,7 +867,7 @@ exit:;
} }
internal U64 internal U64
dw_read_tag_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out) dw_read_tag_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out)
{ {
return dw_read_tag(arena, return dw_read_tag(arena,
input, input,
@@ -1025,14 +1025,14 @@ dw_interp_address(U64 address_size, U64 base_addr, DW_ListUnit *addr_lu, DW_Form
} }
internal String8 internal String8
dw_interp_block(DW_Input *input, DW_CompUnit *cu, DW_Form form) dw_interp_block(DW_Raw *input, DW_CompUnit *cu, DW_Form form)
{ {
NotImplemented; NotImplemented;
return str8_zero(); return str8_zero();
} }
internal String8 internal String8
dw_interp_string(DW_Input *input, dw_interp_string(DW_Raw *input,
DW_Format unit_format, DW_Format unit_format,
DW_ListUnit *str_offsets, DW_ListUnit *str_offsets,
DW_Form form) DW_Form form)
@@ -1070,7 +1070,7 @@ dw_interp_string(DW_Input *input,
} }
internal String8 internal String8
dw_interp_line_ptr(DW_Input *input, DW_Form form) dw_interp_line_ptr(DW_Raw *input, DW_Form form)
{ {
String8 result = {0}; String8 result = {0};
if (form.kind == DW_Form_SecOffset) { if (form.kind == DW_Form_SecOffset) {
@@ -1090,7 +1090,7 @@ dw_interp_file(DW_LineVM *line_vm, DW_Form form)
} }
internal DW_Reference internal DW_Reference
dw_interp_ref(DW_Input *input, DW_CompUnit *cu, DW_Form form) dw_interp_ref(DW_Raw *input, DW_CompUnit *cu, DW_Form form)
{ {
DW_Reference ref = {0}; DW_Reference ref = {0};
if (form.kind == DW_Form_Ref1 || form.kind == DW_Form_Ref2 || if (form.kind == DW_Form_Ref1 || form.kind == DW_Form_Ref2 ||
@@ -1111,7 +1111,7 @@ dw_interp_ref(DW_Input *input, DW_CompUnit *cu, DW_Form form)
} }
internal DW_LocList internal DW_LocList
dw_interp_loclist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form) dw_interp_loclist(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form)
{ {
DW_LocList loclist = {0}; DW_LocList loclist = {0};
@@ -1398,7 +1398,7 @@ dw_interp_flag(DW_Form form)
} }
internal Rng1U64List internal Rng1U64List
dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form) dw_interp_rnglist(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form)
{ {
Rng1U64List rnglist = {0}; Rng1U64List rnglist = {0};
@@ -1589,7 +1589,7 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form)
} }
internal String8 internal String8
dw_interp_secptr(DW_Input *input, DW_SectionKind section, DW_Form form) dw_interp_secptr(DW_Raw *input, DW_SectionKind section, DW_Form form)
{ {
String8 secptr = {0}; String8 secptr = {0};
if (form.kind == DW_Form_SecOffset) { if (form.kind == DW_Form_SecOffset) {
@@ -1603,25 +1603,25 @@ dw_interp_secptr(DW_Input *input, DW_SectionKind section, DW_Form form)
} }
internal String8 internal String8
dw_interp_addrptr(DW_Input *input, DW_Form form) dw_interp_addrptr(DW_Raw *input, DW_Form form)
{ {
return dw_interp_secptr(input, DW_Section_Addr, form); return dw_interp_secptr(input, DW_Section_Addr, form);
} }
internal String8 internal String8
dw_interp_str_offsets_ptr(DW_Input *input, DW_Form form) dw_interp_str_offsets_ptr(DW_Raw *input, DW_Form form)
{ {
return dw_interp_secptr(input, DW_Section_StrOffsets, form); return dw_interp_secptr(input, DW_Section_StrOffsets, form);
} }
internal String8 internal String8
dw_interp_rnglists_ptr(DW_Input *input, DW_Form form) dw_interp_rnglists_ptr(DW_Raw *input, DW_Form form)
{ {
return dw_interp_secptr(input, DW_Section_RngLists, form); return dw_interp_secptr(input, DW_Section_RngLists, form);
} }
internal String8 internal String8
dw_interp_loclists_ptr(DW_Input *input, DW_Form form) dw_interp_loclists_ptr(DW_Raw *input, DW_Form form)
{ {
return dw_interp_secptr(input, DW_Section_LocLists, form); return dw_interp_secptr(input, DW_Section_LocLists, form);
} }
@@ -1633,7 +1633,7 @@ dw_value_class_from_attrib(DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal String8 internal String8
dw_exprloc_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_exprloc_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_ExprLoc || value_class == DW_AttribClass_Block); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_ExprLoc || value_class == DW_AttribClass_Block);
@@ -1641,7 +1641,7 @@ dw_exprloc_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal U128 internal U128
dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_const_u128_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const);
@@ -1649,7 +1649,7 @@ dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal U64 internal U64
dw_const_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_const_u64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const);
@@ -1657,7 +1657,7 @@ dw_const_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal U32 internal U32
dw_const_u32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_const_u32_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const);
@@ -1665,7 +1665,7 @@ dw_const_u32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal S64 internal S64
dw_const_s64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_const_s64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const);
@@ -1673,7 +1673,7 @@ dw_const_s64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal S32 internal S32
dw_const_s32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_const_s32_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Const);
@@ -1681,7 +1681,7 @@ dw_const_s32_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal B32 internal B32
dw_flag_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_flag_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Flag); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Flag);
@@ -1689,7 +1689,7 @@ dw_flag_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal U64 internal U64
dw_address_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_address_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || AssertAlways(value_class == DW_AttribClass_Null ||
@@ -1710,7 +1710,7 @@ dw_address_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal String8 internal String8
dw_block_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_block_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Block); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Block);
@@ -1718,7 +1718,7 @@ dw_block_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal String8 internal String8
dw_string_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_string_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_String || value_class == DW_AttribClass_StrOffsetsPtr); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_String || value_class == DW_AttribClass_StrOffsetsPtr);
@@ -1726,7 +1726,7 @@ dw_string_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal String8 internal String8
dw_line_ptr_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_line_ptr_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_LinePtr); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_LinePtr);
@@ -1742,7 +1742,7 @@ dw_file_from_attrib(DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib)
} }
internal DW_Reference internal DW_Reference
dw_ref_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_ref_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Reference); AssertAlways(value_class == DW_AttribClass_Null || value_class == DW_AttribClass_Reference);
@@ -1750,7 +1750,7 @@ dw_ref_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal DW_LocList internal DW_LocList
dw_loclist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_loclist_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
AssertAlways(value_class == DW_AttribClass_Null || AssertAlways(value_class == DW_AttribClass_Null ||
@@ -1760,7 +1760,7 @@ dw_loclist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib
} }
internal Rng1U64List internal Rng1U64List
dw_rnglist_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_rnglist_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
Rng1U64List rnglist = {0}; Rng1U64List rnglist = {0};
DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib); DW_AttribClass value_class = dw_value_class_from_attrib(cu, attrib);
@@ -1787,7 +1787,7 @@ dw_attrib_from_tag_(DW_Tag tag, DW_AttribKind kind)
} }
internal DW_Attrib * internal DW_Attrib *
dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_attrib_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
DW_Attrib *attrib = dw_attrib_from_tag_(tag, kind); DW_Attrib *attrib = dw_attrib_from_tag_(tag, kind);
@@ -1806,7 +1806,7 @@ dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k
} }
internal B32 internal B32
dw_tag_has_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_tag_has_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind);
B32 has_attrib = attrib->attrib_kind != DW_AttribKind_Null; B32 has_attrib = attrib->attrib_kind != DW_AttribKind_Null;
@@ -1814,85 +1814,85 @@ dw_tag_has_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind ki
} }
internal String8 internal String8
dw_exprloc_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_exprloc_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_exprloc_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_exprloc_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal String8 internal String8
dw_block_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_block_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_block_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_block_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal U128 internal U128
dw_const_u128_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_const_u128_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_const_u128_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_const_u128_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal U64 internal U64
dw_const_u64_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_const_u64_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_const_u64_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_const_u64_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal U32 internal U32
dw_const_u32_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_const_u32_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_const_u32_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_const_u32_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal U64 internal U64
dw_address_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_address_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_address_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_address_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal String8 internal String8
dw_string_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_string_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_string_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_string_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal String8 internal String8
dw_line_ptr_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_line_ptr_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_line_ptr_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_line_ptr_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal DW_Reference internal DW_Reference
dw_ref_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_ref_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_ref_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_ref_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal DW_LocList internal DW_LocList
dw_loclist_from_tag_attrib_kind(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_loclist_from_tag_attrib_kind(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_loclist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_loclist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal Rng1U64List internal Rng1U64List
dw_rnglist_from_tag_attrib_kind(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_rnglist_from_tag_attrib_kind(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_rnglist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_rnglist_from_attrib(arena, input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal B32 internal B32
dw_flag_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_flag_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_flag_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind)); return dw_flag_from_attrib(input, cu, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal DW_LineFile * internal DW_LineFile *
dw_file_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind) dw_file_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind)
{ {
return dw_file_from_attrib(cu, line_vm, dw_attrib_from_tag(input, cu, tag, kind)); return dw_file_from_attrib(cu, line_vm, dw_attrib_from_tag(input, cu, tag, kind));
} }
internal B32 internal B32
dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byte_size_out) dw_try_byte_size_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, U64 *byte_size_out)
{ {
B32 has_byte_size = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_ByteSize); 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 ); B32 has_bit_size = dw_tag_has_attrib(input, cu, tag, DW_AttribKind_BitSize );
@@ -1914,7 +1914,7 @@ dw_try_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, U64 *byt
} }
internal U64 internal U64
dw_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) dw_byte_size_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag)
{ {
U64 byte_size = max_U64; U64 byte_size = max_U64;
dw_try_byte_size_from_tag(input, cu, tag, &byte_size); dw_try_byte_size_from_tag(input, cu, tag, &byte_size);
@@ -1922,7 +1922,7 @@ dw_byte_size_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag)
} }
internal U32 internal U32
dw_byte_size_32_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag) dw_byte_size_32_from_tag(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag)
{ {
U32 byte_size32 = 0; U32 byte_size32 = 0;
U64 byte_size64; U64 byte_size64;
@@ -1933,7 +1933,7 @@ dw_byte_size_32_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag)
} }
internal U64 internal U64
dw_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) dw_u64_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
U64 result = 0; U64 result = 0;
DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind); DW_Attrib *attrib = dw_attrib_from_tag(input, cu, tag, kind);
@@ -1964,7 +1964,7 @@ dw_u64_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k
} }
internal B32 internal B32
dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib) dw_is_attrib_var_ref(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib)
{ {
B32 is_var_ref = 0; B32 is_var_ref = 0;
if (dw_is_form_kind_ref(cu->version, cu->ext, attrib->form.kind)) { if (dw_is_form_kind_ref(cu->version, cu->ext, attrib->form.kind)) {
@@ -1980,7 +1980,7 @@ dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib)
} }
internal DW_CompUnit internal DW_CompUnit
dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 cu_header_offset, B32 relaxed) dw_cu_from_info_off(Arena *arena, DW_Raw *input, DW_ListUnitInput lu_input, U64 cu_header_offset, B32 relaxed)
{ {
DW_CompUnit cu = {0}; DW_CompUnit cu = {0};
@@ -2111,7 +2111,7 @@ exit:;
} }
internal void internal void
dw_tag_tree_from_data(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_TagNode *parent, U64 *cursor, U64 *tag_count) dw_tag_tree_from_data(Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *parent, U64 *cursor, U64 *tag_count)
{ {
while (*cursor < cu->info_range.max) { while (*cursor < cu->info_range.max) {
// read tag // read tag
@@ -2138,7 +2138,7 @@ dw_tag_tree_from_data(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_TagNode
} }
internal DW_TagTree internal DW_TagTree
dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu) dw_tag_tree_from_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu)
{ {
DW_TagNode root = {0}; DW_TagNode root = {0};
U64 cursor = cu->first_tag_info_off; U64 cursor = cu->first_tag_info_off;
@@ -2206,7 +2206,7 @@ dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off)
internal U64 internal U64
dw_read_line_vm_header(Arena *arena, dw_read_line_vm_header(Arena *arena,
DW_Input *input, DW_Raw *input,
String8 cu_stmt_list, String8 cu_stmt_list,
String8 cu_dir, String8 cu_dir,
String8 cu_name, String8 cu_name,
@@ -2438,7 +2438,7 @@ dw_read_line_vm_header(Arena *arena,
} }
internal DW_LineVM * internal DW_LineVM *
dw_line_vm_init(DW_Input *input, DW_CompUnit *cu) dw_line_vm_init(DW_Raw *input, DW_CompUnit *cu)
{ {
DW_LineVM *vm = 0; DW_LineVM *vm = 0;
@@ -2732,7 +2732,7 @@ dw_path_from_file(Arena *arena, String8Array dir_table, DW_LineFile *file)
} }
internal DW_PubStringsTable internal DW_PubStringsTable
dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind) dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Raw *input, DW_SectionKind section_kind)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
+47 -47
View File
@@ -11,11 +11,11 @@ typedef struct DW_Section
B32 is_dwo; B32 is_dwo;
} DW_Section; } DW_Section;
typedef struct DW_Input typedef struct DW_Raw
{ {
DW_Section sec[DW_Section_Count]; DW_Section sec[DW_Section_COUNT];
DW_Section sup[DW_Section_Count]; DW_Section sup[DW_Section_COUNT];
} DW_Input; } DW_Raw;
typedef struct DW_ListUnit typedef struct DW_ListUnit
{ {
@@ -432,7 +432,7 @@ internal U64 dw_read_list_unit_header_addr (String8 unit_data, DW_ListUnit
internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out); internal U64 dw_read_list_unit_header_str_offsets(String8 unit_data, DW_ListUnit *lu_out);
internal U64 dw_read_list_unit_header_list (String8 unit_data, DW_ListUnit *lu_out); internal U64 dw_read_list_unit_header_list (String8 unit_data, DW_ListUnit *lu_out);
internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Input *input); internal DW_ListUnitInput dw_list_unit_input_from_input(Arena *arena, DW_Raw *input);
internal U64 dw_offset_from_list_unit(DW_ListUnit *lu, U64 index); internal U64 dw_offset_from_list_unit(DW_ListUnit *lu, U64 index);
internal U64 dw_addr_from_list_unit (DW_ListUnit *lu, U64 index); internal U64 dw_addr_from_list_unit (DW_ListUnit *lu, U64 index);
@@ -448,8 +448,8 @@ internal U64 dw_abbrev_offset_from_abbrev_id(DW_AbbrevTable table, U6
// form and tag // form and tag
internal B32 dw_read_form (String8 data, DW_Version version, DW_Format unit_format, U64 address_size, DW_FormKind form_kind, S64 implicit_const, DW_Form *form_out, U64 *bytes_read_out); internal B32 dw_read_form (String8 data, DW_Version version, DW_Format unit_format, U64 address_size, DW_FormKind form_kind, S64 implicit_const, DW_Form *form_out, U64 *bytes_read_out);
internal U64 dw_read_tag (Arena *arena, DW_Input *input, DW_AbbrevTable abbrev_table, DW_Version version, DW_Format format, U64 address_size, Rng1U64 cu_info_range, U64 tag_info_off, DW_Tag *tag_out); internal U64 dw_read_tag (Arena *arena, DW_Raw *input, DW_AbbrevTable abbrev_table, DW_Version version, DW_Format format, U64 address_size, Rng1U64 cu_info_range, U64 tag_info_off, DW_Tag *tag_out);
internal U64 dw_read_tag_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out); internal U64 dw_read_tag_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out);
// attrib interp // attrib interp
@@ -462,58 +462,58 @@ internal S64 dw_interp_const_s64 (DW_Form form);
internal S32 dw_interp_const_s32 (DW_Form form); internal S32 dw_interp_const_s32 (DW_Form form);
internal B32 dw_interp_flag (DW_Form form); internal B32 dw_interp_flag (DW_Form form);
internal U64 dw_interp_address (U64 address_size, U64 base_addr, DW_ListUnit *addr_xlist, DW_Form form); internal U64 dw_interp_address (U64 address_size, U64 base_addr, DW_ListUnit *addr_xlist, DW_Form form);
internal String8 dw_interp_block (DW_Input *input, DW_CompUnit *cu, DW_Form form); internal String8 dw_interp_block (DW_Raw *input, DW_CompUnit *cu, DW_Form form);
internal String8 dw_interp_string (DW_Input *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_Form form); internal String8 dw_interp_string (DW_Raw *input, DW_Format unit_format, DW_ListUnit *str_offsets, DW_Form form);
internal String8 dw_interp_line_ptr (DW_Input *input, DW_Form form); internal String8 dw_interp_line_ptr (DW_Raw *input, DW_Form form);
internal DW_LineFile * dw_interp_file (DW_LineVM *line_vm, DW_Form form); internal DW_LineFile * dw_interp_file (DW_LineVM *line_vm, DW_Form form);
internal DW_Reference dw_interp_ref (DW_Input *input, DW_CompUnit *cu, DW_Form form); internal DW_Reference dw_interp_ref (DW_Raw *input, DW_CompUnit *cu, DW_Form form);
internal DW_LocList dw_interp_loclist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form); internal DW_LocList dw_interp_loclist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form);
internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form); internal Rng1U64List dw_interp_rnglist (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Form form);
internal String8 dw_exprloc_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal String8 dw_exprloc_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal U128 dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal U128 dw_const_u128_from_attrib(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal U64 dw_const_u64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal U64 dw_const_u64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal U32 dw_const_u32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal U32 dw_const_u32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal S64 dw_const_s64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal S64 dw_const_s64_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal S32 dw_const_s32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal S32 dw_const_s32_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal B32 dw_flag_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal B32 dw_flag_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal U64 dw_address_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal U64 dw_address_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal String8 dw_block_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal String8 dw_block_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal String8 dw_string_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal String8 dw_string_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal String8 dw_line_ptr_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal String8 dw_line_ptr_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal DW_LineFile * dw_file_from_attrib (DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib); internal DW_LineFile * dw_file_from_attrib (DW_CompUnit *cu, DW_LineVM *line_vm, DW_Attrib *attrib);
internal DW_Reference dw_ref_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal DW_Reference dw_ref_from_attrib (DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal DW_LocList dw_loclist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal Rng1U64List dw_rnglist_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
internal String8 dw_exprloc_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal String8 dw_exprloc_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal U128 dw_const_u128_from_tag_attrib_kind(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal U128 dw_const_u128_from_tag_attrib_kind(DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal U64 dw_const_u64_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal U64 dw_const_u64_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal U32 dw_const_u32_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal U32 dw_const_u32_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal B32 dw_flag_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal B32 dw_flag_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal U64 dw_address_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal U64 dw_address_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal String8 dw_block_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal String8 dw_block_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal String8 dw_string_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal String8 dw_string_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal String8 dw_line_ptr_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind); internal DW_LineFile * dw_file_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_LineVM *line_vm, DW_Tag tag, DW_AttribKind kind);
internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal DW_Reference dw_ref_from_tag_attrib_kind (DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal DW_LocList dw_loclist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
internal B32 dw_is_attrib_var_ref(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib); internal B32 dw_is_attrib_var_ref(DW_Raw *input, DW_CompUnit *cu, DW_Attrib *attrib);
// compile unit // compile unit
internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed); internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Raw *input, DW_ListUnitInput lu_input, U64 offset, B32 relaxed);
internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu); internal DW_TagTree dw_tag_tree_from_cu(Arena *arena, DW_Raw *input, DW_CompUnit *cu);
internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree); internal HashTable * dw_make_tag_hash_table(Arena *arena, DW_TagTree tag_tree);
internal DW_TagNode * dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off); internal DW_TagNode * dw_tag_node_from_info_off(DW_CompUnit *cu, U64 info_off);
// line VM // line VM
internal U64 dw_read_line_vm_header(Arena *arena, DW_Input *input, String8 cu_stmt_list, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out); internal U64 dw_read_line_vm_header(Arena *arena, DW_Raw *input, String8 cu_stmt_list, String8 cu_dir, String8 cu_name, U8 cu_address_size, DW_ListUnit *cu_str_offsets, DW_LineVMHeader *header_out);
internal DW_LineVM * dw_line_vm_init(DW_Input *input, DW_CompUnit *cu); internal DW_LineVM * dw_line_vm_init(DW_Raw *input, DW_CompUnit *cu);
internal void dw_line_vm_release(DW_LineVM *vm); internal void dw_line_vm_release(DW_LineVM *vm);
internal void dw_line_vm_advance(DW_LineVM *vm, U64 advance); internal void dw_line_vm_advance(DW_LineVM *vm, U64 advance);
internal B32 dw_line_vm_step(DW_LineVM *vm); internal B32 dw_line_vm_step(DW_LineVM *vm);
@@ -522,7 +522,7 @@ internal String8 dw_path_from_file(Arena *arena, String8Array dir_table, D
// helper for .debug_pubtypes and .debug_pubnames // helper for .debug_pubtypes and .debug_pubnames
internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Input *input, DW_SectionKind section_kind); internal DW_PubStringsTable dw_v4_pub_strings_table_from_section_kind(Arena *arena, DW_Raw *input, DW_SectionKind section_kind);
// expression // expression
+2
View File
@@ -775,6 +775,7 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
case DW_LNCT_TimeStamp: case DW_LNCT_TimeStamp:
{ {
entry_out->modify_time = form_val.u128.u64[0]; entry_out->modify_time = form_val.u128.u64[0];
entry_out->flags |= DW2_LineTableFileFlag_HasModifyTime;
}break; }break;
case DW_LNCT_Size: case DW_LNCT_Size:
{ {
@@ -783,6 +784,7 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
case DW_LNCT_MD5: case DW_LNCT_MD5:
{ {
entry_out->md5.u128 = form_val.u128; entry_out->md5.u128 = form_val.u128;
entry_out->flags |= DW2_LineTableFileFlag_HasMD5;
}break; }break;
case DW_LNCT_LLVM_Source: case DW_LNCT_LLVM_Source:
{ {
+25
View File
@@ -100,10 +100,18 @@ struct DW2_Tag
//////////////////////////////// ////////////////////////////////
//~ rjf: Line Info //~ rjf: Line Info
typedef U32 DW2_LineTableFileFlags;
enum
{
DW2_LineTableFileFlag_HasMD5 = (1<<0),
DW2_LineTableFileFlag_HasModifyTime = (1<<1),
};
typedef struct DW2_LineTableFile DW2_LineTableFile; typedef struct DW2_LineTableFile DW2_LineTableFile;
struct DW2_LineTableFile struct DW2_LineTableFile
{ {
String8 file_name; String8 file_name;
DW2_LineTableFileFlags flags;
U64 dir_idx; U64 dir_idx;
U64 modify_time; U64 modify_time;
U64 file_size; U64 file_size;
@@ -154,6 +162,23 @@ struct DW2_LineTableHeader
DW2_LineTableFileArray files; DW2_LineTableFileArray files;
}; };
typedef struct DW2_LineVMRegs DW2_LineVMRegs;
struct DW2_LineVMRegs
{
U64 address;
U64 vliw_op_index;
U64 file_index;
U64 line;
U64 column;
B32 is_stmt;
B32 basic_block;
B32 end_sequence;
B32 prologue_end;
B32 epilogue_begin;
U64 isa;
U64 discriminator;
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Globals //~ rjf: Globals
+1 -1
View File
@@ -1253,7 +1253,7 @@ dw_writer_emit_to_obj(DW_Writer *writer, OBJ *obj)
dw_writer_emit(writer); dw_writer_emit(writer);
// push obj sections // push obj sections
OBJ_Section *sections[DW_Section_Count] = {0}; OBJ_Section *sections[DW_Section_COUNT] = {0};
for EachElement(i, writer->sections) { for EachElement(i, writer->sections) {
if (writer->sections[i].srl.total_size) { if (writer->sections[i].srl.total_size) {
sections[i] = obj_push_section(obj, dw_name_string_from_section_kind(i), OBJ_SectionFlag_Read|OBJ_SectionFlag_Write); sections[i] = obj_push_section(obj, dw_name_string_from_section_kind(i), OBJ_SectionFlag_Read|OBJ_SectionFlag_Write);
+1 -1
View File
@@ -240,7 +240,7 @@ typedef struct DW_Writer
// Emit // Emit
DW_WriterFixupList fixups; DW_WriterFixupList fixups;
DW_WriterSection sections[DW_Section_Count]; DW_WriterSection sections[DW_Section_COUNT];
DW_WriterAttribChunkList attrib_chunk_list; DW_WriterAttribChunkList attrib_chunk_list;
DW_WriterTagChunkList tag_chunk_list; DW_WriterTagChunkList tag_chunk_list;
} DW_Writer; } DW_Writer;
+1
View File
@@ -285,6 +285,7 @@ switch(arch)
{ {
default:{}break; default:{}break;
case RDI_Arch_X64:{result = 8;}break; case RDI_Arch_X64:{result = 8;}break;
case RDI_Arch_X86:{result = 4;}break;
} }
return result; return result;
} }
+2
View File
@@ -133,6 +133,7 @@ typedef enum RDI_ArchEnum
{ {
RDI_Arch_NULL = 0, RDI_Arch_NULL = 0,
RDI_Arch_X64 = 1, RDI_Arch_X64 = 1,
RDI_Arch_X86 = 2,
} RDI_ArchEnum; } RDI_ArchEnum;
typedef RDI_U8 RDI_RegCode; typedef RDI_U8 RDI_RegCode;
@@ -578,6 +579,7 @@ X(RDI_U64, idx)\
#define RDI_Arch_XList \ #define RDI_Arch_XList \
X(NULL)\ X(NULL)\
X(X64)\ X(X64)\
X(X86)\
#define RDI_RegCodeX64_XList \ #define RDI_RegCodeX64_XList \
X(nil, 0)\ X(nil, 0)\
+128 -2
View File
@@ -77,7 +77,14 @@ rb_thread_entry_point(void *p)
////////////////////////// //////////////////////////
//- rjf: possibly relative -> absolute path //- rjf: possibly relative -> absolute path
// //
String8 input_file_path = path_normalized_from_string(arena, str8f(arena, "%S/%S", working_directory, n->string)); String8 input_file_path = n->string;
{
PathStyle path_style = path_style_from_str8(n->string);
if(path_style == PathStyle_Relative)
{
input_file_path = path_normalized_from_string(arena, str8f(arena, "%S/%S", working_directory, n->string));
}
}
////////////////////////// //////////////////////////
//- rjf: do thin analysis of file //- rjf: do thin analysis of file
@@ -654,6 +661,7 @@ rb_thread_entry_point(void *p)
B32 convert_done = 0; B32 convert_done = 0;
RDIM_BakeParams pdb_bake_params = {0}; RDIM_BakeParams pdb_bake_params = {0};
RDIM_BakeParams dwarf_bake_params = {0}; RDIM_BakeParams dwarf_bake_params = {0};
RDIM_BakeParams dwarf_bake_params_2 = {0};
typedef struct RDIM_BakeParamsNode RDIM_BakeParamsNode; typedef struct RDIM_BakeParamsNode RDIM_BakeParamsNode;
struct RDIM_BakeParamsNode struct RDIM_BakeParamsNode
{ {
@@ -756,6 +764,124 @@ rb_thread_entry_point(void *p)
convert_params.is_parse_relaxed = 1; // TODO: switch convert_params.is_parse_relaxed = 1; // TODO: switch
} }
ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params); ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params);
// rjf: convert [2]
D2R2_ConvertParams convert_params_2 = {0};
{
B32 got_exe = 0;
B32 got_dbg = 0;
String8 exe_name = {0};
String8 exe_data = {0};
ExecutableImageKind exe_kind = ExecutableImageKind_Null;
String8 dbg_name = {0};
String8 dbg_data = {0};
if(!got_exe && !got_dbg)
{
for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_PE].first; n != 0; n = n->next)
{
if(n->v->format_flags & RB_FileFormatFlag_HasDWARF)
{
got_exe = 1;
got_dbg = 1;
dbg_name = n->v->path;
dbg_data = n->v->data;
exe_name = n->v->path;
exe_data = n->v->data;
exe_kind = ExecutableImageKind_CoffPe;
break;
}
}
}
if(!got_exe)
{
for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next)
{
got_exe = 1;
exe_name = n->v->path;
exe_data = n->v->data;
exe_kind = ExecutableImageKind_Elf32;
if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF))
{
break;
}
}
}
if(!got_exe)
{
for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next)
{
got_exe = 1;
exe_name = n->v->path;
exe_data = n->v->data;
exe_kind = ExecutableImageKind_Elf64;
if(!(n->v->format_flags & RB_FileFormatFlag_HasDWARF))
{
break;
}
}
}
if(!got_dbg)
{
for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF32].first; n != 0; n = n->next)
{
if(n->v->format_flags & RB_FileFormatFlag_HasDWARF)
{
got_dbg = 1;
dbg_name = n->v->path;
dbg_data = n->v->data;
break;
}
}
}
if(!got_dbg)
{
for(RB_FileNode *n = input_files_from_format_table[RB_FileFormat_ELF64].first; n != 0; n = n->next)
{
if(n->v->format_flags & RB_FileFormatFlag_HasDWARF)
{
got_dbg = 1;
dbg_name = n->v->path;
dbg_data = n->v->data;
break;
}
}
}
switch(exe_kind)
{
default:{}break;
case ExecutableImageKind_CoffPe:
{
Temp scratch = scratch_begin(&arena, 1);
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, exe_data);
String8 raw_sections = str8_substr(exe_data, pe.section_table_range);
COFF_SectionHeader *section_table = str8_deserial_get_raw_ptr(raw_sections, 0, sizeof(COFF_SectionHeader) * pe.section_count);
String8 string_table = str8_substr(exe_data, pe.string_table_range);
convert_params_2.arch = pe.arch;
convert_params_2.base_vaddr = pe.image_base;
convert_params_2.raw = dw_input_from_coff_section_table(scratch.arena, exe_data, string_table, pe.section_count, section_table);
convert_params_2.path_style = PathStyle_WindowsAbsolute;
convert_params_2.binary_sections = c2r_rdi_binary_sections_from_coff_sections(arena, exe_data, string_table, pe.section_count, section_table);
scratch_end(scratch);
}break;
case ExecutableImageKind_Elf32:
case ExecutableImageKind_Elf64:
{
Temp scratch = scratch_begin(&arena, 1);
ELF_Bin bin = elf_bin_from_data(scratch.arena, dbg_data);
convert_params_2.arch = arch_from_elf_machine(bin.hdr.e_machine);
convert_params_2.base_vaddr = elf_base_addr_from_bin(&bin);
convert_params_2.raw = dw_input_from_elf_bin(scratch.arena, dbg_data, &bin);
convert_params_2.path_style = PathStyle_UnixAbsolute;
convert_params_2.binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, bin.shdrs);
scratch_end(scratch);
} break;
}
convert_params_2.exe_name = exe_name;
convert_params_2.exe_data = exe_data;
convert_params_2.subset_flags = subset_flags;
convert_params_2.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
}
ProfScope("convert [2]") dwarf_bake_params_2 = d2r2_convert(arena, &convert_params_2);
} }
//- rjf: PDB inputs => PDB -> RDI conversion //- rjf: PDB inputs => PDB -> RDI conversion
@@ -1277,7 +1403,7 @@ rb_thread_entry_point(void *p)
PE_BinInfo pe = {0}; PE_BinInfo pe = {0};
ELF_Bin elf = {0}; ELF_Bin elf = {0};
COFF_FileHeaderInfo coff_obj = {0}; COFF_FileHeaderInfo coff_obj = {0};
DW_Input dw = {0}; DW_Raw dw = {0};
U64 eh_frame_hdr_vaddr = 0; U64 eh_frame_hdr_vaddr = 0;
U64 eh_frame_vaddr = 0; U64 eh_frame_vaddr = 0;
String8 eh_frame_hdr = {0}; String8 eh_frame_hdr = {0};
+2
View File
@@ -37,6 +37,7 @@
#include "rdi_from_elf/rdi_from_elf.h" #include "rdi_from_elf/rdi_from_elf.h"
#include "rdi_from_pdb/rdi_from_pdb.h" #include "rdi_from_pdb/rdi_from_pdb.h"
#include "rdi_from_dwarf/rdi_from_dwarf.h" #include "rdi_from_dwarf/rdi_from_dwarf.h"
#include "rdi_from_dwarf/rdi_from_dwarf_2.h"
#include "radbin/radbin.h" #include "radbin/radbin.h"
//- rjf: [c] //- rjf: [c]
@@ -66,6 +67,7 @@
#include "rdi_from_elf/rdi_from_elf.c" #include "rdi_from_elf/rdi_from_elf.c"
#include "rdi_from_pdb/rdi_from_pdb.c" #include "rdi_from_pdb/rdi_from_pdb.c"
#include "rdi_from_dwarf/rdi_from_dwarf.c" #include "rdi_from_dwarf/rdi_from_dwarf.c"
#include "rdi_from_dwarf/rdi_from_dwarf_2.c"
#include "radbin/radbin.c" #include "radbin/radbin.c"
//////////////////////////////// ////////////////////////////////
+1
View File
@@ -309,6 +309,7 @@ RDI_ArchTable:
{ {
{NULL 0 0} {NULL 0 0}
{X64 1 8} {X64 1 8}
{X86 2 4}
} }
@table(name value) @table(name value)
+14 -14
View File
@@ -717,7 +717,7 @@ d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecod
internal RDIM_EvalBytecode internal RDIM_EvalBytecode
d2r_bytecode_from_expression(Arena *arena, d2r_bytecode_from_expression(Arena *arena,
DW_Input *input, DW_Raw *input,
U64 image_base, U64 image_base,
Arch arch, Arch arch,
DW_ListUnit *addr_lu, DW_ListUnit *addr_lu,
@@ -1312,7 +1312,7 @@ d2r_bytecode_from_expression(Arena *arena,
} }
internal RDIM_Location internal RDIM_Location
d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr) d2r_transpile_expression(Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr)
{ {
RDIM_Location loc = {0}; RDIM_Location loc = {0};
if (expr.size) { if (expr.size) {
@@ -1325,7 +1325,7 @@ d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arc
} }
internal RDIM_Location internal RDIM_Location
d2r_location_from_attrib(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind) d2r_location_from_attrib(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind)
{ {
String8 expr = dw_exprloc_from_tag_attrib_kind(input, cu, tag, kind); String8 expr = dw_exprloc_from_tag_attrib_kind(input, cu, tag, kind);
RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr); RDIM_Location location = d2r_transpile_expression(arena, input, image_base, arch, cu->addr_lu, cu, expr);
@@ -1336,7 +1336,7 @@ internal RDIM_LocationCaseList
d2r_locset_from_attrib(Arena *arena, d2r_locset_from_attrib(Arena *arena,
RDIM_ScopeChunkList *scopes, RDIM_ScopeChunkList *scopes,
RDIM_Scope *curr_scope, RDIM_Scope *curr_scope,
DW_Input *input, DW_Raw *input,
DW_CompUnit *cu, DW_CompUnit *cu,
U64 image_base, U64 image_base,
Arch arch, Arch arch,
@@ -1383,7 +1383,7 @@ internal RDIM_LocationCaseList
d2r_var_locset_from_tag(Arena *arena, d2r_var_locset_from_tag(Arena *arena,
RDIM_ScopeChunkList *scopes, RDIM_ScopeChunkList *scopes,
RDIM_Scope *curr_scope, RDIM_Scope *curr_scope,
DW_Input *input, DW_Raw *input,
DW_CompUnit *cu, DW_CompUnit *cu,
U64 image_base, U64 image_base,
Arch arch, Arch arch,
@@ -1450,7 +1450,7 @@ d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off)
} }
internal RDIM_Type * internal RDIM_Type *
d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind) d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind)
{ {
RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void]; RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void];
@@ -1559,7 +1559,7 @@ d2r_is_type_tag_converted(DW_TagNode *tag_node)
} }
internal RDIM_Type * internal RDIM_Type *
d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind) d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind)
{ {
RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void]; RDIM_Type *type = type_table->builtin_types[RDI_TypeKind_Void];
@@ -1604,7 +1604,7 @@ d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *inpu
internal void internal void
d2r_convert_types(Arena *arena, d2r_convert_types(Arena *arena,
D2R_TypeTable *type_table, D2R_TypeTable *type_table,
DW_Input *input, DW_Raw *input,
DW_CompUnit *cu, DW_CompUnit *cu,
DW_Language cu_lang, DW_Language cu_lang,
Arch arch, Arch arch,
@@ -2088,7 +2088,7 @@ d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, R
internal void internal void
d2r_convert_udts(Arena *arena, d2r_convert_udts(Arena *arena,
D2R_TypeTable *type_table, D2R_TypeTable *type_table,
DW_Input *input, DW_Raw *input,
DW_CompUnit *cu, DW_CompUnit *cu,
DW_Language cu_lang, DW_Language cu_lang,
DW_TagNode *root) DW_TagNode *root)
@@ -2205,7 +2205,7 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D
} }
internal RDIM_Type ** internal RDIM_Type **
d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out) d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
@@ -2238,7 +2238,7 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input
} }
internal Rng1U64List internal Rng1U64List
d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag) d2r_range_list_from_tag(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag)
{ {
// collect non-contiguous range // collect non-contiguous range
Rng1U64List raw_ranges = dw_rnglist_from_tag_attrib_kind(arena, input, cu, tag, DW_AttribKind_Ranges); Rng1U64List raw_ranges = dw_rnglist_from_tag_attrib_kind(arena, input, cu, tag, DW_AttribKind_Ranges);
@@ -2296,7 +2296,7 @@ d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 imag
internal void internal void
d2r_convert_symbols(Arena *arena, d2r_convert_symbols(Arena *arena,
D2R_TypeTable *type_table, D2R_TypeTable *type_table,
DW_Input *input, DW_Raw *input,
DW_CompUnit *cu, DW_CompUnit *cu,
DW_Language cu_lang, DW_Language cu_lang,
U64 image_base, U64 image_base,
@@ -2620,7 +2620,7 @@ d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, void *b))
} }
internal D2R_CompUnitContribMap internal D2R_CompUnitContribMap
d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base) d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Raw *input, U64 image_base)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
Temp temp = temp_begin(arena); Temp temp = temp_begin(arena);
@@ -2726,7 +2726,7 @@ d2r_convert(Arena *arena, D2R_ConvertParams *params)
Arch arch = Arch_Null; Arch arch = Arch_Null;
U64 image_base = 0; U64 image_base = 0;
DW_Input input = {0}; DW_Raw input = {0};
PathStyle path_style = PathStyle_Null; PathStyle path_style = PathStyle_Null;
switch (params->exe_kind) { switch (params->exe_kind) {
+13 -13
View File
@@ -207,11 +207,11 @@ internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *
//////////////////////////////// ////////////////////////////////
//~ Expression Conversion //~ Expression Conversion
internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out); internal RDIM_EvalBytecode d2r_bytecode_from_expression(Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, String8 expr, DW_CompUnit *cu, D2R_ValueType *result_type_out);
internal RDIM_Location d2r_transpile_expression (Arena *arena, DW_Input *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr); internal RDIM_Location d2r_transpile_expression (Arena *arena, DW_Raw *input, U64 image_base, Arch arch, DW_ListUnit *addr_lu, DW_CompUnit *cu, String8 expr);
internal RDIM_Location d2r_location_from_attrib (Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); internal RDIM_Location d2r_location_from_attrib (Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind); internal RDIM_LocationCaseList d2r_locset_from_attrib (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Input *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag); internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_ScopeChunkList *scopes, RDIM_Scope *curr_scope, DW_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
//////////////////////////////// ////////////////////////////////
//~ Type Table //~ Type Table
@@ -219,7 +219,7 @@ internal RDIM_LocationCaseList d2r_var_locset_from_tag (Arena *arena, RDIM_S
internal RDIM_Type * d2r_create_type (Arena *arena, D2R_TypeTable *type_table); internal RDIM_Type * d2r_create_type (Arena *arena, D2R_TypeTable *type_table);
internal RDIM_Type * d2r_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off); internal RDIM_Type * d2r_create_type_from_offset(Arena *arena, D2R_TypeTable *type_table, U64 info_off);
internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off); internal RDIM_Type * d2r_type_from_offset(D2R_TypeTable *type_table, U64 info_off);
internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind); internal RDIM_Type * d2r_type_from_attrib(D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind kind);
//////////////////////////////// ////////////////////////////////
//~ Tag Iterator //~ Tag Iterator
@@ -235,8 +235,8 @@ internal DW_Tag d2r_tag_iterator_parent_tag (D2R_TagIterator *ite
internal void d2r_flag_converted_tag(DW_TagNode *tag_node); internal void d2r_flag_converted_tag(DW_TagNode *tag_node);
internal B8 d2r_is_tag_converted (DW_TagNode *tag_node); internal B8 d2r_is_tag_converted (DW_TagNode *tag_node);
internal RDIM_Type * d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind); internal RDIM_Type * d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_Tag tag, DW_AttribKind kind);
internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_TagNode *root); internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_TagNode *root);
//////////////////////////////// ////////////////////////////////
//~ UDT Conversion //~ UDT Conversion
@@ -244,15 +244,15 @@ internal void d2r_convert_types(Arena *arena, D2R_TypeTable *type_table,
internal B8 d2r_is_udt_tag_converted (DW_TagNode *tag_node); internal B8 d2r_is_udt_tag_converted (DW_TagNode *tag_node);
internal void d2r_flag_converted_udt_tag(DW_TagNode *tag_node); internal void d2r_flag_converted_udt_tag(DW_TagNode *tag_node);
internal void d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, RDIM_UDT *udt); internal void d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, RDIM_UDT *udt);
internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, DW_TagNode *root); internal void d2r_convert_udts(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, DW_TagNode *root);
//////////////////////////////// ////////////////////////////////
//~ Symbol Conversion //~ Symbol Conversion
internal RDIM_Scope * d2r_push_scope (Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D2R_TagFrame *tag_stack, Rng1U64List ranges); internal RDIM_Scope * d2r_push_scope (Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D2R_TagFrame *tag_stack, Rng1U64List ranges);
internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out); internal RDIM_Type ** d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_TagNode *cur_node, U64 *param_count_out);
internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag); internal Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag);
internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, DW_Input *input, DW_CompUnit *cu, DW_Language cu_lang, U64 image_base, Arch arch, DW_TagNode *root, RDIM_Unit *unit_rdi); internal void d2r_convert_symbols(Arena *arena, D2R_TypeTable *type_table, DW_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, U64 image_base, Arch arch, DW_TagNode *root, RDIM_Unit *unit_rdi);
//////////////////////////////// ////////////////////////////////
//~ Line Table Conversion //~ Line Table Conversion
@@ -263,7 +263,7 @@ internal void d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, v
//////////////////////////////// ////////////////////////////////
//~ Contrib Map //~ Contrib Map
internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Input *input, U64 image_base); internal D2R_CompUnitContribMap d2r_cu_contrib_map_from_aranges(Arena *arena, DW_Raw *input, U64 image_base);
internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off); internal RDIM_Rng1U64ChunkList d2r_voff_ranges_from_cu_info_off(D2R_CompUnitContribMap map, U64 info_off);
//////////////////////////////// ////////////////////////////////
+173 -3
View File
@@ -299,9 +299,19 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
lane_sync(); lane_sync();
//////////////////////////// ////////////////////////////
//- rjf: parse each unit's line table //- rjf: parse each unit's line table header
// //
DW2_LineTableHeader *unit_line_table_headers = 0;
U64 *unit_line_table_header_sizes = 0;
ProfScope("parse each unit's line table header")
{ {
if(lane_idx() == 0)
{
unit_line_table_headers = push_array(scratch.arena, DW2_LineTableHeader, unit_count);
unit_line_table_header_sizes = push_array(scratch.arena, U64, unit_count);
}
lane_sync_u64(&unit_line_table_headers, 0);
lane_sync_u64(&unit_line_table_header_sizes, 0);
U64 unit_take_idx = 0; U64 unit_take_idx = 0;
U64 *unit_take_idx_ptr = &unit_take_idx; U64 *unit_take_idx_ptr = &unit_take_idx;
lane_sync_u64(&unit_take_idx_ptr, 0); lane_sync_u64(&unit_take_idx_ptr, 0);
@@ -316,13 +326,173 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
DW2_Tag *unit_root_tag = &unit_root_tags[unit_idx]; DW2_Tag *unit_root_tag = &unit_root_tags[unit_idx];
DW2_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList); DW2_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList);
U64 line_info_off = stmt_list->val.u128.u64[0]; U64 line_info_off = stmt_list->val.u128.u64[0];
DW2_LineTableHeader line_table_header = {0};
String8 line_info_data = raw->sec[DW_Section_Line].data; String8 line_info_data = raw->sec[DW_Section_Line].data;
dw2_read_line_table_header(scratch.arena, ctx, line_info_data, line_info_off, &line_table_header); unit_line_table_header_sizes[unit_idx] = dw2_read_line_table_header(scratch.arena, ctx, line_info_data, line_info_off, &unit_line_table_headers[unit_idx]);
} }
} }
lane_sync(); lane_sync();
////////////////////////////
//- rjf: deduplicate all source files
//
typedef struct UnitSrcFileMap UnitSrcFileMap;
struct UnitSrcFileMap
{
RDIM_SrcFile **v;
};
RDIM_SrcFileChunkList *all_src_files = 0;
UnitSrcFileMap *unit_src_file_maps = 0;
ProfScope("deduplicate all source files") if(lane_idx() == 0)
{
Temp scratch2 = scratch_begin(&scratch.arena, 1);
//- rjf: count all files in all units
U64 total_file_count = 0;
for EachIndex(unit_idx, unit_count)
{
total_file_count += unit_line_table_headers[unit_idx].files.count;
}
//- rjf: set up path -> src file map
typedef struct SrcFileNode SrcFileNode;
struct SrcFileNode
{
SrcFileNode *next;
String8 full_path;
RDIM_SrcFile *src_file;
};
all_src_files = push_array(scratch.arena, RDIM_SrcFileChunkList, 1);
U64 slots_count = 1 + (total_file_count * 3) / 4;
SrcFileNode **slots = push_array(scratch2.arena, SrcFileNode *, slots_count);
//- rjf: set up unit -> src file maps
unit_src_file_maps = push_array(scratch.arena, UnitSrcFileMap, unit_count);
for EachIndex(unit_idx, unit_count)
{
unit_src_file_maps[unit_idx].v = push_array(scratch.arena, RDIM_SrcFile *, unit_line_table_headers[unit_idx].files.count);
}
//- rjf: build path -> src file map
for EachIndex(unit_idx, unit_count)
{
DW2_LineTableHeader *hdr = &unit_line_table_headers[unit_idx];
for EachIndex(file_idx, hdr->files.count)
{
DW2_LineTableFile *f = &hdr->files.v[file_idx];
DW2_LineTableFile *dir = &hdr->dirs.v[f->dir_idx];
String8 full_file_path = str8f(scratch2.arena, "%S/%S", dir->file_name, f->file_name);
U64 hash = u64_hash_from_str8(full_file_path);
U64 slot_idx = hash%slots_count;
SrcFileNode *node = 0;
for(SrcFileNode *n = slots[slot_idx]; n != 0; n = n->next)
{
if(str8_match(n->full_path, full_file_path, 0))
{
node = n;
break;
}
}
if(!node)
{
node = push_array(scratch2.arena, SrcFileNode, 1);
node->full_path = full_file_path;
node->src_file = rdim_src_file_chunk_list_push(arena, all_src_files, slots_count);
node->src_file->path = str8_copy(arena, full_file_path);
if(f->flags & DW2_LineTableFileFlag_HasMD5)
{
node->src_file->checksum_kind = RDI_ChecksumKind_MD5;
node->src_file->checksum = str8_copy(arena, str8_struct(&f->md5));
}
else if(f->flags & DW2_LineTableFileFlag_HasModifyTime)
{
node->src_file->checksum_kind = RDI_ChecksumKind_Timestamp;
node->src_file->checksum = str8_copy(arena, str8_struct(&f->modify_time));
}
}
unit_src_file_maps[unit_idx].v[file_idx] = node->src_file;
}
}
scratch_end(scratch2);
}
lane_sync_u64(&all_src_files, 0);
////////////////////////////
//- rjf: parse each unit's line info; produce line tables
//
RDIM_LineTableChunkList *all_line_tables = 0;
RDIM_LineTable **unit_line_tables = 0;
ProfScope("parse each unit's line info; produce line tables")
{
//- rjf: prep all per-unit line tables
if(lane_idx() == 0)
{
all_line_tables = push_array(scratch.arena, RDIM_LineTableChunkList, 1);
unit_line_tables = push_array(scratch.arena, RDIM_LineTable *, unit_count);
for EachIndex(unit_idx, unit_count)
{
unit_line_tables[unit_idx] = rdim_line_table_chunk_list_push(arena, all_line_tables, unit_count);
}
}
lane_sync_u64(&all_line_tables, 0);
lane_sync_u64(&unit_line_tables, 0);
U64 unit_take_idx = 0;
U64 *unit_take_idx_ptr = &unit_take_idx;
lane_sync_u64(&unit_take_idx_ptr, 0);
for(;;)
{
//- rjf: take unit
U64 unit_idx = ins_atomic_u64_inc_eval(unit_take_idx_ptr) - 1;
if(unit_idx >= unit_count)
{
break;
}
//- rjf: unpack unit info
DW2_LineTableHeader *line_table_header = &unit_line_table_headers[unit_idx];
RDIM_LineTable *dst_line_table = unit_line_tables[unit_idx];
DW2_Tag *unit_root_tag = &unit_root_tags[unit_idx];
DW2_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList);
U64 line_info_off = stmt_list->val.u128.u64[0];
String8 all_line_info_data = raw->sec[DW_Section_Line].data;
String8 unit_line_table_data = str8_substr(all_line_info_data, r1u64(line_info_off + unit_line_table_header_sizes[unit_idx], line_info_off + line_table_header->unit_length));
//- rjf: set up vm registers
DW2_LineVMRegs vm_regs = {0};
{
vm_regs.file_index = 1;
vm_regs.line = 1;
vm_regs.is_stmt = line_table_header->default_is_stmt;
}
//- rjf: run the line opcode program
for(U64 off = 0, next_off = 0; off < unit_line_table_data.size; off = next_off)
{
next_off = unit_line_table_data.size;
//- rjf: read next opcode
U8 opcode = 0;
str8_deserial_read_struct(unit_line_table_data, off, &opcode);
//- rjf: apply "special opcodes" (DWARF v5 6.2.5.1)
if(opcode >= line_table_header->opcode_base)
{
U32 adjusted_opcode = (U32)(opcode - line_table_header->opcode_base);
U32 op_advance = adjusted_opcode / line_table_header->line_range;
S64 line_advance = (S64)line_table_header->line_base + (S64)adjusted_opcode%(S64)line_table_header->line_range;
U64 addr_advance = line_table_header->min_inst_length + (vm_regs.vliw_op_index + op_advance) / line_table_header->max_ops_per_inst;
vm_regs.address += addr_advance;
vm_regs.vliw_op_index = (vm_regs.vliw_op_index + op_advance) % line_table_header->max_ops_per_inst;
vm_regs.line += line_advance;
vm_regs.basic_block = 0;
vm_regs.prologue_end = 0;
vm_regs.epilogue_begin = 0;
vm_regs.discriminator = 0;
}
}
}
}
//////////////////////////// ////////////////////////////
//- rjf: fill result //- rjf: fill result
// //
+1
View File
@@ -16,6 +16,7 @@ struct D2R2_ConvertParams
U64 base_vaddr; U64 base_vaddr;
RDIM_BinarySectionList binary_sections; RDIM_BinarySectionList binary_sections;
DW_Raw raw; DW_Raw raw;
PathStyle path_style;
RDIM_SubsetFlags subset_flags; RDIM_SubsetFlags subset_flags;
B32 deterministic; B32 deterministic;
}; };
+7 -7
View File
@@ -103,7 +103,7 @@ dwt_tags_must_match(DW_WriterTag *writer_tag, DW_TagNode *reader_tag)
return is_match; return is_match;
} }
internal DW_Input internal DW_Raw
dw_input_from_writer(Arena *arena, DW_Writer *writer) dw_input_from_writer(Arena *arena, DW_Writer *writer)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
@@ -127,7 +127,7 @@ dw_input_from_writer(Arena *arena, DW_Writer *writer)
PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, exe); PE_BinInfo pe = pe_bin_info_from_data(scratch.arena, exe);
COFF_SectionHeader *section_table = (COFF_SectionHeader *)(exe.str + pe.section_table_range.min); COFF_SectionHeader *section_table = (COFF_SectionHeader *)(exe.str + pe.section_table_range.min);
String8 string_table = str8_substr(exe, pe.string_table_range); String8 string_table = str8_substr(exe, pe.string_table_range);
DW_Input input = dw_input_from_coff_section_table(arena, exe, string_table, pe.section_count, section_table); DW_Raw input = dw_input_from_coff_section_table(arena, exe, string_table, pe.section_count, section_table);
obj_release(&obj); obj_release(&obj);
scratch_end(scratch); scratch_end(scratch);
@@ -141,7 +141,7 @@ TEST(dwarf_32bit)
dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER")); dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER"));
dw_writer_tag_end(writer); dw_writer_tag_end(writer);
DW_Input input = dw_input_from_writer(arena, writer); DW_Raw input = dw_input_from_writer(arena, writer);
for EachElement(sec_idx, input.sec) { for EachElement(sec_idx, input.sec) {
if (sec_idx == DW_Section_Abbrev) continue; if (sec_idx == DW_Section_Abbrev) continue;
@@ -169,7 +169,7 @@ TEST(dwarf_64bit)
dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER")); dw_writer_push_attrib_string(writer, DW_AttribKind_Producer, str8_lit("RAD DWARF WRITER"));
dw_writer_tag_end(writer); dw_writer_tag_end(writer);
DW_Input input = dw_input_from_writer(arena, writer); DW_Raw input = dw_input_from_writer(arena, writer);
for EachElement(sec_idx, input.sec) { for EachElement(sec_idx, input.sec) {
if (sec_idx == DW_Section_Abbrev) continue; if (sec_idx == DW_Section_Abbrev) continue;
@@ -235,7 +235,7 @@ TEST(dwarf_line_opcodes)
dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_set_discriminator(2)); dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_set_discriminator(2));
dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_end_sequence()); dw_line_inst_list_push(writer->arena, &writer->line.line_insts, DW_LNE_end_sequence());
DW_Input input = dw_input_from_writer(arena, writer); DW_Raw input = dw_input_from_writer(arena, writer);
Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data); Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data);
DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0);
DW_LineVM *line_vm = dw_line_vm_init(&input, &cu); DW_LineVM *line_vm = dw_line_vm_init(&input, &cu);
@@ -411,7 +411,7 @@ TEST(dwarf_line_emit)
} }
} }
DW_Input input = dw_input_from_writer(arena, writer); DW_Raw input = dw_input_from_writer(arena, writer);
Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data); Rng1U64Array cu_ranges = dw_unit_ranges_from_data_arr(arena, input.sec[DW_Section_Info].data);
DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, (DW_ListUnitInput){0}, cu_ranges.v[0].min, 0);
DW_LineVM *line_vm = dw_line_vm_init(&input, &cu); DW_LineVM *line_vm = dw_line_vm_init(&input, &cu);
@@ -621,7 +621,7 @@ TEST(dwarf_writer)
dw_writer_tag_end(writer); dw_writer_tag_end(writer);
} }
DW_Input input = dw_input_from_writer(arena, writer); DW_Raw input = dw_input_from_writer(arena, writer);
DW_ListUnitInput lu_input = dw_list_unit_input_from_input(arena, &input); DW_ListUnitInput lu_input = dw_list_unit_input_from_input(arena, &input);
DW_CompUnit cu = dw_cu_from_info_off(arena, &input, lu_input, 0, 1); DW_CompUnit cu = dw_cu_from_info_off(arena, &input, lu_input, 0, 1);
DW_TagTree tag_tree = dw_tag_tree_from_cu(arena, &input, &cu); DW_TagTree tag_tree = dw_tag_tree_from_cu(arena, &input, &cu);