diff --git a/project.4coder b/project.4coder index bd53fe4b..23c42411 100644 --- a/project.4coder +++ b/project.4coder @@ -47,7 +47,7 @@ commands = { //- rjf: [raddbg] // .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, - .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, + .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, //- rjf: [raddbg wsl] // .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index 137004ac..7b7f885d 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -672,7 +672,23 @@ rb_entry_point(CmdLine *cmdline) convert_params.subset_flags = subset_flags; convert_params.deterministic = cmd_line_has_flag(cmdline, str8_lit("deterministic")); } - ProfScope("convert") bake_params = p2r_convert(arena, async_root, &convert_params); + if(cmd_line_has_flag(cmdline, str8_lit("p2r2"))) + { + ProfScope("convert (2)") + { + U64 thread_count = os_get_system_info()->logical_processor_count; + Arena **thread_arenas = push_array(arena, Arena *, thread_count); + for EachIndex(idx, thread_count) + { + thread_arenas[idx] = arena_alloc(); + } + bake_params = p2r2_convert(thread_arenas, thread_count, &convert_params); + } + } + else + { + ProfScope("convert") bake_params = p2r_convert(arena, async_root, &convert_params); + } // rjf: no output path? -> pick one based on PDB if(output_path.size == 0) switch(output_kind) diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 7618b82c..fcbcda8d 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -239,6 +239,7 @@ #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_pdb/rdi_from_pdb_2.h" #include "rdi_from_dwarf/rdi_from_dwarf.h" #include "rdi_breakpad_from_pdb/rdi_breakpad_from_pdb.h" #include "radbin/radbin.h" @@ -289,6 +290,7 @@ #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_pdb/rdi_from_pdb_2.c" #include "rdi_from_dwarf/rdi_from_dwarf.c" #include "rdi_breakpad_from_pdb/rdi_breakpad_from_pdb.c" #include "radbin/radbin.c" diff --git a/src/rdi_from_pdb/rdi_from_pdb_2.c b/src/rdi_from_pdb/rdi_from_pdb_2.c index 98f748b4..66a9b045 100644 --- a/src/rdi_from_pdb/rdi_from_pdb_2.c +++ b/src/rdi_from_pdb/rdi_from_pdb_2.c @@ -6,7 +6,8 @@ p2r2_convert_thread_entry_point(void *p) { P2R2_ConvertThreadParams *params = (P2R2_ConvertThreadParams *)p; Arena *arena = params->arena; - lane_thread(params->lane_idx, params->lane_count); + lane_ctx(params->lane_ctx); + ThreadNameF("p2r2_convert_thread_%I64u", lane_idx()); ////////////////////////////////////////////////////////////// //- rjf: do top-level MSF/PDB extraction @@ -605,5 +606,39 @@ p2r2_convert_thread_entry_point(void *p) } RDIM_SrcFileChunkList all_src_files__sequenceless = {0}; P2R_SrcFileMap src_file_map = {0}; - +} + +internal RDIM_BakeParams +p2r2_convert(Arena **thread_arenas, U64 thread_count, P2R_ConvertParams *in) +{ + RDIM_BakeParams result = {0}; + Temp scratch = scratch_begin(thread_arenas, thread_count); + Barrier barrier = barrier_alloc(thread_count); + { + P2R2_ConvertThreadParams *thread_params = push_array(scratch.arena, P2R2_ConvertThreadParams, thread_count); + OS_Handle *threads = push_array(scratch.arena, OS_Handle, thread_count); + for EachIndex(idx, thread_count) + { + thread_params[idx].arena = thread_arenas[idx]; + thread_params[idx].lane_ctx.lane_idx = idx; + thread_params[idx].lane_ctx.lane_count = thread_count; + thread_params[idx].lane_ctx.barrier = barrier; + thread_params[idx].input_exe_name = in->input_exe_name; + thread_params[idx].input_exe_data = in->input_exe_data; + thread_params[idx].input_pdb_name = in->input_pdb_name; + thread_params[idx].input_pdb_data = in->input_pdb_data; + thread_params[idx].deterministic = in->deterministic; + } + for EachIndex(idx, thread_count) + { + threads[idx] = os_thread_launch(p2r2_convert_thread_entry_point, &thread_params[idx], 0); + } + for EachIndex(idx, thread_count) + { + os_thread_join(threads[idx], max_U64); + } + } + barrier_release(barrier); + scratch_end(scratch); + return result; } diff --git a/src/rdi_from_pdb/rdi_from_pdb_2.h b/src/rdi_from_pdb/rdi_from_pdb_2.h index cd18b84f..79387ff2 100644 --- a/src/rdi_from_pdb/rdi_from_pdb_2.h +++ b/src/rdi_from_pdb/rdi_from_pdb_2.h @@ -8,8 +8,7 @@ typedef struct P2R2_ConvertThreadParams P2R2_ConvertThreadParams; struct P2R2_ConvertThreadParams { Arena *arena; - U64 lane_idx; - U64 lane_count; + LaneCtx lane_ctx; String8 input_exe_name; String8 input_exe_data; String8 input_pdb_name; @@ -56,5 +55,6 @@ struct P2R2_Shared global P2R2_Shared *p2r2_shared = 0; internal void p2r2_convert_thread_entry_point(void *p); +internal RDIM_BakeParams p2r2_convert(Arena **thread_arenas, U64 thread_count, P2R_ConvertParams *in); #endif // RDI_FROM_PDB_2_H