From 0e414a3dfb7c3a8cf5e7817865b132ffdf33a5d6 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 10 Jun 2025 14:39:09 -0700 Subject: [PATCH] fix clang build; adjust raddbg --convert option to --bin --- src/dbgi/dbgi.c | 2 +- src/linker/hash_table.c | 2 + src/radbin/radbin.c | 3 + src/raddbg/raddbg_main.c | 10 +-- src/rdi_format/rdi_format_local.c | 105 ------------------------------ src/rdi_format/rdi_format_local.h | 1 - src/scratch/convertperf.c | 2 +- 7 files changed, 12 insertions(+), 113 deletions(-) diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index ef92f3ba..be88fc8a 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -1026,7 +1026,7 @@ ASYNC_WORK_DEF(di_parse_work) params.inherit_env = 1; params.consoleless = 1; str8_list_pushf(scratch.arena, ¶ms.cmd_line, "raddbg"); - str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--convert"); + str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--bin"); str8_list_pushf(scratch.arena, ¶ms.cmd_line, "--quiet"); if(should_compress) { diff --git a/src/linker/hash_table.c b/src/linker/hash_table.c index f7f78bf7..c38e224f 100644 --- a/src/linker/hash_table.c +++ b/src/linker/hash_table.c @@ -327,6 +327,8 @@ key_value_pairs_from_hash_table(Arena *arena, HashTable *ht) return pairs; } +#include "third_party/radsort/radsort.h" + internal void sort_key_value_pairs_as_u32(KeyValuePair *pairs, U64 count) { diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index 42d2c8a7..c36ffbc4 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -512,6 +512,7 @@ rb_entry_point(CmdLine *cmdline) RDIM_SubsetFlags subset_flags = 0xffffffff; switch(output_kind) { + default:{}break; case OutputKind_RDI: { String8List only_names = cmd_line_strings(cmdline, str8_lit("only")); @@ -687,6 +688,8 @@ rb_entry_point(CmdLine *cmdline) //- rjf: convert done => generate output if(convert_done) switch(output_kind) { + default:{}break; + //- rjf: generate RDI blobs case OutputKind_RDI: { diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 839d2ad1..be6d8406 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -316,7 +316,7 @@ typedef enum ExecMode { ExecMode_Normal, ExecMode_IPCSender, - ExecMode_Converter, + ExecMode_BinaryUtility, ExecMode_Help, } ExecMode; @@ -421,9 +421,9 @@ entry_point(CmdLine *cmd_line) { exec_mode = ExecMode_IPCSender; } - else if(cmd_line_has_flag(cmd_line, str8_lit("convert"))) + else if(cmd_line_has_flag(cmd_line, str8_lit("bin"))) { - exec_mode = ExecMode_Converter; + exec_mode = ExecMode_BinaryUtility; } else if(cmd_line_has_flag(cmd_line, str8_lit("?")) || cmd_line_has_flag(cmd_line, str8_lit("help"))) @@ -824,8 +824,8 @@ entry_point(CmdLine *cmd_line) scratch_end(scratch); }break; - //- rjf: built-in pdb/dwarf -> rdi converter mode - case ExecMode_Converter: + //- rjf: built-in binary utility mode + case ExecMode_BinaryUtility: { rb_entry_point(cmd_line); }break; diff --git a/src/rdi_format/rdi_format_local.c b/src/rdi_format/rdi_format_local.c index 2000246a..11fe38f3 100644 --- a/src/rdi_format/rdi_format_local.c +++ b/src/rdi_format/rdi_format_local.c @@ -558,111 +558,6 @@ rdi_strings_from_locations(Arena *arena, RDI_Parsed *rdi, RDI_Arch arch, Rng1U64 //////////////////////////////// //~ rjf: RDI Dumping -internal void -rdi_dump_scope(Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RDI_Scope *scope, RDI_Arch arch) -{ - Temp scratch = scratch_begin(&arena, 1); - - U64 scope_count = 0; - U64 scope_voff_count = 0; - U64 local_count = 0; - U64 proc_count = 0; - U64 inline_site_count = 0; - RDI_Scope *scope_array = rdi_table_from_name(rdi, Scopes, &scope_count); - U64 *scope_voff_array = rdi_table_from_name(rdi, ScopeVOffData, &scope_voff_count); - RDI_Local *local_array = rdi_table_from_name(rdi, Locals, &local_count); - RDI_Procedure *proc_array = rdi_table_from_name(rdi, Procedures, &proc_count); - RDI_InlineSite *inline_site_array = rdi_table_from_name(rdi, InlineSites, &inline_site_count); - - U32 voff_range_lo = ClampTop(scope->voff_range_first, scope_voff_count); - U32 voff_range_hi = ClampTop(scope->voff_range_opl, scope_voff_count); - U32 voff_range_count = (voff_range_hi - voff_range_lo); - U64 *voff_ptr = scope_voff_array + voff_range_lo; - String8 voff_str = {0}; - { - Temp scratch = scratch_begin(&arena, 1); - String8List list = {0}; - for(U64 i = 0; i+2 <= voff_range_count; i += 2) - { - str8_list_pushf(scratch.arena, &list, "[%#llx, %#llx)", voff_ptr[i+0], voff_ptr[i+1]); - } - voff_str = str8_list_join(arena, &list, &(StringJoin){.sep=str8_lit(", ")}); - scratch_end(scratch); - } - - U64 scope_idx = (U64)(scope - scope_array); - dumpf("scope[%llu]", scope_idx); - rd_indent(); - - String8 proc_name = str8_lit("???"); - if (scope->proc_idx < proc_count) { - RDI_Procedure *proc = &proc_array[scope->proc_idx]; - proc_name = str8_from_rdi_string_idx(rdi, proc->name_string_idx); - } - - String8 inline_site_name = str8_lit(""); - if (scope->inline_site_idx != 0) { - if (scope->inline_site_idx < inline_site_count) { - RDI_InlineSite *inline_site = &inline_site_array[scope->inline_site_idx]; - inline_site_name = str8_from_rdi_string_idx(rdi, inline_site->name_string_idx); - } else { - inline_site_name = str8_lit("???"); - } - inline_site_name = push_str8f(scratch.arena, " '%S'", inline_site_name); - } - - dumpf("proc_idx =%u '%S'", scope->proc_idx, proc_name); - dumpf("first_child_scope_idx =%u", scope->first_child_scope_idx); - dumpf("next_sibling_scope_idx=%u", scope->next_sibling_scope_idx); - dumpf("inline_site_idx =%u%S", scope->inline_site_idx, inline_site_name); - dumpf("voff_ranges =%S", voff_str); - - // local_array - { - U32 local_lo = ClampTop(scope->local_first, local_count); - U32 local_hi = ClampTop(local_lo + scope->local_count, local_count); - if (local_lo < local_hi) { - for (U32 local_idx = local_lo; local_idx < local_hi; ++local_idx) { - RDI_Local *local_ptr = &local_array[local_idx]; - - dumpf("local[%u]", local_idx); - rd_indent(); - dumpf("kind =%S", rdi_string_from_local_kind(scratch.arena, local_ptr->kind)); - dumpf("name ='%S'", str8_from_rdi_string_idx(rdi, local_ptr->name_string_idx)); - dumpf("type_idx=%u", local_ptr->type_idx); - - if (local_ptr->location_first < local_ptr->location_opl) { - dumpf("locations:"); - rd_indent(); - rdi_dump_locations(arena, out, indent, rdi, arch, local_ptr->location_first, local_ptr->location_opl); - rd_unindent(); - } - rd_unindent(); - } - } - } - - for (U32 child_scope_idx = scope->first_child_scope_idx; child_scope_idx != 0; ) { - if (child_scope_idx >= scope_count) { - rd_errorf("child scope index (%u) is out of bounds", child_scope_idx); - break; - } - - rd_indent(); - RDI_Scope *child_scope = scope_array + child_scope_idx; - rdi_dump_scope(arena, out, indent, rdi, child_scope, arch); - rd_unindent(); - - // advance to next child - child_scope_idx = child_scope->next_sibling_scope_idx; - } - - rd_unindent(); - dumpf("[/%llu]", scope_idx); - - scratch_end(scratch); -} - internal String8List rdi_dump_list_from_parsed(Arena *arena, RDI_Parsed *rdi, RDI_DumpSubsetFlags flags) { diff --git a/src/rdi_format/rdi_format_local.h b/src/rdi_format/rdi_format_local.h index c3b29b90..0dea0f1c 100644 --- a/src/rdi_format/rdi_format_local.h +++ b/src/rdi_format/rdi_format_local.h @@ -97,7 +97,6 @@ internal String8List rdi_strings_from_locations(Arena *arena, RDI_Parsed *rdi, R //////////////////////////////// //~ rjf: RDI Dumping -internal void rdi_dump_scope (Arena *arena, String8List *out, String8 indent, RDI_Parsed *rdi, RDI_Scope *scope, RDI_Arch arch); internal String8List rdi_dump_list_from_parsed(Arena *arena, RDI_Parsed *rdi, RDI_DumpSubsetFlags flags); #endif // RDI_FORMAT_LOCAL_H diff --git a/src/scratch/convertperf.c b/src/scratch/convertperf.c index 88375edb..717db40d 100644 --- a/src/scratch/convertperf.c +++ b/src/scratch/convertperf.c @@ -53,7 +53,7 @@ entry_point(CmdLine *cmdline) String8 dll_name = str8_skip_last_slash(dll_path_no_ext); String8 pdb_path = push_str8f(arena, "%S.pdb", dll_path_no_ext); String8 rdi_path = push_str8f(arena, "dump/%S.rdi", dll_name); - OS_Handle handle = os_cmd_line_launchf("raddbg --convert --pdb:%S --out:%S", pdb_path, rdi_path); + OS_Handle handle = os_cmd_line_launchf("raddbg --bin %S --out:%S", pdb_path, rdi_path); os_handle_list_push(arena, &processes, handle); if(processes_first_path_n == 0) {