From a4978e75a364461f7dfba5813a573a323e62f6a6 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Tue, 6 Aug 2024 14:01:30 -0700 Subject: [PATCH] eliminate separate helper for eval viz block list building --- src/df/gfx/df_views.c | 249 ------------------------------------------ src/df/gfx/df_views.h | 3 - 2 files changed, 252 deletions(-) diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index 8da79529..8692bd6b 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1236,255 +1236,6 @@ df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint p return result; } -//- rjf: windowed watch tree visualization (both single-line and multi-line) - -internal DF_EvalVizBlockList -df_eval_viz_block_list_from_watch_view_state(Arena *arena, DI_Scope *di_scope, FZY_Scope *fzy_scope, DF_View *view, DF_WatchViewState *ews) -{ - ProfBeginFunction(); - Temp scratch = scratch_begin(&arena, 1); - DF_EvalVizBlockList blocks = {0}; - DF_EvalViewKey eval_view_key = df_eval_view_key_from_eval_watch_view(ews); - DF_EvalView *eval_view = df_eval_view_from_key(eval_view_key); - String8 filter = str8(view->query_buffer, view->query_string_size); - RDI_SectionKind fzy_target = RDI_SectionKind_UDTs; - switch(ews->fill_kind) - { - //////////////////////////// - //- rjf: mutable watch fill -> build blocks from top-level mutable root expressions - // - default: - case DF_WatchViewFillKind_Mutable: - { - DF_EntityList watches = df_query_cached_entity_list_with_kind(DF_EntityKind_Watch); - for(DF_EntityNode *n = watches.first; n != 0; n = n->next) - { - DF_Entity *watch = n->entity; - String8 expr_string = watch->name; - FuzzyMatchRangeList matches = fuzzy_match_find(arena, filter, expr_string); - if(matches.count == matches.needle_part_count) - { - DF_ExpandKey parent_key = df_parent_expand_key_from_entity(watch); - DF_ExpandKey key = df_expand_key_from_entity(watch); - DF_EvalVizBlockList watch_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(arena, eval_view, expr_string, parent_key, key); - df_eval_viz_block_list_concat__in_place(&blocks, &watch_blocks);} - } - }break; - - //////////////////////////// - //- rjf: registers fill -> build blocks via iterating all registers/aliases as root-level expressions - // - case DF_WatchViewFillKind_Registers: - { - DF_Entity *thread = df_entity_from_handle(df_interact_regs()->thread); - Architecture arch = df_architecture_from_entity(thread); - U64 reg_count = regs_reg_code_count_from_architecture(arch); - String8 *reg_strings = regs_reg_code_string_table_from_architecture(arch); - U64 alias_count = regs_alias_code_count_from_architecture(arch); - String8 *alias_strings = regs_alias_code_string_table_from_architecture(arch); - U64 num = 1; - for(U64 reg_idx = 1; reg_idx < reg_count; reg_idx += 1, num += 1) - { - String8 root_expr_string = reg_strings[reg_idx]; - FuzzyMatchRangeList matches = fuzzy_match_find(arena, filter, root_expr_string); - if(matches.count == matches.needle_part_count) - { - DF_ExpandKey parent_key = df_expand_key_make(5381, 0); - DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), num); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(arena, eval_view, root_expr_string, parent_key, key); - df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); - } - } - for(U64 alias_idx = 1; alias_idx < alias_count; alias_idx += 1, num += 1) - { - String8 root_expr_string = alias_strings[alias_idx]; - FuzzyMatchRangeList matches = fuzzy_match_find(arena, filter, root_expr_string); - if(matches.count == matches.needle_part_count) - { - DF_ExpandKey parent_key = df_expand_key_make(5381, 0); - DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), num); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(arena, eval_view, root_expr_string, parent_key, key); - df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); - } - } - }break; - - //////////////////////////// - //- rjf: locals fill -> build blocks via iterating all locals as root-level expressions - // - case DF_WatchViewFillKind_Locals: - { - E_String2NumMapNodeArray nodes = e_string2num_map_node_array_from_map(scratch.arena, e_parse_ctx->locals_map); - e_string2num_map_node_array_sort__in_place(&nodes); - for(U64 idx = 0; idx < nodes.count; idx += 1) - { - E_String2NumMapNode *n = nodes.v[idx]; - String8 root_expr_string = n->string; - FuzzyMatchRangeList matches = fuzzy_match_find(arena, filter, root_expr_string); - if(matches.count == matches.needle_part_count) - { - DF_ExpandKey parent_key = df_expand_key_make(5381, 0); - DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(parent_key), idx+1); - DF_EvalVizBlockList root_blocks = df_eval_viz_block_list_from_eval_view_expr_keys(arena, eval_view, root_expr_string, parent_key, key); - df_eval_viz_block_list_concat__in_place(&blocks, &root_blocks); - } - } - }break; - - //////////////////////////// - //- rjf: debug info table fill -> build split debug info table blocks - // - case DF_WatchViewFillKind_Globals: fzy_target = RDI_SectionKind_GlobalVariables; goto dbgi_table; - case DF_WatchViewFillKind_ThreadLocals: fzy_target = RDI_SectionKind_ThreadVariables; goto dbgi_table; - case DF_WatchViewFillKind_Types: fzy_target = RDI_SectionKind_UDTs; goto dbgi_table; - case DF_WatchViewFillKind_Procedures: fzy_target = RDI_SectionKind_Procedures; goto dbgi_table; - dbgi_table:; - { - U64 endt_us = os_now_microseconds()+200; - - //- rjf: unpack context - DI_KeyList dbgi_keys_list = df_push_active_dbgi_key_list(scratch.arena); - DI_KeyArray dbgi_keys = di_key_array_from_list(scratch.arena, &dbgi_keys_list); - U64 rdis_count = dbgi_keys.count; - RDI_Parsed **rdis = push_array(scratch.arena, RDI_Parsed *, rdis_count); - for(U64 idx = 0; idx < rdis_count; idx += 1) - { - rdis[idx] = di_rdi_from_key(di_scope, &dbgi_keys.v[idx], endt_us); - } - - //- rjf: calculate top-level keys, expand root-level, grab root expansion node - DF_ExpandKey parent_key = df_expand_key_make(5381, 0); - DF_ExpandKey root_key = df_expand_key_make(df_hash_from_expand_key(parent_key), 0); - df_expand_set_expansion(eval_view->arena, &eval_view->expand_tree_table, df_expand_key_zero(), parent_key, 1); - DF_ExpandNode *root_node = df_expand_node_from_key(&eval_view->expand_tree_table, parent_key); - - //- rjf: query all filtered items from dbgi searching system - U128 fuzzy_search_key = {(U64)view, df_hash_from_string(str8_struct(&view))}; - B32 items_stale = 0; - FZY_Params params = {fzy_target, dbgi_keys}; - FZY_ItemArray items = fzy_items_from_key_params_query(fzy_scope, fuzzy_search_key, ¶ms, filter, endt_us, &items_stale); - if(items_stale) - { - df_gfx_request_frame(); - } - - //- rjf: gather unsorted child expansion keys - // - // Nodes are sorted in the underlying expansion tree data structure, but - // ONLY by THEIR ORDER IN THE UNDERLYING DEBUG INFO TABLE. This is - // because debug info watch rows use the DEBUG INFO TABLE INDEX to form - // their key - this provides more stable/predictable behavior as rows - // are reordered, filtered, and shuffled around, as the user filters. - // - // When we actually build viz blocks, however, we want to produce viz - // blocks BY THE ORDER OF SUB-EXPANSIONS IN THE FILTERED ITEM ARRAY - // SPACE, so that all of the expansions come out in the right order. - // - DF_ExpandKey *sub_expand_keys = 0; - U64 *sub_expand_item_idxs = 0; - U64 sub_expand_keys_count = 0; - { - for(DF_ExpandNode *child = root_node->first; child != 0; child = child->next) - { - sub_expand_keys_count += 1; - } - sub_expand_keys = push_array(scratch.arena, DF_ExpandKey, sub_expand_keys_count); - sub_expand_item_idxs = push_array(scratch.arena, U64, sub_expand_keys_count); - U64 idx = 0; - for(DF_ExpandNode *child = root_node->first; child != 0; child = child->next) - { - U64 item_num = fzy_item_num_from_array_element_idx__linear_search(&items, child->key.child_num); - if(item_num != 0) - { - sub_expand_keys[idx] = child->key; - sub_expand_item_idxs[idx] = item_num-1; - idx += 1; - } - else - { - sub_expand_keys_count -= 1; - } - } - } - - //- rjf: sort child expansion keys - { - for(U64 idx1 = 0; idx1 < sub_expand_keys_count; idx1 += 1) - { - U64 min_idx2 = 0; - U64 min_item_idx = sub_expand_item_idxs[idx1]; - for(U64 idx2 = idx1+1; idx2 < sub_expand_keys_count; idx2 += 1) - { - if(sub_expand_item_idxs[idx2] < min_item_idx) - { - min_idx2 = idx2; - min_item_idx = sub_expand_item_idxs[idx2]; - } - } - if(min_idx2 != 0) - { - Swap(DF_ExpandKey, sub_expand_keys[idx1], sub_expand_keys[min_idx2]); - Swap(U64, sub_expand_item_idxs[idx1], sub_expand_item_idxs[min_idx2]); - } - } - } - - //- rjf: build blocks for all table items, split by sorted sub-expansions - DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_DebugInfoTable, parent_key, root_key, 0); - { - last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, items.count); - last_vb->fzy_target = fzy_target; - last_vb->fzy_backing_items = items; - } - for(U64 sub_expand_idx = 0; sub_expand_idx < sub_expand_keys_count; sub_expand_idx += 1) - { - FZY_Item *item = &items.v[sub_expand_item_idxs[sub_expand_idx]]; - - // rjf: form split: truncate & complete last block; begin next block - last_vb = df_eval_viz_block_split_and_continue(arena, &blocks, last_vb, sub_expand_item_idxs[sub_expand_idx]); - - // rjf: grab rdi for this item - RDI_Parsed *rdi = &di_rdi_parsed_nil; - U64 base_idx = 0; - { - for(U64 rdi_idx = 0; rdi_idx < rdis_count; rdi_idx += 1) - { - U64 procedures_count = 0; - rdi_section_raw_table_from_kind(rdis[rdi_idx], RDI_SectionKind_Procedures, &procedures_count); - if(base_idx <= item->idx && item->idx < base_idx + procedures_count) - { - rdi = rdis[rdi_idx]; - break; - } - base_idx += procedures_count; - } - } - - // rjf: grab name for the expanded row - String8 name = fzy_item_string_from_rdi_target_element_idx(rdi, fzy_target, sub_expand_keys[sub_expand_idx].child_num-base_idx); - - // rjf: recurse for sub-expansion - { - DF_CfgTable child_cfg = {0}; - { - String8 view_rule_string = df_eval_view_rule_from_key(eval_view, df_expand_key_make(df_hash_from_expand_key(parent_key), sub_expand_keys[sub_expand_idx].child_num)); - if(view_rule_string.size != 0) - { - df_cfg_table_push_unparsed_string(arena, &child_cfg, view_rule_string, DF_CfgSrc_User); - } - } - E_Eval eval = e_eval_from_string(arena, name); - df_append_viz_blocks_for_parent__rec(arena, eval_view, parent_key, sub_expand_keys[sub_expand_idx], name, eval, 0, &child_cfg, 0, &blocks); - } - } - df_eval_viz_block_end(&blocks, last_vb); - }break; - } - scratch_end(scratch); - ProfEnd(); - return blocks; -} - //- rjf: eval/watch views main hooks internal void diff --git a/src/df/gfx/df_views.h b/src/df/gfx/df_views.h index 1d0e46e4..dd58a8b0 100644 --- a/src/df/gfx/df_views.h +++ b/src/df/gfx/df_views.h @@ -534,9 +534,6 @@ internal String8 df_string_from_eval_viz_row_column_kind(Arena *arena, DF_EvalVi //- rjf: table coordinates -> text edit state internal DF_WatchViewTextEditState *df_watch_view_text_edit_state_from_pt(DF_WatchViewState *wv, DF_WatchViewPoint pt); -//- rjf: windowed watch tree visualization -internal DF_EvalVizBlockList df_eval_viz_block_list_from_watch_view_state(Arena *arena, DI_Scope *di_scope, FZY_Scope *fzy_scope, DF_View *view, DF_WatchViewState *ews); - //- rjf: eval/watch views main hooks internal void df_watch_view_init(DF_WatchViewState *ewv, DF_View *view, DF_WatchViewFillKind fill_kind); internal void df_watch_view_cmds(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewState *ewv, DF_CmdList *cmds);