Skip to content

Commit

Permalink
eliminate old universal entity ui; eliminate old stop explanation str…
Browse files Browse the repository at this point in the history
…ing generation path
  • Loading branch information
ryanfleury committed Dec 6, 2024
1 parent 6cf4233 commit 59e2d7d
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 562 deletions.
279 changes: 127 additions & 152 deletions src/raddbg/raddbg_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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()));
Expand Down Expand Up @@ -6241,30 +6204,17 @@ rd_window_frame(RD_Window *ws)

// rjf: status
{
ui_spacer(ui_em(1.f, 1.f));
if(is_running)
{
ui_label(str8_lit("Running"));
}
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);
}
}
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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:
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)
{
if(!rd_entity_is_nil(thread))
default:
{
explanation = push_str8f(arena, "%S completed step", process_thread_string);
}
else
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:
{
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))
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:
{
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))
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:
{
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
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:
{
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(" 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;
}

////////////////////////////////
Expand Down
4 changes: 2 additions & 2 deletions src/raddbg/raddbg_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions src/raddbg/raddbg_views.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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;
}
}

Expand Down
Loading

0 comments on commit 59e2d7d

Please sign in to comment.