mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-04 12:58:41 +00:00
eliminate old eval/eval-viz paths
This commit is contained in:
@@ -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