From 1ecabff7b6443f42d74d23df3ca1b492f6c26947 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 23 Oct 2024 11:49:47 -0700 Subject: [PATCH] prefer usage of pdbs in dbgi layer, if rdi path is not baked in, but pdb path *is* - otherwise the dbgi layer can simply choose a stale rdi file with no way to generate a new one. --- src/ctrl/ctrl_core.c | 36 +++++++++++----------- src/dbg_engine/dbg_engine.mdesk | 1 - src/dbg_engine/dbg_engine_core.c | 15 --------- src/dbg_engine/generated/dbg_engine.meta.h | 2 -- src/raddbg/raddbg_core.c | 12 +++++++- src/raddbg/raddbg_views.c | 2 +- 6 files changed, 30 insertions(+), 38 deletions(-) diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index 6faf6fc9..ab1f3460 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -3614,7 +3614,6 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_ tls_vaddr_range = r1u64(tls_header.index_address, tls_header.index_address+sizeof(U32)); // rjf: grab data about debug info - if(data_dir_count > PE_DataDirectoryIndex_DEBUG) { // rjf: read data dir @@ -3683,27 +3682,28 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_ { Temp scratch = scratch_begin(0, 0); String8 exe_folder = str8_chop_last_slash(path); - String8 rdi_path__absolute = rdi_dbg_path; - String8 rdi_path__relative = push_str8f(scratch.arena, "%S/%S", exe_folder, rdi_dbg_path); - String8 pdb_path__absolute = pdb_dbg_path; - String8 pdb_path__relative = push_str8f(scratch.arena, "%S/%S", exe_folder, pdb_dbg_path); - String8 dbg_path_candidates[] = + String8List dbg_path_candidates = {0}; + if(rdi_dbg_path.size != 0) { - /* inferred (treated as absolute): */ rdi_path__absolute, - /* inferred (treated as relative): */ rdi_path__relative, - /* inferred (treated as absolute): */ pdb_path__absolute, - /* inferred (treated as relative): */ pdb_path__relative, - /* "foo.exe" -> "foo.rdi" */ push_str8f(scratch.arena, "%S.rdi", str8_chop_last_dot(path)), - /* "foo.exe" -> "foo.exe.rdi" */ push_str8f(scratch.arena, "%S.rdi", path), - /* "foo.exe" -> "foo.pdb" */ push_str8f(scratch.arena, "%S.pdb", str8_chop_last_dot(path)), - /* "foo.exe" -> "foo.exe.pdb" */ push_str8f(scratch.arena, "%S.pdb", path), - }; - for(U64 idx = 0; idx < ArrayCount(dbg_path_candidates); idx += 1) + str8_list_push(scratch.arena, &dbg_path_candidates, rdi_dbg_path); + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S/%S", exe_folder, rdi_dbg_path); + } + if(pdb_dbg_path.size != 0) { - FileProperties props = os_properties_from_file_path(dbg_path_candidates[idx]); + str8_list_push(scratch.arena, &dbg_path_candidates, pdb_dbg_path); + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S/%S", exe_folder, pdb_dbg_path); + } + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S.pdb", str8_chop_last_dot(path)); + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S.pdb", path); + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S.rdi", str8_chop_last_dot(path)); + str8_list_pushf(scratch.arena, &dbg_path_candidates, "%S.rdi", path); + for(String8Node *n = dbg_path_candidates.first; n != 0; n = n->next) + { + String8 candidate_path = n->string; + FileProperties props = os_properties_from_file_path(candidate_path); if(props.modified != 0 && props.size != 0) { - initial_debug_info_path = push_str8_copy(arena, dbg_path_candidates[idx]); + initial_debug_info_path = push_str8_copy(arena, candidate_path); break; } } diff --git a/src/dbg_engine/dbg_engine.mdesk b/src/dbg_engine/dbg_engine.mdesk index ce428b4c..8dc7469c 100644 --- a/src/dbg_engine/dbg_engine.mdesk +++ b/src/dbg_engine/dbg_engine.mdesk @@ -107,7 +107,6 @@ D_ViewRuleTable: @table(name) D_DevToggleTable: { - {telemetry_capture} {simulate_lag} {draw_ui_text_pos} {draw_ui_focus_debug} diff --git a/src/dbg_engine/dbg_engine_core.c b/src/dbg_engine/dbg_engine_core.c index 74d8126c..f92b520c 100644 --- a/src/dbg_engine/dbg_engine_core.c +++ b/src/dbg_engine/dbg_engine_core.c @@ -1974,21 +1974,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P } } - ////////////////////////////// - //- rjf: start/stop telemetry captures - // - ProfScope("start/stop telemetry captures") - { - if(!ProfIsCapturing() && DEV_telemetry_capture) - { - ProfBeginCapture("raddbg"); - } - if(ProfIsCapturing() && !DEV_telemetry_capture) - { - ProfEndCapture(); - } - } - ////////////////////////////// //- rjf: process top-level commands // diff --git a/src/dbg_engine/generated/dbg_engine.meta.h b/src/dbg_engine/generated/dbg_engine.meta.h index 7acf8e82..d129e3d2 100644 --- a/src/dbg_engine/generated/dbg_engine.meta.h +++ b/src/dbg_engine/generated/dbg_engine.meta.h @@ -71,7 +71,6 @@ D_ViewRuleKind_Geo3D, D_ViewRuleKind_COUNT, } D_ViewRuleKind; -global B32 DEV_telemetry_capture = 0; global B32 DEV_simulate_lag = 0; global B32 DEV_draw_ui_text_pos = 0; global B32 DEV_draw_ui_focus_debug = 0; @@ -83,7 +82,6 @@ global B32 DEV_scratch_mouse_draw = 0; global B32 DEV_updating_indicator = 0; struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] = { -{&DEV_telemetry_capture, str8_lit_comp("telemetry_capture")}, {&DEV_simulate_lag, str8_lit_comp("simulate_lag")}, {&DEV_draw_ui_text_pos, str8_lit_comp("draw_ui_text_pos")}, {&DEV_draw_ui_focus_debug, str8_lit_comp("draw_ui_focus_debug")}, diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index eed2552f..72c1dafe 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -3962,6 +3962,16 @@ rd_window_frame(RD_Window *ws) ui_set_next_flags(UI_BoxFlag_ViewScrollY|UI_BoxFlag_AllowOverflowY|UI_BoxFlag_ViewClamp); UI_PaneF(r2f32p(30, 30, 30+ui_top_font_size()*100, ui_top_font_size()*150), "###dev_ctx_menu") { + //- rjf: capture + if(!ProfIsCapturing() && ui_clicked(ui_buttonf("Begin Profiler Capture###prof_cap"))) + { + ProfBeginCapture("raddbg"); + } + else if(ProfIsCapturing() && ui_clicked(ui_buttonf("End Profiler Capture###prof_cap"))) + { + ProfEndCapture(); + } + //- rjf: toggles for(U64 idx = 0; idx < ArrayCount(DEV_toggle_table); idx += 1) { @@ -16566,7 +16576,7 @@ rd_frame(void) ////////////////////////////// //- rjf: capture is active? -> keep rendering // - if(ProfIsCapturing() || DEV_telemetry_capture) + if(ProfIsCapturing()) { rd_request_frame(); } diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index eeebc456..649c5271 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -5874,7 +5874,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(text) ////////////////////////////// //- rjf: build missing file interface // - if(file_is_missing && !key_has_data) + if(file_is_missing && !u128_match(hash, u128_zero())) { UI_WidthFill UI_HeightFill UI_Column UI_Padding(ui_pct(1, 0)) {