deduplication from evaluation ctxs - just have base ctx with deduplicated info, then separate type-state, ir-ctx, and interpretation-ctx

This commit is contained in:
Ryan Fleury
2025-04-23 11:49:44 -07:00
parent 0ce85082ec
commit 264dbc8199
18 changed files with 546 additions and 697 deletions
-129
View File
@@ -613,135 +613,6 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
////////////////////////////////
//~ rjf: Debug Info Lookups
//- rjf: symbol lookups
internal String8
d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, U64 depth, B32 decorated)
{
String8 result = {0};
{
Temp scratch = scratch_begin(&arena, 1);
DI_Scope *scope = di_scope_open();
RDI_Parsed *rdi = di_rdi_from_key(scope, dbgi_key, 0);
//- rjf: try scopes
if(result.size == 0)
{
// rjf: voff -> scope
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
// rjf: scope -> # of max possible inline depth
U64 inline_site_count = 0;
for(U64 s_idx = scope_idx, s_idx_next = 0; s_idx != 0; s_idx = s_idx_next)
{
RDI_Scope *s = rdi_element_from_name_idx(rdi, Scopes, s_idx);
s_idx_next = s->parent_scope_idx;
if(s->inline_site_idx != 0)
{
inline_site_count += 1;
}
else
{
break;
}
}
// rjf: depth in [1, max]? -> form name from inline site
if(0 < depth && depth <= inline_site_count)
{
RDI_InlineSite *inline_site = 0;
U64 s_inline_depth = inline_site_count;
for(U64 s_idx = scope_idx, s_idx_next = 0; s_idx != 0; s_idx = s_idx_next)
{
RDI_Scope *s = rdi_element_from_name_idx(rdi, Scopes, s_idx);
s_idx_next = s->parent_scope_idx;
if(s_inline_depth == depth)
{
inline_site = rdi_element_from_name_idx(rdi, InlineSites, s->inline_site_idx);
break;
}
s_inline_depth -= 1;
if(s_inline_depth == 0)
{
break;
}
}
if(inline_site != 0)
{
E_TypeKey type = e_type_key_ext(E_TypeKind_Function, inline_site->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
String8 name = {0};
name.str = rdi_string_from_idx(rdi, inline_site->name_string_idx, &name.size);
if(decorated && inline_site->type_idx != 0)
{
String8List list = {0};
str8_list_pushf(scratch.arena, &list, "[inlined] ");
e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0);
str8_list_push(scratch.arena, &list, name);
e_type_rhs_string_from_key(scratch.arena, type, &list, 0);
result = str8_list_join(arena, &list, 0);
}
else
{
result = push_str8_copy(arena, name);
}
}
}
// rjf: depth == 0 or depth >= max? -> form name from scope procedure
else
{
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
U64 proc_idx = scope->proc_idx;
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
E_TypeKey type = e_type_key_ext(E_TypeKind_Function, procedure->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
String8 name = {0};
name.str = rdi_string_from_idx(rdi, procedure->name_string_idx, &name.size);
if(decorated && procedure->type_idx != 0)
{
String8List list = {0};
e_type_lhs_string_from_key(scratch.arena, type, &list, 0, 0);
str8_list_push(scratch.arena, &list, name);
e_type_rhs_string_from_key(scratch.arena, type, &list, 0);
result = str8_list_join(arena, &list, 0);
}
else
{
result = push_str8_copy(arena, name);
}
}
}
//- rjf: try global variables
if(result.size == 0)
{
U64 global_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_GlobalVMap, voff);
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(rdi, GlobalVariables, global_idx);
U64 name_size = 0;
U8 *name_ptr = rdi_string_from_idx(rdi, global_var->name_string_idx, &name_size);
result = push_str8_copy(arena, str8(name_ptr, name_size));
}
di_scope_close(scope);
scratch_end(scratch);
}
return result;
}
internal String8
d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, U64 depth, B32 decorated)
{
ProfBeginFunction();
String8 result = {0};
{
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
result = d_symbol_name_from_dbgi_key_voff(arena, &dbgi_key, voff, depth, decorated);
}
ProfEnd();
return result;
}
//- rjf: symbol -> voff lookups
internal U64
-4
View File
@@ -395,10 +395,6 @@ internal CTRL_TrapList d_trap_net_from_thread__step_into_line(Arena *arena, CTRL
////////////////////////////////
//~ rjf: Debug Info Lookups
//- rjf: voff|vaddr -> symbol lookups
internal String8 d_symbol_name_from_dbgi_key_voff(Arena *arena, DI_Key *dbgi_key, U64 voff, U64 depth, B32 decorated);
internal String8 d_symbol_name_from_process_vaddr(Arena *arena, CTRL_Entity *process, U64 vaddr, U64 depth, B32 decorated);
//- rjf: symbol -> voff lookups
internal U64 d_voff_from_dbgi_key_symbol_name(DI_Key *dbgi_key, String8 symbol_name);
internal U64 d_type_num_from_dbgi_key_name(DI_Key *dbgi_key, String8 name);