From 59e2d7de616d2b95dd6d19b6cbbc56e18a545141 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 6 Dec 2024 12:20:56 -0800 Subject: [PATCH] eliminate old universal entity ui; eliminate old stop explanation string generation path --- src/raddbg/raddbg_core.c | 291 ++++++++++++-------------- src/raddbg/raddbg_core.h | 4 +- src/raddbg/raddbg_views.c | 10 +- src/raddbg/raddbg_widgets.c | 403 +----------------------------------- src/raddbg/raddbg_widgets.h | 3 - 5 files changed, 143 insertions(+), 568 deletions(-) diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index ec82e06c..b81c4e66 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -459,43 +459,6 @@ rd_display_string_from_entity(Arena *arena, RD_Entity *entity) } }break; - case RD_EntityKind_Process: - { - RD_Entity *main_mod_child = rd_entity_child_from_kind(entity, RD_EntityKind_Module); - String8 main_mod_name = str8_skip_last_slash(main_mod_child->string); - result = push_str8f(arena, "%S%s%sPID: %i%s", - main_mod_name, - main_mod_name.size != 0 ? " " : "", - main_mod_name.size != 0 ? "(" : "", - entity->ctrl_id, - main_mod_name.size != 0 ? ")" : ""); - }break; - - case RD_EntityKind_Thread: - { - String8 name = entity->string; - if(name.size == 0) - { - RD_Entity *process = rd_entity_ancestor_from_kind(entity, RD_EntityKind_Process); - RD_Entity *first_thread = rd_entity_child_from_kind(process, RD_EntityKind_Thread); - if(first_thread == entity) - { - name = str8_lit("Main Thread"); - } - } - result = push_str8f(arena, "%S%s%sTID: %i%s", - name, - name.size != 0 ? " " : "", - name.size != 0 ? "(" : "", - entity->ctrl_id, - name.size != 0 ? ")" : ""); - }break; - - case RD_EntityKind_Module: - { - result = push_str8_copy(arena, str8_skip_last_slash(entity->string)); - }break; - case RD_EntityKind_RecentProject: { result = push_str8_copy(arena, str8_skip_last_slash(entity->string)); @@ -5854,7 +5817,7 @@ rd_window_frame(RD_Window *ws) { Temp scratch = scratch_begin(0, 0); RD_EntityList targets = rd_push_active_target_list(scratch.arena); - RD_EntityList processes = rd_query_cached_entity_list_with_kind(RD_EntityKind_Process); + CTRL_EntityList processes = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Process); B32 have_targets = targets.count != 0; B32 can_send_signal = !d_ctrl_targets_running(); B32 can_play = (have_targets && (can_send_signal || d_ctrl_last_run_frame_idx()+4 > d_frame_index())); @@ -6241,6 +6204,7 @@ rd_window_frame(RD_Window *ws) // rjf: status { + ui_spacer(ui_em(1.f, 1.f)); if(is_running) { ui_label(str8_lit("Running")); @@ -6248,23 +6212,9 @@ rd_window_frame(RD_Window *ws) else { Temp scratch = scratch_begin(0, 0); - RD_IconKind icon = RD_IconKind_Null; - String8 explanation = str8_lit("Not running"); - { - String8 stop_explanation = rd_stop_explanation_string_icon_from_ctrl_event(scratch.arena, &stop_event, &icon); - if(stop_explanation.size != 0) - { - explanation = stop_explanation; - } - } - if(icon != RD_IconKind_Null) - { - UI_PrefWidth(ui_em(2.25f, 1.f)) - RD_Font(RD_FontSlot_Icons) - UI_FontSize(rd_font_size_from_slot(RD_FontSlot_Icons)) - ui_label(rd_icon_kind_text_table[icon]); - } - UI_PrefWidth(ui_text_dim(10, 1)) ui_label(explanation); + DR_FancyStringList explanation_fstrs = rd_stop_explanation_fstrs_from_ctrl_event(scratch.arena, &stop_event); + UI_Box *box = ui_build_box_from_key(UI_BoxFlag_DrawText, ui_key_zero()); + ui_box_equip_display_fancy_strings(box, &explanation_fstrs); scratch_end(scratch); } } @@ -8596,7 +8546,7 @@ rd_window_frame(RD_Window *ws) { Vec4F32 color = rd_rgba_from_theme_color(RD_ThemeColor_Focus); color.w *= b->focus_active_t; - R_Rect2DInst *inst = dr_rect(pad_2f32(b->rect, 0.f), color, 0, 1.f, 1.f); + R_Rect2DInst *inst = dr_rect(b->rect, color, 0, 1.f, 1.f); MemoryCopyArray(inst->corner_radii, b->corner_radii); } @@ -11114,115 +11064,140 @@ rd_string_from_exception_code(U32 code) return string; } -internal String8 -rd_stop_explanation_string_icon_from_ctrl_event(Arena *arena, CTRL_Event *event, RD_IconKind *icon_out) +internal DR_FancyStringList +rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event) { - RD_IconKind icon = RD_IconKind_Null; - String8 explanation = {0}; - Temp scratch = scratch_begin(&arena, 1); - RD_Entity *thread = rd_entity_from_ctrl_handle(event->entity); - String8 thread_display_string = rd_display_string_from_entity(scratch.arena, thread); - String8 process_thread_string = thread_display_string; - RD_Entity *process = rd_entity_ancestor_from_kind(thread, RD_EntityKind_Process); - if(process->kind == RD_EntityKind_Process) + CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, event->entity); + DR_FancyStringList thread_fstrs = rd_title_fstrs_from_ctrl_entity(arena, thread, ui_top_palette()->text, ui_top_font_size(), 0); + DR_FancyStringList fstrs = {0}; + switch(event->cause) { - String8 process_display_string = rd_display_string_from_entity(scratch.arena, process); - process_thread_string = push_str8f(scratch.arena, "%S: %S", process_display_string, thread_display_string); - } - switch(event->kind) - { - default: + default:{}break; + + //- rjf: finished operation; if active thread, completed thread, otherwise we're just stopped + case CTRL_EventCause_Finished: { - switch(event->cause) + if(thread != &ctrl_entity_nil) { - default:{}break; - case CTRL_EventCause_Finished: - { - if(!rd_entity_is_nil(thread)) - { - explanation = push_str8f(arena, "%S completed step", process_thread_string); - } - else - { - explanation = str8_lit("Stopped"); - } - }break; - case CTRL_EventCause_EntryPoint: - { - explanation = str8_lit("Stopped at entry point"); - }break; - case CTRL_EventCause_UserBreakpoint: - { - if(!rd_entity_is_nil(thread)) - { - icon = RD_IconKind_CircleFilled; - explanation = push_str8f(arena, "%S hit a breakpoint", process_thread_string); - } - }break; - case CTRL_EventCause_InterruptedByException: - { - if(!rd_entity_is_nil(thread)) - { - icon = RD_IconKind_WarningBig; - switch(event->exception_kind) - { - default: - { - String8 exception_code_string = rd_string_from_exception_code(event->exception_code); - explanation = push_str8f(arena, "Exception thrown by %S - 0x%x%s%S", process_thread_string, event->exception_code, exception_code_string.size > 0 ? ": " : "", exception_code_string); - }break; - case CTRL_ExceptionKind_CppThrow: - { - explanation = push_str8f(arena, "Exception thrown by %S - 0x%x: C++ exception", process_thread_string, event->exception_code); - }break; - case CTRL_ExceptionKind_MemoryRead: - { - explanation = push_str8f(arena, "Exception thrown by %S - 0x%x: Access violation reading 0x%I64x", - process_thread_string, - event->exception_code, - event->vaddr_rng.min); - }break; - case CTRL_ExceptionKind_MemoryWrite: - { - explanation = push_str8f(arena, "Exception thrown by %S - 0x%x: Access violation writing 0x%I64x", - process_thread_string, - event->exception_code, - event->vaddr_rng.min); - }break; - case CTRL_ExceptionKind_MemoryExecute: - { - explanation = push_str8f(arena, "Exception thrown by %S - 0x%x: Access violation executing 0x%I64x", - process_thread_string, - event->exception_code, - event->vaddr_rng.min); - }break; - } - } - else - { - icon = RD_IconKind_Pause; - explanation = str8_lit("Interrupted"); - } - }break; - case CTRL_EventCause_InterruptedByTrap: - { - icon = RD_IconKind_WarningBig; - explanation = push_str8f(arena, "%S interrupted by trap - 0x%x", process_thread_string, event->exception_code); - }break; - case CTRL_EventCause_InterruptedByHalt: - { - icon = RD_IconKind_Pause; - explanation = str8_lit("Halted"); - }break; + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" completed step")); + } + else + { + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit("Stopped")); } }break; + + //- rjf: stopped at entry point + case CTRL_EventCause_EntryPoint: + { + if(thread != &ctrl_entity_nil) + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" stopped at entry point")); + } + else + { + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit("Stopped at entry point")); + } + }break; + + //- rjf: user breakpoint + case CTRL_EventCause_UserBreakpoint: + { + if(thread != &ctrl_entity_nil) + { + dr_fancy_string_list_push_new(arena, &fstrs, rd_font_from_slot(RD_FontSlot_Icons), ui_top_font_size(), ui_top_palette()->text, rd_icon_kind_text_table[RD_IconKind_CircleFilled]); + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit a breakpoint")); + } + }break; + + //- rjf: exception + case CTRL_EventCause_InterruptedByException: + { + if(thread != &ctrl_entity_nil) + { + dr_fancy_string_list_push_new(arena, &fstrs, rd_font_from_slot(RD_FontSlot_Icons), ui_top_font_size(), ui_top_palette()->text, rd_icon_kind_text_table[RD_IconKind_WarningBig]); + switch(event->exception_kind) + { + default: + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit an exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + String8 exception_explanation_string = rd_string_from_exception_code(event->exception_code); + String8 exception_info_string = push_str8f(arena, "%S%s%S%s", + exception_code_string, + exception_explanation_string.size != 0 ? " (" : "", + exception_explanation_string, + exception_explanation_string.size != 0 ? ")" : ""); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_info_string); + }break; + case CTRL_ExceptionKind_CppThrow: + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit a C++ exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_code_string); + }break; + case CTRL_ExceptionKind_MemoryRead: + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit an exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + String8 exception_info_string = push_str8f(arena, "%S (Access violation reading 0x%I64x)", exception_code_string, event->vaddr_rng.min); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_info_string); + }break; + case CTRL_ExceptionKind_MemoryWrite: + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit an exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + String8 exception_info_string = push_str8f(arena, "%S (Access violation writing 0x%I64x)", exception_code_string, event->vaddr_rng.min); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_info_string); + }break; + case CTRL_ExceptionKind_MemoryExecute: + { + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit an exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + String8 exception_info_string = push_str8f(arena, "%S (Access violation executing 0x%I64x)", exception_code_string, event->vaddr_rng.min); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_info_string); + }break; + } + } + else + { + dr_fancy_string_list_push_new(arena, &fstrs, rd_font_from_slot(RD_FontSlot_Icons), ui_top_font_size(), ui_top_palette()->text, rd_icon_kind_text_table[RD_IconKind_WarningBig]); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit("Hit an exception - ")); + String8 exception_code_string = str8_from_u64(arena, event->exception_code, 16, 0, 0); + String8 exception_explanation_string = rd_string_from_exception_code(event->exception_code); + String8 exception_info_string = push_str8f(arena, "%S%s%S%s", + exception_code_string, + exception_explanation_string.size != 0 ? " (" : "", + exception_explanation_string, + exception_explanation_string.size != 0 ? ")" : ""); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, exception_info_string); + } + }break; + + //- rjf: trap + case CTRL_EventCause_InterruptedByTrap: + { + dr_fancy_string_list_push_new(arena, &fstrs, rd_font_from_slot(RD_FontSlot_Icons), ui_top_font_size(), ui_top_palette()->text, rd_icon_kind_text_table[RD_IconKind_WarningBig]); + dr_fancy_string_list_concat_in_place(&fstrs, &thread_fstrs); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit(" hit a trap")); + }break; + + //- rjf: halt + case CTRL_EventCause_InterruptedByHalt: + { + dr_fancy_string_list_push_new(arena, &fstrs, rd_font_from_slot(RD_FontSlot_Icons), ui_top_font_size(), ui_top_palette()->text, rd_icon_kind_text_table[RD_IconKind_Pause]); + dr_fancy_string_list_push_new(arena, &fstrs, ui_top_font(), ui_top_font_size(), ui_top_palette()->text, str8_lit("Halted")); + }break; } - scratch_end(scratch); - if(icon_out) - { - *icon_out = icon; - } - return explanation; + return fstrs; } //////////////////////////////// diff --git a/src/raddbg/raddbg_core.h b/src/raddbg/raddbg_core.h index 75581917..196c106b 100644 --- a/src/raddbg/raddbg_core.h +++ b/src/raddbg/raddbg_core.h @@ -1423,8 +1423,8 @@ internal String8List rd_cfg_strings_from_gfx(Arena *arena, String8 root_path, RD //////////////////////////////// //~ rjf: Process Control Info Stringification -internal String8 rd_string_from_exception_code(U32 code); -internal String8 rd_stop_explanation_string_icon_from_ctrl_event(Arena *arena, CTRL_Event *event, RD_IconKind *icon_out); +internal String8 rd_string_from_exception_code(U32 code); +internal DR_FancyStringList rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event); //////////////////////////////// //~ rjf: Continuous Frame Requests diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 436256ca..45798975 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -3465,7 +3465,7 @@ RD_VIEW_RULE_UI_FUNCTION_DEF(getting_started) UI_Padding(ui_pct(1, 0)) UI_Focus(UI_FocusKind_Null) { RD_EntityList targets = rd_push_active_target_list(scratch.arena); - RD_EntityList processes = rd_query_cached_entity_list_with_kind(RD_EntityKind_Process); + CTRL_EntityList processes = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Process); //- rjf: icon & info UI_Padding(ui_em(2.f, 1.f)) @@ -4506,14 +4506,14 @@ rd_process_info_list_from_query(Arena *arena, String8 query) U64 attached_process_count = 0; U32 *attached_process_pids = 0; { - RD_EntityList processes = rd_query_cached_entity_list_with_kind(RD_EntityKind_Process); + CTRL_EntityList processes = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Process); attached_process_count = processes.count; attached_process_pids = push_array(scratch.arena, U32, attached_process_count); U64 idx = 0; - for(RD_EntityNode *n = processes.first; n != 0; n = n->next, idx += 1) + for(CTRL_EntityNode *n = processes.first; n != 0; n = n->next, idx += 1) { - RD_Entity *process = n->entity; - attached_process_pids[idx] = process->ctrl_id; + CTRL_Entity *process = n->v; + attached_process_pids[idx] = process->id; } } diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index 62c93ee5..b13fae9b 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -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); } } } diff --git a/src/raddbg/raddbg_widgets.h b/src/raddbg/raddbg_widgets.h index c88e4c61..9048161e 100644 --- a/src/raddbg/raddbg_widgets.h +++ b/src/raddbg/raddbg_widgets.h @@ -91,9 +91,6 @@ internal UI_Signal rd_cmd_spec_button(String8 name); internal void rd_cmd_list_menu_buttons(U64 count, String8 *cmd_names, U32 *fastpath_codepoints); internal UI_Signal rd_icon_button(RD_IconKind kind, FuzzyMatchRangeList *matches, String8 string); internal UI_Signal rd_icon_buttonf(RD_IconKind kind, FuzzyMatchRangeList *matches, char *fmt, ...); -internal void rd_entity_tooltips(RD_Entity *entity); -internal UI_Signal rd_entity_desc_button(RD_Entity *entity, FuzzyMatchRangeList *name_matches, String8 fuzzy_query, B32 is_implicit); -internal void rd_src_loc_button(String8 file_path, TxtPt point); //////////////////////////////// //~ rjf: UI Widgets: Text View