eliminate old universal entity ui; eliminate old stop explanation string generation path

This commit is contained in:
Ryan Fleury committed 2024-12-06 12:31:37 -08:00
1 parent 6cf42338ba
commit 59e2d7de61
5 files changed
+143 -568

No files matched your search

+3 -400
View File
@@ -415,398 +415,6 @@ rd_icon_buttonf(RD_IconKind kind, FuzzyMatchRangeList *matches, char *fmt, ...)
return sig;
}
internal void
rd_entity_tooltips(RD_Entity *entity)
{
Temp scratch = scratch_begin(0, 0);
RD_Palette(RD_PaletteCode_Floating) switch(entity->kind)
{
default:{}break;
case RD_EntityKind_File:
UI_Tooltip UI_PrefWidth(ui_text_dim(10, 1))
{
String8 full_path = rd_full_path_from_entity(scratch.arena, entity);
ui_label(full_path);
}break;
case RD_EntityKind_Thread: UI_Flags(0)
UI_Tooltip UI_PrefWidth(ui_text_dim(10, 1))
{
String8 display_string = rd_display_string_from_entity(scratch.arena, entity);
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
U64 rip_vaddr = d_query_cached_rip_from_thread(entity_ctrl);
Arch arch = entity_ctrl->arch;
String8 arch_str = string_from_arch(arch);
U32 pid_or_tid = entity->ctrl_id;
if(display_string.size != 0) UI_PrefWidth(ui_children_sum(1)) UI_Row
{
if(entity->flags & RD_EntityFlag_HasColor)
{
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_entity(entity)));
}
UI_PrefWidth(ui_text_dim(10, 1)) ui_label(display_string);
}
{
CTRL_Event stop_event = d_ctrl_last_stop_event();
RD_Entity *stopper_thread = rd_entity_from_ctrl_handle(stop_event.entity);
if(stopper_thread == entity)
{
ui_spacer(ui_em(1.5f, 1.f));
RD_IconKind icon_kind = RD_IconKind_Null;
String8 explanation = rd_stop_explanation_string_icon_from_ctrl_event(scratch.arena, &stop_event, &icon_kind);
if(explanation.size != 0)
{
UI_Palette *palette = ui_top_palette();
if(stop_event.cause == CTRL_EventCause_Error ||
stop_event.cause == CTRL_EventCause_InterruptedByException ||
stop_event.cause == CTRL_EventCause_InterruptedByTrap ||
stop_event.cause == CTRL_EventCause_UserBreakpoint)
{
palette = ui_build_palette(ui_top_palette(), .text = rd_rgba_from_theme_color(RD_ThemeColor_TextNegative));
}
UI_PrefWidth(ui_children_sum(1)) UI_Row UI_Palette(palette)
{
UI_PrefWidth(ui_em(1.5f, 1.f))
RD_Font(RD_FontSlot_Icons)
ui_label(rd_icon_kind_text_table[icon_kind]);
UI_PrefWidth(ui_text_dim(10, 1)) ui_label(explanation);
}
}
}
}
ui_spacer(ui_em(1.5f, 1.f));
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("TID: ");
UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("%i", pid_or_tid);
}
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("Arch: ");
UI_PrefWidth(ui_text_dim(10, 1)) ui_label(arch_str);
}
ui_spacer(ui_em(1.5f, 1.f));
DI_Scope *di_scope = di_scope_open();
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity_ctrl, CTRL_EntityKind_Process);
CTRL_Unwind base_unwind = d_query_cached_unwind_from_thread(entity_ctrl);
CTRL_CallStack rich_unwind = ctrl_call_stack_from_unwind(scratch.arena, di_scope, process, &base_unwind);
for(U64 idx = 0; idx < rich_unwind.concrete_frame_count; idx += 1)
{
CTRL_CallStackFrame *f = &rich_unwind.frames[idx];
RDI_Parsed *rdi = f->rdi;
RDI_Procedure *procedure = f->procedure;
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, f->regs);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
String8 module_name = module == &ctrl_entity_nil ? str8_lit("???") : str8_skip_last_slash(module->string);
// rjf: inline frames
for(CTRL_CallStackInlineFrame *fin = f->last_inline_frame; fin != 0; fin = fin->prev)
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
String8 name = {0};
name.str = rdi_string_from_idx(rdi, fin->inline_site->name_string_idx, &name.size);
RD_Font(RD_FontSlot_Code) UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("0x%I64x", rip_vaddr);
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(str8_lit("[inlined]"));
if(name.size != 0)
{
RD_Font(RD_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1))
{
rd_code_label(1.f, 0, rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol), name);
}
}
else
{
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name);
}
}
// rjf: concrete frame
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
String8 name = {0};
name.str = rdi_name_from_procedure(rdi, procedure, &name.size);
RD_Font(RD_FontSlot_Code) UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("0x%I64x", rip_vaddr);
if(name.size != 0)
{
RD_Font(RD_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1))
{
rd_code_label(1.f, 0, rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol), name);
}
}
else
{
RD_Font(RD_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_labelf("[??? in %S]", module_name);
}
}
}
di_scope_close(di_scope);
}break;
case RD_EntityKind_Breakpoint: UI_Flags(0)
UI_Tooltip UI_PrefWidth(ui_text_dim(10, 1))
{
if(entity->flags & RD_EntityFlag_HasColor)
{
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_entity(entity)));
}
String8 display_string = rd_display_string_from_entity(scratch.arena, entity);
UI_PrefWidth(ui_text_dim(10, 1)) ui_label(display_string);
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
String8 stop_condition = rd_entity_child_from_kind(entity, RD_EntityKind_Condition)->string;
if(stop_condition.size == 0)
{
stop_condition = str8_lit("true");
}
UI_PrefWidth(ui_em(12.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("Stop Condition: ");
UI_PrefWidth(ui_text_dim(10, 1)) RD_Font(RD_FontSlot_Code) rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_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_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("Hit Count: ");
UI_PrefWidth(ui_text_dim(10, 1)) RD_Font(RD_FontSlot_Code) rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault), hit_count_text);
}
}break;
case RD_EntityKind_WatchPin:
RD_Font(RD_FontSlot_Code)
UI_Tooltip UI_PrefWidth(ui_text_dim(10, 1))
{
if(entity->flags & RD_EntityFlag_HasColor)
{
ui_set_next_palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_entity(entity)));
}
String8 display_string = rd_display_string_from_entity(scratch.arena, entity);
UI_PrefWidth(ui_text_dim(10, 1)) rd_code_label(1.f, 1, rd_rgba_from_theme_color(RD_ThemeColor_CodeDefault), display_string);
}break;
}
scratch_end(scratch);
}
internal UI_Signal
rd_entity_desc_button(RD_Entity *entity, FuzzyMatchRangeList *name_matches, String8 fuzzy_query, B32 is_implicit)
{
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
UI_Palette *palette = ui_top_palette();
if(entity->kind == RD_EntityKind_Thread)
{
CTRL_Event stop_event = d_ctrl_last_stop_event();
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
CTRL_Entity *stopped_thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, stop_event.entity);
CTRL_Entity *selected_thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_base_regs()->thread);
if(selected_thread == entity_ctrl)
{
palette = rd_palette_from_code(RD_PaletteCode_NeutralPopButton);
}
if(stopped_thread == entity_ctrl &&
(stop_event.cause == CTRL_EventCause_UserBreakpoint ||
stop_event.cause == CTRL_EventCause_InterruptedByException ||
stop_event.cause == CTRL_EventCause_InterruptedByTrap ||
stop_event.cause == CTRL_EventCause_InterruptedByHalt))
{
palette = rd_palette_from_code(RD_PaletteCode_NegativePopButton);
}
}
if(entity->cfg_src == RD_CfgSrc_CommandLine)
{
palette = rd_palette_from_code(RD_PaletteCode_NeutralPopButton);
}
else if(entity->kind == RD_EntityKind_Target && !entity->disabled)
{
palette = rd_palette_from_code(RD_PaletteCode_NeutralPopButton);
}
ui_set_next_palette(palette);
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
(!is_implicit*UI_BoxFlag_DrawBorder)|
UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects,
"entity_ref_button_%p", entity);
//- rjf: build contents
UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 0)) UI_Padding(ui_em(1.f, 1.f))
{
RD_EntityKindFlags kind_flags = rd_entity_kind_flags_table[entity->kind];
RD_IconKind icon = rd_entity_kind_icon_kind_table[entity->kind];
Vec4F32 entity_color = palette->colors[UI_ColorCode_Text];
Vec4F32 entity_color_weak = palette->colors[UI_ColorCode_TextWeak];
if(entity->flags & RD_EntityFlag_HasColor)
{
entity_color = rd_rgba_from_entity(entity);
entity_color_weak = entity_color;
entity_color_weak.w *= 0.5f;
}
UI_TextAlignment(UI_TextAlign_Center)
RD_Font(RD_FontSlot_Icons)
UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Icons))
UI_PrefWidth(ui_em(1.875f, 1.f))
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
ui_label(rd_icon_kind_text_table[icon]);
if(entity->cfg_src == RD_CfgSrc_CommandLine)
{
UI_TextAlignment(UI_TextAlign_Center)
UI_PrefWidth(ui_em(1.875f, 1.f))
{
UI_Box *info_box = &ui_nil_box;
RD_Font(RD_FontSlot_Icons)
UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Icons))
{
info_box = ui_build_box_from_stringf(UI_BoxFlag_DrawText|UI_BoxFlag_DrawTextWeak|UI_BoxFlag_Clickable, "%S###%p_temp_info", rd_icon_kind_text_table[RD_IconKind_Info], entity);
}
UI_Signal info_sig = ui_signal_from_box(info_box);
if(ui_hovering(info_sig)) UI_Tooltip
{
ui_labelf("Specified via command line; not saved in project.");
}
}
}
String8 label = rd_display_string_from_entity(scratch.arena, entity);
UI_Palette(ui_build_palette(ui_top_palette(), .text = entity_color))
RD_Font(kind_flags&RD_EntityKindFlag_NameIsCode ? RD_FontSlot_Code : RD_FontSlot_Main)
UI_Flags((entity->kind == RD_EntityKind_Thread ||
entity->kind == RD_EntityKind_Breakpoint ||
entity->kind == RD_EntityKind_WatchPin)
? UI_BoxFlag_DisableTruncatedHover
: 0)
{
UI_Signal label_sig = ui_label(label);
if(name_matches != 0)
{
ui_box_equip_fuzzy_match_ranges(label_sig.box, name_matches);
}
}
if(entity->kind == RD_EntityKind_Target) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_FontSize(ui_top_font_size()*0.95f)
{
RD_Entity *args = rd_entity_child_from_kind(entity, RD_EntityKind_Arguments);
ui_label(args->string);
}
if(kind_flags & RD_EntityKindFlag_CanEnable && entity->disabled) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_FontSize(ui_top_font_size()*0.95f) UI_HeightFill
{
ui_label(str8_lit("(Disabled)"));
}
if(entity->kind == RD_EntityKind_Thread)
UI_FontSize(ui_top_font_size()*0.75f)
RD_Font(RD_FontSlot_Code)
UI_Palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_theme_color(RD_ThemeColor_CodeSymbol)))
UI_Flags(UI_BoxFlag_DisableTruncatedHover)
{
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
CTRL_Unwind unwind = d_query_cached_unwind_from_thread(entity_ctrl);
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity_ctrl, CTRL_EntityKind_Process);
U64 idx = 0;
U64 limit = 3;
ui_spacer(ui_em(1.f, 1.f));
for(U64 num = unwind.frames.count; num > 0; num -= 1)
{
CTRL_UnwindFrame *f = &unwind.frames.v[num-1];
U64 rip_vaddr = regs_rip_from_arch_block(entity_ctrl->arch, f->regs);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
String8 procedure_name = d_symbol_name_from_dbgi_key_voff(scratch.arena, &dbgi_key, rip_voff, 0);
if(procedure_name.size != 0)
{
FuzzyMatchRangeList fuzzy_matches = {0};
if(fuzzy_query.size != 0)
{
fuzzy_matches = fuzzy_match_find(scratch.arena, fuzzy_query, procedure_name);
}
if(idx != 0)
{
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_em(2.f, 1.f)) ui_label(str8_lit(">"));
}
UI_PrefWidth(ui_text_dim(10.f, 0.f))
{
UI_Box *label_box = ui_label(procedure_name).box;
ui_box_equip_fuzzy_match_ranges(label_box, &fuzzy_matches);
}
idx += 1;
if(idx == limit)
{
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10.f, 1.f)) ui_label(str8_lit("> ..."));
}
}
}
}
}
//- rjf: do interaction on main box
UI_Signal sig = ui_signal_from_box(box);
{
if(ui_hovering(sig) && !rd_drag_is_active())
{
rd_entity_tooltips(entity);
}
// rjf: click => fastpath for this entity
if(ui_clicked(sig))
{
// TODO(rjf): rd_cmd(RD_CmdKind_EntityRefFastPath, .entity = rd_handle_from_entity(entity));
}
// rjf: right-click => context menu for this entity
else if(ui_right_clicked(sig))
{
// RD_Handle handle = rd_handle_from_entity(entity);
// RD_Window *window = rd_window_from_handle(rd_regs()->window);
// ui_ctx_menu_open(rd_state->entity_ctx_menu_key, sig.box->key, v2f32(0, sig.box->rect.y1 - sig.box->rect.y0));
// window->entity_ctx_menu_entity = handle;
}
// rjf: drag+drop
else if(ui_dragging(sig) && !contains_2f32(box->rect, ui_mouse()))
{
RD_RegsScope(.entity = rd_handle_from_entity(entity)) rd_drag_begin(RD_RegSlot_Entity);
}
}
scratch_end(scratch);
ProfEnd();
return sig;
}
internal void
rd_src_loc_button(String8 file_path, TxtPt point)
{
Temp scratch = scratch_begin(0, 0);
String8 filename = str8_skip_last_slash(file_path);
// rjf: build main box
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
UI_BoxFlag_DrawBorder|
UI_BoxFlag_DrawBackground|
UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects,
"file_loc_button_%S", file_path);
UI_Signal sig = ui_signal_from_box(box);
// rjf: build contents
UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 0))
{
RD_IconKind icon = RD_IconKind_FileOutline;
UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
UI_TextAlignment(UI_TextAlign_Center)
RD_Font(RD_FontSlot_Icons)
UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Icons))
ui_label(rd_icon_kind_text_table[icon]);
ui_labelf("%S:%I64d:%I64d", filename, point.line, point.column);
}
// rjf: click => find code location
if(ui_clicked(sig))
{
rd_cmd(RD_CmdKind_FindCodeLocation, .file_path = file_path, .cursor = point);
}
// rjf: hover => show full path
else if(ui_hovering(sig) && !ui_dragging(sig)) UI_Tooltip
{
ui_labelf("%S:%I64d:%I64d", file_path, point.line, point.column);
}
scratch_end(scratch);
}
////////////////////////////////
//~ rjf: UI Widgets: Text View
@@ -1623,17 +1231,12 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
(stop_event.cause == CTRL_EventCause_InterruptedByException ||
stop_event.cause == CTRL_EventCause_InterruptedByTrap))
{
RD_IconKind icon = RD_IconKind_WarningBig;
String8 explanation = rd_stop_explanation_string_icon_from_ctrl_event(scratch.arena, &stop_event, &icon);
DR_FancyStringList explanation_fstrs = rd_stop_explanation_fstrs_from_ctrl_event(scratch.arena, &stop_event);
UI_Parent(line_extras_boxes[line_idx]) UI_PrefWidth(ui_children_sum(1)) UI_PrefHeight(ui_px(params->line_height_px, 1.f))
UI_Palette(ui_build_palette(ui_top_palette(), .text = rd_rgba_from_theme_color(RD_ThemeColor_TextNegative)))
{
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawBorder, "###exception_info");
UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 1))
{
RD_Font(RD_FontSlot_Icons) ui_label(rd_icon_kind_text_table[RD_IconKind_WarningBig]);
ui_label(explanation);
}
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_DrawText, "###exception_info");
ui_box_equip_display_fancy_strings(box, &explanation_fstrs);
}
}
}