simplify testing ipc driving stuff in raddbg layer; put in formal eval/line-from-vaddr commands

This commit is contained in:
Ryan Fleury
2026-06-02 12:10:52 -07:00
parent ec6f569181
commit 5f851ad1b0
17 changed files with 434 additions and 694 deletions
+19 -108
View File
@@ -720,89 +720,7 @@ rb_thread_entry_point(void *p)
else if(elf_w_dwarf) { log_infof("ELFs specified; converting DWARF data to RDI\n"); }
// rjf: convert
D2R_ConvertParams convert_params = {0};
{
B32 got_exe = 0;
B32 got_dbg = 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;
convert_params.dbg_name = n->v->path;
convert_params.dbg_data = n->v->data;
convert_params.exe_name = n->v->path;
convert_params.exe_data = n->v->data;
convert_params.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;
convert_params.exe_name = n->v->path;
convert_params.exe_data = n->v->data;
convert_params.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;
convert_params.exe_name = n->v->path;
convert_params.exe_data = n->v->data;
convert_params.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;
convert_params.dbg_name = n->v->path;
convert_params.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;
convert_params.dbg_name = n->v->path;
convert_params.dbg_data = n->v->data;
break;
}
}
}
convert_params.subset_flags = subset_flags;
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
convert_params.is_parse_relaxed = 1; // TODO: switch
}
#if DWARF_2
// rjf: convert [2]
D2R2_ConvertParams convert_params_2 = {0};
D2R2_ConvertParams convert_params = {0};
{
B32 got_exe = 0;
B32 got_dbg = 0;
@@ -892,11 +810,11 @@ rb_thread_entry_point(void *p)
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);
convert_params.arch = pe.arch;
convert_params.base_vaddr = pe.image_base;
convert_params.raw = dw_input_from_coff_section_table(scratch.arena, exe_data, string_table, pe.section_count, section_table);
convert_params.path_style = PathStyle_WindowsAbsolute;
convert_params.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:
@@ -904,23 +822,20 @@ rb_thread_entry_point(void *p)
{
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, dbg_data, &bin, &bin.shdrs);
convert_params.arch = arch_from_elf_machine(bin.hdr.e_machine);
convert_params.base_vaddr = elf_base_addr_from_bin(&bin);
convert_params.raw = dw_input_from_elf_bin(scratch.arena, dbg_data, &bin);
convert_params.path_style = PathStyle_UnixAbsolute;
convert_params.binary_sections = e2r_rdi_binary_sections_from_elf_section_table(arena, dbg_data, &bin, &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"));
convert_params.exe_name = exe_name;
convert_params.exe_data = exe_data;
convert_params.subset_flags = subset_flags;
convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic"));
}
ProfScope("convert [2]") dwarf_bake_params_2 = d2r2_convert(arena, &convert_params_2);
#else
ProfScope("convert") dwarf_bake_params = d2r_convert(arena, &convert_params);
#endif
ProfScope("convert") dwarf_bake_params = d2r2_convert(arena, &convert_params);
}
//- rjf: PDB inputs => PDB -> RDI conversion
@@ -995,11 +910,7 @@ rb_thread_entry_point(void *p)
{
bake_params = push_array(arena, RDIM_BakeParams, 1);
rdim_bake_params_concat_in_place(bake_params, &pdb_bake_params);
#if DWARF_2
rdim_bake_params_concat_in_place(bake_params, &dwarf_bake_params_2);
#else
rdim_bake_params_concat_in_place(bake_params, &dwarf_bake_params);
#endif
for EachNode(n, RDIM_BakeParamsNode, first_rdi_bake_params)
{
rdim_bake_params_concat_in_place(bake_params, &n->v);
@@ -1334,14 +1245,14 @@ rb_thread_entry_point(void *p)
PathStyle path_style = PathStyle_SystemAbsolute;
if (str8_match_wildcard(top_part, str8_lit("?:"), 0)) { path_style = PathStyle_WindowsAbsolute; }
else if(str8_match_wildcard(top_part, str8_lit("/*"), 0)) { path_style = PathStyle_UnixAbsolute; }
String8 path = str8_from_rdi_path_node_idx(scratch.arena, rdi, path_style, src_file->file_path_node_idx);
str8_list_pushf(arena, &output_blobs, "[inlined] %S %S:%u\n", inline_name, path, inline_line.line_num);
}
}
}
}
// TODO: remove 'path_style' from the str8_from_rdi_path_node_idx and detect
// path style based on the top node [c:|d:] -> windows, / -> unix
String8 top_part = {0};
@@ -1357,7 +1268,7 @@ rb_thread_entry_point(void *p)
PathStyle path_style = PathStyle_SystemAbsolute;
if (str8_match_wildcard(top_part, str8_lit("?:"), 0)) { path_style = PathStyle_WindowsAbsolute; }
else if(str8_match_wildcard(top_part, str8_lit("/*"), 0)) { path_style = PathStyle_UnixAbsolute; }
String8 path = str8_from_rdi_path_node_idx(scratch.arena, rdi, path_style, src_file->file_path_node_idx);
str8_list_pushf(arena, &output_blobs, "%S:%u\n", path, line.line_num);
scratch_end(scratch);
-4
View File
@@ -14,7 +14,6 @@
#include "base/base_inc.h"
#include "x64/x64.h"
#include "linker/hash_table.h"
#include "linker/lf_hash_table.h"
#include "linker/base_ext/base_bit_array.h"
#include "rdi/rdi_local.h"
#include "rdi_make/rdi_make_local.h"
@@ -36,7 +35,6 @@
#include "rdi_from_coff/rdi_from_coff.h"
#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"
@@ -44,7 +42,6 @@
#include "base/base_inc.c"
#include "x64/x64.c"
#include "linker/hash_table.c"
#include "linker/lf_hash_table.c"
#include "linker/base_ext/base_bit_array.c"
#include "rdi/rdi_local.c"
#include "rdi_make/rdi_make_local.c"
@@ -66,7 +63,6 @@
#include "rdi_from_coff/rdi_from_coff.c"
#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"