mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 22:08:41 +00:00
initialize frame base in interp context
This commit is contained in:
@@ -5513,9 +5513,10 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
ctx->reg_space.u64_0 = (U64)thread;
|
ctx->reg_space.u64_0 = (U64)thread;
|
||||||
ctx->module_base = push_array(temp.arena, U64, 1);
|
ctx->module_base = push_array(temp.arena, U64, 1);
|
||||||
ctx->module_base[0]= module->vaddr_range.min;
|
ctx->module_base[0]= module->vaddr_range.min;
|
||||||
|
ctx->frame_base = push_array(temp.arena, U64, 1);
|
||||||
ctx->tls_base = push_array(temp.arena, U64, 1);
|
ctx->tls_base = push_array(temp.arena, U64, 1);
|
||||||
}
|
}
|
||||||
e_select_interpret_ctx(&interpret_ctx);
|
e_select_interpret_ctx(&interpret_ctx, type_ctx.primary_module->rdi, type_ctx.ip_voff);
|
||||||
|
|
||||||
// rjf: evaluate
|
// rjf: evaluate
|
||||||
E_Eval eval = zero_struct;
|
E_Eval eval = zero_struct;
|
||||||
|
|||||||
@@ -11,9 +11,50 @@ e_selected_interpret_ctx(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
e_select_interpret_ctx(E_InterpretCtx *ctx)
|
e_select_interpret_ctx(E_InterpretCtx *ctx, RDI_Parsed *primary_rdi, U64 ip_voff)
|
||||||
{
|
{
|
||||||
e_interpret_ctx = ctx;
|
e_interpret_ctx = ctx;
|
||||||
|
|
||||||
|
// compute and apply frame base
|
||||||
|
{
|
||||||
|
E_Interpretation frame_base = { .code = ~0 };
|
||||||
|
|
||||||
|
RDI_Procedure *proc = rdi_procedure_from_voff(primary_rdi, ip_voff);
|
||||||
|
for(U64 loc_block_idx = proc->frame_base_location_first; loc_block_idx < proc->frame_base_location_opl; loc_block_idx += 1)
|
||||||
|
{
|
||||||
|
RDI_LocationBlock *block = rdi_element_from_name_idx(primary_rdi, LocationBlocks, loc_block_idx);
|
||||||
|
if (block->scope_off_first <= ip_voff && ip_voff < block->scope_off_opl) {
|
||||||
|
U64 all_location_data_size = 0;
|
||||||
|
U8 *all_location_data = rdi_table_from_name(primary_rdi, LocationData, &all_location_data_size);
|
||||||
|
if(block->location_data_off + sizeof(RDI_LocationKind) <= all_location_data_size)
|
||||||
|
{
|
||||||
|
RDI_LocationKind loc_kind = *(RDI_LocationKind *)(all_location_data + block->location_data_off);
|
||||||
|
if(loc_kind == RDI_LocationKind_ValBytecodeStream || loc_kind == RDI_LocationKind_AddrBytecodeStream)
|
||||||
|
{
|
||||||
|
U8 *bytecode_ptr = all_location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||||
|
U8 *bytecode_opl = all_location_data + all_location_data_size;
|
||||||
|
U64 bytecode_size = rdi_size_from_bytecode_stream(bytecode_ptr, bytecode_opl);
|
||||||
|
String8 bytecode = str8(bytecode_ptr, bytecode_size);
|
||||||
|
frame_base = e_interpret(bytecode);
|
||||||
|
}
|
||||||
|
else if(loc_kind != RDI_LocationKind_NULL)
|
||||||
|
{
|
||||||
|
NotImplemented;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(frame_base.code == E_InterpretationCode_Good)
|
||||||
|
{
|
||||||
|
*ctx->frame_base = frame_base.value.u64;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx->frame_base = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ thread_static E_InterpretCtx *e_interpret_ctx = 0;
|
|||||||
//~ rjf: Context Selection Functions (Selection Required For All Subsequent APIs)
|
//~ rjf: Context Selection Functions (Selection Required For All Subsequent APIs)
|
||||||
|
|
||||||
internal E_InterpretCtx *e_selected_interpret_ctx(void);
|
internal E_InterpretCtx *e_selected_interpret_ctx(void);
|
||||||
internal void e_select_interpret_ctx(E_InterpretCtx *ctx);
|
internal void e_select_interpret_ctx(E_InterpretCtx *ctx, RDI_Parsed *primary_rdi, U64 ip_voff);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Space Reading Helpers
|
//~ rjf: Space Reading Helpers
|
||||||
|
|||||||
@@ -12159,10 +12159,11 @@ rd_frame(void)
|
|||||||
ctx->reg_unwind_count = unwind_count;
|
ctx->reg_unwind_count = unwind_count;
|
||||||
ctx->module_base = push_array(scratch.arena, U64, 1);
|
ctx->module_base = push_array(scratch.arena, U64, 1);
|
||||||
ctx->module_base[0] = module->vaddr_range.min;
|
ctx->module_base[0] = module->vaddr_range.min;
|
||||||
|
ctx->frame_base = push_array(scratch.arena, U64, 1);
|
||||||
ctx->tls_base = push_array(scratch.arena, U64, 1);
|
ctx->tls_base = push_array(scratch.arena, U64, 1);
|
||||||
ctx->tls_base[0] = d_query_cached_tls_base_vaddr_from_process_root_rip(process, tls_root_vaddr, rip_vaddr);
|
ctx->tls_base[0] = d_query_cached_tls_base_vaddr_from_process_root_rip(process, tls_root_vaddr, rip_vaddr);
|
||||||
}
|
}
|
||||||
e_select_interpret_ctx(interpret_ctx);
|
e_select_interpret_ctx(interpret_ctx, eval_modules_primary->rdi, rip_voff);
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
//- rjf: build eval visualization view rule table
|
//- rjf: build eval visualization view rule table
|
||||||
|
|||||||
Reference in New Issue
Block a user