From 638140ab8758485bd48a9a4fc3f1b4647eb10abe Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 12 Sep 2024 14:10:41 -0700 Subject: [PATCH] another checkpoint, moving d_regs -> df_regs; eliminating more state & responsibilities from dbg_engine --- project.4coder | 2 +- src/dbg_frontend/dbg_frontend_core.c | 146 +++++++++++------- src/dbg_frontend/dbg_frontend_core.h | 2 + src/dbg_frontend/dbg_frontend_views.c | 192 ++++++++++++------------ src/dbg_frontend/dbg_frontend_widgets.c | 50 +++--- src/raddbg/raddbg_main.c | 34 ----- 6 files changed, 214 insertions(+), 212 deletions(-) diff --git a/project.4coder b/project.4coder index b93c01d4..7ad1d001 100644 --- a/project.4coder +++ b/project.4coder @@ -46,7 +46,7 @@ load_paths = commands = { //- rjf: fkey command slots (change locally but do not commit) - .f1 = { .win = "build raddbg telemetry clang", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, + .f1 = { .win = "build raddbg telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, .f2 = { .win = "build rdi_from_pdb", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, .f3 = { .win = "pushd build && raddbg.exe --user:local_dev.raddbg_user --project:local_dev.raddbg_project --auto_run && popd", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, }, diff --git a/src/dbg_frontend/dbg_frontend_core.c b/src/dbg_frontend/dbg_frontend_core.c index f00cc29d..dab2401b 100644 --- a/src/dbg_frontend/dbg_frontend_core.c +++ b/src/dbg_frontend/dbg_frontend_core.c @@ -469,9 +469,9 @@ df_cmd_params_from_window(DF_Window *window) p.panel = df_handle_from_panel(window->focused_panel); p.view = df_handle_from_view(df_selected_tab_from_panel(window->focused_panel)); p.prefer_dasm = df_prefer_dasm_from_window(window); - p.entity = d_regs()->thread; - p.unwind_index = d_regs()->unwind_count; - p.inline_depth = d_regs()->inline_depth; + p.entity = df_regs()->thread; + p.unwind_index = df_regs()->unwind_count; + p.inline_depth = df_regs()->inline_depth; return p; } @@ -483,9 +483,9 @@ df_cmd_params_from_panel(DF_Window *window, DF_Panel *panel) p.panel = df_handle_from_panel(panel); p.view = df_handle_from_view(df_selected_tab_from_panel(panel)); p.prefer_dasm = df_prefer_dasm_from_window(window); - p.entity = d_regs()->thread; - p.unwind_index = d_regs()->unwind_count; - p.inline_depth = d_regs()->inline_depth; + p.entity = df_regs()->thread; + p.unwind_index = df_regs()->unwind_count; + p.inline_depth = df_regs()->inline_depth; return p; } @@ -497,9 +497,9 @@ df_cmd_params_from_view(DF_Window *window, DF_Panel *panel, DF_View *view) p.panel = df_handle_from_panel(panel); p.view = df_handle_from_view(view); p.prefer_dasm = df_prefer_dasm_from_window(window); - p.entity = d_regs()->thread; - p.unwind_index = d_regs()->unwind_count; - p.inline_depth = d_regs()->inline_depth; + p.entity = df_regs()->thread; + p.unwind_index = df_regs()->unwind_count; + p.inline_depth = df_regs()->inline_depth; return p; } @@ -1033,7 +1033,7 @@ df_window_open(Vec2F32 size, OS_Handle preferred_monitor, D_CfgSrc cfg_src) } if(df_state->first_window == 0) D_RegsScope { - d_regs()->window = df_handle_from_window(window); + df_regs()->window = df_handle_from_window(window); DF_FontSlot english_font_slots[] = {DF_FontSlot_Main, DF_FontSlot_Code}; DF_FontSlot icon_font_slot = DF_FontSlot_Icons; for(U64 idx = 0; idx < ArrayCount(english_font_slots); idx += 1) @@ -1186,8 +1186,8 @@ df_window_frame(DF_Window *ws) ////////////////////////////// //- rjf: fill panel/view interaction registers // - d_regs()->panel = df_handle_from_panel(ws->focused_panel); - d_regs()->view = ws->focused_panel->selected_tab_view; + df_regs()->panel = df_handle_from_panel(ws->focused_panel); + df_regs()->view = ws->focused_panel->selected_tab_view; ////////////////////////////// //- rjf: process view-level commands on leaf panels @@ -1205,15 +1205,15 @@ df_window_frame(DF_Window *ws) DF_View *view = df_selected_tab_from_panel(panel); if(!df_view_is_nil(view)) { - d_push_regs(); - d_regs()->panel = df_handle_from_panel(panel); - d_regs()->view = df_handle_from_view(view); + df_push_regs(); + df_regs()->panel = df_handle_from_panel(panel); + df_regs()->view = df_handle_from_view(view); DF_ViewCmdFunctionType *do_view_cmds_function = view->spec->info.cmd_hook; do_view_cmds_function(view, view->params_roots[view->params_read_gen%ArrayCount(view->params_roots)], str8(view->query_buffer, view->query_string_size)); - D_Regs *view_regs = d_pop_regs(); + DF_Regs *view_regs = df_pop_regs(); if(panel == ws->focused_panel) { - MemoryCopyStruct(d_regs(), view_regs); + MemoryCopyStruct(df_regs(), view_regs); } } } @@ -1481,7 +1481,7 @@ df_window_frame(DF_Window *ws) //- rjf: draw current interaction regs { - D_Regs *regs = d_regs(); + DF_Regs *regs = df_regs(); #define Handle(name) ui_labelf("%s: [0x%I64x, 0x%I64x]", #name, (regs->name).u64[0], (regs->name).u64[1]) Handle(window); Handle(panel); @@ -1613,7 +1613,7 @@ df_window_frame(DF_Window *ws) } if(range.min.line == range.max.line && ui_clicked(df_icon_buttonf(DF_IconKind_RightArrow, 0, "Set Next Statement"))) { - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); U64 new_rip_vaddr = ws->code_ctx_menu_vaddr; if(ws->code_ctx_menu_file_path.size != 0) { @@ -1699,7 +1699,7 @@ df_window_frame(DF_Window *ws) } if(ws->code_ctx_menu_file_path.size != 0 && range.min.line == range.max.line && ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Go To Disassembly"))) { - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); U64 vaddr = 0; for(D_LineNode *n = lines.first; n != 0; n = n->next) { @@ -4828,12 +4828,12 @@ df_window_frame(DF_Window *ws) UI_WidthFill { //- rjf: push interaction registers, fill with per-view states - d_push_regs(); + df_push_regs(); { DF_View *view = df_selected_tab_from_panel(panel); - d_regs()->panel = df_handle_from_panel(panel); - d_regs()->view = df_handle_from_view(view); - d_regs()->file_path = d_file_path_from_eval_string(d_frame_arena(), str8(view->query_buffer, view->query_string_size)); + df_regs()->panel = df_handle_from_panel(panel); + df_regs()->view = df_handle_from_view(view); + df_regs()->file_path = d_file_path_from_eval_string(d_frame_arena(), str8(view->query_buffer, view->query_string_size)); } //- rjf: build view container @@ -4860,10 +4860,10 @@ df_window_frame(DF_Window *ws) } //- rjf: pop interaction registers; commit if this is the selected view - D_Regs *view_regs = d_pop_regs(); + DF_Regs *view_regs = df_pop_regs(); if(ws->focused_panel == panel) { - MemoryCopyStruct(d_regs(), view_regs); + MemoryCopyStruct(df_regs(), view_regs); } } @@ -6055,7 +6055,7 @@ df_append_value_strings_from_eval(Arena *arena, EV_StringFlags flags, U32 defaul E_Eval value_eval = e_value_eval_from_eval(eval); B32 ptee_has_content = (direct_type_kind != E_TypeKind_Null && direct_type_kind != E_TypeKind_Void); B32 ptee_has_string = (E_TypeKind_Char8 <= direct_type_kind && direct_type_kind <= E_TypeKind_UChar32); - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); String8 symbol_name = d_symbol_name_from_process_vaddr(arena, process, value_eval.value.u64, 1); @@ -6343,7 +6343,7 @@ df_value_string_from_eval(Arena *arena, EV_StringFlags flags, U32 default_radix, internal void df_set_hover_eval(Vec2F32 pos, String8 file_path, TxtPt pt, U64 vaddr, String8 string) { - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); if(window->hover_eval_last_frame_idx+1 < df_state->frame_index && ui_key_match(ui_active_key(UI_MouseButtonKind_Left), ui_key_zero()) && ui_key_match(ui_active_key(UI_MouseButtonKind_Middle), ui_key_zero()) && @@ -6585,7 +6585,7 @@ df_view_rule_autocomp_lister_params_from_input_cursor(Arena *arena, String8 stri internal void df_set_autocomp_lister_query(UI_Key root_key, DF_AutoCompListerParams *params, String8 input, U64 cursor_off) { - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); String8 query = df_autocomp_query_word_from_input_string_off(input, cursor_off); String8 current_query = str8(window->autocomp_lister_query_buffer, window->autocomp_lister_query_size); if(cursor_off != window->autocomp_cursor_off) @@ -6785,7 +6785,7 @@ df_theme_color_from_txt_token_kind(TXT_TokenKind kind) internal UI_Palette * df_palette_from_code(DF_PaletteCode code) { - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); UI_Palette *result = &window->cfg_palettes[code]; return result; } @@ -6803,7 +6803,7 @@ internal F32 df_font_size_from_slot(DF_FontSlot slot) { F32 result = 0; - DF_Window *ws = df_window_from_handle(d_regs()->window); + DF_Window *ws = df_window_from_handle(df_regs()->window); F32 dpi = os_dpi_from_window(ws->os); if(dpi != ws->last_dpi) { @@ -6857,7 +6857,7 @@ df_raster_flags_from_slot(DF_FontSlot slot) internal DF_SettingVal df_setting_val_from_code(DF_SettingCode code) { - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); DF_SettingVal result = {0}; if(window != 0) { @@ -7629,6 +7629,17 @@ df_init(CmdLine *cmdln) { df_state->frame_arenas[idx] = arena_alloc(); } + df_state->log = log_alloc(); + log_select(df_state->log); + { + Temp scratch = scratch_begin(0, 0); + String8 user_program_data_path = os_get_process_info()->user_program_data_path; + String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg/logs", user_program_data_path); + df_state->log_path = push_str8f(df_state->arena, "%S/ui_thread.raddbg_log", user_data_folder); + os_make_directory(user_data_folder); + os_write_data_to_file_path(df_state->log_path, str8_zero()); + scratch_end(scratch); + } df_state->num_frames_requested = 2; df_state->seconds_until_autosave = 0.5f; df_state->cmds_arena = arena_alloc(); @@ -7648,6 +7659,8 @@ df_init(CmdLine *cmdln) df_state->cfg_code_font_path_arena = arena_alloc(); df_state->rich_hover_info_next_arena = arena_alloc(); df_state->rich_hover_info_current_arena = arena_alloc(); + df_state->bind_change_arena = arena_alloc(); + df_state->top_regs = &df_state->base_regs; df_clear_bindings(); // rjf: register gfx layer views @@ -7785,6 +7798,7 @@ df_frame(void) Temp scratch = scratch_begin(0, 0); DI_Scope *di_scope = di_scope_open(); local_persist S32 depth = 0; + log_scope_begin(); ////////////////////////////// //- rjf: do per-frame resets @@ -8016,10 +8030,10 @@ df_frame(void) ////////////////////////////// //- rjf: unpack eval-dependent info // - D_Entity *process = d_entity_from_handle(d_regs()->process); - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *process = d_entity_from_handle(df_regs()->process); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); Arch arch = d_arch_from_entity(thread); - U64 unwind_count = d_regs()->unwind_count; + U64 unwind_count = df_regs()->unwind_count; U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); CTRL_Unwind unwind = d_query_cached_unwind_from_thread(thread); D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr); @@ -8290,12 +8304,12 @@ df_frame(void) //- rjf: command fast path case DF_CmdKind_RunCommand: { - DF_CmdKindInfo *info = df_cmd_kind_info_from_string(cmd->name); + DF_CmdKindInfo *info = df_cmd_kind_info_from_string(cmd->regs->string); // rjf: command simply executes - just no-op in this layer - if(info->query.flags & DF_QueryFlag_Required) + if(!(info->query.flags & DF_QueryFlag_Required)) { - df_push_cmd(cmd->name, df_regs()); + df_push_cmd(cmd->regs->string, df_regs()); } // rjf: command has required query -> prep query @@ -8305,7 +8319,7 @@ df_frame(void) if(window != 0) { arena_clear(window->query_cmd_arena); - window->query_cmd_name = push_str8_copy(window->query_cmd_arena, cmd->name); + window->query_cmd_name = push_str8_copy(window->query_cmd_arena, cmd->regs->string); window->query_cmd_regs = df_regs_copy(window->query_cmd_arena, df_regs()); MemoryZeroArray(window->query_cmd_regs_mask); window->query_view_selected = 1; @@ -9195,20 +9209,23 @@ df_frame(void) } else { - cmd_name = child->string; - for(U64 idx = 0; idx < ArrayCount(df_g_binding_version_remap_old_name_table); idx += 1) - { - if(str8_match(df_g_binding_version_remap_old_name_table[idx], child->string, StringMatchFlag_CaseInsensitive)) - { - String8 new_name = df_g_binding_version_remap_new_name_table[idx]; - cmd_name = new_name; - } - } OS_Key k = df_os_key_from_cfg_string(child->string); if(k != OS_Key_Null) { key = k; } + else + { + cmd_name = child->string; + for(U64 idx = 0; idx < ArrayCount(df_g_binding_version_remap_old_name_table); idx += 1) + { + if(str8_match(df_g_binding_version_remap_old_name_table[idx], child->string, StringMatchFlag_CaseInsensitive)) + { + String8 new_name = df_g_binding_version_remap_new_name_table[idx]; + cmd_name = new_name; + } + } + } } } if(cmd_name.size != 0 && key != OS_Key_Null) @@ -10897,7 +10914,7 @@ df_frame(void) { file_path = df_regs()->file_path; point = df_regs()->cursor; - thread = d_entity_from_handle(d_regs()->thread); + thread = d_entity_from_handle(df_regs()->thread); process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); vaddr = df_regs()->vaddr; } @@ -11440,7 +11457,7 @@ df_frame(void) #if 0 // TODO(rjf): @msgs these should no longer be necessary; "at cursor" -> just run the command with whatever the registers have case DF_CmdKind_ToggleBreakpointAtCursor: { - D_Regs *regs = d_regs(); + D_Regs *regs = df_regs(); D_CmdParams p = d_cmd_params_zero(); p.file_path = regs->file_path; p.text_point = regs->cursor; @@ -11449,7 +11466,7 @@ df_frame(void) }break; case DF_CmdKind_ToggleWatchPinAtCursor: { - D_Regs *regs = d_regs(); + D_Regs *regs = df_regs(); D_CmdParams p = d_cmd_params_zero(); p.file_path = regs->file_path; p.text_point = regs->cursor; @@ -11463,7 +11480,7 @@ df_frame(void) { HS_Scope *hs_scope = hs_scope_open(); TXT_Scope *txt_scope = txt_scope_open(); - D_Regs *regs = d_regs(); + DF_Regs *regs = df_regs(); U128 text_key = regs->text_key; TXT_LangKind lang_kind = regs->lang_kind; TxtRng range = txt_rng(regs->cursor, regs->mark); @@ -12191,14 +12208,14 @@ df_frame(void) { df_state->last_focused_window = df_handle_from_window(w); } - d_push_regs(); - d_regs()->window = df_handle_from_window(w); + df_push_regs(); + df_regs()->window = df_handle_from_window(w); df_window_frame(w); MemoryZeroStruct(&w->ui_events); - D_Regs *window_regs = d_pop_regs(); + DF_Regs *window_regs = df_pop_regs(); if(df_window_from_handle(df_state->last_focused_window) == w) { - MemoryCopyStruct(d_regs(), window_regs); + MemoryCopyStruct(df_regs(), window_regs); } } } @@ -12275,6 +12292,23 @@ df_frame(void) df_state->frame_index += 1; df_state->time_in_seconds += df_state->frame_dt; + ////////////////////////////// + //- rjf: collect logs + // + { + LogScopeResult log = log_scope_end(scratch.arena); + os_append_data_to_file_path(df_state->log_path, log.strings[LogMsgKind_Info]); + if(log.strings[LogMsgKind_UserError].size != 0) + { + for(DF_Window *w = df_state->first_window; w != 0; w = w->next) + { + w->error_string_size = Min(sizeof(w->error_buffer), log.strings[LogMsgKind_UserError].size); + MemoryCopy(w->error_buffer, log.strings[LogMsgKind_UserError].str, w->error_string_size); + w->error_t = 1.f; + } + } + } + di_scope_close(di_scope); scratch_end(scratch); } diff --git a/src/dbg_frontend/dbg_frontend_core.h b/src/dbg_frontend/dbg_frontend_core.h index e1ea918f..2b5d1bac 100644 --- a/src/dbg_frontend/dbg_frontend_core.h +++ b/src/dbg_frontend/dbg_frontend_core.h @@ -663,6 +663,8 @@ struct DF_State Arena *arena; B32 quit; F64 time_in_seconds; + Log *log; + String8 log_path; // rjf: frame state F32 frame_dt; diff --git a/src/dbg_frontend/dbg_frontend_views.c b/src/dbg_frontend/dbg_frontend_views.c index d25f6d55..360ebefa 100644 --- a/src/dbg_frontend/dbg_frontend_views.c +++ b/src/dbg_frontend/dbg_frontend_views.c @@ -24,8 +24,8 @@ df_code_view_cmds(DF_View *view, DF_CodeViewState *cv, String8 text_data, TXT_Te for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);) { // rjf: mismatched window/panel => skip - if(!d_handle_match(d_regs()->window, cmd->regs->window) || - !d_handle_match(d_regs()->panel, cmd->regs->panel)) + if(!d_handle_match(df_regs()->window, cmd->regs->window) || + !d_handle_match(df_regs()->panel, cmd->regs->panel)) { continue; } @@ -86,7 +86,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f); Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim); S64 num_possible_visible_lines = (S64)(code_area_dim.y/code_line_height)+1; - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); ////////////////////////////// @@ -142,7 +142,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie Side search_query_side = Side_Invalid; B32 search_query_is_active = 0; { - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); DF_CmdKind query_cmd_kind = df_cmd_kind_from_string(window->query_cmd_name); if(query_cmd_kind == DF_CmdKind_FindTextForward || query_cmd_kind == DF_CmdKind_FindTextBackward) @@ -204,7 +204,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie { D_Entity *bp = n->entity; D_Entity *loc = d_entity_child_from_kind(bp, D_EntityKind_Location); - if(path_match_normalized(loc->string, d_regs()->file_path) && + if(path_match_normalized(loc->string, df_regs()->file_path) && visible_line_num_range.min <= loc->text_point.line && loc->text_point.line <= visible_line_num_range.max) { U64 slice_line_idx = (loc->text_point.line-visible_line_num_range.min); @@ -216,15 +216,15 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: find live threads mapping to source code ProfScope("find live threads mapping to this file") { - String8 file_path = d_regs()->file_path; - D_Entity *selected_thread = d_entity_from_handle(d_regs()->thread); + String8 file_path = df_regs()->file_path; + D_Entity *selected_thread = d_entity_from_handle(df_regs()->thread); D_EntityList threads = d_query_cached_entity_list_with_kind(D_EntityKind_Thread); for(D_EntityNode *thread_n = threads.first; thread_n != 0; thread_n = thread_n->next) { D_Entity *thread = thread_n->entity; D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); - U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0; - U64 inline_depth = (thread == selected_thread) ? d_regs()->inline_depth : 0; + U64 unwind_count = (thread == selected_thread) ? df_regs()->unwind_count : 0; + U64 inline_depth = (thread == selected_thread) ? df_regs()->inline_depth : 0; U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count; D_Entity *module = d_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr); @@ -250,7 +250,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie { D_Entity *wp = n->entity; D_Entity *loc = d_entity_child_from_kind(wp, D_EntityKind_Location); - if(path_match_normalized(loc->string, d_regs()->file_path) && + if(path_match_normalized(loc->string, df_regs()->file_path) && visible_line_num_range.min <= loc->text_point.line && loc->text_point.line <= visible_line_num_range.max) { U64 slice_line_idx = (loc->text_point.line-visible_line_num_range.min); @@ -262,7 +262,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: find all src -> dasm info ProfScope("find all src -> dasm info") { - String8 file_path = d_regs()->file_path; + String8 file_path = df_regs()->file_path; D_LineListArray lines_array = d_lines_array_from_file_path_line_range(scratch.arena, file_path, visible_line_num_range); if(lines_array.count != 0) { @@ -274,12 +274,12 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: find live threads mapping to disasm if(dasm_lines) ProfScope("find live threads mapping to this disassembly") { - D_Entity *selected_thread = d_entity_from_handle(d_regs()->thread); + D_Entity *selected_thread = d_entity_from_handle(df_regs()->thread); D_EntityList threads = d_query_cached_entity_list_with_kind(D_EntityKind_Thread); for(D_EntityNode *thread_n = threads.first; thread_n != 0; thread_n = thread_n->next) { D_Entity *thread = thread_n->entity; - U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0; + U64 unwind_count = (thread == selected_thread) ? df_regs()->unwind_count : 0; U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); if(d_entity_ancestor_from_kind(thread, D_EntityKind_Process) == process && contains_1u64(dasm_vaddr_range, rip_vaddr)) { @@ -394,7 +394,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie Temp scratch = scratch_begin(0, 0); B32 found = 0; B32 first = 1; - S64 line_num_start = d_regs()->cursor.line; + S64 line_num_start = df_regs()->cursor.line; S64 line_num_last = (S64)text_info->lines_count; for(S64 line_num = line_num_start;; first = 0) { @@ -404,18 +404,18 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: gather line info String8 line_string = str8_substr(text_data, text_info->lines_ranges[line_num-1]); U64 search_start = 0; - if(d_regs()->cursor.line == line_num && first) + if(df_regs()->cursor.line == line_num && first) { - search_start = d_regs()->cursor.column; + search_start = df_regs()->cursor.column; } // rjf: search string U64 needle_pos = str8_find_needle(line_string, search_start, cv->find_text_fwd, StringMatchFlag_CaseInsensitive); if(needle_pos < line_string.size) { - d_regs()->cursor.line = line_num; - d_regs()->cursor.column = needle_pos+1; - d_regs()->mark = d_regs()->cursor; + df_regs()->cursor.line = line_num; + df_regs()->cursor.column = needle_pos+1; + df_regs()->mark = df_regs()->cursor; found = 1; break; } @@ -447,7 +447,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie Temp scratch = scratch_begin(0, 0); B32 found = 0; B32 first = 1; - S64 line_num_start = d_regs()->cursor.line; + S64 line_num_start = df_regs()->cursor.line; S64 line_num_last = (S64)text_info->lines_count; for(S64 line_num = line_num_start;; first = 0) { @@ -456,9 +456,9 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: gather line info String8 line_string = str8_substr(text_data, text_info->lines_ranges[line_num-1]); - if(d_regs()->cursor.line == line_num && first) + if(df_regs()->cursor.line == line_num && first) { - line_string = str8_prefix(line_string, d_regs()->cursor.column-1); + line_string = str8_prefix(line_string, df_regs()->cursor.column-1); } // rjf: search string @@ -474,9 +474,9 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie } if(next_needle_pos < line_string.size) { - d_regs()->cursor.line = line_num; - d_regs()->cursor.column = next_needle_pos+1; - d_regs()->mark = d_regs()->cursor; + df_regs()->cursor.line = line_num; + df_regs()->cursor.column = next_needle_pos+1; + df_regs()->mark = df_regs()->cursor; found = 1; break; } @@ -515,7 +515,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie S64 line_num = cv->goto_line_num; cv->goto_line_num = 0; line_num = Clamp(1, line_num, text_info->lines_count); - d_regs()->cursor = d_regs()->mark = txt_pt(line_num, 1); + df_regs()->cursor = df_regs()->mark = txt_pt(line_num, 1); cv->center_cursor = !cv->contain_cursor || (line_num < target_visible_line_num_range.min+4 || target_visible_line_num_range.max-4 < line_num); } @@ -527,7 +527,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie { if(ui_is_focus_active() && visible_line_num_range.max >= visible_line_num_range.min) { - snap[Axis2_X] = snap[Axis2_Y] = df_do_txt_controls(text_info, text_data, ClampBot(num_possible_visible_lines, 10) - 10, &d_regs()->cursor, &d_regs()->mark, &cv->preferred_column); + snap[Axis2_X] = snap[Axis2_Y] = df_do_txt_controls(text_info, text_data, ClampBot(num_possible_visible_lines, 10) - 10, &df_regs()->cursor, &df_regs()->mark, &cv->preferred_column); } } @@ -544,7 +544,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie DF_CodeSliceSignal sig = {0}; UI_Focus(UI_FocusKind_On) { - sig = df_code_slicef(&code_slice_params, &d_regs()->cursor, &d_regs()->mark, &cv->preferred_column, "txt_view_%p", view); + sig = df_code_slicef(&code_slice_params, &df_regs()->cursor, &df_regs()->mark, &cv->preferred_column, "txt_view_%p", view); } //- rjf: press code slice? -> focus panel @@ -581,9 +581,9 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie } //- rjf: selected text on single line, no query? -> set search text - if(!txt_pt_match(d_regs()->cursor, d_regs()->mark) && d_regs()->cursor.line == d_regs()->mark.line && search_query.size == 0) + if(!txt_pt_match(df_regs()->cursor, df_regs()->mark) && df_regs()->cursor.line == df_regs()->mark.line && search_query.size == 0) { - String8 text = txt_string_from_info_data_txt_rng(text_info, text_data, txt_rng(d_regs()->cursor, d_regs()->mark)); + String8 text = txt_string_from_info_data_txt_rng(text_info, text_data, txt_rng(df_regs()->cursor, df_regs()->mark)); df_set_search_string(text); } } @@ -604,8 +604,8 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie if(cv->center_cursor) { cv->center_cursor = 0; - String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[d_regs()->cursor.line-1]); - F32 cursor_advance = fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, d_regs()->cursor.column-1)).x; + String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[df_regs()->cursor.line-1]); + F32 cursor_advance = fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_regs()->cursor.column-1)).x; // rjf: scroll x { @@ -617,7 +617,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: scroll y { - S64 new_idx = (d_regs()->cursor.line-1) - num_possible_visible_lines/2 + 2; + S64 new_idx = (df_regs()->cursor.line-1) - num_possible_visible_lines/2 + 2; new_idx = Clamp(scroll_idx_rng[Axis2_Y].min, new_idx, scroll_idx_rng[Axis2_Y].max); ui_scroll_pt_target_idx(&view->scroll_pos.y, new_idx); snap[Axis2_Y] = 0; @@ -627,8 +627,8 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: snap in X if(snap[Axis2_X]) { - String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[d_regs()->cursor.line-1]); - S64 cursor_off = (S64)(fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, d_regs()->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px); + String8 cursor_line = str8_substr(text_data, text_info->lines_ranges[df_regs()->cursor.line-1]); + S64 cursor_off = (S64)(fnt_dim_from_tag_size_string(code_font, code_font_size, 0, code_tab_size, str8_prefix(cursor_line, df_regs()->cursor.column-1)).x + priority_margin_width_px + catchall_margin_width_px + line_num_width_px); Rng1S64 visible_pixel_range = { view->scroll_pos.x.idx, @@ -649,7 +649,7 @@ df_code_view_build(Arena *arena, DF_View *view, DF_CodeViewState *cv, DF_CodeVie // rjf: snap in Y if(snap[Axis2_Y]) { - Rng1S64 cursor_visibility_range = r1s64(d_regs()->cursor.line-4, d_regs()->cursor.line+4); + Rng1S64 cursor_visibility_range = r1s64(df_regs()->cursor.line-4, df_regs()->cursor.line+4); cursor_visibility_range.min = ClampBot(0, cursor_visibility_range.min); cursor_visibility_range.max = ClampBot(0, cursor_visibility_range.max); S64 min_delta = Min(0, cursor_visibility_range.min-(target_visible_line_num_range.min)); @@ -834,7 +834,7 @@ df_string_from_eval_viz_row_column(Arena *arena, EV_View *ev, EV_Row *row, DF_Wa case DF_WatchViewColumnKind_Module: { E_Eval eval = e_eval_from_expr(arena, row->expr); - D_Entity *process = d_entity_from_handle(d_regs()->process); + D_Entity *process = d_entity_from_handle(df_regs()->process); D_Entity *module = d_module_from_process_vaddr(process, eval.value.u64); result = d_display_string_from_entity(arena, module); }break; @@ -938,12 +938,12 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d //- rjf: unpack arguments // FNT_Tag code_font = df_font_from_slot(DF_FontSlot_Code); - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); Arch arch = d_arch_from_entity(thread); CTRL_Unwind base_unwind = d_query_cached_unwind_from_thread(thread); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Unwind rich_unwind = d_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind); - U64 thread_ip_vaddr = d_query_cached_rip_from_thread_unwind(thread, d_regs()->unwind_count); + U64 thread_ip_vaddr = d_query_cached_rip_from_thread_unwind(thread, df_regs()->unwind_count); String8 eval_view_key_string = push_str8f(scratch.arena, "eval_view_watch_%p", ewv); EV_View *eval_view = df_ev_view_from_key(d_hash_from_string(eval_view_key_string)); String8 filter = str8(view->query_buffer, view->query_string_size); @@ -1187,7 +1187,7 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d // case DF_WatchViewFillKind_Registers: { - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); Arch arch = d_arch_from_entity(thread); U64 reg_count = regs_reg_code_count_from_arch(arch); String8 *reg_strings = regs_reg_code_string_table_from_arch(arch); @@ -1645,7 +1645,7 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d { FrameRow *frame_row = &frame_rows[selection_tbl.min.y-1]; df_cmd(DF_CmdKind_SelectUnwind, - .entity = d_regs()->thread, + .entity = df_regs()->thread, .unwind_count = frame_row->unwind_idx, .inline_depth = frame_row->inline_depth); } @@ -2343,10 +2343,10 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d df_loading_overlay(canvas_rect, canvas_view->loading_t, canvas_view->loading_progress_v, canvas_view->loading_progress_v_target); //- rjf: push interaction registers, fill with per-view states - d_push_regs(); + df_push_regs(); { - d_regs()->view = df_handle_from_view(canvas_view); - d_regs()->file_path = d_file_path_from_eval_string(d_frame_arena(), str8(canvas_view->query_buffer, canvas_view->query_string_size)); + df_regs()->view = df_handle_from_view(canvas_view); + df_regs()->file_path = d_file_path_from_eval_string(d_frame_arena(), str8(canvas_view->query_buffer, canvas_view->query_string_size)); } //- rjf: build @@ -2356,7 +2356,7 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d } //- rjf: pop interaction registers - d_pop_regs(); + df_pop_regs(); } } } @@ -2504,10 +2504,10 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d }break; case DF_WatchViewColumnKind_FrameSelection: { - if(semantic_idx == d_regs()->unwind_count - d_regs()->inline_depth) + if(semantic_idx == df_regs()->unwind_count - df_regs()->inline_depth) { cell_icon = DF_IconKind_RightArrow; - cell_base_color = d_rgba_from_entity(d_entity_from_handle(d_regs()->thread)); + cell_base_color = d_rgba_from_entity(d_entity_from_handle(df_regs()->thread)); } }break; } @@ -2663,7 +2663,7 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d { FrameRow *frame_row = &frame_rows[semantic_idx]; df_cmd(DF_CmdKind_SelectUnwind, - .entity = d_regs()->thread, + .entity = df_regs()->thread, .unwind_count = frame_row->unwind_idx, .inline_depth = frame_row->inline_depth); } @@ -3500,7 +3500,7 @@ DF_VIEW_UI_FUNCTION_DEF(file_system) DF_PathQuery path_query = df_path_query_from_string(query_normalized_with_opt_slash); F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); F32 scroll_bar_dim = floor_f32(ui_top_font_size()*1.5f); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); DF_CmdKindInfo *cmd_kind_info = df_cmd_kind_info_from_string(window->query_cmd_name); B32 file_selection = !!(cmd_kind_info->query.flags & DF_QueryFlag_AllowFiles); B32 dir_selection = !!(cmd_kind_info->query.flags & DF_QueryFlag_AllowFolders); @@ -4326,7 +4326,7 @@ DF_VIEW_UI_FUNCTION_DEF(entity_lister) { ProfBeginFunction(); Temp scratch = scratch_begin(0, 0); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); DF_CmdKindInfo *cmd_kind_info = df_cmd_kind_info_from_string(window->query_cmd_name); D_EntityKind entity_kind = cmd_kind_info->query.entity_kind; D_EntityFlags entity_flags_omit = D_EntityFlag_IsFolder; @@ -4670,8 +4670,8 @@ DF_VIEW_CMD_FUNCTION_DEF(target) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);) { // rjf: mismatched window/panel => skip - if(!d_handle_match(d_regs()->window, cmd->params.window) || - !d_handle_match(d_regs()->panel, cmd->params.panel)) + if(!d_handle_match(df_regs()->window, cmd->params.window) || + !d_handle_match(df_regs()->panel, cmd->params.panel)) { continue; } @@ -6387,10 +6387,10 @@ DF_VIEW_CMD_FUNCTION_DEF(text) TXT_Scope *txt_scope = txt_scope_open(); E_Eval eval = e_eval_from_string(scratch.arena, string); Rng1U64 range = d_range_from_eval_params(eval, params); - d_regs()->text_key = d_key_from_eval_space_range(eval.space, range, 1); - d_regs()->lang_kind = d_lang_kind_from_eval_params(eval, params); + df_regs()->text_key = d_key_from_eval_space_range(eval.space, range, 1); + df_regs()->lang_kind = d_lang_kind_from_eval_params(eval, params); U128 hash = {0}; - TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, d_regs()->text_key, d_regs()->lang_kind, &hash); + TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_regs()->text_key, df_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); //- rjf: process general code-view commands @@ -6452,17 +6452,17 @@ DF_VIEW_UI_FUNCTION_DEF(text) ////////////////////////////// //- rjf: unpack parameterization info // - d_regs()->cursor.line = d_value_from_params_key(params, str8_lit("cursor_line")).s64; - d_regs()->cursor.column = d_value_from_params_key(params, str8_lit("cursor_column")).s64; - d_regs()->mark.line = d_value_from_params_key(params, str8_lit("mark_line")).s64; - d_regs()->mark.column = d_value_from_params_key(params, str8_lit("mark_column")).s64; + df_regs()->cursor.line = d_value_from_params_key(params, str8_lit("cursor_line")).s64; + df_regs()->cursor.column = d_value_from_params_key(params, str8_lit("cursor_column")).s64; + df_regs()->mark.line = d_value_from_params_key(params, str8_lit("mark_line")).s64; + df_regs()->mark.column = d_value_from_params_key(params, str8_lit("mark_column")).s64; String8 path = d_file_path_from_eval_string(scratch.arena, string); E_Eval eval = e_eval_from_string(scratch.arena, string); Rng1U64 range = d_range_from_eval_params(eval, params); - d_regs()->text_key = d_key_from_eval_space_range(eval.space, range, 1); - d_regs()->lang_kind = d_lang_kind_from_eval_params(eval, params); + df_regs()->text_key = d_key_from_eval_space_range(eval.space, range, 1); + df_regs()->lang_kind = d_lang_kind_from_eval_params(eval, params); U128 hash = {0}; - TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, d_regs()->text_key, d_regs()->lang_kind, &hash); + TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_regs()->text_key, df_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); B32 file_is_missing = (path.size != 0 && os_properties_from_file_path(path).modified == 0); B32 key_has_data = !u128_match(hash, u128_zero()) && info.lines_count; @@ -6522,7 +6522,7 @@ DF_VIEW_UI_FUNCTION_DEF(text) // if(path.size != 0) { - d_regs()->lines = d_lines_from_file_path_line_num(d_frame_arena(), path, d_regs()->cursor.line); + df_regs()->lines = d_lines_from_file_path_line_num(d_frame_arena(), path, df_regs()->cursor.line); } ////////////////////////////// @@ -6591,7 +6591,7 @@ DF_VIEW_UI_FUNCTION_DEF(text) ui_label(path); ui_spacer(ui_em(1.5f, 1)); } - ui_labelf("Line: %I64d, Column: %I64d", d_regs()->cursor.line, d_regs()->cursor.column); + ui_labelf("Line: %I64d, Column: %I64d", df_regs()->cursor.line, df_regs()->cursor.column); ui_spacer(ui_pct(1, 0)); ui_labelf("(read only)"); ui_labelf("%s", @@ -6605,10 +6605,10 @@ DF_VIEW_UI_FUNCTION_DEF(text) ////////////////////////////// //- rjf: store params // - df_view_store_param_s64(view, str8_lit("cursor_line"), d_regs()->cursor.line); - df_view_store_param_s64(view, str8_lit("cursor_column"), d_regs()->cursor.column); - df_view_store_param_s64(view, str8_lit("mark_line"), d_regs()->mark.line); - df_view_store_param_s64(view, str8_lit("mark_column"), d_regs()->mark.column); + df_view_store_param_s64(view, str8_lit("cursor_line"), df_regs()->cursor.line); + df_view_store_param_s64(view, str8_lit("cursor_column"), df_regs()->cursor.column); + df_view_store_param_s64(view, str8_lit("mark_line"), df_regs()->mark.line); + df_view_store_param_s64(view, str8_lit("mark_column"), df_regs()->mark.column); txt_scope_close(txt_scope); hs_scope_close(hs_scope); @@ -6669,7 +6669,7 @@ DF_VIEW_CMD_FUNCTION_DEF(disasm) E_Space space = eval.space; if(auto_selected_thread) { - space = d_eval_space_from_entity(d_entity_from_handle(d_regs()->process)); + space = d_eval_space_from_entity(d_entity_from_handle(df_regs()->process)); } Rng1U64 range = d_range_from_eval_params(eval, params); Arch arch = d_arch_from_eval_params(eval, params); @@ -6700,10 +6700,10 @@ DF_VIEW_CMD_FUNCTION_DEF(disasm) dasm_params.dbgi_key = dbgi_key; } DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash); - d_regs()->text_key = dasm_info.text_key; - d_regs()->lang_kind = txt_lang_kind_from_arch(arch); + df_regs()->text_key = dasm_info.text_key; + df_regs()->lang_kind = txt_lang_kind_from_arch(arch); U128 dasm_text_hash = {0}; - TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, d_regs()->text_key, d_regs()->lang_kind, &dasm_text_hash); + TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, df_regs()->text_key, df_regs()->lang_kind, &dasm_text_hash); String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash); B32 has_disasm = (dasm_info.lines.count != 0 && dasm_text_info.lines_count != 0); B32 is_loading = (!has_disasm && dim_1u64(range) != 0 && eval.msgs.max_kind == E_MsgKind_Null); @@ -6719,8 +6719,8 @@ DF_VIEW_CMD_FUNCTION_DEF(disasm) for(DF_Cmd *cmd = 0; df_next_cmd(&cmd);) { // rjf: mismatched window/panel => skip - if(!d_handle_match(d_regs()->window, cmd->regs->window) || - !d_handle_match(d_regs()->panel, cmd->regs->panel)) + if(!d_handle_match(df_regs()->window, cmd->regs->window) || + !d_handle_match(df_regs()->panel, cmd->regs->panel)) { continue; } @@ -6788,8 +6788,8 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) F32 bottom_bar_height = ui_top_font_size()*2.f; Rng2F32 code_area_rect = r2f32p(rect.x0, rect.y0, rect.x1, rect.y1 - bottom_bar_height); Rng2F32 bottom_bar_rect = r2f32p(rect.x0, rect.y1 - bottom_bar_height, rect.x1, rect.y1); - d_regs()->cursor = dv->cursor; - d_regs()->mark = dv->mark; + df_regs()->cursor = dv->cursor; + df_regs()->mark = dv->mark; ////////////////////////////// //- rjf: unpack parameterization info @@ -6798,7 +6798,7 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) E_Space space = eval.space; if(auto_selected_thread) { - space = d_eval_space_from_entity(d_entity_from_handle(d_regs()->process)); + space = d_eval_space_from_entity(d_entity_from_handle(df_regs()->process)); } Rng1U64 range = d_range_from_eval_params(eval, params); Arch arch = d_arch_from_eval_params(eval, params); @@ -6829,10 +6829,10 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) dasm_params.dbgi_key = dbgi_key; } DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash); - d_regs()->text_key = dasm_info.text_key; - d_regs()->lang_kind = txt_lang_kind_from_arch(arch); + df_regs()->text_key = dasm_info.text_key; + df_regs()->lang_kind = txt_lang_kind_from_arch(arch); U128 dasm_text_hash = {0}; - TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, d_regs()->text_key, d_regs()->lang_kind, &dasm_text_hash); + TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, df_regs()->text_key, df_regs()->lang_kind, &dasm_text_hash); String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash); B32 has_disasm = (dasm_info.lines.count != 0 && dasm_text_info.lines_count != 0); B32 is_loading = (!has_disasm && dim_1u64(range) != 0 && eval.msgs.max_kind == E_MsgKind_Null); @@ -6870,10 +6870,10 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) // if(!is_loading && has_disasm) { - U64 off = dasm_line_array_code_off_from_idx(&dasm_info.lines, d_regs()->cursor.line-1); - d_regs()->vaddr_range = r1u64(base_vaddr+off, base_vaddr+off); - d_regs()->voff_range = d_voff_range_from_vaddr_range(dasm_module, d_regs()->vaddr_range); - d_regs()->lines = d_lines_from_dbgi_key_voff(d_frame_arena(), &dbgi_key, d_regs()->voff_range.min); + U64 off = dasm_line_array_code_off_from_idx(&dasm_info.lines, df_regs()->cursor.line-1); + df_regs()->vaddr_range = r1u64(base_vaddr+off, base_vaddr+off); + df_regs()->voff_range = d_voff_range_from_vaddr_range(dasm_module, df_regs()->vaddr_range); + df_regs()->lines = d_lines_from_dbgi_key_voff(d_frame_arena(), &dbgi_key, df_regs()->voff_range.min); } ////////////////////////////// @@ -6889,13 +6889,13 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) DF_Font(DF_FontSlot_Code) { - U64 cursor_vaddr = (1 <= d_regs()->cursor.line && d_regs()->cursor.line <= dasm_info.lines.count) ? (range.min+dasm_info.lines.v[d_regs()->cursor.line-1].code_off) : 0; + U64 cursor_vaddr = (1 <= df_regs()->cursor.line && df_regs()->cursor.line <= dasm_info.lines.count) ? (range.min+dasm_info.lines.v[df_regs()->cursor.line-1].code_off) : 0; if(!d_entity_is_nil(dasm_module)) { ui_labelf("%S", path_normalized_from_string(scratch.arena, dasm_module->string)); ui_spacer(ui_em(1.5f, 1)); } - ui_labelf("Address: 0x%I64x, Line: %I64d, Column: %I64d", cursor_vaddr, d_regs()->cursor.line, d_regs()->cursor.column); + ui_labelf("Address: 0x%I64x, Line: %I64d, Column: %I64d", cursor_vaddr, df_regs()->cursor.line, df_regs()->cursor.column); ui_spacer(ui_pct(1, 0)); ui_labelf("(read only)"); ui_labelf("bin"); @@ -6905,8 +6905,8 @@ DF_VIEW_UI_FUNCTION_DEF(disasm) ////////////////////////////// //- rjf: commit storage // - dv->cursor = d_regs()->cursor; - dv->mark = d_regs()->mark; + dv->cursor = df_regs()->cursor; + dv->mark = df_regs()->mark; txt_scope_close(txt_scope); dasm_scope_close(dasm_scope); @@ -6929,10 +6929,10 @@ DF_VIEW_CMD_FUNCTION_DEF(output) Temp scratch = scratch_begin(0, 0); HS_Scope *hs_scope = hs_scope_open(); TXT_Scope *txt_scope = txt_scope_open(); - d_regs()->text_key = d_state->output_log_key; - d_regs()->lang_kind = TXT_LangKind_Null; + df_regs()->text_key = d_state->output_log_key; + df_regs()->lang_kind = TXT_LangKind_Null; U128 hash = {0}; - TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, d_regs()->text_key, d_regs()->lang_kind, &hash); + TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_regs()->text_key, df_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); df_code_view_cmds(view, cv, data, &info, 0, r1u64(0, 0), di_key_zero()); txt_scope_close(txt_scope); @@ -6990,7 +6990,7 @@ DF_VIEW_UI_FUNCTION_DEF(output) { ui_labelf("(Debug String Output)"); ui_spacer(ui_em(1.5f, 1)); - ui_labelf("Line: %I64d, Column: %I64d", d_regs()->cursor.line, d_regs()->cursor.column); + ui_labelf("Line: %I64d, Column: %I64d", df_regs()->cursor.line, df_regs()->cursor.column); ui_spacer(ui_pct(1, 0)); ui_labelf("(read only)"); } @@ -7068,7 +7068,7 @@ DF_VIEW_UI_FUNCTION_DEF(memory) E_Eval eval = e_eval_from_string(scratch.arena, string); if(eval.space.kind == 0) { - eval.space = d_eval_space_from_entity(d_entity_from_handle(d_regs()->process)); + eval.space = d_eval_space_from_entity(d_entity_from_handle(df_regs()->process)); } Rng1U64 space_range = d_whole_range_from_eval_space(eval.space); U64 cursor = d_value_from_params_key(params, str8_lit("cursor_vaddr")).u64; @@ -7290,7 +7290,7 @@ DF_VIEW_UI_FUNCTION_DEF(memory) }; AnnotationList *visible_memory_annotations = push_array(scratch.arena, AnnotationList, visible_memory_size); { - D_Entity *thread = d_entity_from_handle(d_regs()->thread); + D_Entity *thread = d_entity_from_handle(df_regs()->thread); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); CTRL_Unwind unwind = d_query_cached_unwind_from_thread(thread); @@ -7362,7 +7362,7 @@ DF_VIEW_UI_FUNCTION_DEF(memory) df_rgba_from_theme_color(DF_ThemeColor_Thread6), df_rgba_from_theme_color(DF_ThemeColor_Thread7), }; - U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, d_regs()->unwind_count); + U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, df_regs()->unwind_count); for(E_String2NumMapNode *n = e_parse_ctx->locals_map->first; n != 0; n = n->order_next) { String8 local_name = n->string; @@ -8588,7 +8588,7 @@ DF_VIEW_UI_FUNCTION_DEF(settings) Temp scratch = scratch_begin(0, 0); F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); String8 query = string; - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); ////////////////////////////// //- rjf: get state diff --git a/src/dbg_frontend/dbg_frontend_widgets.c b/src/dbg_frontend/dbg_frontend_widgets.c index f8f5df04..a5d3dc9e 100644 --- a/src/dbg_frontend/dbg_frontend_widgets.c +++ b/src/dbg_frontend/dbg_frontend_widgets.c @@ -342,7 +342,7 @@ df_cmd_list_menu_buttons(U64 count, String8 *cmd_names, U32 *fastpath_codepoints { df_cmd(DF_CmdKind_RunCommand, .string = cmd_names[idx]); ui_ctx_menu_close(); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->menu_bar_focused = 0; } } @@ -745,7 +745,7 @@ df_entity_desc_button(D_Entity *entity, FuzzyMatchRangeList *name_matches, Strin else if(ui_right_clicked(sig)) { D_Handle handle = d_handle_from_entity(entity); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); ui_ctx_menu_open(df_state->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0)); window->entity_ctx_menu_entity = handle; } @@ -949,9 +949,9 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe DF_CodeSliceSignal result = {0}; ProfBeginFunction(); Temp scratch = scratch_begin(0, 0); - D_Entity *selected_thread = d_entity_from_handle(d_regs()->thread); + D_Entity *selected_thread = d_entity_from_handle(df_regs()->thread); D_Entity *selected_thread_process = d_entity_ancestor_from_kind(selected_thread, D_EntityKind_Process); - U64 selected_thread_rip_unwind_vaddr = d_query_cached_rip_from_thread_unwind(selected_thread, d_regs()->unwind_count); + U64 selected_thread_rip_unwind_vaddr = d_query_cached_rip_from_thread_unwind(selected_thread, df_regs()->unwind_count); D_Entity *selected_thread_module = d_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr); CTRL_Event stop_event = d_ctrl_last_stop_event(); D_Entity *stopper_thread = d_entity_from_ctrl_handle(stop_event.entity); @@ -1050,7 +1050,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe continue; } CTRL_Entity *thread_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, thread->ctrl_handle); - U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0; + U64 unwind_count = (thread == selected_thread) ? df_regs()->unwind_count : 0; U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *module = d_module_from_process_vaddr(process, thread_rip_vaddr); @@ -1150,7 +1150,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { D_Handle handle = d_handle_from_entity(thread); ui_ctx_menu_open(df_state->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0)); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->entity_ctx_menu_entity = handle; } @@ -1209,7 +1209,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe continue; } CTRL_Entity *thread_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, thread->ctrl_handle); - U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0; + U64 unwind_count = (thread == selected_thread) ? df_regs()->unwind_count : 0; U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *module = d_module_from_process_vaddr(process, thread_rip_vaddr); @@ -1272,7 +1272,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe // rjf: fill out progress t (progress into range of current line's // voff range) - if(d_regs()->file_path.size != 0 && params->line_infos[line_idx].first != 0) + if(df_regs()->file_path.size != 0 && params->line_infos[line_idx].first != 0) { D_LineList *lines = ¶ms->line_infos[line_idx]; D_Line *line = 0; @@ -1307,7 +1307,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { D_Handle handle = d_handle_from_entity(thread); ui_ctx_menu_open(df_state->entity_ctx_menu_key, thread_box->key, v2f32(0, thread_box->rect.y1-thread_box->rect.y0)); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->entity_ctx_menu_entity = handle; } @@ -1349,7 +1349,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe bp_draw->alive_t = bp->alive_t; bp_draw->do_lines = df_setting_val_from_code(DF_SettingCode_BreakpointLines).s32; bp_draw->do_glow = df_setting_val_from_code(DF_SettingCode_BreakpointGlow).s32; - if(d_regs()->file_path.size != 0) + if(df_regs()->file_path.size != 0) { D_LineList *lines = ¶ms->line_infos[line_idx]; for(D_LineNode *n = lines->first; n != 0; n = n->next) @@ -1408,7 +1408,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { D_Handle handle = d_handle_from_entity(bp); ui_ctx_menu_open(df_state->entity_ctx_menu_key, bp_box->key, v2f32(0, bp_box->rect.y1-bp_box->rect.y0)); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->entity_ctx_menu_entity = handle; } } @@ -1466,7 +1466,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { D_Handle handle = d_handle_from_entity(pin); ui_ctx_menu_open(df_state->entity_ctx_menu_key, pin_box->key, v2f32(0, pin_box->rect.y1-pin_box->rect.y0)); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->entity_ctx_menu_entity = handle; } } @@ -1477,7 +1477,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe if(ui_clicked(line_margin_sig)) { df_cmd(DF_CmdKind_AddBreakpoint, - .file_path = d_regs()->file_path, + .file_path = df_regs()->file_path, .cursor = txt_pt(line_num, 1), .vaddr = params->line_vaddrs[line_idx]); } @@ -1522,7 +1522,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { if(n->v.dbgi_key.min_timestamp >= best_stamp) { - has_line_info = (n->v.pt.line == line_num || d_regs()->file_path.size == 0); + has_line_info = (n->v.pt.line == line_num || df_regs()->file_path.size == 0); line_info_line_num = n->v.pt.line; best_stamp = n->v.dbgi_key.min_timestamp; } @@ -1692,7 +1692,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe if(ui_right_clicked(sig)) { ui_ctx_menu_open(df_state->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1-sig.box->rect.y0)); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); window->entity_ctx_menu_entity = d_handle_from_entity(pin); } } @@ -1833,11 +1833,11 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe *cursor = *mark = mouse_pt; } ui_ctx_menu_open(df_state->code_ctx_menu_key, ui_key_zero(), sub_2f32(ui_mouse(), v2f32(2, 2))); - DF_Window *window = df_window_from_handle(d_regs()->window); + DF_Window *window = df_window_from_handle(df_regs()->window); arena_clear(window->code_ctx_menu_arena); - window->code_ctx_menu_file_path = push_str8_copy(window->code_ctx_menu_arena, d_regs()->file_path); - window->code_ctx_menu_text_key = d_regs()->text_key; - window->code_ctx_menu_lang_kind = d_regs()->lang_kind; + window->code_ctx_menu_file_path = push_str8_copy(window->code_ctx_menu_arena, df_regs()->file_path); + window->code_ctx_menu_text_key = df_regs()->text_key; + window->code_ctx_menu_lang_kind = df_regs()->lang_kind; window->code_ctx_menu_range = txt_rng(*cursor, *mark); if(params->line_num_range.min <= cursor->line && cursor->line < params->line_num_range.max) { @@ -1880,14 +1880,14 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { df_cmd(DF_CmdKind_RelocateEntity, .entity = d_handle_from_entity(dropped_entity), - .file_path = d_regs()->file_path, + .file_path = df_regs()->file_path, .cursor = txt_pt(line_num, 1), .vaddr = line_vaddr); }break; case D_EntityKind_Thread: { U64 new_rip_vaddr = line_vaddr; - if(d_regs()->file_path.size != 0) + if(df_regs()->file_path.size != 0) { D_LineList *lines = ¶ms->line_infos[line_idx]; for(D_LineNode *n = lines->first; n != 0; n = n->next) @@ -1960,7 +1960,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe { U64 line_slice_idx = mouse_pt.line-params->line_num_range.min; D_LineList *lines = ¶ms->line_infos[line_slice_idx]; - if(lines->first != 0 && (d_regs()->file_path.size == 0 || lines->first->v.pt.line == mouse_pt.line)) + if(lines->first != 0 && (df_regs()->file_path.size == 0 || lines->first->v.pt.line == mouse_pt.line)) { DF_RichHoverInfo info = {0}; info.process = d_handle_from_entity(selected_thread_process); @@ -1986,7 +1986,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe U64 line_idx = mouse_pt.line-params->line_num_range.min; line_vaddr = params->line_vaddrs[line_idx]; } - df_set_hover_eval(mouse_expr_baseline_pos, d_regs()->file_path, mouse_pt, line_vaddr, mouse_expr); + df_set_hover_eval(mouse_expr_baseline_pos, df_regs()->file_path, mouse_pt, line_vaddr, mouse_expr); } } @@ -2349,7 +2349,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe D_LineList *lines = ¶ms->line_infos[line_idx]; for(D_LineNode *n = lines->first; n != 0; n = n->next) { - if((n->v.pt.line == line_num || d_regs()->file_path.size == 0) && + if((n->v.pt.line == line_num || df_regs()->file_path.size == 0) && ((di_key_match(&n->v.dbgi_key, &rich_hover.dbgi_key) && n->v.voff_range.min <= rich_hover_voff_range.min && rich_hover_voff_range.min < n->v.voff_range.max) || (params->line_vaddrs[line_idx] == rich_hover.vaddr_range.min && rich_hover.vaddr_range.min != 0))) @@ -2729,7 +2729,7 @@ df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_s } else { - D_Entity *module = d_entity_from_handle(d_regs()->module); + D_Entity *module = d_entity_from_handle(df_regs()->module); DI_Key dbgi_key = d_dbgi_key_from_module(module); U64 symbol_voff = d_voff_from_dbgi_key_symbol_name(&dbgi_key, token_string); if(symbol_voff != 0) diff --git a/src/raddbg/raddbg_main.c b/src/raddbg/raddbg_main.c index 8ad92c8c..a489e113 100644 --- a/src/raddbg/raddbg_main.c +++ b/src/raddbg/raddbg_main.c @@ -618,10 +618,6 @@ global U64 ipc_s2m_ring_read_pos = 0; global OS_Handle ipc_s2m_ring_mutex = {0}; global OS_Handle ipc_s2m_ring_cv = {0}; -//- rjf: main thread log -global Log *main_thread_log = 0; -global String8 main_thread_log_path = {0}; - //////////////////////////////// //~ rjf: IPC Signaler Thread @@ -672,37 +668,7 @@ internal CTRL_WAKEUP_FUNCTION_DEF(wakeup_hook_ctrl) internal B32 frame(void) { - ProfBeginFunction(); - Temp scratch = scratch_begin(0, 0); - - //- rjf: begin logging - if(main_thread_log == 0) - { - main_thread_log = log_alloc(); - String8 user_program_data_path = os_get_process_info()->user_program_data_path; - String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg/logs", user_program_data_path); - main_thread_log_path = push_str8f(d_state->arena, "%S/ui_thread.raddbg_log", user_data_folder); - os_make_directory(user_data_folder); - os_write_data_to_file_path(main_thread_log_path, str8_zero()); - } - log_select(main_thread_log); - log_scope_begin(); - - //- rjf: do frontend frame df_frame(); - - //- rjf: end logging - { - LogScopeResult log = log_scope_end(scratch.arena); - os_append_data_to_file_path(main_thread_log_path, log.strings[LogMsgKind_Info]); - if(log.strings[LogMsgKind_UserError].size != 0) - { - // TODO(rjf): @msgs - } - } - - scratch_end(scratch); - ProfEnd(); return df_state->quit; }