From bee2570d3991d1e40e60669c1e6feeedae5de0d7 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 18 Jun 2025 09:56:47 -0700 Subject: [PATCH] fix double-load in radbin conversion path; fix incorrect mutation of potentially-nil trees when snapping to a file without a specific line; fix di_close path when work is occurring --- project.4coder | 3 +++ src/ctrl/ctrl_core.c | 10 +--------- src/dbgi/dbgi.c | 6 +++--- src/radbin/radbin.c | 10 ++++++---- src/raddbg/raddbg_core.c | 8 ++++---- src/rdi_make/rdi_make_local.c | 2 +- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/project.4coder b/project.4coder index 020bef78..9da7220b 100644 --- a/project.4coder +++ b/project.4coder @@ -48,6 +48,9 @@ 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, }, + //- rjf: [scratch] + .f2 = { .win = "raddbg_stable --ipc kill_all && build radbin release telemetry && raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, + //- rjf: [textperf] // .f1 = { .win = "raddbg_stable --ipc kill_all && build no_meta telemetry textperf && raddbg_stable --ipc bring_to_front && raddbg_stable --ipc run", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 1611c6b5..74d42c35 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -4879,15 +4879,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg, } } - //- rjf: for each pre-emptively loaded key, try to grab RDI - kicking off parse - for(DI_KeyNode *n = preemptively_loaded_keys.first; n != 0; n = n->next) - { - DI_Scope *di_scope = di_scope_open(); - RDI_Parsed *rdi = di_rdi_from_key(di_scope, &n->v, 0, 0); - di_scope_close(di_scope); - } - - //- rjf: close all pre-emptively loaded keys + //- rjf: close each pre-emptively loaded key for(DI_KeyNode *n = preemptively_loaded_keys.first; n != 0; n = n->next) { di_close(&n->v); diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index cec1e2e3..fc1801b9 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -531,7 +531,6 @@ di_close(DI_Key *key) DI_Slot *slot = &di_shared->slots[slot_idx]; DI_Stripe *stripe = &di_shared->stripes[stripe_idx]; log_infof("close_debug_info: {\"%S\", 0x%I64x}\n", key_normalized.path, key_normalized.min_timestamp); - B32 closed = 0; OS_MutexScopeW(stripe->rw_mutex) { //- rjf: find existing node @@ -544,7 +543,8 @@ di_close(DI_Key *key) if(node->ref_count == 0) for(;;) { //- rjf: release - if(ins_atomic_u64_eval(&node->touch_count) == 0) + if(ins_atomic_u64_eval(&node->touch_count) == 0 && + ins_atomic_u64_eval(&node->is_working) == 0) { di_string_release__stripe_mutex_w_guarded(stripe, node->key.path); if(node->file_base != 0) @@ -568,7 +568,7 @@ di_close(DI_Key *key) break; } - //- rjf: wait for touch count to go to 0 + //- rjf: wait for touch count / working marker to go to 0 os_condition_variable_wait_rw_w(stripe->cv, stripe->rw_mutex, max_U64); } } diff --git a/src/radbin/radbin.c b/src/radbin/radbin.c index 236c1d29..80752243 100644 --- a/src/radbin/radbin.c +++ b/src/radbin/radbin.c @@ -22,6 +22,7 @@ rb_entry_point(CmdLine *cmdline) //- rjf: analyze & load command line input files // RB_FileList input_files = {0}; + ProfScope("analyze & load command line input files") { String8List input_file_path_tasks = str8_list_copy(arena, &cmdline->inputs); for(String8Node *n = input_file_path_tasks.first; n != 0; n = n->next) @@ -31,6 +32,7 @@ rb_entry_point(CmdLine *cmdline) // RB_FileFormat file_format = RB_FileFormat_Null; RB_FileFormatFlags file_format_flags = 0; + ProfScope("do thin analysis of file") { OS_Handle file = os_file_open(OS_AccessFlag_Read, n->string); FileProperties props = os_properties_from_file(file); @@ -232,7 +234,7 @@ rb_entry_point(CmdLine *cmdline) //- rjf: load recognized files // String8 file_data = {0}; - if(file_format != RB_FileFormat_Null) + if(file_format != RB_FileFormat_Null) ProfScope("load recognized file") { file_data = os_data_from_file_path(arena, n->string); } @@ -240,7 +242,7 @@ rb_entry_point(CmdLine *cmdline) ////////////////////////// //- rjf: PE format => generate new implicit path tasks for PDBs // - if(file_format == RB_FileFormat_PE) + if(file_format == RB_FileFormat_PE) ProfScope("PE file => generate task for PDB") { Temp scratch = scratch_begin(&arena, 1); PE_BinInfo pe_bin_info = pe_bin_info_from_data(scratch.arena, file_data); @@ -656,8 +658,8 @@ rb_entry_point(CmdLine *cmdline) RB_File *pdb_file = rb_file_list_first(&input_files_from_format_table[RB_FileFormat_PDB]); String8 exe_path = exe_file->path; String8 pdb_path = pdb_file->path; - String8 exe_data = os_data_from_file_path(arena, exe_path); - String8 pdb_data = os_data_from_file_path(arena, pdb_path); + String8 exe_data = exe_file->data; + String8 pdb_data = pdb_file->data; // rjf: convert P2R_ConvertParams convert_params = {0}; diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 2e7d4066..7e62e953 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -15121,10 +15121,10 @@ rd_frame(void) vs->last_frame_index_built = 0; RD_Cfg *expr = rd_cfg_child_from_string_or_alloc(dst_tab, str8_lit("expression")); rd_cfg_new_replace(expr, rd_eval_string_from_file_path(scratch.arena, file_path)); - rd_cfg_new_replace(rd_cfg_child_from_string(dst_tab, str8_lit("cursor_line")), str8_lit("1")); - rd_cfg_new_replace(rd_cfg_child_from_string(dst_tab, str8_lit("cursor_column")), str8_lit("1")); - rd_cfg_new_replace(rd_cfg_child_from_string(dst_tab, str8_lit("mark_line")), str8_lit("1")); - rd_cfg_new_replace(rd_cfg_child_from_string(dst_tab, str8_lit("mark_column")), str8_lit("1")); + rd_cfg_new_replace(rd_cfg_child_from_string_or_alloc(dst_tab, str8_lit("cursor_line")), str8_lit("1")); + rd_cfg_new_replace(rd_cfg_child_from_string_or_alloc(dst_tab, str8_lit("cursor_column")), str8_lit("1")); + rd_cfg_new_replace(rd_cfg_child_from_string_or_alloc(dst_tab, str8_lit("mark_line")), str8_lit("1")); + rd_cfg_new_replace(rd_cfg_child_from_string_or_alloc(dst_tab, str8_lit("mark_column")), str8_lit("1")); } else if(dst_panel != &rd_nil_panel_node && dst_tab == &rd_nil_cfg) { diff --git a/src/rdi_make/rdi_make_local.c b/src/rdi_make/rdi_make_local.c index dd75baf1..3fd652cb 100644 --- a/src/rdi_make/rdi_make_local.c +++ b/src/rdi_make/rdi_make_local.c @@ -917,7 +917,7 @@ rdim_bake(Arena *arena, ASYNC_Root *async_root, RDIM_BakeParams *in_params) ASYNC_TaskList sort_bake_string_map_tasks = {0}; RDIM_BakeStringMapLoose *sorted_bake_string_map__in_progress = rdim_bake_string_map_loose_make(arena, &bake_string_map_topology); { - U64 slots_per_task = 4096; + U64 slots_per_task = 256; U64 num_tasks = (bake_string_map_topology.slots_count+slots_per_task-1)/slots_per_task; for(U64 task_idx = 0; task_idx < num_tasks; task_idx += 1) {