mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-19 10:32:23 -07:00
eliminate old eval/eval-viz paths
This commit is contained in:
@@ -4702,382 +4702,6 @@ df_append_viz_blocks_for_parent__rec(Arena *arena, DF_EvalView *eval_view, DF_Ex
|
||||
|
||||
scratch_end(scratch);
|
||||
ProfEnd();
|
||||
|
||||
//-
|
||||
//-
|
||||
//-
|
||||
// TODO(rjf): OLD vvvvvvvvvvvvvvvvvvvv
|
||||
#if 0
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (pointers) extract type & info to use for members and/or arrays
|
||||
//
|
||||
E_Eval udt_eval = eval;
|
||||
E_Eval arr_eval = eval;
|
||||
E_Eval ptr_eval = zero_struct;
|
||||
E_TypeKind udt_type_kind = eval_type_kind;
|
||||
E_TypeKind arr_type_kind = eval_type_kind;
|
||||
E_TypeKind ptr_type_kind = E_TypeKind_Null;
|
||||
if(eval_type_kind == E_TypeKind_Ptr || eval_type_kind == E_TypeKind_LRef || eval_type_kind == E_TypeKind_RRef)
|
||||
{
|
||||
E_TypeKey direct_type_key = e_type_ptee_from_key(eval_type_key);
|
||||
E_TypeKind direct_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
E_Eval ptr_val_eval = e_value_eval_from_eval(eval);
|
||||
|
||||
// rjf: ptrs to udts
|
||||
if(parent_is_expanded &&
|
||||
(direct_type_kind == E_TypeKind_Struct ||
|
||||
direct_type_kind == E_TypeKind_Union ||
|
||||
direct_type_kind == E_TypeKind_Class ||
|
||||
direct_type_kind == E_TypeKind_IncompleteStruct ||
|
||||
direct_type_kind == E_TypeKind_IncompleteUnion ||
|
||||
direct_type_kind == E_TypeKind_IncompleteClass))
|
||||
{
|
||||
udt_eval.type_key = direct_type_key;
|
||||
udt_eval.mode = E_Mode_Offset;
|
||||
udt_eval.space = ptr_val_eval.space;
|
||||
udt_eval.value = ptr_val_eval.value;
|
||||
udt_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
}
|
||||
|
||||
// rjf: ptrs to arrays
|
||||
if(direct_type_kind == E_TypeKind_Array)
|
||||
{
|
||||
arr_eval.type_key = direct_type_key;
|
||||
arr_eval.mode = E_Mode_Offset;
|
||||
arr_eval.space = ptr_val_eval.space;
|
||||
arr_eval.value = ptr_val_eval.value;
|
||||
arr_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
}
|
||||
|
||||
// rjf: ptrs to ptrs
|
||||
if(direct_type_kind == E_TypeKind_Ptr || direct_type_kind == E_TypeKind_LRef || direct_type_kind == E_TypeKind_RRef)
|
||||
{
|
||||
ptr_eval.type_key = direct_type_key;
|
||||
ptr_eval.mode = E_Mode_Offset;
|
||||
ptr_eval.space = ptr_val_eval.space;
|
||||
ptr_eval.value = ptr_val_eval.value;
|
||||
ptr_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: determine rule for building expansion children
|
||||
//
|
||||
typedef enum DF_EvalVizExpandRule
|
||||
{
|
||||
DF_EvalVizExpandRule_Default,
|
||||
DF_EvalVizExpandRule_List,
|
||||
DF_EvalVizExpandRule_ViewRule,
|
||||
}
|
||||
DF_EvalVizExpandRule;
|
||||
DF_EvalVizExpandRule expand_rule = DF_EvalVizExpandRule_Default;
|
||||
DF_CoreViewRuleSpec *expand_view_rule_spec = &df_g_nil_core_view_rule_spec;
|
||||
DF_CfgVal *expand_view_rule_cfg = &df_g_nil_cfg_val;
|
||||
String8 list_next_link_member_name = {0};
|
||||
{
|
||||
//- rjf: look for view rules which have their own custom viz block building rules
|
||||
if(expand_rule == DF_EvalVizExpandRule_Default && parent_is_expanded)
|
||||
{
|
||||
for(DF_CfgVal *val = cfg_table->first_val; val != 0 && val != &df_g_nil_cfg_val; val = val->linear_next)
|
||||
{
|
||||
DF_CoreViewRuleSpec *spec = df_core_view_rule_spec_from_string(val->string);
|
||||
if(str8_match(spec->info.string, str8_lit("list"), 0) ||
|
||||
str8_match(spec->info.string, str8_lit("omit"), 0) ||
|
||||
str8_match(spec->info.string, str8_lit("only"), 0))
|
||||
{
|
||||
// TODO(rjf): "list" view rule needs to be formally moved into the visualization
|
||||
// engine hooks when the system is mature enough to support it
|
||||
// also "omit", "only"
|
||||
continue;
|
||||
}
|
||||
if(spec->info.flags & DF_CoreViewRuleSpecInfoFlag_VizBlockProd)
|
||||
{
|
||||
expand_rule = DF_EvalVizExpandRule_ViewRule;
|
||||
expand_view_rule_spec = spec;
|
||||
expand_view_rule_cfg = val;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: get linked list viz view rule info for structs
|
||||
if(expand_rule == DF_EvalVizExpandRule_Default &&
|
||||
parent_is_expanded &&
|
||||
(udt_type_kind == E_TypeKind_Struct ||
|
||||
udt_type_kind == E_TypeKind_Union ||
|
||||
udt_type_kind == E_TypeKind_Class))
|
||||
{
|
||||
DF_CfgVal *list_cfg = df_cfg_val_from_string(cfg_table, str8_lit("list"));
|
||||
if(list_cfg != &df_g_nil_cfg_val)
|
||||
{
|
||||
list_next_link_member_name = list_cfg->first->first->string;
|
||||
expand_rule = DF_EvalVizExpandRule_List;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (all) descend to make blocks according to lens
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_ViewRule &&
|
||||
expand_view_rule_spec != &df_g_nil_core_view_rule_spec &&
|
||||
expand_view_rule_cfg != &df_g_nil_cfg_val)
|
||||
ProfScope("build viz blocks for lens")
|
||||
{
|
||||
expand_view_rule_spec->info.viz_block_prod(arena, eval_view, eval, string, cfg_table, parent_key, key, depth+1, expand_view_rule_cfg->last, list_out);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (structs, unions, classes) descend to members & make block(s), normally
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_Default &&
|
||||
(udt_type_kind == E_TypeKind_Struct ||
|
||||
udt_type_kind == E_TypeKind_Union ||
|
||||
udt_type_kind == E_TypeKind_Class))
|
||||
ProfScope("build viz blocks for UDT members")
|
||||
{
|
||||
//- rjf: type -> filtered data members
|
||||
E_MemberArray data_members = e_type_data_members_from_key(scratch.arena, udt_eval.type_key);
|
||||
E_MemberArray filtered_data_members = df_filtered_data_members_from_members_cfg_table(scratch.arena, data_members, cfg_table);
|
||||
|
||||
//- rjf: build blocks for all members, split by sub-expansions
|
||||
DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Members, key, df_expand_key_make(df_hash_from_expand_key(key), 0), depth+1);
|
||||
{
|
||||
last_vb->eval = udt_eval;
|
||||
last_vb->string = eval_string;
|
||||
last_vb->cfg_table = cfg_table;
|
||||
last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, filtered_data_members.count);
|
||||
}
|
||||
for(DF_ExpandNode *child = node->first; child != 0; child = child->next)
|
||||
{
|
||||
// rjf: unpack expansion info; skip out-of-bounds splits
|
||||
U64 child_num = child->key.child_num;
|
||||
U64 child_idx = child_num-1;
|
||||
if(child_idx >= filtered_data_members.count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// rjf: form split: truncate & complete last block; begin next block
|
||||
last_vb = df_eval_viz_block_split_and_continue(arena, list_out, last_vb, child_idx);
|
||||
|
||||
// rjf: recurse for sub-expansion
|
||||
{
|
||||
DF_CfgTable child_cfg = *cfg_table;
|
||||
{
|
||||
String8 view_rule_string = df_eval_view_rule_from_key(eval_view, df_expand_key_make(df_hash_from_expand_key(key), child_num));
|
||||
child_cfg = df_cfg_table_from_inheritance(arena, cfg_table);
|
||||
if(view_rule_string.size != 0)
|
||||
{
|
||||
df_cfg_table_push_unparsed_string(arena, &child_cfg, view_rule_string, DF_CfgSrc_User);
|
||||
}
|
||||
}
|
||||
E_Member *member = &filtered_data_members.v[child_idx];
|
||||
E_Eval child_eval = zero_struct;
|
||||
{
|
||||
child_eval.type_key = member->type_key;
|
||||
child_eval.mode = udt_eval.mode;
|
||||
child_eval.space = udt_eval.space;
|
||||
child_eval.value.u64 = udt_eval.value.u64 + member->off;
|
||||
}
|
||||
df_append_viz_blocks_for_parent__rec(arena, eval_view, key, child->key, member->name, child_eval, member, &child_cfg, depth+1, list_out);
|
||||
}
|
||||
}
|
||||
df_eval_viz_block_end(list_out, last_vb);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (enums) descend to members & make block(s)
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_Default &&
|
||||
udt_eval.mode == E_Mode_Null &&
|
||||
udt_type_kind == E_TypeKind_Enum)
|
||||
ProfScope("build viz blocks for UDT type-eval enums")
|
||||
{
|
||||
//- rjf: type -> full type info
|
||||
E_Type *type = e_type_from_key(scratch.arena, udt_eval.type_key);
|
||||
|
||||
//- rjf: build block for all members (cannot be expanded)
|
||||
DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_EnumMembers, key, df_expand_key_make(df_hash_from_expand_key(key), 0), depth+1);
|
||||
{
|
||||
last_vb->eval = udt_eval;
|
||||
last_vb->string = eval_string;
|
||||
last_vb->cfg_table = cfg_table;
|
||||
last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, type->count);
|
||||
}
|
||||
df_eval_viz_block_end(list_out, last_vb);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (structs, unions, classes) descend to members & make block(s), with linked list view
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_List &&
|
||||
(udt_type_kind == E_TypeKind_Struct ||
|
||||
udt_type_kind == E_TypeKind_Union ||
|
||||
udt_type_kind == E_TypeKind_Class))
|
||||
ProfScope("(structs, unions, classes) descend to members & make block(s), with linked list view")
|
||||
{
|
||||
//- rjf: type -> data members
|
||||
E_MemberArray data_members = e_type_data_members_from_key(scratch.arena, udt_eval.type_key);
|
||||
|
||||
//- rjf: find link member
|
||||
E_Member *link_member = 0;
|
||||
E_TypeKind link_member_type_kind = E_TypeKind_Null;
|
||||
E_TypeKey link_member_ptee_type_key = zero_struct;
|
||||
for(U64 idx = 0; idx < data_members.count; idx += 1)
|
||||
{
|
||||
E_Member *mem = &data_members.v[idx];
|
||||
if(str8_match(mem->name, list_next_link_member_name, 0))
|
||||
{
|
||||
link_member = mem;
|
||||
link_member_type_kind = e_type_kind_from_key(link_member->type_key);
|
||||
link_member_ptee_type_key = e_type_ptee_from_key(link_member->type_key);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: check if link member is good
|
||||
B32 link_member_is_good = 1;
|
||||
if(link_member == 0 ||
|
||||
link_member_type_kind != E_TypeKind_Ptr ||
|
||||
!e_type_key_match(link_member_ptee_type_key, udt_eval.type_key))
|
||||
{
|
||||
link_member_is_good = 0;
|
||||
}
|
||||
|
||||
//- rjf: gather link bases
|
||||
DF_EvalLinkBaseChunkList link_bases = {0};
|
||||
if(link_member_is_good)
|
||||
{
|
||||
link_bases = df_eval_link_base_chunk_list_from_eval(scratch.arena, link_member->type_key, link_member->off, udt_eval, 512);
|
||||
}
|
||||
|
||||
//- rjf: build blocks for all links, split by sub-expansions
|
||||
if(link_member_is_good)
|
||||
{
|
||||
DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Links, key, df_expand_key_make(df_hash_from_expand_key(key), 0), depth+1);
|
||||
{
|
||||
last_vb->eval = udt_eval;
|
||||
last_vb->string = eval_string;
|
||||
last_vb->cfg_table = cfg_table;
|
||||
last_vb->link_member_type_key = link_member->type_key;
|
||||
last_vb->link_member_off = link_member->off;
|
||||
last_vb->visual_idx_range = r1u64(0, link_bases.count);
|
||||
last_vb->semantic_idx_range = r1u64(0, link_bases.count);
|
||||
}
|
||||
for(DF_ExpandNode *child = node->first; child != 0; child = child->next)
|
||||
{
|
||||
// rjf: unpack expansion info; skip out-of-bounds splits
|
||||
U64 child_num = child->key.child_num;
|
||||
U64 child_idx = child_num-1;
|
||||
if(child_idx >= link_bases.count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// rjf: form split: truncate & complete last block; begin next block
|
||||
last_vb = df_eval_viz_block_split_and_continue(arena, list_out, last_vb, child_idx);
|
||||
|
||||
// rjf: find mode/offset of this link
|
||||
DF_EvalLinkBase link_base = df_eval_link_base_from_chunk_list_index(&link_bases, child_idx);
|
||||
|
||||
// rjf: recurse for sub-expansion
|
||||
{
|
||||
DF_CfgTable child_cfg = *cfg_table;
|
||||
{
|
||||
String8 view_rule_string = df_eval_view_rule_from_key(eval_view, df_expand_key_make(df_hash_from_expand_key(key), child_num));
|
||||
child_cfg = df_cfg_table_from_inheritance(arena, cfg_table);
|
||||
if(view_rule_string.size != 0)
|
||||
{
|
||||
df_cfg_table_push_unparsed_string(arena, &child_cfg, view_rule_string, DF_CfgSrc_User);
|
||||
}
|
||||
}
|
||||
E_Eval child_eval = zero_struct;
|
||||
{
|
||||
child_eval.type_key = udt_eval.type_key;
|
||||
child_eval.mode = E_Mode_Offset;
|
||||
child_eval.space = udt_eval.space;
|
||||
child_eval.value.u64= link_base.offset;
|
||||
}
|
||||
df_append_viz_blocks_for_parent__rec(arena, eval_view, key, child->key, push_str8f(arena, "[%I64u]", child_idx), child_eval, 0, &child_cfg, depth+1, list_out);
|
||||
}
|
||||
}
|
||||
df_eval_viz_block_end(list_out, last_vb);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (arrays) descend to elements & make block(s), normally
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_Default &&
|
||||
arr_type_kind == E_TypeKind_Array)
|
||||
ProfScope("(arrays) descend to elements & make block(s)")
|
||||
{
|
||||
//- rjf: unpack array type info
|
||||
E_Type *array_type = e_type_from_key(scratch.arena, arr_eval.type_key);
|
||||
U64 array_count = array_type->count;
|
||||
E_TypeKey element_type_key = array_type->direct_type_key;
|
||||
U64 element_type_byte_size = e_type_byte_size_from_key(element_type_key);
|
||||
|
||||
//- rjf: build blocks for all elements, split by sub-expansions
|
||||
DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_Elements, key, df_expand_key_make(df_hash_from_expand_key(key), 0), depth+1);
|
||||
{
|
||||
last_vb->eval = arr_eval;
|
||||
last_vb->string = eval_string;
|
||||
last_vb->cfg_table = cfg_table;
|
||||
last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, array_count);
|
||||
}
|
||||
for(DF_ExpandNode *child = node->first; child != 0; child = child->next)
|
||||
{
|
||||
// rjf: unpack expansion info; skip out-of-bounds splits
|
||||
U64 child_num = child->key.child_num;
|
||||
U64 child_idx = child_num-1;
|
||||
if(child_idx >= array_count)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// rjf: form split: truncate & complete last block; begin next block
|
||||
last_vb = df_eval_viz_block_split_and_continue(arena, list_out, last_vb, child_idx);
|
||||
|
||||
// rjf: recurse for sub-expansion
|
||||
{
|
||||
DF_CfgTable child_cfg = *cfg_table;
|
||||
{
|
||||
String8 view_rule_string = df_eval_view_rule_from_key(eval_view, df_expand_key_make(df_hash_from_expand_key(key), child_num));
|
||||
child_cfg = df_cfg_table_from_inheritance(arena, cfg_table);
|
||||
if(view_rule_string.size != 0)
|
||||
{
|
||||
df_cfg_table_push_unparsed_string(arena, &child_cfg, view_rule_string, DF_CfgSrc_User);
|
||||
}
|
||||
}
|
||||
E_Eval child_eval = zero_struct;
|
||||
{
|
||||
child_eval.type_key = element_type_key;
|
||||
child_eval.mode = arr_eval.mode;
|
||||
child_eval.space = arr_eval.space;
|
||||
child_eval.value.u64= arr_eval.value.u64 + child_idx*element_type_byte_size;
|
||||
}
|
||||
df_append_viz_blocks_for_parent__rec(arena, eval_view, key, child->key, push_str8f(arena, "[%I64u]", child_idx), child_eval, 0, &child_cfg, depth+1, list_out);
|
||||
}
|
||||
}
|
||||
df_eval_viz_block_end(list_out, last_vb);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: (ptr to ptrs) descend to make blocks for pointed-at-pointer
|
||||
//
|
||||
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_Default && (ptr_type_kind == E_TypeKind_Ptr || ptr_type_kind == E_TypeKind_LRef || ptr_type_kind == E_TypeKind_RRef))
|
||||
ProfScope("build viz blocks for ptr-to-ptrs")
|
||||
{
|
||||
String8 subexpr = push_str8f(arena, "*(%S)", string);
|
||||
df_append_viz_blocks_for_parent__rec(arena, eval_view, key, df_expand_key_make(df_hash_from_expand_key(key), 1), subexpr, ptr_eval, 0, cfg_table, depth+1, list_out);
|
||||
}
|
||||
|
||||
scratch_end(scratch);
|
||||
ProfEnd();
|
||||
#endif
|
||||
}
|
||||
|
||||
internal DF_EvalVizBlockList
|
||||
|
||||
@@ -5934,328 +5934,6 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
|
||||
ProfEnd();
|
||||
}
|
||||
|
||||
#if 0
|
||||
DF_VIEW_SETUP_FUNCTION_DEF(CallStack) {}
|
||||
DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(CallStack) { return str8_lit(""); }
|
||||
DF_VIEW_CMD_FUNCTION_DEF(CallStack) {}
|
||||
DF_VIEW_UI_FUNCTION_DEF(CallStack)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
DI_Scope *scope = di_scope_open();
|
||||
DF_Entity *thread = df_entity_from_handle(df_interact_regs()->thread);
|
||||
Architecture arch = df_architecture_from_entity(thread);
|
||||
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
|
||||
Vec4F32 thread_color = ui_top_palette()->text;
|
||||
if(thread->flags & DF_EntityFlag_HasColor)
|
||||
{
|
||||
thread_color = df_rgba_from_entity(thread);
|
||||
}
|
||||
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread);
|
||||
DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, scope, process, &base_unwind);
|
||||
|
||||
//- rjf: build per-row information
|
||||
typedef struct FrameRow FrameRow;
|
||||
struct FrameRow
|
||||
{
|
||||
void *regs;
|
||||
RDI_Parsed *rdi;
|
||||
RDI_Procedure *procedure;
|
||||
RDI_InlineSite *inline_site;
|
||||
U64 unwind_idx;
|
||||
U64 inline_depth;
|
||||
};
|
||||
U64 rows_count = rich_unwind.frames.total_frame_count;
|
||||
FrameRow *rows = push_array(scratch.arena, FrameRow, rows_count);
|
||||
{
|
||||
U64 concrete_frame_idx = 0;
|
||||
U64 row_idx = 0;
|
||||
for(;concrete_frame_idx < rich_unwind.frames.concrete_frame_count; concrete_frame_idx += 1, row_idx += 1)
|
||||
{
|
||||
DF_UnwindFrame *f = &rich_unwind.frames.v[concrete_frame_idx];
|
||||
|
||||
// rjf: fill rows for inline frames
|
||||
{
|
||||
U64 inline_unwind_idx = 0;
|
||||
for(DF_UnwindInlineFrame *fin = f->last_inline_frame; fin != 0; fin = fin->prev, row_idx += 1, inline_unwind_idx += 1)
|
||||
{
|
||||
rows[row_idx].regs = f->regs;
|
||||
rows[row_idx].rdi = f->rdi;
|
||||
rows[row_idx].inline_site = fin->inline_site;
|
||||
rows[row_idx].unwind_idx = concrete_frame_idx;
|
||||
rows[row_idx].inline_depth = f->inline_frame_count - inline_unwind_idx;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: fill row for concrete frame
|
||||
{
|
||||
rows[row_idx].regs = f->regs;
|
||||
rows[row_idx].rdi = f->rdi;
|
||||
rows[row_idx].procedure = f->procedure;
|
||||
rows[row_idx].unwind_idx= concrete_frame_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: grab state
|
||||
typedef struct DF_CallStackViewState DF_CallStackViewState;
|
||||
struct DF_CallStackViewState
|
||||
{
|
||||
B32 initialized;
|
||||
Vec2S64 cursor;
|
||||
Vec2S64 mark;
|
||||
F32 selection_col_pct;
|
||||
F32 module_col_pct;
|
||||
F32 function_name_col_pct;
|
||||
F32 addr_col_pct;
|
||||
};
|
||||
DF_CallStackViewState *cs = df_view_user_state(view, DF_CallStackViewState);
|
||||
if(cs->initialized == 0)
|
||||
{
|
||||
cs->initialized = 1;
|
||||
cs->selection_col_pct = 0.05f;
|
||||
cs->module_col_pct = 0.35f;
|
||||
cs->function_name_col_pct = 0.4f;
|
||||
cs->addr_col_pct = 0.2f;
|
||||
}
|
||||
|
||||
//- rjf: build ui
|
||||
Rng1S64 visible_row_range = {0};
|
||||
UI_ScrollListParams scroll_list_params = {0};
|
||||
{
|
||||
scroll_list_params.flags = UI_ScrollListFlag_All;
|
||||
scroll_list_params.row_height_px = floor_f32(ui_top_font_size()*2.5f);
|
||||
scroll_list_params.dim_px = dim_2f32(rect);
|
||||
scroll_list_params.cursor_range = r2s64(v2s64(0, 0), v2s64(3, rich_unwind.frames.total_frame_count));
|
||||
scroll_list_params.item_range = r1s64(0, rich_unwind.frames.total_frame_count+1);
|
||||
scroll_list_params.cursor_min_is_empty_selection[Axis2_Y] = 1;
|
||||
}
|
||||
UI_ScrollListSignal scroll_list_sig = {0};
|
||||
UI_Focus(UI_FocusKind_On)
|
||||
UI_ScrollList(&scroll_list_params,
|
||||
&view->scroll_pos.y,
|
||||
&cs->cursor,
|
||||
&cs->mark,
|
||||
&visible_row_range,
|
||||
&scroll_list_sig)
|
||||
UI_Focus(UI_FocusKind_Null)
|
||||
{
|
||||
Vec2S64 next_cursor = cs->cursor;
|
||||
|
||||
//- rjf: build table
|
||||
if(df_ctrl_targets_running())
|
||||
{
|
||||
ui_set_next_flags(UI_BoxFlag_Disabled);
|
||||
}
|
||||
F32 *col_pcts[] =
|
||||
{
|
||||
&cs->selection_col_pct,
|
||||
&cs->function_name_col_pct,
|
||||
&cs->addr_col_pct,
|
||||
&cs->module_col_pct,
|
||||
};
|
||||
UI_TableF(ArrayCount(col_pcts), col_pcts, "###tbl")
|
||||
{
|
||||
//- rjf: header
|
||||
if(visible_row_range.min == 0) UI_TableVector UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
|
||||
{
|
||||
UI_TableCell {}
|
||||
UI_TableCell ui_label(str8_lit("Function Name"));
|
||||
UI_TableCell ui_label(str8_lit("Address"));
|
||||
UI_TableCell ui_label(str8_lit("Module"));
|
||||
}
|
||||
|
||||
//- rjf: frame rows
|
||||
for(S64 row_num = visible_row_range.min;
|
||||
row_num <= visible_row_range.max && row_num <= rows_count;
|
||||
row_num += 1)
|
||||
{
|
||||
if(row_num == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
B32 row_selected = (cs->cursor.y == row_num);
|
||||
|
||||
// rjf: unpack frame
|
||||
U64 row_idx = row_num-1;
|
||||
FrameRow *row = &rows[row_idx];
|
||||
U64 rip_vaddr = regs_rip_from_arch_block(thread->arch, row->regs);
|
||||
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
|
||||
B32 frame_valid = (rip_vaddr != 0);
|
||||
String8 symbol_name = {0};
|
||||
String8 symbol_type_string = {0};
|
||||
if(row->procedure != 0)
|
||||
{
|
||||
symbol_name.str = rdi_name_from_procedure(row->rdi, row->procedure, &symbol_name.size);
|
||||
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->procedure->type_idx);
|
||||
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->procedure->type_idx, e_parse_ctx_module_idx_from_rdi(row->rdi)));
|
||||
}
|
||||
if(row->inline_site != 0)
|
||||
{
|
||||
symbol_name.str = rdi_string_from_idx(row->rdi, row->inline_site->name_string_idx, &symbol_name.size);
|
||||
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->inline_site->type_idx);
|
||||
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->inline_site->type_idx, e_parse_ctx_module_idx_from_rdi(row->rdi)));
|
||||
}
|
||||
|
||||
// rjf: build row
|
||||
if(frame_valid) UI_NamedTableVectorF("###callstack_%p_%I64x", view, row_idx)
|
||||
{
|
||||
// rjf: build cell for selection
|
||||
UI_TableCell
|
||||
DF_Font(ws, DF_FontSlot_Icons)
|
||||
UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Icons))
|
||||
UI_WidthFill
|
||||
UI_TextAlignment(UI_TextAlign_Center)
|
||||
UI_FocusHot((row_selected && cs->cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
String8 selected_string = {0};
|
||||
if(df_interact_regs()->unwind_count == row->unwind_idx &&
|
||||
df_interact_regs()->inline_depth == row->inline_depth)
|
||||
{
|
||||
selected_string = df_g_icon_kind_text_table[DF_IconKind_RightArrow];
|
||||
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = thread_color));
|
||||
}
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, "%S###selection_%I64u", selected_string, row_idx);
|
||||
UI_Signal sig = ui_signal_from_box(box);
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
next_cursor = v2s64(0, row_num);
|
||||
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
|
||||
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
|
||||
}
|
||||
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
|
||||
{
|
||||
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_UnwindIndex);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_InlineDepth);
|
||||
params.unwind_index = row->unwind_idx;
|
||||
params.inline_depth = row->inline_depth;
|
||||
df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: build cell for function header
|
||||
UI_TableCell DF_Font(ws, DF_FontSlot_Code)
|
||||
UI_FocusHot((row_selected && cs->cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
ui_set_next_child_layout_axis(Axis2_X);
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_Clip, "row_%I64x", row_idx);
|
||||
UI_Parent(box)
|
||||
{
|
||||
if(row->inline_site != 0)
|
||||
{
|
||||
UI_PrefWidth(ui_text_dim(10, 1)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
|
||||
{
|
||||
ui_label(str8_lit("[inlined]"));
|
||||
}
|
||||
}
|
||||
if(symbol_name.size == 0)
|
||||
{
|
||||
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_label(str8_lit("[unknown symbol]"));
|
||||
}
|
||||
else UI_WidthFill
|
||||
{
|
||||
D_FancyStringList symbol_name_fstrs = df_fancy_string_list_from_code_string(scratch.arena, 1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol), symbol_name);
|
||||
D_FancyStringList symbol_type_fstrs = df_fancy_string_list_from_code_string(scratch.arena, 0.5f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), symbol_type_string);
|
||||
D_FancyStringList fstrs = {0};
|
||||
d_fancy_string_list_concat_in_place(&fstrs, &symbol_name_fstrs);
|
||||
D_FancyString sep = {ui_top_font(), str8_lit(": "), ui_top_palette()->colors[UI_ColorCode_TextWeak], ui_top_font_size()};
|
||||
d_fancy_string_list_push(scratch.arena, &fstrs, &sep);
|
||||
d_fancy_string_list_concat_in_place(&fstrs, &symbol_type_fstrs);
|
||||
UI_Box *label = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero());
|
||||
ui_box_equip_display_fancy_strings(label, &fstrs);
|
||||
}
|
||||
}
|
||||
UI_Signal sig = ui_signal_from_box(box);
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
next_cursor = v2s64(1, row_num);
|
||||
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
|
||||
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
|
||||
}
|
||||
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
|
||||
{
|
||||
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_UnwindIndex);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_InlineDepth);
|
||||
params.unwind_index = row->unwind_idx;
|
||||
params.inline_depth = row->inline_depth;
|
||||
df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: build cell for rip
|
||||
UI_TableCell
|
||||
UI_FocusHot((row_selected && cs->cursor.x == 2) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "0x%I64x", rip_vaddr);
|
||||
UI_Signal sig = ui_signal_from_box(box);
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
next_cursor = v2s64(2, row_num);
|
||||
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
|
||||
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
|
||||
}
|
||||
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
|
||||
{
|
||||
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_UnwindIndex);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_InlineDepth);
|
||||
params.unwind_index = row->unwind_idx;
|
||||
params.inline_depth = row->inline_depth;
|
||||
df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: build cell for module
|
||||
UI_TableCell UI_FocusHot((row_selected && cs->cursor.x == 3) ? UI_FocusKind_On : UI_FocusKind_Off)
|
||||
{
|
||||
UI_Signal sig = {0};
|
||||
if(df_entity_is_nil(module)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
|
||||
{
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, "(No Module)###moduleless_frame_%I64x", row_idx);
|
||||
sig = ui_signal_from_box(box);
|
||||
}
|
||||
else
|
||||
{
|
||||
sig = df_entity_desc_button(ws, module, 0, str8_zero(), 1);
|
||||
}
|
||||
if(ui_pressed(sig))
|
||||
{
|
||||
next_cursor = v2s64(3, row_num);
|
||||
DF_CmdParams p = df_cmd_params_from_panel(ws, panel);
|
||||
df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FocusPanel));
|
||||
}
|
||||
if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
|
||||
{
|
||||
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_UnwindIndex);
|
||||
df_cmd_params_mark_slot(¶ms, DF_CmdParamSlot_InlineDepth);
|
||||
params.unwind_index = row->unwind_idx;
|
||||
params.inline_depth = row->inline_depth;
|
||||
df_push_cmd__root(¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: end if hit invalid frame
|
||||
if(frame_valid == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: apply moves to selection
|
||||
cs->cursor = next_cursor;
|
||||
}
|
||||
}
|
||||
|
||||
di_scope_close(scope);
|
||||
scratch_end(scratch);
|
||||
ProfEnd();
|
||||
}
|
||||
#endif
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Modules @view_hook_impl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user