data member offset sorting -> take into account base offset, when doing inheritance graph search; visualize inheritance chain for inherited members; use contextual base color in code labels, do not assume default code color implicitly

This commit is contained in:
Ryan Fleury
2024-01-16 14:01:37 -08:00
parent e2e1382508
commit 114dd96e50
6 changed files with 121 additions and 33 deletions
+1
View File
@@ -818,6 +818,7 @@ struct DF_EvalVizRow
String8 expr;
String8 display_value;
String8 edit_value;
TG_KeyList inherited_type_key_chain;
// rjf: variable-size & hook info
U64 size_in_rows;
+25 -13
View File
@@ -4172,7 +4172,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
}
UI_PrefWidth(ui_em(30.f, 1.f))
{
UI_PrefWidth(ui_text_dim(10, 1.f)) df_code_label(1.f, 1, row->expr);
UI_PrefWidth(ui_text_dim(10, 1.f)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), row->expr);
ui_spacer(ui_em(1.5f, 1.f));
if(row->flags & DF_EvalVizRowFlag_CanEditValue)
{
@@ -4197,7 +4197,7 @@ df_window_update_and_render(Arena *arena, OS_EventList *events, DF_Window *ws, D
}
else
{
df_code_label(1.f, 1, row->display_value);
df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), row->display_value);
}
}
ui_spacer(ui_em(0.75f, 1.f));
@@ -7207,6 +7207,7 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
row->expr = push_str8_copy(arena, member->name);
row->display_value = str8_list_join(arena, &display_strings, 0);
row->edit_value = str8_list_join(arena, &edit_strings, 0);
row->inherited_type_key_chain = tg_key_list_copy(arena, &member->inheritance_key_chain);
row->value_ui_rule_node = value_ui_rule_node;
row->value_ui_rule_spec = value_ui_rule_spec;
row->expand_ui_rule_node = expand_ui_rule_node;
@@ -8646,14 +8647,14 @@ df_entity_tooltips(DF_Entity *entity)
stop_condition = str8_lit("true");
}
UI_PrefWidth(ui_em(12.f, 1.f)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) ui_labelf("Stop Condition: ");
UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, stop_condition);
UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), stop_condition);
}
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
U64 hit_count = entity->u64;
String8 hit_count_text = str8_from_u64(scratch.arena, hit_count, 10, 0, 0);
UI_PrefWidth(ui_em(12.f, 1.f)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) ui_labelf("Hit Count: ");
UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, hit_count_text);
UI_PrefWidth(ui_text_dim(10, 1)) UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), hit_count_text);
}
}break;
case DF_EntityKind_WatchPin: UI_Font(df_font_from_slot(DF_FontSlot_Code))
@@ -8664,7 +8665,7 @@ df_entity_tooltips(DF_Entity *entity)
ui_set_next_text_color(color);
}
String8 display_string = df_display_string_from_entity(scratch.arena, entity);
UI_PrefWidth(ui_text_dim(10, 1)) df_code_label(1.f, 1, display_string);
UI_PrefWidth(ui_text_dim(10, 1)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), display_string);
}break;
}
scratch_end(scratch);
@@ -9554,8 +9555,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
ws->entity_ctx_menu_entity = df_handle_from_entity(pin);
}
}
df_code_label(0.8f, 1, pin_expr);
df_code_label(0.6f, 1, eval_string);
df_code_label(0.8f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), pin_expr);
df_code_label(0.6f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), eval_string);
}
UI_Signal pin_sig = ui_signal_from_box(pin_box);
if(ui_key_match(pin_box_key, ui_hot_key()))
@@ -10466,7 +10467,7 @@ df_help_label(String8 string)
}
internal D_FancyStringList
df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_size_change, String8 string)
df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_size_change, Vec4F32 base_color, String8 string)
{
Temp scratch = scratch_begin(&arena, 1);
D_FancyStringList fancy_strings = {0};
@@ -10495,6 +10496,17 @@ df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_s
};
d_fancy_string_list_push(arena, &fancy_strings, &fancy_string);
}break;
case TXTI_TokenKind_Identifier:
{
D_FancyString fancy_string =
{
ui_top_font(),
token_string,
base_color,
ui_top_font_size() * (1.f - !!indirection_size_change*(indirection_counter/10.f)),
};
d_fancy_string_list_push(arena, &fancy_strings, &fancy_string);
}break;
case TXTI_TokenKind_Numeric:
{
Vec4F32 token_color_rgba_alt = token_color_rgba;
@@ -10606,10 +10618,10 @@ df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_s
}
internal void
df_code_label(F32 alpha, B32 indirection_size_change, String8 string)
df_code_label(F32 alpha, B32 indirection_size_change, Vec4F32 base_color, String8 string)
{
Temp scratch = scratch_begin(0, 0);
D_FancyStringList fancy_strings = df_fancy_string_list_from_code_string(scratch.arena, alpha, indirection_size_change, string);
D_FancyStringList fancy_strings = df_fancy_string_list_from_code_string(scratch.arena, alpha, indirection_size_change, base_color, string);
UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero());
ui_box_equip_display_fancy_strings(box, &fancy_strings);
scratch_end(scratch);
@@ -10815,11 +10827,11 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, TxtPt *cursor, TxtPt *mark, U8 *
if(!(flags & DF_LineEditFlag_PreferDisplayString) && pre_edit_value.size != 0)
{
display_string = pre_edit_value;
df_code_label(1.f, 1, display_string);
df_code_label(1.f, 1, ui_top_text_color(), display_string);
}
else if(flags & DF_LineEditFlag_DisplayStringIsCode)
{
df_code_label(1.f, 1, display_string);
df_code_label(1.f, 1, ui_top_text_color(), display_string);
}
else
{
@@ -10848,7 +10860,7 @@ df_line_edit(DF_LineEditFlags flags, S32 depth, TxtPt *cursor, TxtPt *mark, U8 *
F32 total_editstr_width = total_text_width - !!(flags & (DF_LineEditFlag_Expander|DF_LineEditFlag_ExpanderSpace|DF_LineEditFlag_ExpanderPlaceholder)) * expander_size_px;
ui_set_next_pref_width(ui_px(total_editstr_width+ui_top_font_size()*2, 0.f));
UI_Box *editstr_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DisableTextTrunc, "###editstr");
D_FancyStringList code_fancy_strings = df_fancy_string_list_from_code_string(scratch.arena, 1.f, 0, edit_string);
D_FancyStringList code_fancy_strings = df_fancy_string_list_from_code_string(scratch.arena, 1.f, 0, ui_top_text_color(), edit_string);
ui_box_equip_display_fancy_strings(editstr_box, &code_fancy_strings);
UI_LineEditDrawData *draw_data = push_array(ui_build_arena(), UI_LineEditDrawData, 1);
draw_data->edited_string = push_str8_copy(ui_build_arena(), edit_string);
+2 -2
View File
@@ -1031,8 +1031,8 @@ internal B32 df_do_dasm_controls(DASM_Handle handle, U64 line_count_per_page, Tx
internal UI_Signal df_error_label(String8 string);
internal B32 df_help_label(String8 string);
internal D_FancyStringList df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_size_change, String8 string);
internal void df_code_label(F32 alpha, B32 indirection_size_change, String8 string);
internal D_FancyStringList df_fancy_string_list_from_code_string(Arena *arena, F32 alpha, B32 indirection_size_change, Vec4F32 base_color, String8 string);
internal void df_code_label(F32 alpha, B32 indirection_size_change, Vec4F32 base_color, String8 string);
////////////////////////////////
//~ rjf: UI Widgets: Line Edit
+44 -17
View File
@@ -1051,22 +1051,49 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
// rjf: build
UI_Signal sig = {0};
B32 next_expanded = row_expanded;
UI_TableCell UI_Font(code_font)
UI_TextColor(row->depth > 0 ? df_rgba_from_theme_color(DF_ThemeColor_WeakText) : ui_top_text_color())
UI_FocusHot(cell_selected) UI_FocusActive(cell_selected && ewv->input_editing)
UI_TableCell UI_FocusHot(cell_selected) UI_FocusActive(cell_selected && ewv->input_editing)
{
B32 expr_editing_active = ui_is_focus_active();
sig = df_line_editf((DF_LineEditFlag_CodeContents|
DF_LineEditFlag_NoBackground|
DF_LineEditFlag_DisableEdit*(!can_edit_expr)|
DF_LineEditFlag_Expander*!!(row->flags & DF_EvalVizRowFlag_CanExpand)|
DF_LineEditFlag_ExpanderPlaceholder*(row->depth==0)|
DF_LineEditFlag_ExpanderSpace*(row->depth!=0)),
row->depth,
&ewv->input_cursor, &ewv->input_mark, ewv->input_buffer, sizeof(ewv->input_buffer), &ewv->input_size, &next_expanded,
row->expr,
"###row_%I64x", row_hash);
B32 is_inherited = (row->inherited_type_key_chain.count != 0);
UI_Font(code_font) UI_TextColor(row->depth > 0 ? df_rgba_from_theme_color(DF_ThemeColor_WeakText) : ui_top_text_color())
{
if(is_inherited)
{
Vec4F32 inherited_bg_color = df_rgba_from_theme_color(DF_ThemeColor_Highlight1);
inherited_bg_color.w *= 0.2f;
ui_set_next_background_color(inherited_bg_color);
}
sig = df_line_editf((DF_LineEditFlag_CodeContents|
DF_LineEditFlag_NoBackground*(!is_inherited)|
DF_LineEditFlag_DisableEdit*(!can_edit_expr)|
DF_LineEditFlag_Expander*!!(row->flags & DF_EvalVizRowFlag_CanExpand)|
DF_LineEditFlag_ExpanderPlaceholder*(row->depth==0)|
DF_LineEditFlag_ExpanderSpace*(row->depth!=0)),
row->depth,
&ewv->input_cursor, &ewv->input_mark, ewv->input_buffer, sizeof(ewv->input_buffer), &ewv->input_size, &next_expanded,
row->expr,
"###row_%I64x", row_hash);
}
edit_commit = edit_commit || sig.commit;
if(sig.hovering && is_inherited) UI_Tooltip
{
String8List inheritance_chain_type_names = {0};
for(TG_KeyNode *n = row->inherited_type_key_chain.first; n != 0; n = n->next)
{
String8 inherited_type_name = tg_string_from_key(scratch.arena, parse_ctx.type_graph, parse_ctx.rdbg, 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);
ui_set_next_pref_width(ui_children_sum(1));
UI_Row
{
ui_labelf("Inherited from ");
UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1.f, df_rgba_from_theme_color(DF_ThemeColor_CodeType), inheritance_type);
}
}
if(sig.hovering && DEV_eval_watch_key_tooltips) UI_Tooltip UI_Font(df_font_from_slot(DF_FontSlot_Code))
{
ui_labelf("Parent Key: %I64x, %I64x, %I64x", row->parent_key.uniquifier, row->parent_key.parent_hash, row->parent_key.child_num);
@@ -1217,7 +1244,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_Clickable, "###val_%I64x", row_hash);
UI_Parent(box)
{
df_code_label(1.f, 1, row->display_value);
df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), row->display_value);
}
sig = ui_signal_from_box(box);
}
@@ -1261,7 +1288,7 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_Clickable, "###type_%I64x", row_hash);
if(!tg_key_match(key, tg_key_zero())) UI_Parent(box)
{
df_code_label(1.f, 1, string);
df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeType), string);
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
@@ -7928,7 +7955,7 @@ DF_VIEW_UI_FUNCTION_DEF(Memory)
}
if(a->type_string.size != 0)
{
df_code_label(1.f, 1, a->type_string);
df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeType), a->type_string);
}
UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) ui_label(str8_from_memory_size(scratch.arena, dim_1u64(a->vaddr_range)));
if(a->next != 0)
@@ -8197,7 +8224,7 @@ DF_VIEW_UI_FUNCTION_DEF(Breakpoints)
UI_Parent(box)
{
String8 hit_count_string = str8_from_u64(scratch.arena, entity->u64, 10, 0, 0);
UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, hit_count_string);
UI_Font(df_font_from_slot(DF_FontSlot_Code)) df_code_label(1.f, 1, df_rgba_from_theme_color(DF_ThemeColor_CodeDefault), hit_count_string);
}
UI_Signal sig = ui_signal_from_box(box);
if(sig.pressed)
+31 -1
View File
@@ -30,6 +30,26 @@ tg_qsort_compare_members_offset(TG_Member *a, TG_Member *b)
return result;
}
internal void
tg_key_list_push(Arena *arena, TG_KeyList *list, TG_Key key)
{
TG_KeyNode *n = push_array(arena, TG_KeyNode, 1);
n->v = key;
SLLQueuePush(list->first, list->last, n);
list->count += 1;
}
internal TG_KeyList
tg_key_list_copy(Arena *arena, TG_KeyList *src)
{
TG_KeyList dst = {0};
for(TG_KeyNode *n = src->first; n != 0; n = n->next)
{
tg_key_list_push(arena, &dst, n->v);
}
return dst;
}
////////////////////////////////
//~ rjf: RADDBG <-> TG Enum Conversions
@@ -936,9 +956,12 @@ tg_data_members_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Pars
struct Task
{
Task *next;
U64 base_off;
TG_KeyList inheritance_chain;
TG_Key type_key;
TG_Type *type;
};
Task start_task = {0, root_type};
Task start_task = {0, 0, {0}, key, root_type};
Task *first_task = &start_task;
Task *last_task = &start_task;
for(Task *task = first_task; task != 0; task = task->next)
@@ -952,12 +975,18 @@ tg_data_members_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Pars
{
TG_MemberNode *n = push_array(scratch.arena, TG_MemberNode, 1);
MemoryCopyStruct(&n->v, &type->members[member_idx]);
n->v.off += task->base_off;
n->v.inheritance_key_chain = task->inheritance_chain;
SLLQueuePush(members_list.first, members_list.last, n);
members_list.count += 1;
}
else if(type->members[member_idx].kind == TG_MemberKind_Base)
{
Task *t = push_array(scratch.arena, Task, 1);
t->base_off = type->members[member_idx].off + task->base_off;
t->inheritance_chain = tg_key_list_copy(scratch.arena, &task->inheritance_chain);
tg_key_list_push(scratch.arena, &t->inheritance_chain, type->members[member_idx].type_key);
t->type_key = type->members[member_idx].type_key;
t->type = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, type->members[member_idx].type_key);
SLLQueuePush(first_task, last_task, t);
members_need_offset_sort = 1;
@@ -975,6 +1004,7 @@ tg_data_members_from_graph_raddbg_key(Arena *arena, TG_Graph *graph, RADDBG_Pars
{
MemoryCopyStruct(&members.v[idx], &n->v);
members.v[idx].name = push_str8_copy(arena, members.v[idx].name);
members.v[idx].inheritance_key_chain = tg_key_list_copy(arena, &members.v[idx].inheritance_key_chain);
idx += 1;
}
}
+18
View File
@@ -31,6 +31,21 @@ struct TG_Key
U64 u64[1]; // ext -> unique id; cons -> idx; reg -> code
};
typedef struct TG_KeyNode TG_KeyNode;
struct TG_KeyNode
{
TG_KeyNode *next;
TG_Key v;
};
typedef struct TG_KeyList TG_KeyList;
struct TG_KeyList
{
TG_KeyNode *first;
TG_KeyNode *last;
U64 count;
};
////////////////////////////////
//~ rjf: Graph Types
@@ -102,6 +117,7 @@ struct TG_Member
TG_Key type_key;
String8 name;
U64 off;
TG_KeyList inheritance_key_chain;
};
typedef struct TG_MemberNode TG_MemberNode;
@@ -180,6 +196,8 @@ thread_static Arena *tg_build_arena = 0;
internal U64 tg_hash_from_string(U64 seed, String8 string);
internal int tg_qsort_compare_members_offset(TG_Member *a, TG_Member *b);
internal void tg_key_list_push(Arena *arena, TG_KeyList *list, TG_Key key);
internal TG_KeyList tg_key_list_copy(Arena *arena, TG_KeyList *src);
////////////////////////////////
//~ rjf: RADDBG <-> TG Enum Conversions