fix line info voff baking; default selected inline frame depth to being shallowest; rework rich unwind to not lose concrete/inline frame structured info

This commit is contained in:
Ryan Fleury
2024-07-26 11:09:55 -07:00
parent 1d87c34dca
commit c13833f74f
9 changed files with 6279 additions and 6249 deletions
+50 -75
View File
@@ -923,15 +923,15 @@ df_cmd_params_apply_spec_query(Arena *arena, DF_CtrlCtx *ctrl_ctx, DF_CmdParams
params->index = u64; params->index = u64;
df_cmd_params_mark_slot(params, DF_CmdParamSlot_Index); df_cmd_params_mark_slot(params, DF_CmdParamSlot_Index);
}break; }break;
case DF_CmdParamSlot_BaseUnwindIndex: case DF_CmdParamSlot_UnwindIndex:
{ {
params->base_unwind_index = u64; params->unwind_index = u64;
df_cmd_params_mark_slot(params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(params, DF_CmdParamSlot_UnwindIndex);
}break; }break;
case DF_CmdParamSlot_InlineUnwindIndex: case DF_CmdParamSlot_InlineDepth:
{ {
params->inline_unwind_index = u64; params->inline_depth = u64;
df_cmd_params_mark_slot(params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(params, DF_CmdParamSlot_InlineDepth);
}break; }break;
case DF_CmdParamSlot_ID: case DF_CmdParamSlot_ID:
{ {
@@ -3241,7 +3241,7 @@ df_lines_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff)
String8 file_normalized_full_path = {0}; String8 file_normalized_full_path = {0};
file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size); file_normalized_full_path.str = rdi_string_from_idx(rdi, file->normal_full_path_string_idx, &file_normalized_full_path.size);
DF_LineNode *n = push_array(arena, DF_LineNode, 1); DF_LineNode *n = push_array(arena, DF_LineNode, 1);
SLLQueuePush(result.first, result.last, n); SLLQueuePushFront(result.first, result.last, n);
result.count += 1; result.count += 1;
if(line->file_idx != 0 && file_normalized_full_path.size != 0) if(line->file_idx != 0 && file_normalized_full_path.size != 0)
{ {
@@ -3671,80 +3671,44 @@ df_module_from_thread_candidates(DF_Entity *thread, DF_EntityList *candidates)
internal DF_Unwind internal DF_Unwind
df_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, DF_Entity *process, CTRL_Unwind *base_unwind) df_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, DF_Entity *process, CTRL_Unwind *base_unwind)
{ {
Temp scratch = scratch_begin(&arena, 1);
DF_UnwindFrameList rich_frames_list = {0};
Architecture arch = df_architecture_from_entity(process); Architecture arch = df_architecture_from_entity(process);
for(U64 base_frame_idx = 0; base_frame_idx < base_unwind->frames.count; base_frame_idx += 1) DF_Unwind result = {0};
result.frames.concrete_frame_count = base_unwind->frames.count;
result.frames.total_frame_count = result.frames.concrete_frame_count;
result.frames.v = push_array(arena, DF_UnwindFrame, result.frames.concrete_frame_count);
for(U64 idx = 0; idx < result.frames.concrete_frame_count; idx += 1)
{ {
CTRL_UnwindFrame *base_frame = &base_unwind->frames.v[base_frame_idx]; CTRL_UnwindFrame *src = &base_unwind->frames.v[idx];
U64 rip_vaddr = regs_rip_from_arch_block(arch, base_frame->regs); DF_UnwindFrame *dst = &result.frames.v[idx];
U64 rip_vaddr = regs_rip_from_arch_block(arch, src->regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr); U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
DI_Key dbgi_key = df_dbgi_key_from_module(module); DI_Key dbgi_key = df_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 0); RDI_Parsed *rdi = di_rdi_from_key(di_scope, &dbgi_key, 0);
RDI_Scope *scope = rdi_scope_from_voff(rdi, rip_voff); RDI_Scope *scope = rdi_scope_from_voff(rdi, rip_voff);
// rjf: add rich frames for inlines // rjf: fill concrete frame info
U64 inline_unwind_idx = 0; dst->regs = src->regs;
for(RDI_Scope *s = scope; s->inline_site_idx != 0; s = rdi_element_from_name_idx(rdi, Scopes, s->parent_scope_idx)) dst->rdi = rdi;
dst->procedure = rdi_element_from_name_idx(rdi, Procedures, scope->proc_idx);
// rjf: push inline frames
for(RDI_Scope *s = scope;
s->inline_site_idx != 0;
s = rdi_element_from_name_idx(rdi, Scopes, s->parent_scope_idx))
{ {
RDI_InlineSite *site = rdi_element_from_name_idx(rdi, InlineSites, s->inline_site_idx); RDI_InlineSite *site = rdi_element_from_name_idx(rdi, InlineSites, s->inline_site_idx);
DF_UnwindFrameNode *n = push_array(scratch.arena, DF_UnwindFrameNode, 1); DF_UnwindInlineFrame *inline_frame = push_array(arena, DF_UnwindInlineFrame, 1);
SLLQueuePush(rich_frames_list.first, rich_frames_list.last, n); DLLPushFront(dst->first_inline_frame, dst->last_inline_frame, inline_frame);
rich_frames_list.count += 1; inline_frame->inline_site = site;
n->v.regs = base_frame->regs; dst->inline_frame_count += 1;
n->v.rdi = rdi; result.frames.inline_frame_count += 1;
n->v.procedure = 0; result.frames.total_frame_count += 1;
n->v.inline_site = site;
n->v.base_unwind_idx = base_frame_idx;
n->v.inline_unwind_idx = inline_unwind_idx;
inline_unwind_idx += 1;
}
// rjf: add frame for concrete frame
DF_UnwindFrameNode *n = push_array(scratch.arena, DF_UnwindFrameNode, 1);
SLLQueuePush(rich_frames_list.first, rich_frames_list.last, n);
rich_frames_list.count += 1;
n->v.regs = base_frame->regs;
n->v.rdi = rdi;
n->v.procedure = rdi_element_from_name_idx(rdi, Procedures, scope->proc_idx);
n->v.inline_site = 0;
n->v.base_unwind_idx = base_frame_idx;
n->v.inline_unwind_idx = inline_unwind_idx;
inline_unwind_idx = 0;
}
DF_Unwind result = {0};
{
result.frames.count = rich_frames_list.count;
result.frames.v = push_array(arena, DF_UnwindFrame, result.frames.count);
U64 idx = 0;
for(DF_UnwindFrameNode *n = rich_frames_list.first; n != 0; n = n->next, idx += 1)
{
MemoryCopyStruct(&result.frames.v[idx], &n->v);
} }
} }
scratch_end(scratch);
return result; return result;
} }
internal DF_UnwindFrame *
df_frame_from_unwind_idxs(DF_Unwind *unwind, U64 base_unwind_idx, U64 inline_unwind_idx)
{
DF_UnwindFrame *f = 0;
for(U64 idx = 0; idx < unwind->frames.count; idx += 1)
{
if(unwind->frames.v[idx].base_unwind_idx == base_unwind_idx)
{
f = &unwind->frames.v[idx];
if(unwind->frames.v[idx].inline_unwind_idx == inline_unwind_idx)
{
break;
}
}
}
return f;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Target Controls //~ rjf: Target Controls
@@ -3870,7 +3834,7 @@ df_ctrl_run(DF_RunKind run, DF_Entity *run_thread, CTRL_RunFlags flags, CTRL_Tra
// rjf: set control context to top unwind // rjf: set control context to top unwind
df_state->ctrl_ctx.unwind_count = 0; df_state->ctrl_ctx.unwind_count = 0;
df_state->ctrl_ctx.inline_unwind_count = 0; df_state->ctrl_ctx.inline_depth = 0;
scratch_end(scratch); scratch_end(scratch);
} }
@@ -5731,7 +5695,7 @@ df_ctrl_ctx_apply_overrides(DF_CtrlCtx *ctx, DF_CtrlCtx *overrides)
{ {
ctx->thread = overrides->thread; ctx->thread = overrides->thread;
ctx->unwind_count = overrides->unwind_count; ctx->unwind_count = overrides->unwind_count;
ctx->inline_unwind_count = overrides->inline_unwind_count; ctx->inline_depth = overrides->inline_depth;
} }
} }
@@ -6531,8 +6495,8 @@ df_push_cmd__root(DF_CmdParams *params, DF_CmdSpec *spec)
if(params->vaddr != 0) { log_infof("vaddr: 0x%I64x\n", params->vaddr); } if(params->vaddr != 0) { log_infof("vaddr: 0x%I64x\n", params->vaddr); }
if(params->voff != 0) { log_infof("voff: 0x%I64x\n", params->voff); } if(params->voff != 0) { log_infof("voff: 0x%I64x\n", params->voff); }
if(params->index != 0) { log_infof("index: 0x%I64x\n", params->index); } if(params->index != 0) { log_infof("index: 0x%I64x\n", params->index); }
if(params->base_unwind_index != 0) { log_infof("base_unwind_index: 0x%I64x\n", params->base_unwind_index); } if(params->unwind_index != 0) { log_infof("unwind_index: 0x%I64x\n", params->unwind_index); }
if(params->inline_unwind_index != 0){ log_infof("inline_unwind_index: 0x%I64x\n", params->inline_unwind_index); } if(params->inline_depth != 0) { log_infof("inline_depth: 0x%I64x\n", params->inline_depth); }
if(params->id != 0) { log_infof("id: 0x%I64x\n", params->id); } if(params->id != 0) { log_infof("id: 0x%I64x\n", params->id); }
if(params->os_event != 0) if(params->os_event != 0)
{ {
@@ -7646,17 +7610,23 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread); CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread);
DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind); DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind);
DF_UnwindFrame *frame = df_frame_from_unwind_idxs(&rich_unwind, params.base_unwind_index, params.inline_unwind_index); if(params.unwind_index < rich_unwind.frames.concrete_frame_count)
if(frame != 0)
{ {
df_state->ctrl_ctx.unwind_count = frame->base_unwind_idx; DF_UnwindFrame *frame = &rich_unwind.frames.v[params.unwind_index];
df_state->ctrl_ctx.inline_unwind_count = frame->inline_unwind_idx; df_state->ctrl_ctx.unwind_count = params.unwind_index;
df_state->ctrl_ctx.inline_depth = 0;
if(params.inline_depth < frame->inline_frame_count)
{
df_state->ctrl_ctx.inline_depth = params.inline_depth;
}
} }
di_scope_close(di_scope); di_scope_close(di_scope);
}break; }break;
case DF_CoreCmdKind_UpOneFrame: case DF_CoreCmdKind_UpOneFrame:
case DF_CoreCmdKind_DownOneFrame: case DF_CoreCmdKind_DownOneFrame:
{ {
// TODO(rjf)
#if 0
DF_CtrlCtx ctrl_ctx = df_ctrl_ctx(); DF_CtrlCtx ctrl_ctx = df_ctrl_ctx();
DI_Scope *di_scope = di_scope_open(); DI_Scope *di_scope = di_scope_open();
DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread); DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread);
@@ -7664,6 +7634,10 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread); CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(thread);
DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind); DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind);
DF_UnwindFrame *current_frame = 0; DF_UnwindFrame *current_frame = 0;
if(ctrl_ctx.unwind_count < rich_unwind.frames.concrete_frame_count)
{
current_frame = &rich_unwind.frames.v[ctrl_ctx.unwind_count];
}
for(U64 idx = 0; idx < rich_unwind.frames.count; idx += 1) for(U64 idx = 0; idx < rich_unwind.frames.count; idx += 1)
{ {
if(rich_unwind.frames.v[idx].base_unwind_idx == ctrl_ctx.unwind_count && if(rich_unwind.frames.v[idx].base_unwind_idx == ctrl_ctx.unwind_count &&
@@ -7702,6 +7676,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind)); df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
} }
di_scope_close(di_scope); di_scope_close(di_scope);
#endif
}break; }break;
case DF_CoreCmdKind_FreezeThread: case DF_CoreCmdKind_FreezeThread:
case DF_CoreCmdKind_ThawThread: case DF_CoreCmdKind_ThawThread:
@@ -8999,7 +8974,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
df_interact_regs()->module = df_handle_from_entity(module); df_interact_regs()->module = df_handle_from_entity(module);
df_interact_regs()->process = df_handle_from_entity(process); df_interact_regs()->process = df_handle_from_entity(process);
df_interact_regs()->unwind_count = df_state->ctrl_ctx.unwind_count; df_interact_regs()->unwind_count = df_state->ctrl_ctx.unwind_count;
df_interact_regs()->inline_unwind_count = df_state->ctrl_ctx.inline_unwind_count; df_interact_regs()->inline_depth = df_state->ctrl_ctx.inline_depth;
} }
ProfEnd(); ProfEnd();
+16 -22
View File
@@ -77,7 +77,7 @@ struct DF_CtrlCtx
{ {
DF_Handle thread; DF_Handle thread;
U64 unwind_count; U64 unwind_count;
U64 inline_unwind_count; U64 inline_depth;
}; };
//////////////////////////////// ////////////////////////////////
@@ -452,37 +452,32 @@ struct DF_EntityFuzzyItemArray
//////////////////////////////// ////////////////////////////////
//~ rjf: Rich (Including Inline) Unwind Types //~ rjf: Rich (Including Inline) Unwind Types
typedef struct DF_UnwindInlineFrame DF_UnwindInlineFrame;
struct DF_UnwindInlineFrame
{
DF_UnwindInlineFrame *next;
DF_UnwindInlineFrame *prev;
RDI_InlineSite *inline_site;
};
typedef struct DF_UnwindFrame DF_UnwindFrame; typedef struct DF_UnwindFrame DF_UnwindFrame;
struct DF_UnwindFrame struct DF_UnwindFrame
{ {
DF_UnwindInlineFrame *first_inline_frame;
DF_UnwindInlineFrame *last_inline_frame;
U64 inline_frame_count;
void *regs; void *regs;
RDI_Parsed *rdi; RDI_Parsed *rdi;
RDI_Procedure *procedure; RDI_Procedure *procedure;
RDI_InlineSite *inline_site;
U64 base_unwind_idx;
U64 inline_unwind_idx;
};
typedef struct DF_UnwindFrameNode DF_UnwindFrameNode;
struct DF_UnwindFrameNode
{
DF_UnwindFrameNode *next;
DF_UnwindFrame v;
};
typedef struct DF_UnwindFrameList DF_UnwindFrameList;
struct DF_UnwindFrameList
{
DF_UnwindFrameNode *first;
DF_UnwindFrameNode *last;
U64 count;
}; };
typedef struct DF_UnwindFrameArray DF_UnwindFrameArray; typedef struct DF_UnwindFrameArray DF_UnwindFrameArray;
struct DF_UnwindFrameArray struct DF_UnwindFrameArray
{ {
DF_UnwindFrame *v; DF_UnwindFrame *v;
U64 count; U64 concrete_frame_count;
U64 inline_frame_count;
U64 total_frame_count;
}; };
typedef struct DF_Unwind DF_Unwind; typedef struct DF_Unwind DF_Unwind;
@@ -598,7 +593,7 @@ struct DF_InteractRegs
DF_Handle process; DF_Handle process;
DF_Handle thread; DF_Handle thread;
U64 unwind_count; U64 unwind_count;
U64 inline_unwind_count; U64 inline_depth;
DF_Handle window; DF_Handle window;
DF_Handle panel; DF_Handle panel;
DF_Handle view; DF_Handle view;
@@ -1609,7 +1604,6 @@ internal EVAL_String2NumMap *df_push_member_map_from_dbgi_key_voff(Arena *arena,
internal B32 df_set_thread_rip(DF_Entity *thread, U64 vaddr); internal B32 df_set_thread_rip(DF_Entity *thread, U64 vaddr);
internal DF_Entity *df_module_from_thread_candidates(DF_Entity *thread, DF_EntityList *candidates); internal DF_Entity *df_module_from_thread_candidates(DF_Entity *thread, DF_EntityList *candidates);
internal DF_Unwind df_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, DF_Entity *process, CTRL_Unwind *base_unwind); internal DF_Unwind df_unwind_from_ctrl_unwind(Arena *arena, DI_Scope *di_scope, DF_Entity *process, CTRL_Unwind *base_unwind);
internal DF_UnwindFrame *df_frame_from_unwind_idxs(DF_Unwind *unwind, U64 base_unwind_idx, U64 inline_unwind_idx);
//////////////////////////////// ////////////////////////////////
//~ rjf: Target Controls //~ rjf: Target Controls
+2 -2
View File
@@ -93,8 +93,8 @@ DF_CmdParamSlotTable:
{PreferDisassembly prefer_dasm `B32`} {PreferDisassembly prefer_dasm `B32`}
{ForceConfirm force_confirm `B32`} {ForceConfirm force_confirm `B32`}
{Dir2 dir2 `Dir2`} {Dir2 dir2 `Dir2`}
{BaseUnwindIndex base_unwind_index `U64`} {UnwindIndex unwind_index `U64`}
{InlineUnwindIndex inline_unwind_index `U64`} {InlineDepth inline_depth `U64`}
} }
@table(name lister_omit q_slot q_ent_kind q_allow_files q_allow_folders q_keep_oi q_select_oi q_is_code q_required canonical_icon string display_name desc search_tags ) @table(name lister_omit q_slot q_ent_kind q_allow_files q_allow_folders q_keep_oi q_select_oi q_is_code q_required canonical_icon string display_name desc search_tags )
+2 -2
View File
@@ -28,8 +28,8 @@ Rng1U64 df_g_cmd_param_slot_range_table[24] =
{OffsetOf(DF_CmdParams, prefer_dasm), OffsetOf(DF_CmdParams, prefer_dasm) + sizeof(B32)}, {OffsetOf(DF_CmdParams, prefer_dasm), OffsetOf(DF_CmdParams, prefer_dasm) + sizeof(B32)},
{OffsetOf(DF_CmdParams, force_confirm), OffsetOf(DF_CmdParams, force_confirm) + sizeof(B32)}, {OffsetOf(DF_CmdParams, force_confirm), OffsetOf(DF_CmdParams, force_confirm) + sizeof(B32)},
{OffsetOf(DF_CmdParams, dir2), OffsetOf(DF_CmdParams, dir2) + sizeof(Dir2)}, {OffsetOf(DF_CmdParams, dir2), OffsetOf(DF_CmdParams, dir2) + sizeof(Dir2)},
{OffsetOf(DF_CmdParams, base_unwind_index), OffsetOf(DF_CmdParams, base_unwind_index) + sizeof(U64)}, {OffsetOf(DF_CmdParams, unwind_index), OffsetOf(DF_CmdParams, unwind_index) + sizeof(U64)},
{OffsetOf(DF_CmdParams, inline_unwind_index), OffsetOf(DF_CmdParams, inline_unwind_index) + sizeof(U64)}, {OffsetOf(DF_CmdParams, inline_depth), OffsetOf(DF_CmdParams, inline_depth) + sizeof(U64)},
}; };
DF_IconKind df_g_entity_kind_icon_kind_table[25] = DF_IconKind df_g_entity_kind_icon_kind_table[25] =
+4 -4
View File
@@ -392,8 +392,8 @@ DF_CmdParamSlot_ID,
DF_CmdParamSlot_PreferDisassembly, DF_CmdParamSlot_PreferDisassembly,
DF_CmdParamSlot_ForceConfirm, DF_CmdParamSlot_ForceConfirm,
DF_CmdParamSlot_Dir2, DF_CmdParamSlot_Dir2,
DF_CmdParamSlot_BaseUnwindIndex, DF_CmdParamSlot_UnwindIndex,
DF_CmdParamSlot_InlineUnwindIndex, DF_CmdParamSlot_InlineDepth,
DF_CmdParamSlot_COUNT, DF_CmdParamSlot_COUNT,
} DF_CmdParamSlot; } DF_CmdParamSlot;
@@ -422,8 +422,8 @@ U64 id;
B32 prefer_dasm; B32 prefer_dasm;
B32 force_confirm; B32 force_confirm;
Dir2 dir2; Dir2 dir2;
U64 base_unwind_index; U64 unwind_index;
U64 inline_unwind_index; U64 inline_depth;
}; };
DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array); DF_CORE_VIEW_RULE_EVAL_RESOLUTION_FUNCTION_DEF(array);
+68 -54
View File
@@ -522,15 +522,15 @@ df_cmd_params_from_window(DF_Window *window)
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineDepth);
p.window = df_handle_from_window(window); p.window = df_handle_from_window(window);
p.panel = df_handle_from_panel(window->focused_panel); p.panel = df_handle_from_panel(window->focused_panel);
p.view = df_handle_from_view(df_selected_tab_from_panel(window->focused_panel)); p.view = df_handle_from_view(df_selected_tab_from_panel(window->focused_panel));
p.prefer_dasm = df_prefer_dasm_from_window(window); p.prefer_dasm = df_prefer_dasm_from_window(window);
p.entity = ctrl_ctx.thread; p.entity = ctrl_ctx.thread;
p.base_unwind_index = ctrl_ctx.unwind_count; p.unwind_index = ctrl_ctx.unwind_count;
p.inline_unwind_index = ctrl_ctx.inline_unwind_count; p.inline_depth = ctrl_ctx.inline_depth;
return p; return p;
} }
@@ -544,15 +544,15 @@ df_cmd_params_from_panel(DF_Window *window, DF_Panel *panel)
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineDepth);
p.window = df_handle_from_window(window); p.window = df_handle_from_window(window);
p.panel = df_handle_from_panel(panel); p.panel = df_handle_from_panel(panel);
p.view = df_handle_from_view(df_selected_tab_from_panel(panel)); p.view = df_handle_from_view(df_selected_tab_from_panel(panel));
p.prefer_dasm = df_prefer_dasm_from_window(window); p.prefer_dasm = df_prefer_dasm_from_window(window);
p.entity = ctrl_ctx.thread; p.entity = ctrl_ctx.thread;
p.base_unwind_index = ctrl_ctx.unwind_count; p.unwind_index = ctrl_ctx.unwind_count;
p.inline_unwind_index = ctrl_ctx.inline_unwind_count; p.inline_depth = ctrl_ctx.inline_depth;
return p; return p;
} }
@@ -566,15 +566,15 @@ df_cmd_params_from_view(DF_Window *window, DF_Panel *panel, DF_View *view)
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_View);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_PreferDisassembly);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&p, DF_CmdParamSlot_InlineDepth);
p.window = df_handle_from_window(window); p.window = df_handle_from_window(window);
p.panel = df_handle_from_panel(panel); p.panel = df_handle_from_panel(panel);
p.view = df_handle_from_view(view); p.view = df_handle_from_view(view);
p.prefer_dasm = df_prefer_dasm_from_window(window); p.prefer_dasm = df_prefer_dasm_from_window(window);
p.entity = ctrl_ctx.thread; p.entity = ctrl_ctx.thread;
p.base_unwind_index = ctrl_ctx.unwind_count; p.unwind_index = ctrl_ctx.unwind_count;
p.inline_unwind_index = ctrl_ctx.inline_unwind_count; p.inline_depth = ctrl_ctx.inline_depth;
return p; return p;
} }
@@ -2585,12 +2585,12 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{ {
DI_Scope *scope = di_scope_open(); DI_Scope *scope = di_scope_open();
DF_Entity *thread = df_entity_from_handle(params.entity); DF_Entity *thread = df_entity_from_handle(params.entity);
U64 base_unwind_index = params.base_unwind_index; U64 unwind_index = params.unwind_index;
U64 inline_unwind_index = params.inline_unwind_index; U64 inline_depth = params.inline_depth;
if(thread->kind == DF_EntityKind_Thread) if(thread->kind == DF_EntityKind_Thread)
{ {
// rjf: grab rip // rjf: grab rip
U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, base_unwind_index); U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_index);
// rjf: extract thread/rip info // rjf: extract thread/rip info
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
@@ -2605,7 +2605,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
for(DF_LineNode *n = lines.first; n != 0; n = n->next, idx += 1) for(DF_LineNode *n = lines.first; n != 0; n = n->next, idx += 1)
{ {
line = n->v; line = n->v;
if(idx == inline_unwind_index) if(idx == inline_depth)
{ {
break; break;
} }
@@ -2632,12 +2632,13 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
params.entity = df_handle_from_entity(thread); params.entity = df_handle_from_entity(thread);
params.voff = rip_voff; params.voff = rip_voff;
params.vaddr = rip_vaddr; params.vaddr = rip_vaddr;
params.base_unwind_index = base_unwind_index; params.unwind_index = unwind_index;
params.inline_unwind_index = inline_unwind_index; params.inline_depth = inline_depth;
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualOff); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualOff);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualAddr); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualAddr);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation)); df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
} }
@@ -2648,12 +2649,13 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
params.entity = df_handle_from_entity(thread); params.entity = df_handle_from_entity(thread);
params.voff = rip_voff; params.voff = rip_voff;
params.vaddr = rip_vaddr; params.vaddr = rip_vaddr;
params.base_unwind_index = base_unwind_index; params.unwind_index = unwind_index;
params.inline_unwind_index = inline_unwind_index; params.inline_depth = inline_depth;
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualOff); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualOff);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualAddr); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_VirtualAddr);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Index); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation)); df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
} }
@@ -2671,11 +2673,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
DF_Entity *selected_thread = df_entity_from_handle(ctrl_ctx.thread); DF_Entity *selected_thread = df_entity_from_handle(ctrl_ctx.thread);
DF_CmdParams params = df_cmd_params_from_window(ws); DF_CmdParams params = df_cmd_params_from_window(ws);
params.entity = df_handle_from_entity(selected_thread); params.entity = df_handle_from_entity(selected_thread);
params.base_unwind_index = ctrl_ctx.unwind_count; params.unwind_index = ctrl_ctx.unwind_count;
params.inline_unwind_index = ctrl_ctx.inline_unwind_count; params.inline_depth = ctrl_ctx.inline_depth;
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindThread)); df_cmd_list_push(arena, cmds, &params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindThread));
}break; }break;
@@ -3732,7 +3734,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
ui_labelf("cursor: (L:%I64d, C:%I64d)", regs->cursor.line, regs->cursor.column); ui_labelf("cursor: (L:%I64d, C:%I64d)", regs->cursor.line, regs->cursor.column);
ui_labelf("mark: (L:%I64d, C:%I64d)", regs->mark.line, regs->mark.column); ui_labelf("mark: (L:%I64d, C:%I64d)", regs->mark.line, regs->mark.column);
ui_labelf("unwind_count: %I64u", regs->unwind_count); ui_labelf("unwind_count: %I64u", regs->unwind_count);
ui_labelf("inline_unwind_count: %I64u", regs->inline_unwind_count); ui_labelf("inline_depth: %I64u", regs->inline_depth);
ui_labelf("text_key: [0x%I64x, 0x%I64x]", regs->text_key.u64[0], regs->text_key.u64[1]); ui_labelf("text_key: [0x%I64x, 0x%I64x]", regs->text_key.u64[0], regs->text_key.u64[1]);
ui_labelf("lang_kind: '%S'", txt_extension_from_lang_kind(regs->lang_kind)); ui_labelf("lang_kind: '%S'", txt_extension_from_lang_kind(regs->lang_kind));
ui_labelf("vaddr_range: [0x%I64x, 0x%I64x)", regs->vaddr_range.min, regs->vaddr_range.max); ui_labelf("vaddr_range: [0x%I64x, 0x%I64x)", regs->vaddr_range.min, regs->vaddr_range.max);
@@ -4340,25 +4342,28 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(entity); CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(entity);
DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind); DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind);
String8List lines = {0}; String8List lines = {0};
for(U64 frame_idx = 0; frame_idx < rich_unwind.frames.count; frame_idx += 1) for(U64 frame_idx = 0; frame_idx < rich_unwind.frames.concrete_frame_count; frame_idx += 1)
{ {
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, rich_unwind.frames.v[frame_idx].regs); DF_UnwindFrame *concrete_frame = &rich_unwind.frames.v[frame_idx];
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, concrete_frame->regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
RDI_Parsed *rdi = rich_unwind.frames.v[frame_idx].rdi; RDI_Parsed *rdi = concrete_frame->rdi;
RDI_Procedure *procedure = rich_unwind.frames.v[frame_idx].procedure; RDI_Procedure *procedure = concrete_frame->procedure;
RDI_InlineSite *inline_site = rich_unwind.frames.v[frame_idx].inline_site; for(DF_UnwindInlineFrame *inline_frame = concrete_frame->last_inline_frame;
inline_frame != 0;
inline_frame = inline_frame->prev)
{
RDI_InlineSite *inline_site = inline_frame->inline_site;
String8 name = {0};
name.str = rdi_string_from_idx(rdi, inline_site->name_string_idx, &name.size);
str8_list_pushf(scratch.arena, &lines, "0x%I64x: [inlined] \"%S\"%s%S", rip_vaddr, name, df_entity_is_nil(module) ? "" : " in ", module->name);
}
if(procedure != 0) if(procedure != 0)
{ {
String8 name = {0}; String8 name = {0};
name.str = rdi_name_from_procedure(rdi, procedure, &name.size); name.str = rdi_name_from_procedure(rdi, procedure, &name.size);
str8_list_pushf(scratch.arena, &lines, "0x%I64x: \"%S\"%s%S", rip_vaddr, name, df_entity_is_nil(module) ? "" : " in ", module->name); str8_list_pushf(scratch.arena, &lines, "0x%I64x: \"%S\"%s%S", rip_vaddr, name, df_entity_is_nil(module) ? "" : " in ", module->name);
} }
else if(inline_site != 0)
{
String8 name = {0};
name.str = rdi_string_from_idx(rdi, inline_site->name_string_idx, &name.size);
str8_list_pushf(scratch.arena, &lines, "0x%I64x: [inlined] \"%S\"%s%S", rip_vaddr, name, df_entity_is_nil(module) ? "" : " in ", module->name);
}
else if(!df_entity_is_nil(module)) else if(!df_entity_is_nil(module))
{ {
str8_list_pushf(scratch.arena, &lines, "0x%I64x: [??? in %S]", rip_vaddr, module->name); str8_list_pushf(scratch.arena, &lines, "0x%I64x: [??? in %S]", rip_vaddr, module->name);
@@ -10624,33 +10629,42 @@ df_entity_tooltips(DF_Window *ws, DF_Entity *entity)
DF_Entity *process = df_entity_ancestor_from_kind(entity, DF_EntityKind_Process); DF_Entity *process = df_entity_ancestor_from_kind(entity, DF_EntityKind_Process);
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(entity); CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(entity);
DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind); DF_Unwind rich_unwind = df_unwind_from_ctrl_unwind(scratch.arena, di_scope, process, &base_unwind);
for(U64 idx = 0; idx < rich_unwind.frames.count; idx += 1) for(U64 idx = 0; idx < rich_unwind.frames.concrete_frame_count; idx += 1)
{ {
DF_UnwindFrame *f = &rich_unwind.frames.v[idx]; DF_UnwindFrame *f = &rich_unwind.frames.v[idx];
RDI_Parsed *rdi = f->rdi; RDI_Parsed *rdi = f->rdi;
RDI_Procedure *procedure = f->procedure; RDI_Procedure *procedure = f->procedure;
RDI_InlineSite *inline_site = f->inline_site;
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, f->regs); U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, f->regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
String8 module_name = df_entity_is_nil(module) ? str8_lit("???") : str8_skip_last_slash(module->name); String8 module_name = df_entity_is_nil(module) ? str8_lit("???") : str8_skip_last_slash(module->name);
String8 name = {0};
String8 info = {0}; // rjf: inline frames
if(procedure != 0) for(DF_UnwindInlineFrame *fin = f->last_inline_frame; fin != 0; fin = fin->prev)
UI_PrefWidth(ui_children_sum(1)) UI_Row
{ {
name.str = rdi_name_from_procedure(rdi, procedure, &name.size); String8 name = {0};
} name.str = rdi_string_from_idx(rdi, fin->inline_site->name_string_idx, &name.size);
else if(inline_site != 0) DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("0x%I64x", rip_vaddr);
{ DF_Font(ws, DF_FontSlot_Code) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(str8_lit("[inlined]"));
name.str = rdi_string_from_idx(rdi, inline_site->name_string_idx, &name.size); if(name.size != 0)
info = str8_lit("[inlined]"); {
DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1))
{
df_code_label(1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol), name);
}
}
else
{
DF_Font(ws, DF_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 UI_PrefWidth(ui_children_sum(1)) UI_Row
{ {
String8 name = {0};
name.str = rdi_name_from_procedure(rdi, procedure, &name.size);
DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("0x%I64x", rip_vaddr); DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_em(18.f, 1.f)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) ui_labelf("0x%I64x", rip_vaddr);
if(info.size != 0)
{
DF_Font(ws, DF_FontSlot_Code)UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) ui_label(info);
}
if(name.size != 0) if(name.size != 0)
{ {
DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1)) DF_Font(ws, DF_FontSlot_Code) UI_PrefWidth(ui_text_dim(10, 1))
@@ -12513,7 +12527,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
{ {
if((n->v.pt.line == line_num || df_entity_is_nil(df_entity_from_handle(df_interact_regs()->file))) && if((n->v.pt.line == line_num || df_entity_is_nil(df_entity_from_handle(df_interact_regs()->file))) &&
((di_key_match(&n->v.dbgi_key, &rich_hover.dbgi_key) && ((di_key_match(&n->v.dbgi_key, &rich_hover.dbgi_key) &&
n->v.voff_range.min <= rich_hover_voff_range.min && rich_hover_voff_range.min <= n->v.voff_range.max) || n->v.voff_range.min <= rich_hover_voff_range.min && rich_hover_voff_range.min < n->v.voff_range.max) ||
(params->line_vaddrs[line_idx] == rich_hover.vaddr_range.min && rich_hover.vaddr_range.min != 0))) (params->line_vaddrs[line_idx] == rich_hover.vaddr_range.min && rich_hover.vaddr_range.min != 0)))
{ {
matches = 1; matches = 1;
+88 -45
View File
@@ -622,8 +622,8 @@ df_code_view_build(Arena *arena, DF_Window *ws, DF_Panel *panel, DF_View *view,
{ {
DF_Entity *thread = thread_n->entity; DF_Entity *thread = thread_n->entity;
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process); DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
U64 base_unwind_count = (thread == selected_thread) ? ctrl_ctx.unwind_count : 0; U64 unwind_count = (thread == selected_thread) ? ctrl_ctx.unwind_count : 0;
U64 inline_unwind_count = (thread == selected_thread) ? ctrl_ctx.inline_unwind_count : 0; U64 inline_depth = (thread == selected_thread) ? ctrl_ctx.inline_depth : 0;
U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count);
U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count; U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count;
DF_Entity *module = df_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr); DF_Entity *module = df_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr);
@@ -4230,7 +4230,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
UI_BoxFlag_DrawHotEffects| UI_BoxFlag_DrawHotEffects|
UI_BoxFlag_DrawActiveEffects, UI_BoxFlag_DrawActiveEffects,
"###procedure_%I64x", item->idx); "###procedure_%I64x", item->idx);
UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 1)) UI_Parent(box) UI_PrefWidth(ui_text_dim(10, 1)) DF_Font(ws, DF_FontSlot_Code)
{ {
UI_Box *box = df_code_label(1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol), name); UI_Box *box = df_code_label(1.f, 0, df_rgba_from_theme_color(DF_ThemeColor_CodeSymbol), name);
ui_box_equip_fuzzy_match_ranges(box, &item->match_ranges); ui_box_equip_fuzzy_match_ranges(box, &item->match_ranges);
@@ -5684,6 +5684,49 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
CTRL_Unwind base_unwind = df_query_cached_unwind_from_thread(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); 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 //- rjf: grab state
typedef struct DF_CallStackViewState DF_CallStackViewState; typedef struct DF_CallStackViewState DF_CallStackViewState;
struct DF_CallStackViewState struct DF_CallStackViewState
@@ -5713,8 +5756,8 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
scroll_list_params.flags = UI_ScrollListFlag_All; scroll_list_params.flags = UI_ScrollListFlag_All;
scroll_list_params.row_height_px = floor_f32(ui_top_font_size()*2.5f); 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.dim_px = dim_2f32(rect);
scroll_list_params.cursor_range = r2s64(v2s64(0, 0), v2s64(3, rich_unwind.frames.count)); 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.count+1); 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; scroll_list_params.cursor_min_is_empty_selection[Axis2_Y] = 1;
} }
UI_ScrollListSignal scroll_list_sig = {0}; UI_ScrollListSignal scroll_list_sig = {0};
@@ -5754,7 +5797,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
//- rjf: frame rows //- rjf: frame rows
for(S64 row_num = visible_row_range.min; for(S64 row_num = visible_row_range.min;
row_num <= visible_row_range.max && row_num <= rich_unwind.frames.count; row_num <= visible_row_range.max && row_num <= rows_count;
row_num += 1) row_num += 1)
{ {
if(row_num == 0) if(row_num == 0)
@@ -5764,29 +5807,29 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
B32 row_selected = (cs->cursor.y == row_num); B32 row_selected = (cs->cursor.y == row_num);
// rjf: unpack frame // rjf: unpack frame
U64 frame_idx = row_num-1; U64 row_idx = row_num-1;
DF_UnwindFrame *frame = &rich_unwind.frames.v[frame_idx]; FrameRow *row = &rows[row_idx];
U64 rip_vaddr = regs_rip_from_arch_block(thread->arch, frame->regs); U64 rip_vaddr = regs_rip_from_arch_block(thread->arch, row->regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr); DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
B32 frame_valid = (rip_vaddr != 0); B32 frame_valid = (rip_vaddr != 0);
TG_Graph *graph = tg_graph_begin(bit_size_from_arch(thread->arch)/8, 256); TG_Graph *graph = tg_graph_begin(bit_size_from_arch(thread->arch)/8, 256);
String8 symbol_name = {0}; String8 symbol_name = {0};
String8 symbol_type_string = {0}; String8 symbol_type_string = {0};
if(frame->procedure != 0) if(row->procedure != 0)
{ {
symbol_name.str = rdi_name_from_procedure(frame->rdi, frame->procedure, &symbol_name.size); symbol_name.str = rdi_name_from_procedure(row->rdi, row->procedure, &symbol_name.size);
RDI_TypeNode *type = rdi_element_from_name_idx(frame->rdi, TypeNodes, frame->procedure->type_idx); RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->procedure->type_idx);
symbol_type_string = tg_string_from_key(scratch.arena, graph, frame->rdi, tg_key_ext(tg_kind_from_rdi_type_kind(type->kind), frame->procedure->type_idx)); symbol_type_string = tg_string_from_key(scratch.arena, graph, row->rdi, tg_key_ext(tg_kind_from_rdi_type_kind(type->kind), row->procedure->type_idx));
} }
if(frame->inline_site != 0) if(row->inline_site != 0)
{ {
symbol_name.str = rdi_string_from_idx(frame->rdi, frame->inline_site->name_string_idx, &symbol_name.size); 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(frame->rdi, TypeNodes, frame->inline_site->type_idx); RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->inline_site->type_idx);
symbol_type_string = tg_string_from_key(scratch.arena, graph, frame->rdi, tg_key_ext(tg_kind_from_rdi_type_kind(type->kind), frame->inline_site->type_idx)); symbol_type_string = tg_string_from_key(scratch.arena, graph, row->rdi, tg_key_ext(tg_kind_from_rdi_type_kind(type->kind), row->inline_site->type_idx));
} }
// rjf: build row // rjf: build row
if(frame_valid) UI_NamedTableVectorF("###callstack_%p_%I64x", view, frame_idx) if(frame_valid) UI_NamedTableVectorF("###callstack_%p_%I64x", view, row_idx)
{ {
// rjf: build cell for selection // rjf: build cell for selection
UI_TableCell UI_TableCell
@@ -5797,28 +5840,27 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_FocusHot((row_selected && cs->cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off) UI_FocusHot((row_selected && cs->cursor.x == 0) ? UI_FocusKind_On : UI_FocusKind_Off)
{ {
String8 selected_string = {0}; String8 selected_string = {0};
if(ctrl_ctx.unwind_count == frame->base_unwind_idx && if(ctrl_ctx.unwind_count == row->unwind_idx &&
ctrl_ctx.inline_unwind_count == frame->inline_unwind_idx) ctrl_ctx.inline_depth == row->inline_depth)
{ {
selected_string = df_g_icon_kind_text_table[DF_IconKind_RightArrow]; 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_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_%i", selected_string, UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_DrawText, "%S###selection_%I64u", selected_string, row_idx);
(int)frame_idx);
UI_Signal sig = ui_signal_from_box(box); UI_Signal sig = ui_signal_from_box(box);
if(ui_pressed(sig)) if(ui_pressed(sig))
{ {
next_cursor = v2s64(0, (S64)frame_idx+1); next_cursor = v2s64(0, row_num);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel); 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)); 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) if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{ {
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
params.base_unwind_index = frame->base_unwind_idx; params.unwind_index = row->unwind_idx;
params.inline_unwind_index = frame->inline_unwind_idx; params.inline_depth = row->inline_depth;
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind)); df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
} }
} }
@@ -5828,10 +5870,10 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_FocusHot((row_selected && cs->cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off) UI_FocusHot((row_selected && cs->cursor.x == 1) ? UI_FocusKind_On : UI_FocusKind_Off)
{ {
ui_set_next_child_layout_axis(Axis2_X); 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_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|UI_BoxFlag_Clip, "row_%I64x", row_idx);
UI_Parent(box) UI_Parent(box)
{ {
if(frame->inline_site != 0) if(row->inline_site != 0)
{ {
UI_PrefWidth(ui_text_dim(10, 1)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) UI_PrefWidth(ui_text_dim(10, 1)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak)
{ {
@@ -5858,17 +5900,17 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_Signal sig = ui_signal_from_box(box); UI_Signal sig = ui_signal_from_box(box);
if(ui_pressed(sig)) if(ui_pressed(sig))
{ {
next_cursor = v2s64(1, (S64)frame_idx+1); next_cursor = v2s64(1, row_num);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel); 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)); 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) if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{ {
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
params.base_unwind_index = frame->base_unwind_idx; params.unwind_index = row->unwind_idx;
params.inline_unwind_index = frame->inline_unwind_idx; params.inline_depth = row->inline_depth;
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind)); df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
} }
} }
@@ -5881,17 +5923,17 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_Signal sig = ui_signal_from_box(box); UI_Signal sig = ui_signal_from_box(box);
if(ui_pressed(sig)) if(ui_pressed(sig))
{ {
next_cursor = v2s64(2, (S64)frame_idx+1); next_cursor = v2s64(2, row_num);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel); 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)); 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) if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{ {
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
params.base_unwind_index = frame->base_unwind_idx; params.unwind_index = row->unwind_idx;
params.inline_unwind_index = frame->inline_unwind_idx; params.inline_depth = row->inline_depth;
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind)); df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
} }
} }
@@ -5902,7 +5944,7 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
UI_Signal sig = {0}; UI_Signal sig = {0};
if(df_entity_is_nil(module)) UI_FlagsAdd(UI_BoxFlag_DrawTextWeak) 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", frame_idx); 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); sig = ui_signal_from_box(box);
} }
else else
@@ -5911,17 +5953,17 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
} }
if(ui_pressed(sig)) if(ui_pressed(sig))
{ {
next_cursor = v2s64(3, (S64)frame_idx+1); next_cursor = v2s64(3, row_num);
DF_CmdParams p = df_cmd_params_from_panel(ws, panel); 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)); 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) if(ui_double_clicked(sig) || sig.f&UI_SignalFlag_KeyboardPressed)
{ {
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_BaseUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_UnwindIndex);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineUnwindIndex); df_cmd_params_mark_slot(&params, DF_CmdParamSlot_InlineDepth);
params.base_unwind_index = frame->base_unwind_idx; params.unwind_index = row->unwind_idx;
params.inline_unwind_index = frame->inline_unwind_idx; params.inline_depth = row->inline_depth;
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind)); df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SelectUnwind));
} }
} }
@@ -6525,6 +6567,7 @@ DF_VIEW_UI_FUNCTION_DEF(Code)
UI_PrefWidth(ui_text_dim(10, 1)) UI_PrefWidth(ui_text_dim(10, 1))
UI_Focus(UI_FocusKind_On) UI_Focus(UI_FocusKind_On)
DF_Palette(ws, DF_PaletteCode_NeutralPopButton) DF_Palette(ws, DF_PaletteCode_NeutralPopButton)
UI_TextAlignment(UI_TextAlign_Center)
if(ui_clicked(ui_buttonf("Find alternative..."))) if(ui_clicked(ui_buttonf("Find alternative...")))
{ {
DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); DF_CmdParams params = df_cmd_params_from_view(ws, panel, view);
+1 -1
View File
@@ -2863,7 +2863,7 @@ rdim_bake_line_tables(RDIM_Arena *arena, RDIM_LineTableChunkList *src)
result.line_tables = dst_line_tables; result.line_tables = dst_line_tables;
result.line_tables_count = src->total_count+1; result.line_tables_count = src->total_count+1;
result.line_table_voffs = dst_line_voffs; result.line_table_voffs = dst_line_voffs;
result.line_table_voffs_count = (src->total_line_count + src->total_seq_count); result.line_table_voffs_count = (src->total_line_count + 2*src->total_seq_count);
result.line_table_lines = dst_lines; result.line_table_lines = dst_lines;
result.line_table_lines_count = (src->total_line_count + src->total_seq_count); result.line_table_lines_count = (src->total_line_count + src->total_seq_count);
result.line_table_columns = dst_cols; result.line_table_columns = dst_cols;
+4
View File
@@ -4,6 +4,10 @@
//////////////////////////////// ////////////////////////////////
//~ rjf: Frontend/UI Pass Tasks //~ rjf: Frontend/UI Pass Tasks
// //
// [ ] file overrides -> always pick most specific one! found with conflicting
// overrides, e.g. C:/devel/ -> D:/devel/, but also C:/devel/foo ->
// C:/devel/bar, etc.
//
// [ ] auto-scroll output window // [ ] auto-scroll output window
// [ ] inline breakpoint hit_count // [ ] inline breakpoint hit_count
// [ ] to count hit counts, resolve all bps to addresses, check addresses // [ ] to count hit counts, resolve all bps to addresses, check addresses