mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-22 19:54:59 -07:00
fix incorrect assumption of 0 slot -> primary rdi; fixes mistyped locals
This commit is contained in:
@@ -4643,10 +4643,11 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
}
|
||||
|
||||
// rjf: gather debug infos
|
||||
U64 rdis_count = all_modules_count;
|
||||
U64 rdis_count = Max(1, all_modules_count);
|
||||
RDI_Parsed **rdis = push_array(temp.arena, RDI_Parsed *, rdis_count);
|
||||
rdis[0] = &di_rdi_parsed_nil;
|
||||
Rng1U64 *rdis_vaddr_ranges = push_array(temp.arena, Rng1U64, rdis_count);
|
||||
RDI_Parsed *rdi_primary = &di_rdi_parsed_nil;
|
||||
U64 rdis_primary_idx = 0;
|
||||
ProfScope("gather debug infos")
|
||||
{
|
||||
U64 primary_idx = 0;
|
||||
@@ -4671,7 +4672,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
// rjf: pick primary module
|
||||
if(m == module)
|
||||
{
|
||||
rdi_primary = rdis[idx];
|
||||
rdis_primary_idx = idx;
|
||||
}
|
||||
|
||||
// rjf: inc
|
||||
@@ -4686,8 +4687,8 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
ctx->arch = arch;
|
||||
ctx->ip_vaddr = thread_rip_vaddr;
|
||||
ctx->ip_voff = thread_rip_voff;
|
||||
ctx->rdi_primary = rdi_primary;
|
||||
ctx->rdis_count = rdis_count;
|
||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
||||
ctx->rdis = rdis;
|
||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
||||
}
|
||||
@@ -4700,14 +4701,14 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
ctx->arch = arch;
|
||||
ctx->ip_vaddr = thread_rip_vaddr;
|
||||
ctx->ip_voff = thread_rip_voff;
|
||||
ctx->rdi_primary = rdi_primary;
|
||||
ctx->rdis_count = rdis_count;
|
||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
||||
ctx->rdis = rdis;
|
||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
||||
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
||||
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
|
||||
ctx->locals_map = e_push_locals_map_from_rdi_voff(temp.arena, ctx->rdi_primary, thread_rip_voff);
|
||||
ctx->member_map = e_push_member_map_from_rdi_voff(temp.arena, ctx->rdi_primary, thread_rip_voff);
|
||||
ctx->locals_map = e_push_locals_map_from_rdi_voff(temp.arena, ctx->rdis[ctx->rdis_primary_idx], thread_rip_voff);
|
||||
ctx->member_map = e_push_member_map_from_rdi_voff(temp.arena, ctx->rdis[ctx->rdis_primary_idx], thread_rip_voff);
|
||||
}
|
||||
|
||||
// rjf: build eval IR context
|
||||
|
||||
@@ -8561,10 +8561,11 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
DF_EntityList all_modules = df_query_cached_entity_list_with_kind(DF_EntityKind_Module);
|
||||
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
|
||||
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(df_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
|
||||
U64 rdis_count = all_modules.count;
|
||||
U64 rdis_count = Max(1, all_modules.count);
|
||||
RDI_Parsed **rdis = push_array(arena, RDI_Parsed *, rdis_count);
|
||||
rdis[0] = &di_rdi_parsed_nil;
|
||||
U64 rdis_primary_idx = 0;
|
||||
Rng1U64 *rdis_vaddr_ranges = push_array(arena, Rng1U64, rdis_count);
|
||||
RDI_Parsed *rdi_primary = &di_rdi_parsed_nil;
|
||||
DI_Key primary_dbgi_key = {0};
|
||||
{
|
||||
U64 idx = 0;
|
||||
@@ -8576,7 +8577,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
if(n->entity == module)
|
||||
{
|
||||
primary_dbgi_key = dbgi_key;
|
||||
rdi_primary = rdis[idx];
|
||||
rdis_primary_idx = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8588,8 +8589,8 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
ctx->arch = arch;
|
||||
ctx->ip_vaddr = rip_vaddr;
|
||||
ctx->ip_voff = rip_voff;
|
||||
ctx->rdi_primary = rdi_primary;
|
||||
ctx->rdis_count = rdis_count;
|
||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
||||
ctx->rdis = rdis;
|
||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
||||
}
|
||||
@@ -8603,8 +8604,8 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
||||
ctx->arch = arch;
|
||||
ctx->ip_vaddr = rip_vaddr;
|
||||
ctx->ip_voff = rip_voff;
|
||||
ctx->rdi_primary = rdi_primary;
|
||||
ctx->rdis_count = rdis_count;
|
||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
||||
ctx->rdis = rdis;
|
||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
||||
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
||||
|
||||
@@ -44,7 +44,7 @@ e_autoresolved_eval_from_eval(E_Eval eval)
|
||||
{
|
||||
U64 vaddr = eval.value.u64;
|
||||
U64 voff = vaddr - e_interpret_ctx->module_base[0];
|
||||
RDI_Parsed *rdi = e_parse_ctx->rdi_primary;
|
||||
RDI_Parsed *rdi = e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx];
|
||||
RDI_Scope *scope = rdi_scope_from_voff(rdi, voff);
|
||||
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff);
|
||||
RDI_GlobalVariable *gvar = rdi_global_variable_from_voff(rdi, voff);
|
||||
|
||||
@@ -1178,12 +1178,12 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
//- rjf: form namespaceified fallback versions of this lookup string
|
||||
String8List namespaceified_token_strings = {0};
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(e_parse_ctx->rdi_primary, RDI_SectionKind_ScopeVMap, e_parse_ctx->ip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(e_parse_ctx->rdi_primary, Scopes, scope_idx);
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], RDI_SectionKind_ScopeVMap, e_parse_ctx->ip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Scopes, scope_idx);
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(e_parse_ctx->rdi_primary, Procedures, proc_idx);
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Procedures, proc_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(e_parse_ctx->rdi_primary, procedure->name_string_idx, &name_size);
|
||||
U8 *name_ptr = rdi_string_from_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], procedure->name_string_idx, &name_size);
|
||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||
U64 last_past_scope_resolution_pos = 0;
|
||||
for(;;)
|
||||
@@ -1221,20 +1221,20 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(e_parse_ctx->rdi_primary, Locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(e_parse_ctx->rdi_primary, TypeNodes, local_var->type_idx);
|
||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), local_var->type_idx, 0);
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], TypeNodes, local_var->type_idx);
|
||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), local_var->type_idx, (U32)e_parse_ctx->rdis_primary_idx);
|
||||
|
||||
// rjf: grab location info
|
||||
for(U32 loc_block_idx = local_var->location_first;
|
||||
loc_block_idx < local_var->location_opl;
|
||||
loc_block_idx += 1)
|
||||
{
|
||||
RDI_LocationBlock *block = rdi_element_from_name_idx(e_parse_ctx->rdi_primary, LocationBlocks, loc_block_idx);
|
||||
RDI_LocationBlock *block = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], LocationBlocks, loc_block_idx);
|
||||
if(block->scope_off_first <= e_parse_ctx->ip_voff && e_parse_ctx->ip_voff < block->scope_off_opl)
|
||||
{
|
||||
U64 all_location_data_size = 0;
|
||||
U8 *all_location_data = rdi_table_from_name(e_parse_ctx->rdi_primary, LocationData, &all_location_data_size);
|
||||
U8 *all_location_data = rdi_table_from_name(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], LocationData, &all_location_data_size);
|
||||
loc_kind = *((RDI_LocationKind *)(all_location_data + block->location_data_off));
|
||||
switch(loc_kind)
|
||||
{
|
||||
|
||||
@@ -192,19 +192,19 @@ struct E_ParseCtx
|
||||
|
||||
// rjf: instruction pointer info
|
||||
U64 ip_vaddr;
|
||||
U64 ip_voff; // (within module, which uses `rdi_primary` for debug info)
|
||||
U64 ip_voff; // (within module, which uses `rdis[rdis_primary_idx]` for debug info)
|
||||
|
||||
// rjf: debug info
|
||||
RDI_Parsed *rdi_primary;
|
||||
RDI_Parsed **rdis;
|
||||
Rng1U64 *rdis_vaddr_ranges;
|
||||
U64 rdis_count;
|
||||
U64 rdis_primary_idx;
|
||||
|
||||
// rjf: identifier resolution maps
|
||||
E_String2NumMap *regs_map;
|
||||
E_String2NumMap *reg_alias_map;
|
||||
E_String2NumMap *locals_map; // (within `rdi_primary`)
|
||||
E_String2NumMap *member_map; // (within `rdi_primary`)
|
||||
E_String2NumMap *locals_map; // (within `rdis[rdis_primary_idx]`)
|
||||
E_String2NumMap *member_map; // (within `rdis[rdis_primary_idx]`)
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -160,13 +160,13 @@ struct E_TypeCtx
|
||||
|
||||
// rjf: instruction pointer info
|
||||
U64 ip_vaddr;
|
||||
U64 ip_voff; // (within module, which uses `rdi_primary` for debug info)
|
||||
U64 ip_voff; // (within module, which uses `rdis[rdis_primary_idx]` for debug info)
|
||||
|
||||
// rjf: debug info
|
||||
RDI_Parsed *rdi_primary;
|
||||
RDI_Parsed **rdis;
|
||||
Rng1U64 *rdis_vaddr_ranges;
|
||||
U64 rdis_count;
|
||||
U64 rdis_primary_idx;
|
||||
};
|
||||
|
||||
typedef struct E_TypeState E_TypeState;
|
||||
|
||||
Reference in New Issue
Block a user