linux_demon: eliminate active-trap layer; do pre-trap instruction memory read in one batch before doing write, robustly handles duplicates; eliminate deduplication inside linux demon (ultimately we want to deduplicate traps sent by the dbg engine, but we should just dedup at that layer, long before the set of traps ever reaches the demon backend)

This commit is contained in:
Ryan Fleury committed 2026-08-10 14:20:22 -06:00
1 parent 9f83e388d2
commit 6b30c395d7
3 files changed
+104 -78

No files matched your search

+22 -3
View File
@@ -1685,10 +1685,30 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
}
}
//////////////////////////
//- rjf: read all initial memory at trap locations
//
U8 *trap_swap_bytes = push_array(scratch.arena, U8, ctrls->traps.trap_count);
{
U64 trap_idx = 0;
for(DMN_TrapChunkNode *n = ctrls->traps.first; n != 0; n = n->next)
{
for(U64 n_idx = 0; n_idx < n->count; n_idx += 1, trap_idx += 1)
{
DMN_Trap *trap = n->v+n_idx;
if(trap->flags == 0)
{
// TODO(rjf): assumes x86
trap_swap_bytes[trap_idx] = 0xCC;
dmn_process_read(trap->process, r1u64(trap->vaddr, trap->vaddr+1), trap_swap_bytes+trap_idx);
}
}
}
}
//////////////////////////
//- rjf: write all traps into memory
//
U8 *trap_swap_bytes = push_array_no_zero(scratch.arena, U8, ctrls->traps.trap_count);
ProfScope("write all traps into memory")
{
U64 trap_idx = 0;
@@ -1699,8 +1719,7 @@ dmn_ctrl_run(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls)
DMN_Trap *trap = n->v+n_idx;
if(trap->flags == 0)
{
trap_swap_bytes[trap_idx] = 0xCC;
dmn_process_read(trap->process, r1u64(trap->vaddr, trap->vaddr+1), trap_swap_bytes+trap_idx);
// TODO(rjf): assumes x86
U8 int3 = 0xCC;
dmn_process_write(trap->process, r1u64(trap->vaddr, trap->vaddr+1), &int3);
}