From 3d272a598b1cf8b14802210476222bd21b49a936 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 26 Jun 2024 10:57:49 -0700 Subject: [PATCH] complete convergence of new disasm view, which uses the core code view path --- src/dbgi/dbgi.c | 7 ++++++ src/dbgi/dbgi.h | 1 + src/df/gfx/df_gfx.c | 50 ++++++++++++++++++++++++------------------- src/df/gfx/df_views.c | 34 ++++++++++++++++++----------- src/df/gfx/df_views.h | 4 ++-- 5 files changed, 59 insertions(+), 37 deletions(-) diff --git a/src/dbgi/dbgi.c b/src/dbgi/dbgi.c index e29085ad..340d67fe 100644 --- a/src/dbgi/dbgi.c +++ b/src/dbgi/dbgi.c @@ -22,6 +22,13 @@ di_hash_from_key(DI_Key *k) return hash; } +internal DI_Key +di_key_zero(void) +{ + DI_Key key = {0}; + return key; +} + internal B32 di_key_match(DI_Key *a, DI_Key *b) { diff --git a/src/dbgi/dbgi.h b/src/dbgi/dbgi.h index 80e84c73..72e166b2 100644 --- a/src/dbgi/dbgi.h +++ b/src/dbgi/dbgi.h @@ -199,6 +199,7 @@ global RDI_Parsed di_rdi_parsed_nil = {0}; internal U64 di_hash_from_string(String8 string, StringMatchFlags match_flags); internal U64 di_hash_from_key(DI_Key *k); +internal DI_Key di_key_zero(void); internal B32 di_key_match(DI_Key *a, DI_Key *b); internal DI_Key di_key_copy(Arena *arena, DI_Key *src); internal DI_Key di_normalized_key_from_key(Arena *arena, DI_Key *src); diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 0d3a1f04..a804bc40 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -6367,7 +6367,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_ToggleWatchExpression)); } } - if(!df_entity_is_nil(df_entity_from_handle(ws->hover_eval_file))) + if(!df_entity_is_nil(df_entity_from_handle(ws->hover_eval_file)) || ws->hover_eval_vaddr != 0) UI_TextAlignment(UI_TextAlign_Center) UI_PrefWidth(ui_em(3.f, 1.f)) UI_CornerRadius10(corner_radius) UI_CornerRadius11(corner_radius) @@ -11894,7 +11894,13 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ DF_Eval eval = df_eval_from_string(scratch.arena, di_scope, ctrl_ctx, parse_ctx, &eval_string2expr_map_nil, mouse_expr); if(eval.mode != EVAL_EvalMode_NULL) { - df_set_hover_eval(ws, mouse_expr_baseline_pos, *ctrl_ctx, df_entity_from_handle(df_interact_regs()->file), mouse_pt, 0, mouse_expr); + U64 line_vaddr = 0; + if(contains_1s64(params->line_num_range, mouse_pt.line)) + { + U64 line_idx = mouse_pt.line-params->line_num_range.min; + line_vaddr = params->line_vaddrs[line_idx]; + } + df_set_hover_eval(ws, mouse_expr_baseline_pos, *ctrl_ctx, df_entity_from_handle(df_interact_regs()->file), mouse_pt, line_vaddr, mouse_expr); } di_scope_close(di_scope); } @@ -12078,28 +12084,28 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ mix_t = selected_thread_module->alive_t; } } - if(!mapped_special) - { - U64 reg_num = eval_num_from_string(parse_ctx->regs_map, token_string); - if(reg_num != 0) - { - mapped_special = 1; - new_color_kind = DF_ThemeColor_CodeRegister; - mix_t = selected_thread_module->alive_t; - } - } - if(!mapped_special) - { - U64 alias_num = eval_num_from_string(parse_ctx->reg_alias_map, token_string); - if(alias_num != 0) - { - mapped_special = 1; - new_color_kind = DF_ThemeColor_CodeRegister; - mix_t = selected_thread_module->alive_t; - } - } break; } + if(!mapped_special) + { + U64 reg_num = eval_num_from_string(parse_ctx->regs_map, token_string); + if(reg_num != 0) + { + mapped_special = 1; + new_color_kind = DF_ThemeColor_CodeRegister; + mix_t = selected_thread_module->alive_t; + } + } + if(!mapped_special) + { + U64 alias_num = eval_num_from_string(parse_ctx->reg_alias_map, token_string); + if(alias_num != 0) + { + mapped_special = 1; + new_color_kind = DF_ThemeColor_CodeRegister; + mix_t = selected_thread_module->alive_t; + } + } } if(new_color_kind != DF_ThemeColor_Null) { diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index a2ffd060..0b17428a 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -387,7 +387,7 @@ df_code_view_init(DF_CodeViewState *cv, DF_View *view) } internal void -df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range) +df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key) { for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) { @@ -432,7 +432,7 @@ df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewStat } internal void -df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range) +df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key) { ProfBeginFunction(); Temp scratch = scratch_begin(0, 0); @@ -711,6 +711,12 @@ df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewSta code_slice_params.line_infos[slice_idx] = df_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, voff); } } + + // rjf: add dasm dbgi key to relevant dbgis + if(dasm_insts != 0) + { + di_key_list_push(scratch.arena, &code_slice_params.relevant_dbgi_keys, &dasm_dbgi_key); + } } ////////////////////////////// @@ -6294,7 +6300,7 @@ DF_VIEW_CMD_FUNCTION_DEF(Code) String8 data = hs_data_from_hash(hs_scope, hash); //- rjf: process general code-view commands - df_code_view_cmds(ws, panel, view, cv, cmds, data, &info, 0, r1u64(0, 0)); + df_code_view_cmds(ws, panel, view, cv, cmds, data, &info, 0, r1u64(0, 0), di_key_zero()); //- rjf: process code-file commands for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) @@ -6417,7 +6423,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code) // if(!entity_is_missing && key_has_data) { - df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0)); + df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero()); } ////////////////////////////// @@ -6525,13 +6531,14 @@ DF_VIEW_CMD_FUNCTION_DEF(Disassembly) dasm_params.dbgi_key = dasm_dbgi_key; } DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash); - TXT_LangKind lang_kind = txt_lang_kind_from_architecture(arch); + df_interact_regs()->text_key = dasm_info.text_key; + df_interact_regs()->lang_kind = txt_lang_kind_from_architecture(arch); U128 dasm_text_hash = {0}; - TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, dasm_info.text_key, lang_kind, &dasm_text_hash); + TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &dasm_text_hash); String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash); //- rjf: process general code-view commands - df_code_view_cmds(ws, panel, view, &dv->cv, cmds, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range); + df_code_view_cmds(ws, panel, view, &dv->cv, cmds, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range, dasm_dbgi_key); //- rjf: process disassembly-specific commands for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) @@ -6633,9 +6640,10 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly) dasm_params.dbgi_key = dasm_dbgi_key; } DASM_Info dasm_info = dasm_info_from_key_params(dasm_scope, dasm_key, &dasm_params, &dasm_data_hash); - TXT_LangKind lang_kind = txt_lang_kind_from_architecture(arch); + df_interact_regs()->text_key = dasm_info.text_key; + df_interact_regs()->lang_kind = txt_lang_kind_from_architecture(arch); U128 dasm_text_hash = {0}; - TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, dasm_info.text_key, lang_kind, &dasm_text_hash); + TXT_TextInfo dasm_text_info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &dasm_text_hash); String8 dasm_text_data = hs_data_from_hash(hs_scope, dasm_text_hash); B32 has_disasm = (dasm_info.insts.count != 0 && dasm_text_info.lines_count != 0); B32 is_loading = (!has_disasm && !df_entity_is_nil(process) && dim_1u64(dasm_vaddr_range) != 0); @@ -6665,7 +6673,7 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly) // if(!is_loading && has_disasm) { - df_code_view_build(ws, panel, view, cv, code_area_rect, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range); + df_code_view_build(ws, panel, view, cv, code_area_rect, dasm_text_data, &dasm_text_info, &dasm_info.insts, dasm_vaddr_range, dasm_dbgi_key); } ////////////////////////////// @@ -6674,7 +6682,7 @@ DF_VIEW_UI_FUNCTION_DEF(Disassembly) if(!is_loading && has_disasm) { U64 off = dasm_inst_array_code_off_from_idx(&dasm_info.insts, df_interact_regs()->cursor.line-1); - df_interact_regs()->vaddr_range = r1u64(dv->base_vaddr+off, dv->base_vaddr+off); + df_interact_regs()->vaddr_range = r1u64(dasm_base_vaddr+off, dasm_base_vaddr+off); df_interact_regs()->voff_range = df_voff_range_from_vaddr_range(dasm_module, df_interact_regs()->vaddr_range); df_interact_regs()->lines = df_lines_from_dbgi_key_voff(df_frame_arena(), &dasm_dbgi_key, df_interact_regs()->voff_range.min); } @@ -6906,7 +6914,7 @@ DF_VIEW_CMD_FUNCTION_DEF(Output) U128 hash = {0}; TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); - df_code_view_cmds(ws, panel, view, cv, cmds, data, &info, 0, r1u64(0, 0)); + df_code_view_cmds(ws, panel, view, cv, cmds, data, &info, 0, r1u64(0, 0), di_key_zero()); txt_scope_close(txt_scope); hs_scope_close(hs_scope); scratch_end(scratch); @@ -6945,7 +6953,7 @@ DF_VIEW_UI_FUNCTION_DEF(Output) //- rjf: build code contents // { - df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0)); + df_code_view_build(ws, panel, view, cv, code_area_rect, data, &info, 0, r1u64(0, 0), di_key_zero()); } ////////////////////////////// diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index 9c8c386f..258235b2 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -457,8 +457,8 @@ internal void df_entity_lister_item_array_sort_by_strength__in_place(DF_EntityLi //~ rjf: Code Views internal void df_code_view_init(DF_CodeViewState *cv, DF_View *view); -internal void df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range); -internal void df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range); +internal void df_code_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, DF_CmdList *cmds, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key); +internal void df_code_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_CodeViewState *cv, Rng2F32 rect, String8 text_data, TXT_TextInfo *text_info, DASM_InstArray *dasm_insts, Rng1U64 dasm_vaddr_range, DI_Key dasm_dbgi_key); //////////////////////////////// //~ rjf: Watch Views