From 04b38eb405ad6122995ff150841c7590697f49a5 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 16 Aug 2024 15:28:16 -0700 Subject: [PATCH] more progress on new expanded watch path; mostly feature convergent for procedures & callstack --- src/df/core/df_core.c | 26 +++++--- src/df/core/df_core.h | 4 +- src/df/gfx/df_gfx.c | 12 +++- src/df/gfx/df_views.c | 140 +++++++++++++++++++++++++++++++----------- src/df/gfx/df_views.h | 4 +- 5 files changed, 136 insertions(+), 50 deletions(-) diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index 986c9fd4..148fa77d 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -1354,7 +1354,7 @@ df_search_tags_from_entity(Arena *arena, DF_Entity *entity) DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr); DI_Key dbgi_key = df_dbgi_key_from_module(module); - String8 procedure_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff); + String8 procedure_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 0); if(procedure_name.size != 0) { str8_list_push(scratch.arena, &strings, procedure_name); @@ -2957,7 +2957,7 @@ df_vaddr_range_from_voff_range(DF_Entity *module, Rng1U64 voff_rng) //- rjf: symbol lookups internal String8 -df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff) +df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 decorated) { String8 result = {0}; { @@ -2970,9 +2970,21 @@ df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff) RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx); U64 proc_idx = scope->proc_idx; RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx); - U64 name_size = 0; - U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size); - result = push_str8_copy(arena, str8(name_ptr, name_size)); + E_TypeKey type = e_type_key_ext(E_TypeKind_Function, procedure->type_idx, e_parse_ctx_module_idx_from_rdi(rdi)); + String8 name = {0}; + name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &name.size); + if(decorated && procedure->type_idx != 0) + { + String8List list = {0}; + e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0); + str8_list_push(scratch.arena, &list, name); + e_type_rhs_string_from_key(scratch.arena, type, &list, 0); + result = str8_list_join(arena, &list, 0); + } + else + { + result = push_str8_copy(arena, name); + } } if(result.size == 0) { @@ -2989,14 +3001,14 @@ df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff) } internal String8 -df_symbol_name_from_process_vaddr(Arena *arena, DF_Entity *process, U64 vaddr) +df_symbol_name_from_process_vaddr(Arena *arena, DF_Entity *process, U64 vaddr, B32 decorated) { String8 result = {0}; { DF_Entity *module = df_module_from_process_vaddr(process, vaddr); DI_Key dbgi_key = df_dbgi_key_from_module(module); U64 voff = df_voff_from_vaddr(module, vaddr); - result = df_symbol_name_from_dbgi_key_voff(arena, &dbgi_key, voff); + result = df_symbol_name_from_dbgi_key_voff(arena, &dbgi_key, voff, decorated); } return result; } diff --git a/src/df/core/df_core.h b/src/df/core/df_core.h index af4cf393..f33ae7b6 100644 --- a/src/df/core/df_core.h +++ b/src/df/core/df_core.h @@ -1521,8 +1521,8 @@ internal Rng1U64 df_vaddr_range_from_voff_range(DF_Entity *module, Rng1U64 voff_ //~ rjf: Debug Info Lookups //- rjf: voff|vaddr -> symbol lookups -internal String8 df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff); -internal String8 df_symbol_name_from_process_vaddr(Arena *arena, DF_Entity *process, U64 vaddr); +internal String8 df_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, B32 decorated); +internal String8 df_symbol_name_from_process_vaddr(Arena *arena, DF_Entity *process, U64 vaddr, B32 decorated); //- rjf: symbol -> voff lookups internal U64 df_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name); diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index dd1c2e55..abce9557 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -8396,7 +8396,7 @@ df_single_line_eval_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags (E_TypeKind_Char8 <= direct_type_kind && direct_type_kind <= E_TypeKind_UChar32)); DF_Entity *thread = df_entity_from_handle(df_interact_regs()->thread); DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); - String8 symbol_name = df_symbol_name_from_process_vaddr(arena, process, value_eval.value.u64); + String8 symbol_name = df_symbol_name_from_process_vaddr(arena, process, value_eval.value.u64, 1); // rjf: display ptr value B32 did_ptr_value = 0; @@ -10717,7 +10717,7 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr); DI_Key dbgi_key = df_dbgi_key_from_module(module); - String8 procedure_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff); + String8 procedure_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 0); if(procedure_name.size != 0) { FuzzyMatchRangeList fuzzy_matches = {0}; @@ -12753,11 +12753,17 @@ df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_s }break; case TXT_TokenKind_Identifier: { + E_TypeKey type = e_leaf_type_from_name(token_string); + Vec4F32 color = base_color; + if(!e_type_key_match(e_type_key_zero(), type)) + { + color = df_rgba_from_theme_color(DF_ThemeColor_CodeType); + } D_FancyString fancy_string = { ui_top_font(), token_string, - base_color, + color, ui_top_font_size() * (1.f - !!indirection_size_change*(indirection_counter/10.f)), }; d_fancy_string_list_push(arena, &fancy_strings, &fancy_string); diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index c2f620ef..45861d7d 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1224,16 +1224,54 @@ df_tbl_from_watch_view_point(DF_EvalVizBlockList *blocks, DF_WatchViewPoint pt) //- rjf: table coordinates -> strings internal String8 -df_string_from_eval_viz_row_column_kind(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumnKind col_kind, B32 editable) +df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable) { String8 result = {0}; - switch(col_kind) + switch(col->kind) { default:{}break; - case DF_WatchViewColumnKind_Expr: {result = editable ? row->edit_expr : row->display_expr;}break; - case DF_WatchViewColumnKind_Value: {result = editable ? row->edit_value : row->display_value;}break; - case DF_WatchViewColumnKind_Type: {result = !e_type_key_match(row->eval.type_key, e_type_key_zero()) ? e_type_string_from_key(arena, row->eval.type_key) : str8_zero();}break; - case DF_WatchViewColumnKind_ViewRule:{result = df_eval_view_rule_from_key(ev, row->key);}break; + case DF_WatchViewColumnKind_Expr: + { + result = editable ? row->edit_expr : row->display_expr; + if(row->inherited_type_key_chain.first != 0) + { + Temp scratch = scratch_begin(&arena, 1); + String8List inheritance_chain_type_names = {0}; + for(E_TypeKeyNode *n = row->inherited_type_key_chain.first; n != 0; n = n->next) + { + String8 inherited_type_name = e_type_string_from_key(scratch.arena, n->v); + inherited_type_name = str8_skip_chop_whitespace(inherited_type_name); + str8_list_push(scratch.arena, &inheritance_chain_type_names, inherited_type_name); + } + if(inheritance_chain_type_names.node_count != 0) + { + StringJoin join = {0}; + join.sep = str8_lit("::"); + String8 inheritance_type = str8_list_join(scratch.arena, &inheritance_chain_type_names, &join); + result = push_str8f(scratch.arena, "%S::%S", inheritance_type, result); + } + scratch_end(scratch); + } + }break; + case DF_WatchViewColumnKind_Value: + { + result = editable ? row->edit_value : row->display_value; + }break; + case DF_WatchViewColumnKind_Type: + { + result = !e_type_key_match(row->eval.type_key, e_type_key_zero()) ? e_type_string_from_key(arena, row->eval.type_key) : str8_zero(); + result = str8_skip_chop_whitespace(result); + }break; + case DF_WatchViewColumnKind_ViewRule: + { + result = df_eval_view_rule_from_key(ev, row->key); + }break; + case DF_WatchViewColumnKind_Module: + { + DF_Entity *process = df_entity_from_handle(df_interact_regs()->process); + DF_Entity *module = df_module_from_process_vaddr(process, row->eval.value.u64); + result = df_display_string_from_entity(arena, module); + }break; } return result; } @@ -1998,7 +2036,8 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { for(S64 x = selection_tbl.min.x; x <= selection_tbl.max.x; x += 1) { - String8 string = df_string_from_eval_viz_row_column_kind(scratch.arena, eval_view, row, (DF_WatchViewColumnKind)x, 1); + DF_WatchViewColumn *col = df_watch_view_column_from_x(ewv, x); + String8 string = df_string_from_eval_viz_row_column(scratch.arena, eval_view, row, col, 1); string.size = Min(string.size, sizeof(ewv->dummy_text_edit_state.input_buffer)); DF_WatchViewPoint pt = {x, row->parent_key, row->key}; U64 hash = df_hash_from_expand_key(pt.key); @@ -2246,7 +2285,8 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { for(S64 x = selection_tbl.min.x; x <= selection_tbl.max.x; x += 1) { - String8 cell_string = df_string_from_eval_viz_row_column_kind(scratch.arena, eval_view, row, (DF_WatchViewColumnKind)x, 0); + DF_WatchViewColumn *col = df_watch_view_column_from_x(ewv, x); + String8 cell_string = df_string_from_eval_viz_row_column(scratch.arena, eval_view, row, col, 0); cell_string = str8_skip_chop_whitespace(cell_string); U64 comma_pos = str8_find_needle(cell_string, 0, str8_lit(","), 0); if(selection_tbl.min.x != selection_tbl.max.x || selection_tbl.min.y != selection_tbl.max.y) @@ -2311,7 +2351,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS new_cursor_parent_key = df_parent_expand_key_from_entity(fallback_watch); } } - DF_WatchViewPoint new_cursor_pt = {DF_WatchViewColumnKind_Expr, new_cursor_parent_key, new_cursor_key}; + DF_WatchViewPoint new_cursor_pt = {0, new_cursor_parent_key, new_cursor_key}; df_entity_mark_for_deletion(watch); ewv->cursor = ewv->mark = ewv->next_cursor = ewv->next_mark = new_cursor_pt; } @@ -2537,6 +2577,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS case DF_WatchViewColumnKind_Value: {name = str8_lit("Value");}break; case DF_WatchViewColumnKind_Type: {name = str8_lit("Type");}break; case DF_WatchViewColumnKind_ViewRule:{name = str8_lit("View Rule");}break; + case DF_WatchViewColumnKind_Module: {name = str8_lit("Module");}break; } switch(col->kind) { @@ -2685,7 +2726,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS //- rjf: do canvas row interactions { - DF_WatchViewPoint pt = {DF_WatchViewColumnKind_Expr, row->parent_key, row->key}; + DF_WatchViewPoint pt = {0, row->parent_key, row->key}; UI_Signal sig = ui_signal_from_box(row_box); // rjf: press -> focus @@ -2770,16 +2811,17 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS DF_WatchViewPoint cell_pt = {x, row->parent_key, row->key}; DF_WatchViewTextEditState *cell_edit_state = df_watch_view_text_edit_state_from_pt(ewv, cell_pt); B32 cell_selected = (row_selected && selection_tbl.min.x <= cell_pt.x && cell_pt.x <= selection_tbl.max.x); + String8 cell_pre_edit_string = df_string_from_eval_viz_row_column(scratch.arena, eval_view, row, col, 0); //- rjf: unpack column-kind-specific info B32 cell_can_edit = 0; FuzzyMatchRangeList cell_matches = {0}; - String8 cell_pre_edit_string = {0}; String8 cell_error_string = {0}; String8 cell_error_tooltip_string = {0}; DF_AutoCompListerFlags cell_autocomp_flags = 0; DF_GfxViewRuleRowUIFunctionType *cell_ui_hook = 0; Vec4F32 cell_base_color = ui_top_palette()->text; + DF_IconKind cell_icon = DF_IconKind_Null; switch(col->kind) { default:{}break; @@ -2790,21 +2832,6 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { cell_matches = fuzzy_match_find(scratch.arena, filter, row->display_expr); } - cell_pre_edit_string = row->display_expr; - if(row_is_inherited) - { - String8List inheritance_chain_type_names = {0}; - for(E_TypeKeyNode *n = row->inherited_type_key_chain.first; n != 0; n = n->next) - { - String8 inherited_type_name = e_type_string_from_key(scratch.arena, n->v); - inherited_type_name = str8_skip_chop_whitespace(inherited_type_name); - str8_list_push(scratch.arena, &inheritance_chain_type_names, inherited_type_name); - } - StringJoin join = {0}; - join.sep = str8_lit("::"); - String8 inheritance_type = str8_list_join(scratch.arena, &inheritance_chain_type_names, &join); - cell_pre_edit_string = push_str8f(scratch.arena, "%S::%S", inheritance_type, cell_pre_edit_string); - } cell_autocomp_flags = DF_AutoCompListerFlag_Locals; }break; case DF_WatchViewColumnKind_Value: @@ -2828,20 +2855,29 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { cell_ui_hook = row->value_ui_rule_spec->info.row_ui; } - cell_pre_edit_string = row->display_value; + if(row->eval.space >= E_Space_FIXED_COUNT) + { + cell_base_color = df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol); + } }break; case DF_WatchViewColumnKind_Type: { cell_can_edit = 0; E_TypeKey key = row->eval.type_key; - cell_pre_edit_string = str8_skip_chop_whitespace(e_type_string_from_key(scratch.arena, key)); cell_base_color = df_rgba_from_theme_color(DF_ThemeColor_CodeType); }break; case DF_WatchViewColumnKind_ViewRule: { cell_can_edit = 1; cell_autocomp_flags = DF_AutoCompListerFlag_ViewRules; - cell_pre_edit_string = df_eval_view_rule_from_key(eval_view, row->key); + }break; + case DF_WatchViewColumnKind_FrameSelection: + { + if(semantic_idx == df_interact_regs()->unwind_count - df_interact_regs()->inline_depth) + { + cell_icon = DF_IconKind_RightArrow; + cell_base_color = df_rgba_from_entity(df_entity_from_handle(df_interact_regs()->thread)); + } }break; } @@ -2890,6 +2926,17 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS sig = ui_signal_from_box(box); } + // rjf: cell has icon? build icon + else if(cell_icon != DF_IconKind_Null) + { + UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "###cell_%I64x", row_hash); + UI_Parent(box) DF_Font(ws, DF_FontSlot_Icons) UI_WidthFill UI_TextAlignment(UI_TextAlign_Center) + { + ui_label(df_g_icon_kind_text_table[cell_icon]); + } + sig = ui_signal_from_box(box); + } + // rjf: build cell line edit else { @@ -2898,7 +2945,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS DF_LineEditFlag_NoBackground| DF_LineEditFlag_DisableEdit*(!cell_can_edit)| DF_LineEditFlag_Expander*!!(x == 0 && row->flags & DF_EvalVizRowFlag_CanExpand)| - DF_LineEditFlag_ExpanderPlaceholder*(x == 0 && row->depth==0)| + DF_LineEditFlag_ExpanderPlaceholder*(x == 0 && row->depth==0 && col->kind == DF_WatchViewColumnKind_Expr)| DF_LineEditFlag_ExpanderSpace*(x == 0 && row->depth!=0)), x == 0 ? row->depth : 0, &cell_matches, @@ -2941,6 +2988,25 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Edit)); } + // rjf: double-click, not editable -> go-to-location + if(ui_double_clicked(sig) && !cell_can_edit) + { + U64 vaddr = row->eval.value.u64; + DF_Entity *module = df_module_from_process_vaddr(process, vaddr); + DI_Key dbgi_key = df_dbgi_key_from_module(module); + U64 voff = df_voff_from_vaddr(module, vaddr); + DF_LineList lines = df_lines_from_dbgi_key_voff(scratch.arena, &dbgi_key, voff); + DF_CmdParams p = df_cmd_params_from_view(ws, panel, view); + p.entity = df_handle_from_entity(process); + p.vaddr = vaddr; + if(lines.first != 0) + { + p.file_path = lines.first->v.file_path; + p.text_point = lines.first->v.pt; + } + df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation)); + } + // rjf: hovering with error tooltip -> show tooltip if(ui_hovering(sig) && cell_error_tooltip_string.size != 0) UI_Tooltip { @@ -6261,8 +6327,9 @@ DF_VIEW_SETUP_FUNCTION_DEF(CallStack) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_CallStack); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.5f); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.5f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_FrameSelection, 0.05f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.7f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Module, 0.25f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(CallStack) {return str8_zero();} DF_VIEW_CMD_FUNCTION_DEF(CallStack){} @@ -7656,10 +7723,9 @@ DF_VIEW_SETUP_FUNCTION_DEF(Procedures) { DF_WatchViewState *wv = df_view_user_state(view, DF_WatchViewState); df_watch_view_init(wv, view, DF_WatchViewFillKind_Procedures); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.25f); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.3f); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Type, 0.15f); - df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.30f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Expr, 0.2f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_Value, 0.6f); + df_watch_view_column_alloc(wv, DF_WatchViewColumnKind_ViewRule, 0.2f); } DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Procedures) { return str8_zero(); } DF_VIEW_CMD_FUNCTION_DEF(Procedures) {} @@ -8132,7 +8198,7 @@ DF_VIEW_UI_FUNCTION_DEF(Memory) DF_Entity *module = df_module_from_process_vaddr(process, f_rip); DI_Key dbgi_key = df_dbgi_key_from_module(module); U64 rip_voff = df_voff_from_vaddr(module, f_rip); - String8 symbol_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff); + String8 symbol_name = df_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 1); Annotation *annotation = push_array(scratch.arena, Annotation, 1); annotation->name_string = symbol_name.size != 0 ? symbol_name : str8_lit("[external code]"); annotation->kind_string = str8_lit("Call Stack Frame"); diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index f0e9e075..79b3e602 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -276,6 +276,8 @@ typedef enum DF_WatchViewColumnKind DF_WatchViewColumnKind_Value, DF_WatchViewColumnKind_Type, DF_WatchViewColumnKind_ViewRule, + DF_WatchViewColumnKind_Module, + DF_WatchViewColumnKind_FrameSelection, DF_WatchViewColumnKind_COUNT } DF_WatchViewColumnKind; @@ -546,7 +548,7 @@ internal DF_WatchViewPoint df_watch_view_point_from_tbl(DF_EvalVizBlockList *blo internal Vec2S64 df_tbl_from_watch_view_point(DF_EvalVizBlockList *blocks, DF_WatchViewPoint pt); //- rjf: table coordinates -> strings -internal String8 df_string_from_eval_viz_row_column_kind(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumnKind col_kind, B32 editable); +internal String8 df_string_from_eval_viz_row_column(Arena *arena, DF_EvalView *ev, DF_EvalVizRow *row, DF_WatchViewColumn *col, B32 editable); //- rjf: table coordinates -> text edit state internal DF_WatchViewTextEditState *df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint pt);