pass over callstack view to display function type info and properly display richer/weirder C++ symbol names

This commit is contained in:
Ryan Fleury
2024-05-29 10:36:22 -07:00
parent e073ff3218
commit 8f446d1f9a
5 changed files with 65 additions and 21 deletions
+1 -1
View File
@@ -5992,7 +5992,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
//- rjf: calculate width of exp row
if(row == viz_rows.first)
{
expr_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), row->display_expr).x + ui_top_font_size()*0.5f;
expr_column_width_px = f_dim_from_tag_size_string(ui_top_font(), ui_top_font_size(), 0, ui_top_tab_size(), row->display_expr).x + ui_top_font_size()*2.5f;
expr_column_width_px = Max(expr_column_width_px, ui_top_font_size()*10.f);
}
+45 -19
View File
@@ -4835,6 +4835,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
{
ProfBeginFunction();
Temp scratch = scratch_begin(0, 0);
DI_Scope *scope = di_scope_open();
DF_CtrlCtx ctrl_ctx = df_ctrl_ctx_from_view(ws, view);
DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread);
U64 selected_unwind_count = ctrl_ctx.unwind_count;
@@ -4915,20 +4916,33 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
{
continue;
}
U64 frame_idx = row_num-1;
CTRL_UnwindFrame *frame = &unwind.frames.v[frame_idx];
// rjf: determine selection
B32 row_selected = (cs->cursor.y == row_num);
// rjf: regs => rip
// rjf: unpack frame
U64 frame_idx = row_num-1;
CTRL_UnwindFrame *frame = &unwind.frames.v[frame_idx];
U64 rip_vaddr = regs_rip_from_arch_block(thread->arch, frame->regs);
// rjf: rip_vaddr => module
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
// rjf: rip => validity?
B32 frame_valid = (rip_vaddr != 0);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
DI_Key dbgi_key = df_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(scope, &dbgi_key, 0);
String8 symbol_name = {0};
String8 symbol_type_string = {0};
if(rdi->scope_vmap != 0)
{
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, rip_voff);
RDI_Scope *scope = rdi_element_from_idx(rdi, scopes, scope_idx);
U64 proc_idx = scope->proc_idx;
RDI_Procedure *procedure = &rdi->procedures[proc_idx];
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, procedure->type_idx);
TG_Key type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), procedure->type_idx);
U64 name_size = 0;
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
TG_Graph *graph = tg_graph_begin(rdi_addr_size_from_arch(rdi->top_level_info->architecture), 256);
symbol_name = str8(name_ptr, name_size);
symbol_type_string = tg_string_from_key(scratch.arena, graph, rdi, type_key);
}
// rjf: build row
if(frame_valid) UI_NamedTableVectorF("###callstack_%p_%I64x", view, frame_idx)
@@ -4981,21 +4995,32 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
}
}
// rjf: build cell for function name
// rjf: build cell for function header
UI_TableCell UI_Font(df_font_from_slot(DF_FontSlot_Code))
UI_FocusHot((row_selected && cs->cursor.x == 2) ? UI_FocusKind_On : UI_FocusKind_Off)
{
String8 symbol = df_symbol_name_from_process_vaddr(scratch.arena, process, rip_vaddr);
if(symbol.size == 0)
ui_set_next_child_layout_axis(Axis2_X);
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_Clip, "frame_%I64x", frame_idx);
UI_Parent(box)
{
symbol = str8_lit("[external code]");
ui_set_next_text_color(df_rgba_from_theme_color(DF_ThemeColor_WeakText));
if(symbol_name.size == 0)
{
ui_set_next_text_color(df_rgba_from_theme_color(DF_ThemeColor_WeakText));
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_CodeFunction), 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(": "), df_rgba_from_theme_color(DF_ThemeColor_WeakText), 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, 0, &fstrs);
}
}
else
{
ui_set_next_text_color(df_rgba_from_theme_color(DF_ThemeColor_CodeFunction));
}
UI_Box *box = ui_build_box_from_string(UI_BoxFlag_DrawText|UI_BoxFlag_Clickable, symbol);
UI_Signal sig = ui_signal_from_box(box);
if(ui_pressed(sig))
{
@@ -5046,6 +5071,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
}
}
di_scope_close(scope);
scratch_end(scratch);
ProfEnd();
}
+17
View File
@@ -54,6 +54,23 @@ d_fancy_string_list_push(Arena *arena, D_FancyStringList *list, D_FancyString *s
list->total_size += str->string.size;
}
internal void
d_fancy_string_list_concat_in_place(D_FancyStringList *dst, D_FancyStringList *to_push)
{
if(dst->last != 0 && to_push->first != 0)
{
dst->last->next = to_push->first;
dst->last = to_push->last;
dst->node_count += to_push->node_count;
dst->total_size += to_push->total_size;
}
else if(to_push->first != 0)
{
MemoryCopyStruct(dst, to_push);
}
MemoryZeroStruct(to_push);
}
internal String8
d_string_from_fancy_string_list(Arena *arena, D_FancyStringList *list)
{
+1
View File
@@ -109,6 +109,7 @@ internal U64 d_hash_from_string(String8 string);
//~ rjf: Fancy String Type Functions
internal void d_fancy_string_list_push(Arena *arena, D_FancyStringList *list, D_FancyString *str);
internal void d_fancy_string_list_concat_in_place(D_FancyStringList *dst, D_FancyStringList *to_push);
internal String8 d_string_from_fancy_string_list(Arena *arena, D_FancyStringList *list);
internal D_FancyRunList d_fancy_run_list_from_fancy_string_list(Arena *arena, F32 tab_size_px, D_FancyStringList *strs);
internal D_FancyRunList d_fancy_run_list_copy(Arena *arena, D_FancyRunList *src);
+1 -1
View File
@@ -180,7 +180,7 @@ global read_only TG_Type tg_type_nil =
{
/* kind */ TG_Kind_Null,
/* flags */ 0,
/* name */ {(U8*)"<nil>",5},
/* name */ {(U8*)"???",3},
};
global read_only TG_Type tg_type_variadic =