mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
checkpoint on multi-lane / simplified dwarf parsing/conversion; fix incorrect assumption of relative in radbin
This commit is contained in:
+1285
-1285
File diff suppressed because it is too large
Load Diff
@@ -23,14 +23,14 @@ dw_is_dwarf_present_coff_section_table(String8 string_table, U64 section_count,
|
||||
return is_dwarf_present;
|
||||
}
|
||||
|
||||
internal DW_Input
|
||||
internal DW_Raw
|
||||
dw_input_from_coff_section_table(Arena *arena,
|
||||
String8 raw_image,
|
||||
String8 string_table,
|
||||
U64 section_count,
|
||||
COFF_SectionHeader *section_table)
|
||||
{
|
||||
DW_Input input = {0};
|
||||
DW_Raw input = {0};
|
||||
B32 sect_status[ArrayCount(input.sec)] = {0};
|
||||
|
||||
for (U64 i = 0; i < section_count; ++i) {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define DWARF_COFF_H
|
||||
|
||||
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
|
||||
|
||||
|
||||
+20
-20
@@ -231,7 +231,7 @@ dw_string_list_from_cfi_program(Arena *arena,
|
||||
}
|
||||
}
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
scratch_end(scratch);
|
||||
return list;
|
||||
}
|
||||
@@ -633,7 +633,7 @@ dw_single_line_string_from_expression(Arena *arena, String8 raw_data, U64 cu_bas
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -778,7 +778,7 @@ dw_string_from_attrib_value(Arena *arena, DW_Input *input, Arch arch, DW_CompUni
|
||||
internal
|
||||
DW_PRINTER(dw_print_abbrev)
|
||||
{
|
||||
DW_Input *input = dumper->input;
|
||||
DW_Raw *input = dumper->input;
|
||||
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
DW_Section abbrev = input->sec[DW_Section_Abbrev];
|
||||
@@ -842,7 +842,7 @@ DW_PRINTER(dw_print_abbrev)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -897,7 +897,7 @@ dw_print_tag(Arena *arena, String8List *strings, int indent, Arch arch, DW_Input
|
||||
internal
|
||||
DW_PRINTER(dw_print_info)
|
||||
{
|
||||
DW_Input *input = dumper->input;
|
||||
DW_Raw *input = dumper->input;
|
||||
Arch arch = dumper->arch;
|
||||
HashTable *line_vm_map = dw_get_line_vm_map(dumper);
|
||||
Rng1U64Array cu_ranges = dw_get_info_ranges(dumper);
|
||||
@@ -941,7 +941,7 @@ DW_PRINTER(dw_print_info)
|
||||
|
||||
DW_PRINTER(dw_print_line)
|
||||
{
|
||||
DW_Input *input = dumper->input;
|
||||
DW_Raw *input = dumper->input;
|
||||
B32 is_verbose = dumper->is_verbose;
|
||||
DW_CompUnit *cu_arr = dw_get_cu_arr(dumper);
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
@@ -1163,7 +1163,7 @@ DW_PRINTER(dw_print_line)
|
||||
|
||||
DW_PRINTER(dw_print_strings)
|
||||
{
|
||||
DW_Input *input = dumper->input;
|
||||
DW_Raw *input = dumper->input;
|
||||
String8 data = input->sec[DW_Section_Str].data;
|
||||
for (U64 cursor = 0, read_size = 0; cursor < data.size; cursor += read_size) {
|
||||
String8 string = {0};
|
||||
@@ -1174,7 +1174,7 @@ DW_PRINTER(dw_print_strings)
|
||||
|
||||
DW_PRINTER(dw_print_frame)
|
||||
{
|
||||
DW_Input *input = dumper->input;
|
||||
DW_Raw *input = dumper->input;
|
||||
Arch arch = dumper->arch;
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
HashTable *cie_ht = hash_table_init(scratch.arena, 0x2000);
|
||||
@@ -1275,7 +1275,7 @@ DW_PRINTER(dw_print_frame)
|
||||
internal
|
||||
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_Section info = input->sec[DW_Section_Info];
|
||||
DW_Section loc = input->sec[DW_Section_Loc];
|
||||
@@ -1397,7 +1397,7 @@ DW_PRINTER(dw_print_debug_loc)
|
||||
|
||||
#if 0
|
||||
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;
|
||||
#if 0
|
||||
@@ -1503,7 +1503,7 @@ dw_print_debug_ranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_In
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -1592,7 +1592,7 @@ dw_print_debug_aranges(Arena *arena, String8List *out, String8 g_dw_indent, DW_I
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -1701,7 +1701,7 @@ dw_based_range_read_address(void *base, Rng1U64 range, U64 offset, Rng1U64Array
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -1854,7 +1854,7 @@ dw_print_debug_loclists(Arena *arena, String8List *out, String8 g_dw_indent, DW_
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -1993,7 +1993,7 @@ dw_print_debug_rnglists(Arena *arena, String8List *out, String8 g_dw_indent, DW_
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -2055,19 +2055,19 @@ dw_format_string_table(Arena *arena, String8List *out, String8 g_dw_indent, DW_I
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -2097,7 +2097,7 @@ dw_print_debug_line_str(Arena *arena, String8List *out, String8 g_dw_indent, DW_
|
||||
}
|
||||
|
||||
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;
|
||||
#if 0
|
||||
@@ -2180,7 +2180,7 @@ read_only struct {
|
||||
|
||||
internal String8List
|
||||
dw_dump_list_from_sections(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
Arch arch,
|
||||
DW_SectionFlags subset_flags,
|
||||
B32 is_verbose)
|
||||
|
||||
+13
-13
@@ -18,7 +18,7 @@ typedef struct DW_Dumper
|
||||
Arch arch;
|
||||
B32 is_relaxed;
|
||||
B32 is_verbose;
|
||||
DW_Input *input;
|
||||
DW_Raw *input;
|
||||
DW_DumperCacheFlags cache_flags;
|
||||
struct {
|
||||
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 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_cfa (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFA cfa);
|
||||
internal String8 dw_string_from_cfi_row (Arena *arena, Arch arch, U64 address_size, DW_Version version, DW_Ext ext, DW_Format format, DW_CFI_Row *row);
|
||||
|
||||
#if 0
|
||||
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_ranges (Arena *arena, String8List *out, String8 indent, DW_Input *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_addr (Arena *arena, String8List *out, String8 indent, DW_Input *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_rnglists (Arena *arena, String8List *out, String8 indent, DW_Input *input, Rng1U64Array segment_vranges);
|
||||
internal void dw_print_debug_pubnames (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||
internal void dw_print_debug_pubtypes (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||
internal void dw_print_debug_line_str (Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||
internal void dw_print_debug_str_offsets(Arena *arena, String8List *out, String8 indent, DW_Input *input);
|
||||
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_Raw *input, Arch arch, ExecutableImageKind image_type, B32 relaxed);
|
||||
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_Raw *input);
|
||||
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_Raw *input, Rng1U64Array segment_vranges);
|
||||
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_Raw *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_Raw *input);
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ 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
|
||||
|
||||
@@ -27,10 +27,10 @@ dw_is_dwarf_present_from_elf_bin(String8 data, ELF_Bin *bin)
|
||||
#define SINFL_IMPLEMENTATION
|
||||
#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 result = {0};
|
||||
DW_Raw result = {0};
|
||||
B32 is_section_present[ArrayCount(result.sec)] = {0};
|
||||
for(U64 section_idx = 1; section_idx < bin->shdrs.count; section_idx += 1)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
#define DWARF_ELF_H
|
||||
|
||||
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
|
||||
|
||||
@@ -10,5 +10,6 @@
|
||||
#include "dwarf/dwarf_dump.c"
|
||||
#include "dwarf/dwarf_help.c"
|
||||
#include "dwarf/dwarf_writer.c"
|
||||
#include "dwarf/dwarf_parse_2.c"
|
||||
#include "dwarf/eh_frame.c"
|
||||
#include "dwarf/eh_dump.c"
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "dwarf/dwarf_dump.h"
|
||||
#include "dwarf/dwarf_help.h"
|
||||
#include "dwarf/dwarf_writer.h"
|
||||
#include "dwarf/dwarf_parse_2.h"
|
||||
#include "dwarf/eh_frame.h"
|
||||
#include "dwarf/eh_dump.h"
|
||||
|
||||
|
||||
+65
-65
@@ -353,7 +353,7 @@ 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)
|
||||
dw_list_unit_input_from_input(Arena *arena, DW_Raw *input)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
@@ -491,7 +491,7 @@ dw_read_abbrev_tag(String8 data, U64 offset, DW_Abbrev *out_abbrev)
|
||||
}
|
||||
|
||||
total_bytes_read = cursor - offset;
|
||||
exit:;
|
||||
exit:;
|
||||
return total_bytes_read;
|
||||
}
|
||||
|
||||
@@ -522,7 +522,7 @@ dw_read_abbrev_attrib(String8 data, U64 offset, DW_Abbrev *out_abbrev)
|
||||
}
|
||||
|
||||
total_bytes_read = cursor - offset;
|
||||
exit:;
|
||||
exit:;
|
||||
return total_bytes_read;
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ dw_make_abbrev_table(Arena *arena, String8 abbrev_data, U64 abbrev_base)
|
||||
}
|
||||
|
||||
failed_to_make = 0;
|
||||
exit:;
|
||||
exit:;
|
||||
if (failed_to_make) {
|
||||
MemoryZeroStruct(&table);
|
||||
temp_end(temp);
|
||||
@@ -769,14 +769,14 @@ dw_read_form(String8 data,
|
||||
}
|
||||
|
||||
is_ok = 1;
|
||||
exit:;
|
||||
exit:;
|
||||
Assert(is_ok);
|
||||
return is_ok;
|
||||
}
|
||||
|
||||
internal U64
|
||||
dw_read_tag(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_AbbrevTable abbrev_table,
|
||||
DW_Version version,
|
||||
DW_Format format,
|
||||
@@ -862,12 +862,12 @@ dw_read_tag(Arena *arena,
|
||||
tag_out->info_off = tag_info_off;
|
||||
|
||||
bytes_read = tag_cursor - (tag_info_off - cu_info_range.min);
|
||||
exit:;
|
||||
exit:;
|
||||
return bytes_read;
|
||||
}
|
||||
|
||||
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,
|
||||
input,
|
||||
@@ -1025,14 +1025,14 @@ dw_interp_address(U64 address_size, U64 base_addr, DW_ListUnit *addr_lu, DW_Form
|
||||
}
|
||||
|
||||
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;
|
||||
return str8_zero();
|
||||
}
|
||||
|
||||
internal String8
|
||||
dw_interp_string(DW_Input *input,
|
||||
dw_interp_string(DW_Raw *input,
|
||||
DW_Format unit_format,
|
||||
DW_ListUnit *str_offsets,
|
||||
DW_Form form)
|
||||
@@ -1070,7 +1070,7 @@ dw_interp_string(DW_Input *input,
|
||||
}
|
||||
|
||||
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};
|
||||
if (form.kind == DW_Form_SecOffset) {
|
||||
@@ -1090,7 +1090,7 @@ 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)
|
||||
dw_interp_ref(DW_Raw *input, DW_CompUnit *cu, DW_Form form)
|
||||
{
|
||||
DW_Reference ref = {0};
|
||||
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
|
||||
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};
|
||||
|
||||
@@ -1398,7 +1398,7 @@ dw_interp_flag(DW_Form form)
|
||||
}
|
||||
|
||||
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};
|
||||
|
||||
@@ -1589,7 +1589,7 @@ dw_interp_rnglist(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form)
|
||||
}
|
||||
|
||||
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};
|
||||
if (form.kind == DW_Form_SecOffset) {
|
||||
@@ -1603,25 +1603,25 @@ dw_interp_secptr(DW_Input *input, DW_SectionKind section, DW_Form form)
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -1633,7 +1633,7 @@ dw_value_class_from_attrib(DW_CompUnit *cu, DW_Attrib *attrib)
|
||||
}
|
||||
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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);
|
||||
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
|
||||
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};
|
||||
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 *
|
||||
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);
|
||||
|
||||
@@ -1806,7 +1806,7 @@ dw_attrib_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag, DW_AttribKind k
|
||||
}
|
||||
|
||||
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);
|
||||
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
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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_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
|
||||
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;
|
||||
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
|
||||
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;
|
||||
U64 byte_size64;
|
||||
@@ -1933,7 +1933,7 @@ dw_byte_size_32_from_tag(DW_Input *input, DW_CompUnit *cu, DW_Tag tag)
|
||||
}
|
||||
|
||||
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;
|
||||
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
|
||||
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;
|
||||
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
|
||||
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};
|
||||
|
||||
@@ -2106,12 +2106,12 @@ dw_cu_from_info_off(Arena *arena, DW_Input *input, DW_ListUnitInput lu_input, U6
|
||||
cu.tag = cu_tag;
|
||||
}
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
return cu;
|
||||
}
|
||||
|
||||
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) {
|
||||
// read tag
|
||||
@@ -2138,7 +2138,7 @@ dw_tag_tree_from_data(Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_TagNode
|
||||
}
|
||||
|
||||
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};
|
||||
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
|
||||
dw_read_line_vm_header(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
String8 cu_stmt_list,
|
||||
String8 cu_dir,
|
||||
String8 cu_name,
|
||||
@@ -2438,7 +2438,7 @@ dw_read_line_vm_header(Arena *arena,
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -2732,7 +2732,7 @@ dw_path_from_file(Arena *arena, String8Array dir_table, DW_LineFile *file)
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -2861,7 +2861,7 @@ dw_expr_from_data(Arena *arena, DW_Format format, U64 addr_size, String8 data)
|
||||
DLLPushBack(expr.first, expr.last, inst);
|
||||
expr.count += 1;
|
||||
}
|
||||
exit:;
|
||||
exit:;
|
||||
return expr;
|
||||
}
|
||||
|
||||
@@ -2917,7 +2917,7 @@ dw_parse_descriptor_entry_header(String8 data, U64 off, DW_DescriptorEntry *desc
|
||||
desc_out->cie_pointer = id;
|
||||
desc_out->cie_pointer_off = length_size;
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
return length + length_size;
|
||||
}
|
||||
|
||||
@@ -2969,7 +2969,7 @@ dw_parse_cie(String8 data, DW_Format format, Arch arch, DW_CIE *cie_out)
|
||||
cie_out->segment_selector_size = segment_selector_size;
|
||||
|
||||
is_parsed = 1;
|
||||
exit:;
|
||||
exit:;
|
||||
return is_parsed;
|
||||
}
|
||||
|
||||
@@ -3002,7 +3002,7 @@ dw_parse_fde(String8 data, DW_Format format, DW_CIE *cie, DW_FDE *fde_out)
|
||||
fde_out->insts = str8_skip(data, cursor);
|
||||
|
||||
is_parsed = 1;
|
||||
exit:;
|
||||
exit:;
|
||||
return is_parsed;
|
||||
}
|
||||
|
||||
@@ -3303,7 +3303,7 @@ dw_parse_cfa_inst(String8 data,
|
||||
|
||||
error_code = DW_CFA_ParseErrorCode_NewInst;
|
||||
|
||||
exit:;
|
||||
exit:;
|
||||
return error_code;
|
||||
}
|
||||
|
||||
|
||||
+47
-47
@@ -11,11 +11,11 @@ typedef struct DW_Section
|
||||
B32 is_dwo;
|
||||
} DW_Section;
|
||||
|
||||
typedef struct DW_Input
|
||||
typedef struct DW_Raw
|
||||
{
|
||||
DW_Section sec[DW_Section_Count];
|
||||
DW_Section sup[DW_Section_Count];
|
||||
} DW_Input;
|
||||
DW_Section sec[DW_Section_COUNT];
|
||||
DW_Section sup[DW_Section_COUNT];
|
||||
} DW_Raw;
|
||||
|
||||
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_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_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
|
||||
|
||||
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_cu(Arena *arena, DW_Input *input, DW_CompUnit *cu, U64 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_Raw *input, DW_CompUnit *cu, U64 info_off, DW_Tag *tag_out);
|
||||
|
||||
// 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 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 String8 dw_interp_block (DW_Input *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_line_ptr (DW_Input *input, DW_Form form);
|
||||
internal String8 dw_interp_block (DW_Raw *input, DW_CompUnit *cu, 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_Raw *input, 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_LocList dw_interp_loclist (Arena *arena, DW_Input *input, DW_CompUnit *cu, DW_Form form);
|
||||
internal Rng1U64List dw_interp_rnglist (Arena *arena, 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_Raw *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 U128 dw_const_u128_from_attrib(DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal U64 dw_const_u64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal U32 dw_const_u32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal S64 dw_const_s64_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal S32 dw_const_s32_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal B32 dw_flag_from_attrib (DW_Input *input, DW_CompUnit *cu, DW_Attrib *attrib);
|
||||
internal U64 dw_address_from_attrib (DW_Input *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_string_from_attrib (DW_Input *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_exprloc_from_attrib (DW_Raw *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_Raw *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_Raw *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_Raw *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_Raw *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_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_Reference dw_ref_from_attrib (DW_Input *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 Rng1U64List dw_rnglist_from_attrib (Arena *arena, 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_Raw *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 U128 dw_const_u128_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_Input *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 B32 dw_flag_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_Input *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_string_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_Input *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 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_Reference dw_ref_from_tag_attrib_kind (DW_Input *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 Rng1U64List dw_rnglist_from_tag_attrib_kind (Arena *arena, 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_Raw *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_Raw *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_Raw *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_Raw *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_Raw *input, DW_CompUnit *cu, 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_Raw *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_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
|
||||
|
||||
internal DW_CompUnit dw_cu_from_info_off(Arena *arena, DW_Input *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_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_Raw *input, DW_CompUnit *cu);
|
||||
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);
|
||||
|
||||
// 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 DW_LineVM * dw_line_vm_init(DW_Input *input, DW_CompUnit *cu);
|
||||
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_Raw *input, DW_CompUnit *cu);
|
||||
internal void dw_line_vm_release(DW_LineVM *vm);
|
||||
internal void dw_line_vm_advance(DW_LineVM *vm, U64 advance);
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -775,6 +775,7 @@ dw2_read_line_table_header(Arena *arena, DW2_ParseCtx *ctx, String8 data, U64 of
|
||||
case DW_LNCT_TimeStamp:
|
||||
{
|
||||
entry_out->modify_time = form_val.u128.u64[0];
|
||||
entry_out->flags |= DW2_LineTableFileFlag_HasModifyTime;
|
||||
}break;
|
||||
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:
|
||||
{
|
||||
entry_out->md5.u128 = form_val.u128;
|
||||
entry_out->flags |= DW2_LineTableFileFlag_HasMD5;
|
||||
}break;
|
||||
case DW_LNCT_LLVM_Source:
|
||||
{
|
||||
|
||||
@@ -100,10 +100,18 @@ struct DW2_Tag
|
||||
////////////////////////////////
|
||||
//~ rjf: Line Info
|
||||
|
||||
typedef U32 DW2_LineTableFileFlags;
|
||||
enum
|
||||
{
|
||||
DW2_LineTableFileFlag_HasMD5 = (1<<0),
|
||||
DW2_LineTableFileFlag_HasModifyTime = (1<<1),
|
||||
};
|
||||
|
||||
typedef struct DW2_LineTableFile DW2_LineTableFile;
|
||||
struct DW2_LineTableFile
|
||||
{
|
||||
String8 file_name;
|
||||
DW2_LineTableFileFlags flags;
|
||||
U64 dir_idx;
|
||||
U64 modify_time;
|
||||
U64 file_size;
|
||||
@@ -154,6 +162,23 @@ struct DW2_LineTableHeader
|
||||
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
|
||||
|
||||
|
||||
@@ -1253,7 +1253,7 @@ dw_writer_emit_to_obj(DW_Writer *writer, OBJ *obj)
|
||||
dw_writer_emit(writer);
|
||||
|
||||
// push obj sections
|
||||
OBJ_Section *sections[DW_Section_Count] = {0};
|
||||
OBJ_Section *sections[DW_Section_COUNT] = {0};
|
||||
for EachElement(i, writer->sections) {
|
||||
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);
|
||||
|
||||
@@ -240,7 +240,7 @@ typedef struct DW_Writer
|
||||
|
||||
// Emit
|
||||
DW_WriterFixupList fixups;
|
||||
DW_WriterSection sections[DW_Section_Count];
|
||||
DW_WriterSection sections[DW_Section_COUNT];
|
||||
DW_WriterAttribChunkList attrib_chunk_list;
|
||||
DW_WriterTagChunkList tag_chunk_list;
|
||||
} DW_Writer;
|
||||
|
||||
@@ -285,6 +285,7 @@ switch(arch)
|
||||
{
|
||||
default:{}break;
|
||||
case RDI_Arch_X64:{result = 8;}break;
|
||||
case RDI_Arch_X86:{result = 4;}break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,7 @@ typedef enum RDI_ArchEnum
|
||||
{
|
||||
RDI_Arch_NULL = 0,
|
||||
RDI_Arch_X64 = 1,
|
||||
RDI_Arch_X86 = 2,
|
||||
} RDI_ArchEnum;
|
||||
|
||||
typedef RDI_U8 RDI_RegCode;
|
||||
@@ -578,6 +579,7 @@ X(RDI_U64, idx)\
|
||||
#define RDI_Arch_XList \
|
||||
X(NULL)\
|
||||
X(X64)\
|
||||
X(X86)\
|
||||
|
||||
#define RDI_RegCodeX64_XList \
|
||||
X(nil, 0)\
|
||||
|
||||
+128
-2
@@ -77,7 +77,14 @@ rb_thread_entry_point(void *p)
|
||||
//////////////////////////
|
||||
//- 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
|
||||
@@ -654,6 +661,7 @@ rb_thread_entry_point(void *p)
|
||||
B32 convert_done = 0;
|
||||
RDIM_BakeParams pdb_bake_params = {0};
|
||||
RDIM_BakeParams dwarf_bake_params = {0};
|
||||
RDIM_BakeParams dwarf_bake_params_2 = {0};
|
||||
typedef struct RDIM_BakeParamsNode RDIM_BakeParamsNode;
|
||||
struct RDIM_BakeParamsNode
|
||||
{
|
||||
@@ -756,6 +764,124 @@ rb_thread_entry_point(void *p)
|
||||
convert_params.is_parse_relaxed = 1; // TODO: switch
|
||||
}
|
||||
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
|
||||
@@ -1277,7 +1403,7 @@ rb_thread_entry_point(void *p)
|
||||
PE_BinInfo pe = {0};
|
||||
ELF_Bin elf = {0};
|
||||
COFF_FileHeaderInfo coff_obj = {0};
|
||||
DW_Input dw = {0};
|
||||
DW_Raw dw = {0};
|
||||
U64 eh_frame_hdr_vaddr = 0;
|
||||
U64 eh_frame_vaddr = 0;
|
||||
String8 eh_frame_hdr = {0};
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "rdi_from_elf/rdi_from_elf.h"
|
||||
#include "rdi_from_pdb/rdi_from_pdb.h"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf.h"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.h"
|
||||
#include "radbin/radbin.h"
|
||||
|
||||
//- rjf: [c]
|
||||
@@ -66,6 +67,7 @@
|
||||
#include "rdi_from_elf/rdi_from_elf.c"
|
||||
#include "rdi_from_pdb/rdi_from_pdb.c"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf.c"
|
||||
#include "rdi_from_dwarf/rdi_from_dwarf_2.c"
|
||||
#include "radbin/radbin.c"
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -309,6 +309,7 @@ RDI_ArchTable:
|
||||
{
|
||||
{NULL 0 0}
|
||||
{X64 1 8}
|
||||
{X86 2 4}
|
||||
}
|
||||
|
||||
@table(name value)
|
||||
|
||||
@@ -717,7 +717,7 @@ d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *stack, RDIM_EvalBytecod
|
||||
|
||||
internal RDIM_EvalBytecode
|
||||
d2r_bytecode_from_expression(Arena *arena,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
U64 image_base,
|
||||
Arch arch,
|
||||
DW_ListUnit *addr_lu,
|
||||
@@ -1312,7 +1312,7 @@ d2r_bytecode_from_expression(Arena *arena,
|
||||
}
|
||||
|
||||
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};
|
||||
if (expr.size) {
|
||||
@@ -1325,7 +1325,7 @@ d2r_transpile_expression(Arena *arena, DW_Input *input, U64 image_base, Arch arc
|
||||
}
|
||||
|
||||
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);
|
||||
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,
|
||||
RDIM_ScopeChunkList *scopes,
|
||||
RDIM_Scope *curr_scope,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_CompUnit *cu,
|
||||
U64 image_base,
|
||||
Arch arch,
|
||||
@@ -1383,7 +1383,7 @@ internal RDIM_LocationCaseList
|
||||
d2r_var_locset_from_tag(Arena *arena,
|
||||
RDIM_ScopeChunkList *scopes,
|
||||
RDIM_Scope *curr_scope,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_CompUnit *cu,
|
||||
U64 image_base,
|
||||
Arch arch,
|
||||
@@ -1450,7 +1450,7 @@ 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)
|
||||
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];
|
||||
|
||||
@@ -1559,7 +1559,7 @@ d2r_is_type_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)
|
||||
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];
|
||||
|
||||
@@ -1604,7 +1604,7 @@ d2r_find_or_convert_type(Arena *arena, D2R_TypeTable *type_table, DW_Input *inpu
|
||||
internal void
|
||||
d2r_convert_types(Arena *arena,
|
||||
D2R_TypeTable *type_table,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_CompUnit *cu,
|
||||
DW_Language cu_lang,
|
||||
Arch arch,
|
||||
@@ -2088,7 +2088,7 @@ d2r_inline_anonymous_udt_member(Arena *arena, RDIM_UDT *top_udt, U64 base_off, R
|
||||
internal void
|
||||
d2r_convert_udts(Arena *arena,
|
||||
D2R_TypeTable *type_table,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_CompUnit *cu,
|
||||
DW_Language cu_lang,
|
||||
DW_TagNode *root)
|
||||
@@ -2205,7 +2205,7 @@ d2r_push_scope(Arena *arena, RDIM_ScopeChunkList *scopes, U64 scope_chunk_cap, D
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@@ -2238,7 +2238,7 @@ d2r_collect_proc_params(Arena *arena, D2R_TypeTable *type_table, DW_Input *input
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
d2r_convert_symbols(Arena *arena,
|
||||
D2R_TypeTable *type_table,
|
||||
DW_Input *input,
|
||||
DW_Raw *input,
|
||||
DW_CompUnit *cu,
|
||||
DW_Language cu_lang,
|
||||
U64 image_base,
|
||||
@@ -2620,7 +2620,7 @@ d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, void *b))
|
||||
}
|
||||
|
||||
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 temp = temp_begin(arena);
|
||||
@@ -2726,7 +2726,7 @@ d2r_convert(Arena *arena, D2R_ConvertParams *params)
|
||||
|
||||
Arch arch = Arch_Null;
|
||||
U64 image_base = 0;
|
||||
DW_Input input = {0};
|
||||
DW_Raw input = {0};
|
||||
PathStyle path_style = PathStyle_Null;
|
||||
|
||||
switch (params->exe_kind) {
|
||||
|
||||
@@ -207,11 +207,11 @@ internal void d2r_push_relational_op(Arena *arena, D2R_ValueTypeStack *
|
||||
////////////////////////////////
|
||||
//~ 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_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_location_from_attrib (Arena *arena, 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_Input *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_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_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_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_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_Raw *input, DW_CompUnit *cu, U64 image_base, Arch arch, DW_Tag tag);
|
||||
|
||||
////////////////////////////////
|
||||
//~ 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_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_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
|
||||
@@ -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 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 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 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_Raw *input, DW_CompUnit *cu, DW_Language cu_lang, Arch arch, DW_TagNode *root);
|
||||
|
||||
////////////////////////////////
|
||||
//~ 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 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_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
|
||||
|
||||
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 Rng1U64List d2r_range_list_from_tag(Arena *arena, DW_Input *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 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_Raw *input, DW_CompUnit *cu, U64 image_base, DW_Tag tag);
|
||||
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
|
||||
@@ -263,7 +263,7 @@ internal void d2r_sort_ptrs(void **ptrs, U64 count, int (* is_before)(void *a, v
|
||||
////////////////////////////////
|
||||
//~ 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);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -299,9 +299,19 @@ d2r2_convert(Arena *arena, D2R2_ConvertParams *params)
|
||||
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_ptr = &unit_take_idx;
|
||||
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_Attrib *stmt_list = dw2_attrib_from_kind(unit_root_tag, DW_AttribKind_StmtList);
|
||||
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;
|
||||
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();
|
||||
|
||||
////////////////////////////
|
||||
//- 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
|
||||
//
|
||||
|
||||
@@ -16,6 +16,7 @@ struct D2R2_ConvertParams
|
||||
U64 base_vaddr;
|
||||
RDIM_BinarySectionList binary_sections;
|
||||
DW_Raw raw;
|
||||
PathStyle path_style;
|
||||
RDIM_SubsetFlags subset_flags;
|
||||
B32 deterministic;
|
||||
};
|
||||
|
||||
@@ -103,7 +103,7 @@ dwt_tags_must_match(DW_WriterTag *writer_tag, DW_TagNode *reader_tag)
|
||||
return is_match;
|
||||
}
|
||||
|
||||
internal DW_Input
|
||||
internal DW_Raw
|
||||
dw_input_from_writer(Arena *arena, DW_Writer *writer)
|
||||
{
|
||||
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);
|
||||
COFF_SectionHeader *section_table = (COFF_SectionHeader *)(exe.str + pe.section_table_range.min);
|
||||
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);
|
||||
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_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) {
|
||||
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_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) {
|
||||
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_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);
|
||||
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);
|
||||
@@ -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);
|
||||
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);
|
||||
@@ -621,7 +621,7 @@ TEST(dwarf_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_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);
|
||||
|
||||
Reference in New Issue
Block a user