Skip to content

Commit

Permalink
simplify/collapse/deduplicate eval viz block building code; correctly…
Browse files Browse the repository at this point in the history
… build filtered-info-table-sorted expansions for filtered debug info table watches; eliminate special-case empty row in watch views, just feed everything through the viz blocks path
  • Loading branch information
ryanfleury committed Feb 2, 2024
1 parent be4c52b commit 20ff4ac
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 461 deletions.
2 changes: 0 additions & 2 deletions src/base/base_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,11 @@ push_str8_cat(Arena *arena, String8 s1, String8 s2){

internal String8
push_str8_copy(Arena *arena, String8 s){
//ProfBeginFunction();
String8 str;
str.size = s.size;
str.str = push_array_no_zero(arena, U8, str.size + 1);
MemoryCopy(str.str, s.str, s.size);
str.str[str.size] = 0;
//ProfEnd();
return(str);
}

Expand Down
433 changes: 240 additions & 193 deletions src/df/core/df_core.c

Large diffs are not rendered by default.

54 changes: 42 additions & 12 deletions src/df/core/df_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ struct DF_EvalLinkBaseArray

typedef enum DF_EvalVizBlockKind
{
DF_EvalVizBlockKind_Null, // empty
DF_EvalVizBlockKind_Root, // root of tree or subtree; possibly-expandable expression.
DF_EvalVizBlockKind_Members, // members of struct, class, union
DF_EvalVizBlockKind_Elements, // elements of array
Expand All @@ -706,27 +707,49 @@ DF_EvalVizBlockKind;
typedef struct DF_EvalVizBlock DF_EvalVizBlock;
struct DF_EvalVizBlock
{
DF_EvalVizBlock *next;
// rjf: kind & keys
DF_EvalVizBlockKind kind;
DF_Eval eval;
TG_Key link_member_type_key;
U64 link_member_off;
DF_CfgTable cfg_table;
String8 string;
DF_ExpandKey parent_key;
DF_ExpandKey key;
S32 depth;

// rjf: evaluation info
DF_Eval eval;
String8 string;
TG_Member *member;

// rjf: info about ranges that this block spans
Rng1U64 visual_idx_range;
Rng1U64 semantic_idx_range;
DBGI_FuzzySearchItemArray backing_search_items;
TG_Member *member;
S32 depth;

// rjf: visualization config extensions
DF_CfgTable cfg_table;
TG_Key link_member_type_key;
U64 link_member_off;
};

typedef struct DF_EvalVizBlockNode DF_EvalVizBlockNode;
struct DF_EvalVizBlockNode
{
DF_EvalVizBlockNode *next;
DF_EvalVizBlock v;
};

typedef struct DF_EvalVizBlockList DF_EvalVizBlockList;
struct DF_EvalVizBlockList
{
DF_EvalVizBlock *first;
DF_EvalVizBlock *last;
DF_EvalVizBlockNode *first;
DF_EvalVizBlockNode *last;
U64 count;
U64 total_visual_row_count;
U64 total_semantic_row_count;
};

typedef struct DF_EvalVizBlockArray DF_EvalVizBlockArray;
struct DF_EvalVizBlockArray
{
DF_EvalVizBlock *v;
U64 count;
U64 total_visual_row_count;
U64 total_semantic_row_count;
Expand Down Expand Up @@ -1540,7 +1563,7 @@ internal void df_eval_view_set_key_rule(DF_EvalView *eval_view, DF_ExpandKey key
internal String8 df_eval_view_rule_from_key(DF_EvalView *eval_view, DF_ExpandKey key);

////////////////////////////////
//~ rjf: Evaluation View Visualization & Interaction
//~ rjf: Evaluation Visualization

//- rjf: evaluation value string builder helpers
internal String8 df_string_from_ascii_value(Arena *arena, U8 val);
Expand All @@ -1555,13 +1578,20 @@ internal DF_EvalLinkBaseChunkList df_eval_link_base_chunk_list_from_eval(Arena *
internal DF_EvalLinkBase df_eval_link_base_from_chunk_list_index(DF_EvalLinkBaseChunkList *list, U64 idx);
internal DF_EvalLinkBaseArray df_eval_link_base_array_from_chunk_list(Arena *arena, DF_EvalLinkBaseChunkList *chunks);

//- rjf: watch tree visualization
//- rjf: viz block collection building
internal DF_EvalVizBlock *df_eval_viz_block_begin(Arena *arena, DF_EvalVizBlockKind kind, DF_ExpandKey parent_key, DF_ExpandKey key, S32 depth);
internal DF_EvalVizBlock *df_eval_viz_block_split_and_continue(Arena *arena, DF_EvalVizBlockList *list, DF_EvalVizBlock *split_block, U64 split_idx);
internal void df_eval_viz_block_end(DF_EvalVizBlockList *list, DF_EvalVizBlock *block);
internal void df_append_viz_blocks_for_parent__rec(Arena *arena, DBGI_Scope *scope, DF_EvalView *view, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_ExpandKey parent_key, DF_ExpandKey key, String8 string, DF_Eval eval, TG_Member *opt_member, DF_CfgTable *cfg_table, S32 depth, DF_EvalVizBlockList *list_out);
internal DF_EvalVizBlockList df_eval_viz_block_list_from_eval_view_expr_num(Arena *arena, DBGI_Scope *scope, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_EvalView *eval_view, String8 expr, U64 num);
internal void df_eval_viz_block_list_concat__in_place(DF_EvalVizBlockList *dst, DF_EvalVizBlockList *to_push);

//- rjf: viz block list <-> table coordinates
internal DF_ExpandKey df_key_from_viz_block_idx_off(DF_EvalVizBlock *block, U64 idx);
internal B32 df_viz_block_contains_key(DF_EvalVizBlock *block, DF_ExpandKey key);
internal U64 df_idx_off_from_viz_block_key(DF_EvalVizBlock *block, DF_ExpandKey key);
internal S64 df_row_num_from_viz_block_list_key(DF_EvalVizBlockList *blocks, DF_ExpandKey key);
internal DF_ExpandKey df_key_from_viz_block_list_row_num(DF_EvalVizBlockList *blocks, S64 row_num);

////////////////////////////////
//~ rjf: Main State Accessors/Mutators
Expand Down
19 changes: 17 additions & 2 deletions src/df/gfx/df_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -7062,8 +7062,10 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
U64 visual_idx_off = 0;
U64 semantic_idx_off = 0;
DF_EvalVizWindowedRowList list = {0};
for(DF_EvalVizBlock *block = blocks->first; block != 0; block = block->next)
for(DF_EvalVizBlockNode *n = blocks->first; n != 0; n = n->next)
{
DF_EvalVizBlock *block = &n->v;

//////////////////////////////
//- rjf: extract block info
//
Expand Down Expand Up @@ -7149,7 +7151,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
//////////////////////////////
//- rjf: sum & advance
//
list.count_before_visual += num_skipped_visual;
list.count_before_visual += num_skipped_visual;
if(block_num_visual_rows != 0)
{
list.count_before_semantic += block_num_semantic_rows * num_skipped_visual / block_num_visual_rows;
Expand All @@ -7164,6 +7166,19 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
{
default:{}break;

//////////////////////////////
//- rjf: null -> empty row
//
case DF_EvalVizBlockKind_Null:
if(visible_idx_range.max > visible_idx_range.min)
{
DF_EvalVizRow *row = push_array(arena, DF_EvalVizRow, 1);
SLLQueuePush(list.first, list.last, row);
list.count += 1;
row->key = block->key;
row->parent_key = block->parent_key;
}break;

//////////////////////////////
//- rjf: root -> just a single row. possibly expandable.
//
Expand Down
95 changes: 30 additions & 65 deletions src/df/gfx/df_view_rule_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -483,19 +483,12 @@ struct DF_ViewRuleHooks_RGBAState

DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(rgba)
{
DF_EvalVizBlock *block = push_array(arena, DF_EvalVizBlock, 1);
block->kind = DF_EvalVizBlockKind_Canvas;
block->eval = eval;
block->cfg_table = *cfg_table;
block->parent_key = key;
block->key = df_expand_key_make(df_hash_from_expand_key(key), 1);
block->visual_idx_range = r1u64(0, 8);
block->semantic_idx_range = r1u64(0, 1);
block->depth = depth;
SLLQueuePush(out->first, out->last, block);
out->count += 1;
out->total_visual_row_count += 8;
out->total_semantic_row_count += 1;
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->eval = eval;
vb->cfg_table = *cfg_table;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
df_eval_viz_block_end(out, vb);
}

DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(rgba)
Expand Down Expand Up @@ -656,19 +649,12 @@ struct DF_ViewRuleHooks_TextState

DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(text)
{
DF_EvalVizBlock *block = push_array(arena, DF_EvalVizBlock, 1);
block->kind = DF_EvalVizBlockKind_Canvas;
block->eval = eval;
block->cfg_table = *cfg_table;
block->parent_key = key;
block->key = df_expand_key_make(df_hash_from_expand_key(key), 1);
block->visual_idx_range = r1u64(0, 8);
block->semantic_idx_range = r1u64(0, 1);
block->depth = depth;
SLLQueuePush(out->first, out->last, block);
out->count += 1;
out->total_visual_row_count += 8;
out->total_semantic_row_count += 1;
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->eval = eval;
vb->cfg_table = *cfg_table;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
df_eval_viz_block_end(out, vb);
}

DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(text)
Expand Down Expand Up @@ -764,19 +750,12 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(text)

DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(disasm)
{
DF_EvalVizBlock *block = push_array(arena, DF_EvalVizBlock, 1);
block->kind = DF_EvalVizBlockKind_Canvas;
block->eval = eval;
block->cfg_table = *cfg_table;
block->parent_key = key;
block->key = df_expand_key_make(df_hash_from_expand_key(key), 1);
block->visual_idx_range = r1u64(0, 8);
block->semantic_idx_range = r1u64(0, 1);
block->depth = depth;
SLLQueuePush(out->first, out->last, block);
out->count += 1;
out->total_visual_row_count += 8;
out->total_semantic_row_count += 1;
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->eval = eval;
vb->cfg_table = *cfg_table;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
df_eval_viz_block_end(out, vb);
}

DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(disasm)
Expand Down Expand Up @@ -855,19 +834,12 @@ internal UI_BOX_CUSTOM_DRAW(df_view_rule_hooks__bitmap_zoom_draw)

DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(bitmap)
{
DF_EvalVizBlock *block = push_array(arena, DF_EvalVizBlock, 1);
block->kind = DF_EvalVizBlockKind_Canvas;
block->eval = eval;
block->cfg_table = *cfg_table;
block->parent_key = key;
block->key = df_expand_key_make(df_hash_from_expand_key(key), 1);
block->visual_idx_range = r1u64(0, 8);
block->semantic_idx_range = r1u64(0, 1);
block->depth = depth;
SLLQueuePush(out->first, out->last, block);
out->count += 1;
out->total_visual_row_count += 8;
out->total_semantic_row_count += 1;
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->eval = eval;
vb->cfg_table = *cfg_table;
vb->visual_idx_range = r1u64(0, 8);
vb->semantic_idx_range = r1u64(0, 1);
df_eval_viz_block_end(out, vb);
}

DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(bitmap)
Expand Down Expand Up @@ -1101,19 +1073,12 @@ internal UI_BOX_CUSTOM_DRAW(df_view_rule_hooks__geo_box_draw)

DF_CORE_VIEW_RULE_VIZ_BLOCK_PROD_FUNCTION_DEF(geo)
{
DF_EvalVizBlock *block = push_array(arena, DF_EvalVizBlock, 1);
block->kind = DF_EvalVizBlockKind_Canvas;
block->eval = eval;
block->cfg_table = *cfg_table;
block->parent_key = key;
block->key = df_expand_key_make(df_hash_from_expand_key(key), 1);
block->visual_idx_range = r1u64(0, 16);
block->semantic_idx_range = r1u64(0, 1);
block->depth = depth;
SLLQueuePush(out->first, out->last, block);
out->count += 1;
out->total_visual_row_count += 16;
out->total_semantic_row_count += 1;
DF_EvalVizBlock *vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Canvas, key, df_expand_key_make(df_hash_from_expand_key(key), 1), depth);
vb->eval = eval;
vb->cfg_table = *cfg_table;
vb->visual_idx_range = r1u64(0, 16);
vb->semantic_idx_range = r1u64(0, 1);
df_eval_viz_block_end(out, vb);
}

DF_GFX_VIEW_RULE_ROW_UI_FUNCTION_DEF(geo)
Expand Down
Loading

0 comments on commit 20ff4ac

Please sign in to comment.