get ctrl and debug frontend layers onto new pdb-path-based debug info loader layer; sketch out standalone fuzzy search layer, to replace old dbgi searching functionality; shift all debug frontend code from referring to debug info via 'binaries' to referring to debug info via 'dbgis', just file entities at the location of o.g. debug info

This commit is contained in:
Ryan Fleury
2024-05-21 10:08:28 -07:00
parent b9ac104276
commit a019115b95
17 changed files with 1029 additions and 499 deletions
+61 -69
View File
@@ -583,17 +583,17 @@ df_queue_drag_drop(void)
}
internal void
df_set_hovered_line_info(DF_Entity *binary, U64 voff)
df_set_hovered_line_info(DF_Entity *dbgi, U64 voff)
{
df_gfx_state->hover_line_binary = df_handle_from_entity(binary);
df_gfx_state->hover_line_dbgi = df_handle_from_entity(dbgi);
df_gfx_state->hover_line_voff = voff;
df_gfx_state->hover_line_set_this_frame = 1;
}
internal DF_Entity *
df_get_hovered_line_info_binary(void)
df_get_hovered_line_info_dbgi(void)
{
return df_entity_from_handle(df_gfx_state->hover_line_binary);
return df_entity_from_handle(df_gfx_state->hover_line_dbgi);
}
internal U64
@@ -2488,7 +2488,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
//- rjf: thread finding
case DF_CoreCmdKind_FindThread:
{
DBGI_Scope *scope = dbgi_scope_open();
DI_Scope *scope = di_scope_open();
DF_Entity *thread = df_entity_from_handle(params.entity);
U64 unwind_count = params.index;
if(thread->kind == DF_EntityKind_Thread)
@@ -2499,15 +2499,15 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
// rjf: extract thread/rip info
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
DF_Entity *debug = df_dbgi_from_module(module);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
DBGI_Parse *dbgi = df_dbgi_parse_from_binary_file(scope, binary);
DF_TextLineDasm2SrcInfo line_info = df_text_line_dasm2src_info_from_binary_voff(binary, rip_voff);
RDI_Parsed *rdi = df_rdi_from_dbgi(scope, debug);
DF_TextLineDasm2SrcInfo line_info = df_text_line_dasm2src_info_from_dbgi_voff(debug, rip_voff);
// rjf: snap to resolved line
B32 missing_rip = (rip_vaddr == 0);
B32 binary_missing = (binary->flags & DF_EntityFlag_IsMissing);
B32 dbg_info_pending = !binary_missing && dbgi == &dbgi_parse_nil;
B32 binary_missing = (debug->flags & DF_EntityFlag_IsMissing);
B32 dbg_info_pending = !binary_missing && rdi == &di_rdi_parsed_nil;
B32 has_line_info = (line_info.voff_range.max != line_info.voff_range.min);
B32 has_module = !df_entity_is_nil(module);
B32 has_dbg_info = has_module && !binary_missing;
@@ -2537,7 +2537,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindThread));
}
}
dbgi_scope_close(scope);
di_scope_close(scope);
}break;
case DF_CoreCmdKind_FindSelectedThread:
{
@@ -2561,17 +2561,17 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
// rjf: try to resolve name as a symbol
U64 voff = 0;
DF_Entity *voff_binary = &df_g_nil_entity;
DF_Entity *voff_dbgi = &df_g_nil_entity;
if(name_resolved == 0)
{
DF_EntityList binaries = df_push_active_binary_list(scratch.arena);
for(DF_EntityNode *n = binaries.first; n != 0; n = n->next)
DF_EntityList dbgis = df_push_active_dbgi_list(scratch.arena);
for(DF_EntityNode *n = dbgis.first; n != 0; n = n->next)
{
U64 binary_voff = df_voff_from_binary_symbol_name(n->entity, name);
U64 binary_voff = df_voff_from_dbgi_symbol_name(n->entity, name);
if(binary_voff != 0)
{
voff = binary_voff;
voff_binary = n->entity;
voff_dbgi = n->entity;
name_resolved = 1;
break;
}
@@ -2680,19 +2680,25 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
// rjf: name resolved to voff * dbg info
if(name_resolved != 0 && voff != 0)
{
DF_TextLineDasm2SrcInfo dasm2src_info = df_text_line_dasm2src_info_from_binary_voff(voff_binary, voff);
DF_TextLineDasm2SrcInfo dasm2src_info = df_text_line_dasm2src_info_from_dbgi_voff(voff_dbgi, voff);
DF_CmdParams p = params;
{
p.file_path = df_full_path_from_entity(scratch.arena, dasm2src_info.file);
p.text_point = dasm2src_info.pt;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_FilePath);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_TextPoint);
if(!df_entity_is_nil(voff_binary))
if(!df_entity_is_nil(voff_dbgi))
{
p.entity = df_handle_from_entity(voff_binary);
p.voff = dasm2src_info.voff_range.min;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_VirtualOff);
DF_EntityList modules = df_modules_from_dbgi(scratch.arena, voff_dbgi);
DF_Entity *module = df_first_entity_from_list(&modules);
DF_Entity *process = df_entity_ancestor_from_kind(module, DF_EntityKind_Process);
if(!df_entity_is_nil(process))
{
p.entity = df_handle_from_entity(process);
p.vaddr = module->vaddr_rng.min + dasm2src_info.voff_range.min;
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity);
df_cmd_params_mark_slot(&p, DF_CmdParamSlot_VirtualAddr);
}
}
}
df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_FindCodeLocation));
@@ -2911,7 +2917,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{
for(DF_TextLineSrc2DasmInfoNode *n = src2dasm.v[src2dasm_idx].first; n != 0; n = n->next)
{
DF_EntityList modules = df_modules_from_binary_file(scratch.arena, n->v.binary);
DF_EntityList modules = df_modules_from_dbgi(scratch.arena, n->v.dbgi);
DF_Entity *module = df_module_from_thread_candidates(thread, &modules);
vaddr = df_vaddr_from_voff(module, n->v.voff_range.min);
goto end_lookup;
@@ -3411,26 +3417,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
case DF_EntityKind_Module:
{
DF_Entity *bin_file = df_binary_file_from_module(entity);
if(ui_clicked(df_icon_buttonf(DF_IconKind_Module, 0, "Inspect Binary File Memory")))
{
DF_CmdParams params = df_cmd_params_from_panel(ws, panel);
params.entity = df_handle_from_entity(bin_file);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PendingEntity));
ui_ctx_menu_close();
}
if(ui_clicked(df_icon_buttonf(DF_IconKind_Module, 0, "View Binary File Disassembly")))
{
DF_CmdParams params = df_cmd_params_from_panel(ws, panel);
params.entity = df_handle_from_entity(bin_file);
df_cmd_params_mark_slot(&params, DF_CmdParamSlot_Entity);
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PendingEntity));
ui_ctx_menu_close();
}
}break;
case DF_EntityKind_Process:
{
#if 0
if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Process Log")))
{
DF_Entity *log = df_log_from_entity(entity);
@@ -3440,9 +3430,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Code));
ui_ctx_menu_close();
}
#endif
}break;
case DF_EntityKind_Thread:
{
#if 0
if(ui_clicked(df_icon_buttonf(DF_IconKind_FileOutline, 0, "Open Thread Log")))
{
DF_Entity *log = df_log_from_entity(entity);
@@ -3452,6 +3444,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
df_push_cmd__root(&params, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_Code));
ui_ctx_menu_close();
}
#endif
}break;
}
}
@@ -3928,9 +3921,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
{
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, unwind.frames.v[frame_idx].regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
DF_Entity *dbgi = df_dbgi_from_module(module);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
String8 symbol = df_symbol_name_from_binary_voff(scratch.arena, binary, rip_voff);
String8 symbol = df_symbol_name_from_dbgi_voff(scratch.arena, dbgi, rip_voff);
if(symbol.size != 0)
{
str8_list_pushf(scratch.arena, &lines, "0x%I64x: %S", rip_vaddr, symbol);
@@ -4255,7 +4248,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
DF_Entity *module = df_module_from_process_vaddr(process, thread_rip_vaddr);
U64 thread_rip_voff = df_voff_from_vaddr(module, thread_rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
DF_Entity *dbgi = df_dbgi_from_module(module);
//- rjf: gather lister items
DF_AutoCompListerItemChunkList item_list = {0};
@@ -4263,7 +4256,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
//- rjf: gather locals
if(ws->autocomp_lister_params.flags & DF_AutoCompListerFlag_Locals)
{
EVAL_String2NumMap *locals_map = df_query_cached_locals_map_from_binary_voff(binary, thread_rip_voff);
EVAL_String2NumMap *locals_map = df_query_cached_locals_map_from_dbgi_voff(dbgi, thread_rip_voff);
for(EVAL_String2NumMapNode *n = locals_map->first; n != 0; n = n->order_next)
{
DF_AutoCompListerItem item = {0};
@@ -5716,7 +5709,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
UI_FontSize(df_font_size_from_slot(ws, DF_FontSlot_Main))
{
Temp scratch = scratch_begin(&arena, 1);
DBGI_Scope *scope = dbgi_scope_open();
DI_Scope *scope = di_scope_open();
DF_CtrlCtx ctrl_ctx = ws->hover_eval_ctrl_ctx;
DF_Entity *thread = df_entity_from_handle(ctrl_ctx.thread);
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
@@ -5983,7 +5976,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds)
}
}
dbgi_scope_close(scope);
di_scope_close(scope);
scratch_end(scratch);
}
}
@@ -8311,7 +8304,7 @@ df_single_line_eval_value_strings_from_eval(Arena *arena, DF_EvalVizStringFlags
}
internal DF_EvalVizWindowedRowList
df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scope, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, EVAL_String2ExprMap *macro_map, DF_EvalView *eval_view, U32 default_radix, F_Tag font, F32 font_size, Rng1S64 visible_range, DF_EvalVizBlockList *blocks)
df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DI_Scope *scope, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, EVAL_String2ExprMap *macro_map, DF_EvalView *eval_view, U32 default_radix, F_Tag font, F32 font_size, Rng1S64 visible_range, DF_EvalVizBlockList *blocks)
{
ProfBeginFunction();
Temp scratch = scratch_begin(&arena, 1);
@@ -8697,12 +8690,12 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
for(U64 idx = visible_idx_range.min; idx < visible_idx_range.max; idx += 1)
{
// rjf: unpack info about this row
String8 name = dbgi_fuzzy_item_string_from_rdi_target_element_idx(parse_ctx->rdi, block->dbgi_target, block->backing_search_items.v[idx].idx);
String8 name = push_str8f(arena, "Item %I64u", idx); // TODO(rjf): dbgi_fuzzy_item_string_from_rdi_target_element_idx(parse_ctx->rdi, block->dbgi_target, block->fzy_backing_items.v[idx].idx);
// rjf: get keys for this row
DF_ExpandKey parent_key = block->parent_key;
DF_ExpandKey key = block->key;
key.child_num = block->backing_search_items.v[idx].idx;
key.child_num = block->fzy_backing_items.v[idx].idx;
// rjf: get eval for this row
DF_Eval eval = df_eval_from_string(arena, scope, ctrl_ctx, parse_ctx, macro_map, name);
@@ -9942,9 +9935,9 @@ df_entity_tooltips(DF_Entity *entity)
{
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, unwind.frames.v[idx].regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
DF_Entity *dbgi = df_dbgi_from_module(module);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
String8 symbol = df_symbol_name_from_binary_voff(scratch.arena, binary, rip_voff);
String8 symbol = df_symbol_name_from_dbgi_voff(scratch.arena, dbgi, rip_voff);
UI_PrefWidth(ui_children_sum(1)) UI_Row
{
UI_Font(df_font_from_slot(DF_FontSlot_Code)) UI_PrefWidth(ui_em(18.f, 1.f)) UI_TextColor(df_rgba_from_theme_color(DF_ThemeColor_WeakText)) ui_labelf("0x%I64x", rip_vaddr);
@@ -10138,8 +10131,8 @@ df_entity_desc_button(DF_Window *ws, DF_Entity *entity, FuzzyMatchRangeList *nam
U64 rip_vaddr = regs_rip_from_arch_block(entity->arch, f->regs);
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
String8 procedure_name = df_symbol_name_from_binary_voff(scratch.arena, binary, rip_voff);
DF_Entity *dbgi = df_dbgi_from_module(module);
String8 procedure_name = df_symbol_name_from_dbgi_voff(scratch.arena, dbgi, rip_voff);
if(procedure_name.size != 0)
{
FuzzyMatchRangeList fuzzy_matches = {0};
@@ -10582,7 +10575,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
U64 thread_rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count);
DF_Entity *process = df_entity_ancestor_from_kind(thread, DF_EntityKind_Process);
DF_Entity *module = df_module_from_process_vaddr(process, thread_rip_vaddr);
DF_Entity *binary = df_binary_file_from_module(module);
DF_Entity *dbgi = df_dbgi_from_module(module);
U64 thread_rip_voff = df_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color
@@ -10649,7 +10642,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
n != 0;
n = n->next)
{
if(n->v.binary == binary)
if(n->v.dbgi == dbgi)
{
line_info = &n->v;
break;
@@ -10964,7 +10957,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
//
UI_Focus(UI_FocusKind_Off)
{
DBGI_Scope *scope = dbgi_scope_open();
DI_Scope *scope = di_scope_open();
U64 line_idx = 0;
for(S64 line_num = params->line_num_range.min;
line_num < params->line_num_range.max;
@@ -11029,7 +11022,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
}
}
}
dbgi_scope_close(scope);
di_scope_close(scope);
}
//////////////////////////////
@@ -11257,11 +11250,11 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(params->line_src2dasm[line_slice_idx].first != 0 &&
params->line_src2dasm[line_slice_idx].first->v.remap_line == mouse_pt.line)
{
df_set_hovered_line_info(params->line_src2dasm[line_slice_idx].first->v.binary, params->line_src2dasm[line_slice_idx].first->v.voff_range.min);
df_set_hovered_line_info(params->line_src2dasm[line_slice_idx].first->v.dbgi, params->line_src2dasm[line_slice_idx].first->v.voff_range.min);
}
if(params->line_dasm2src[line_slice_idx].first != 0)
{
df_set_hovered_line_info(params->line_dasm2src[line_slice_idx].first->v.binary, params->line_dasm2src[line_slice_idx].first->v.voff_range.min);
df_set_hovered_line_info(params->line_dasm2src[line_slice_idx].first->v.dbgi, params->line_dasm2src[line_slice_idx].first->v.voff_range.min);
}
}
@@ -11399,7 +11392,6 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
}
if(dasm2src_info != 0)
{
DF_Entity *binary = dasm2src_info->binary;
has_line_info = 1;
line_info_line_num = dasm2src_info->pt.line;
line_info_t = selected_thread_module->alive_t;
@@ -11426,7 +11418,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
//
UI_Parent(text_container_box) ProfScope("build line text") UI_Focus(UI_FocusKind_Off)
{
DF_Entity *hovered_line_binary = df_get_hovered_line_info_binary();
DF_Entity *hovered_line_dbgi = df_get_hovered_line_info_dbgi();
U64 hovered_line_voff = df_get_hovered_line_info_voff();
ui_set_next_pref_height(ui_px(params->line_height_px*(dim_1s64(params->line_num_range)+1), 1.f));
UI_WidthFill
@@ -11501,12 +11493,12 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
if(token->kind == TXT_TokenKind_Identifier || token->kind == TXT_TokenKind_Keyword)
{
B32 mapped_special = 0;
for(DF_EntityNode *n = params->relevant_binaries.first; n != 0; n = n->next)
for(DF_EntityNode *n = params->relevant_dbgis.first; n != 0; n = n->next)
{
DF_Entity *binary = n->entity;
DF_Entity *dbgi = n->entity;
if(!mapped_special && token->kind == TXT_TokenKind_Identifier)
{
U64 voff = df_voff_from_binary_symbol_name(binary, token_string);
U64 voff = df_voff_from_dbgi_symbol_name(dbgi, token_string);
if(voff != 0)
{
mapped_special = 1;
@@ -11516,7 +11508,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
}
if(!mapped_special && token->kind == TXT_TokenKind_Identifier)
{
U64 type_num = df_type_num_from_binary_name(binary, token_string);
U64 type_num = df_type_num_from_dbgi_name(dbgi, token_string);
if(type_num != 0)
{
mapped_special = 1;
@@ -11708,7 +11700,7 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
for(DF_TextLineSrc2DasmInfoNode *n = src2dasm_list->first; n != 0; n = n->next)
{
if(n->v.remap_line == line_num &&
n->v.binary == hovered_line_binary &&
n->v.dbgi == hovered_line_dbgi &&
n->v.voff_range.min <= hovered_line_voff && hovered_line_voff < n->v.voff_range.max)
{
matches = 1;
@@ -11721,8 +11713,8 @@ df_code_slice(DF_Window *ws, DF_CtrlCtx *ctrl_ctx, EVAL_ParseCtx *parse_ctx, DF_
// rjf: check dasm2src
if(dasm2src_list->first != 0)
{
DF_Entity *binary = dasm2src_list->first->v.binary;
if(binary == hovered_line_binary)
DF_Entity *dbgi = dasm2src_list->first->v.dbgi;
if(dbgi == hovered_line_dbgi)
{
for(DF_TextLineDasm2SrcInfoNode *n = dasm2src_list->first; n != 0; n = n->next)
{
@@ -13829,7 +13821,7 @@ df_gfx_end_frame(void)
//- rjf: clear hover line info
if(df_gfx_state->hover_line_set_this_frame == 0)
{
df_gfx_state->hover_line_binary = df_handle_zero();
df_gfx_state->hover_line_dbgi = df_handle_zero();
df_gfx_state->hover_line_voff = 0;
}