raddbg: explicit packet headers for ipc; render_opengl: fix bad scissoring; linux_socket: fix not waking up, fix SIGPIPE; dbg_engine: checkpoint on sketching out multi-demon attaching abstraction, machine ID -> demon ID

This commit is contained in:
Ryan Fleury committed 2026-10-06 18:10:49 -06:00
1 parent 7da38c5f3b
commit 98467d0868
12 files changed
+230 -88

No files matched your search

+3 -3
View File
@@ -22,7 +22,7 @@ struct D_Eval
//~ rjf: ID Types
typedef U64 D_MsgID;
typedef U32 D_MachineID;
typedef U32 D_DemonID;
typedef U32 D_ControllerKind;
typedef enum D_ControllerKindEnum
{
@@ -31,7 +31,7 @@ typedef enum D_ControllerKindEnum
}
D_ControllerKindEnum;
#define D_MachineID_Local (1)
#define D_DemonID_LocalHost (1)
////////////////////////////////
//~ rjf: Entity Handle Types
@@ -39,7 +39,7 @@ D_ControllerKindEnum;
typedef struct D_Handle D_Handle;
struct D_Handle
{
D_MachineID machine_id;
D_DemonID demon_id;
D_ControllerKind controller_kind;
U64 entity_id;
};
+78 -51
View File
@@ -1,13 +1,40 @@
// Copyright (c) Epic Games Tools
// Licensed under the MIT license (https://opensource.org/license/mit/)
////////////////////////////////
//~ rjf: Local Host Demon Interface
D_DemonInterface d_local_demon =
{
dmn_ctrl_exclusive_access_begin,
dmn_ctrl_exclusive_access_end,
dmn_ctrl_launch,
dmn_ctrl_attach,
dmn_ctrl_kill,
dmn_ctrl_detach,
dmn_ctrl_run,
dmn_halt,
dmn_access_open,
dmn_access_close,
dmn_process_memory_reserve,
dmn_process_memory_commit,
dmn_process_memory_decommit,
dmn_process_memory_release,
dmn_process_memory_protect,
dmn_process_read,
dmn_process_write,
dmn_thread_read_reg_block,
dmn_thread_write_reg_block,
dmn_thread_get_module_tls_vaddr,
};
////////////////////////////////
//~ rjf: Basic Type Functions
internal U64
d_hash_from_handle(D_Handle handle)
{
U64 buf[] = {handle.machine_id, handle.controller_kind, handle.entity_id};
U64 buf[] = {handle.demon_id, handle.controller_kind, handle.entity_id};
U64 hash = u64_hash_from_str8(str8_struct(&handle));
return hash;
}
@@ -182,7 +209,7 @@ d_handle_array_from_list(Arena *arena, D_HandleList *src)
internal String8
d_string_from_handle(Arena *arena, D_Handle handle)
{
String8 result = str8f(arena, "$%x$%x$%I64x", handle.machine_id, handle.controller_kind, handle.entity_id);
String8 result = str8f(arena, "$%x$%x$%I64x", handle.demon_id, handle.controller_kind, handle.entity_id);
return result;
}
@@ -196,10 +223,10 @@ d_handle_from_string(String8 string)
String8List parts = str8_split(scratch.arena, string, &split, 1, 0);
if(parts.first && parts.first->next && parts.first->next->next)
{
D_MachineID machine_id = (U32)u64_from_str8(parts.first->string, 16);
D_DemonID demon_id = (U32)u64_from_str8(parts.first->string, 16);
D_ControllerKind controller_kind = (U32)u64_from_str8(parts.first->next->string, 16);
U64 entity_id = u64_from_str8(parts.first->next->next->string, 16);
handle.machine_id = machine_id;
handle.demon_id = demon_id;
handle.controller_kind = controller_kind;
handle.entity_id = entity_id;
}
@@ -220,11 +247,11 @@ d_dmn_from_handle(D_Handle handle)
}
internal D_Handle
d_handle_from_dmn(D_MachineID machine_id, DMN_Handle handle)
d_handle_from_dmn(D_DemonID demon_id, DMN_Handle handle)
{
D_Handle result = {0};
{
result.machine_id = machine_id;
result.demon_id = demon_id;
result.controller_kind = D_ControllerKind_Demon;
result.entity_id = handle.u64[0];
}
@@ -232,11 +259,11 @@ d_handle_from_dmn(D_MachineID machine_id, DMN_Handle handle)
}
internal D_Handle
d_dump_handle_make(D_MachineID machine_id, U64 id)
d_dump_handle_make(D_DemonID demon_id, U64 id)
{
D_Handle result = {0};
{
result.machine_id = machine_id;
result.demon_id = demon_id;
result.controller_kind = D_ControllerKind_Dump;
result.entity_id = id;
}
@@ -915,7 +942,7 @@ d_entity_ctx_rw_store_alloc(void)
store->ctx.hash_slots_count = 1024;
store->ctx.hash_slots = push_array(arena, D_EntityHashSlot, store->ctx.hash_slots_count);
D_Entity *root = store->ctx.root = d_entity_alloc(store, &d_entity_nil, D_EntityKind_Root, Arch_Null, d_handle_zero(), 0);
D_Entity *local_machine = d_entity_alloc(store, root, D_EntityKind_Machine, Arch_CURRENT, d_handle_from_dmn(D_MachineID_Local, dmn_handle_zero()), 0);
D_Entity *local_machine = d_entity_alloc(store, root, D_EntityKind_Machine, Arch_CURRENT, d_handle_from_dmn(D_DemonID_LocalHost, dmn_handle_zero()), 0);
Temp scratch = scratch_begin(0, 0);
String8 local_machine_name = push_str8f(scratch.arena, "This PC (%S)", get_system_info()->machine_name);
d_entity_equip_string(store, local_machine, local_machine_name);
@@ -1306,7 +1333,7 @@ d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list)
//- rjf: processes
case D_EventKind_NewProc:
{
D_Entity *machine = d_entity_from_handle(d_handle_from_dmn(event->entity.machine_id, dmn_handle_zero()));
D_Entity *machine = d_entity_from_handle(d_handle_from_dmn(event->entity.demon_id, dmn_handle_zero()));
if(machine != &d_entity_nil)
{
D_Entity *process = d_entity_alloc(store, machine, D_EntityKind_Process, event->arch, event->entity, (U64)event->entity_id);
@@ -2934,7 +2961,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
(spoof == 0 || ev->instruction_pointer != spoof->new_ip_value))
{
Access *access = access_open();
D_Handle process_handle = d_handle_from_dmn(D_MachineID_Local, ev->process);
D_Handle process_handle = d_handle_from_dmn(D_DemonID_LocalHost, ev->process);
D_Entity *process = d_entity_from_handle(process_handle);
D_Entity *module = d_module_from_process_vaddr(process, ev->instruction_pointer);
if(module != &d_entity_nil)
@@ -3135,7 +3162,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_NewProc;
out_evt->msg_id = msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->arch = event->arch;
out_evt->entity_id = event->code;
out_evt->os = OperatingSystem_CURRENT; // TODO: operating system of the remote target machine
@@ -3148,8 +3175,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_NewThread;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->arch = event->arch;
out_evt->entity_id = event->code;
out_evt->stack_base = event->stack_pointer;
@@ -3164,8 +3191,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
Temp scratch2 = scratch_begin(&scratch.arena, 1);
//- rjf: unpack module
D_Handle process_handle = d_handle_from_dmn(D_MachineID_Local, event->process);
D_Handle module_handle = d_handle_from_dmn(D_MachineID_Local, event->module);
D_Handle process_handle = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
D_Handle module_handle = d_handle_from_dmn(D_DemonID_LocalHost, event->module);
String8 module_path = path_normalized_from_string(scratch2.arena, event->string);
U64 exe_timestamp = properties_from_file_path(module_path).modified;
DMN_ModuleInfo *module_info = event->module_info;
@@ -3330,7 +3357,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_EndProc;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->u64_code = event->code;
d_ctrl_state->process_counter -= 1;
}break;
@@ -3341,7 +3368,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_EndThread;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->entity_id = event->code;
}break;
@@ -3349,7 +3376,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
case DMN_EventKind_UnloadModule:
{
//- rjf: unpack module
D_Handle module_handle = d_handle_from_dmn(D_MachineID_Local, event->module);
D_Handle module_handle = d_handle_from_dmn(D_DemonID_LocalHost, event->module);
D_Entity *module_ent = d_entity_from_handle(module_handle);
D_Entity *process_ent = d_process_from_entity(module_ent);
String8 module_path = event->string;
@@ -3386,8 +3413,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_DebugString;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->string = str8_substr(event->string, r1u64(string_idx*d_ctrl_state->c2u_ring_max_string_size, (string_idx+1)*d_ctrl_state->c2u_ring_max_string_size));
}
}break;
@@ -3398,8 +3425,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_ThreadName;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->string = event->string;
out_evt->entity_id = event->code;
}break;
@@ -3410,8 +3437,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_ThreadColor;
out_evt->msg_id = msg->msg_id;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->entity_id = event->code;
out_evt->rgba = event->user_data;
}break;
@@ -3421,7 +3448,7 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
{
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_SetVAddrRangeNote;
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->msg_id = msg->msg_id;
out_evt->vaddr_rng = r1u64(event->address, event->address + event->size);
out_evt->string = event->string;
@@ -3432,8 +3459,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
{
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_SetBreakpoint;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->vaddr_rng = r1u64(event->address, event->address+event->size);
out_evt->bp_flags = d_breakpoint_flags_from_dmn_trap_flags(event->flags);
}break;
@@ -3444,8 +3471,8 @@ d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, D
// TODO(rjf): this needs to be reflected in the resolved trap list too!!!!!!!!
D_Event *out_evt = d_event_list_push(scratch.arena, &evts);
out_evt->kind = D_EventKind_UnsetBreakpoint;
out_evt->entity = d_handle_from_dmn(D_MachineID_Local, event->thread);
out_evt->parent = d_handle_from_dmn(D_MachineID_Local, event->process);
out_evt->entity = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
out_evt->parent = d_handle_from_dmn(D_DemonID_LocalHost, event->process);
out_evt->vaddr_rng = r1u64(event->address, event->address+event->size);
out_evt->bp_flags = d_breakpoint_flags_from_dmn_trap_flags(event->flags);
}break;
@@ -4111,7 +4138,7 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
// rjf: create process handle
d_ctrl_state->ctrl_thread_dump_handle_id_gen += 1;
process = d_dump_handle_make(D_MachineID_Local, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
process = d_dump_handle_make(D_DemonID_LocalHost, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
// rjf: gather threads
dump_threads_count = threads_count;
@@ -4128,7 +4155,7 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
{
d_ctrl_state->ctrl_thread_dump_handle_id_gen += 1;
MDMP_Thread *thread = &threads[idx];
D_Handle thread_handle = d_dump_handle_make(D_MachineID_Local, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
D_Handle thread_handle = d_dump_handle_make(D_DemonID_LocalHost, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
dump_threads[idx].thread_handle = thread_handle;
dump_threads[idx].id = thread->id;
dump_threads[idx].context_foff = thread->thread_context.foff;
@@ -4233,7 +4260,7 @@ d_ctrl_thread__open_crash_dump(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
// rjf: store
d_ctrl_state->ctrl_thread_dump_handle_id_gen += 1;
dump_modules[idx].module_handle = d_dump_handle_make(D_MachineID_Local, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
dump_modules[idx].module_handle = d_dump_handle_make(D_DemonID_LocalHost, d_ctrl_state->ctrl_thread_dump_handle_id_gen);
dump_modules[idx].vaddr_range = vaddr_range;
dump_modules[idx].path = str8_copy(arena, module_name);
dump_modules[idx].file = module_file;
@@ -4589,7 +4616,7 @@ d_ctrl_thread__kill_all(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
default:{}break;
case DMN_EventKind_CreateProcess:
{
D_Entity *new_process = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->process));
D_Entity *new_process = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->process));
Task *t = push_array(scratch.arena, Task, 1);
t->process = new_process;
DLLPushBack(first_task, last_task, t);
@@ -4810,7 +4837,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
node != 0;
node = node->next)
{
D_Handle thread = d_handle_from_dmn(D_MachineID_Local, node->v);
D_Handle thread = d_handle_from_dmn(D_DemonID_LocalHost, node->v);
U64 thread_pre_rip = d_ip_from_thread(thread);
U64 thread_post_rip = thread_pre_rip;
for(B32 done = 0; !done;)
@@ -4829,7 +4856,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
{
default:{}break;
case DMN_EventKind_ExitThread:
if(d_handle_match(d_handle_from_dmn(D_MachineID_Local, event->thread), thread))
if(d_handle_match(d_handle_from_dmn(D_DemonID_LocalHost, event->thread), thread))
{
stop_cause = D_EventCause_Error;
goto stop;
@@ -4992,7 +5019,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
D_EvalScope *eval_scope = d_ctrl_thread__eval_scope_begin(scratch.arena, &msg->user_bps, &d_entity_nil);
{
DMN_TrapChunkList new_traps = {0};
d_ctrl_thread__append_resolved_process_user_bp_traps(scratch.arena, eval_scope, d_handle_from_dmn(D_MachineID_Local, event->process), &msg->user_bps, &new_traps);
d_ctrl_thread__append_resolved_process_user_bp_traps(scratch.arena, eval_scope, d_handle_from_dmn(D_DemonID_LocalHost, event->process), &msg->user_bps, &new_traps);
log_infof("step_rule: create_process -> resolve traps\n");
log_infof("new_traps:\n{\n");
for(DMN_TrapChunkNode *n = new_traps.first; n != 0; n = n->next)
@@ -5011,11 +5038,11 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
}break;
case DMN_EventKind_LoadModule:
{
D_Entity *thread = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->thread));
D_Entity *thread = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->thread));
D_EvalScope *eval_scope = d_ctrl_thread__eval_scope_begin(scratch.arena, &msg->user_bps, thread);
{
DMN_TrapChunkList new_traps = {0};
d_ctrl_thread__append_resolved_module_user_bp_traps(scratch.arena, eval_scope, d_handle_from_dmn(D_MachineID_Local, event->process), d_handle_from_dmn(D_MachineID_Local, event->module), &msg->user_bps, &new_traps);
d_ctrl_thread__append_resolved_module_user_bp_traps(scratch.arena, eval_scope, d_handle_from_dmn(D_DemonID_LocalHost, event->process), d_handle_from_dmn(D_DemonID_LocalHost, event->module), &msg->user_bps, &new_traps);
log_infof("step_rule: load_module -> resolve traps\n");
log_infof("new_traps:\n{\n");
for(DMN_TrapChunkNode *n = new_traps.first; n != 0; n = n->next)
@@ -5036,7 +5063,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
{
D_Entity *bp = &d_entity_nil;
{
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->process));
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->process));
for(D_Entity *child = process->first; child != &d_entity_nil; child = child->next)
{
if(child->kind == D_EntityKind_Breakpoint &&
@@ -5068,7 +5095,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
Access *access = access_open();
//- rjf: unpack process/module info
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->process));
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->process));
D_Entity *module = d_entity_child_from_kind(process, D_EntityKind_Module);
U64 module_base_vaddr = module->vaddr_range.min;
DI_Key dbgi_key = d_dbgi_key_from_module(module);
@@ -5294,8 +5321,8 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
//////////////////////////
//- rjf: unpack info about thread attached to event
//
D_Entity *thread = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->thread));
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_MachineID_Local, event->process));
D_Entity *thread = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->thread));
D_Entity *process = d_entity_from_handle(d_handle_from_dmn(D_DemonID_LocalHost, event->process));
Arch arch = thread->arch;
U64 thread_rip_vaddr = d_ip_from_thread(thread->handle);
D_Entity *module = d_module_from_process_vaddr(process, thread_rip_vaddr);
@@ -5483,7 +5510,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
D_EventCause cond_bp_single_step_stop_cause = D_EventCause_Null;
if(hit_conditional_bp_but_filtered) LogInfoNamedBlockF("conditional_bp_hit_single_step")
{
D_Handle thread = d_handle_from_dmn(D_MachineID_Local, event->thread);
D_Handle thread = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
U64 thread_pre_rip = d_ip_from_thread(thread);
U64 thread_post_rip = thread_pre_rip;
for(B32 single_step_done = 0; !single_step_done;)
@@ -5513,7 +5540,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
}break;
case DMN_EventKind_SingleStep:
{
single_step_done = d_handle_match(d_handle_from_dmn(D_MachineID_Local, event->thread), thread);
single_step_done = d_handle_match(d_handle_from_dmn(D_DemonID_LocalHost, event->thread), thread);
cond_bp_single_step_stop_cause = d_event_cause_from_dmn_event_kind(event->kind);
}break;
}
@@ -5674,7 +5701,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
D_EventCause step_past_trap_net_stop_cause = D_EventCause_Null;
if(step_past_trap_net) LogInfoNamedBlockF("trap_net__single_step_past_trap_net")
{
D_Handle thread = d_handle_from_dmn(D_MachineID_Local, event->thread);
D_Handle thread = d_handle_from_dmn(D_DemonID_LocalHost, event->thread);
U64 thread_pre_rip = d_ip_from_thread(thread);
U64 thread_post_rip = thread_pre_rip;
for(B32 single_step_done = 0; single_step_done == 0;)
@@ -5703,7 +5730,7 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
}break;
case DMN_EventKind_SingleStep:
{
single_step_done = d_handle_match(d_handle_from_dmn(D_MachineID_Local, event->thread), thread);
single_step_done = d_handle_match(d_handle_from_dmn(D_DemonID_LocalHost, event->thread), thread);
step_past_trap_net_stop_cause = d_event_cause_from_dmn_event_kind(event->kind);
}break;
}
@@ -5763,8 +5790,8 @@ d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
D_Event *event = d_event_list_push(scratch.arena, &evts);
event->kind = D_EventKind_Stopped;
event->cause = stop_cause;
event->entity = d_handle_from_dmn(D_MachineID_Local, stop_event->thread);
event->parent = d_handle_from_dmn(D_MachineID_Local, stop_event->process);
event->entity = d_handle_from_dmn(D_DemonID_LocalHost, stop_event->thread);
event->parent = d_handle_from_dmn(D_DemonID_LocalHost, stop_event->process);
event->exception_code = stop_event->code;
event->exception_kind = d_exception_kind_from_dmn(stop_event->exception_kind);
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
@@ -5847,8 +5874,8 @@ d_ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg)
event->cause = stop_cause;
if(stop_event != 0)
{
event->entity = d_handle_from_dmn(D_MachineID_Local, stop_event->thread);
event->parent = d_handle_from_dmn(D_MachineID_Local, stop_event->process);
event->entity = d_handle_from_dmn(D_DemonID_LocalHost, stop_event->thread);
event->parent = d_handle_from_dmn(D_DemonID_LocalHost, stop_event->process);
event->exception_code = stop_event->code;
event->exception_kind = d_exception_kind_from_dmn(stop_event->exception_kind);
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
+64 -2
View File
@@ -313,6 +313,68 @@ struct D_ModuleReqCacheNode
#define D_WAKEUP_FUNCTION_DEF(name) void name(void)
typedef D_WAKEUP_FUNCTION_DEF(D_WakeupFunctionType);
////////////////////////////////
//~ rjf: Demon Interface V-Table
typedef struct D_DemonInterface D_DemonInterface;
struct D_DemonInterface
{
//- rjf: control
void (*ctrl_exclusive_access_begin)(void);
void (*ctrl_exclusive_access_end)(void);
U32 (*launch)(DMN_CtrlCtx *ctx, ProcessLaunchParams *params);
B32 (*attach)(DMN_CtrlCtx *ctx, U32 pid);
B32 (*kill)(DMN_CtrlCtx *ctx, DMN_Handle process, U32 exit_code);
B32 (*detach)(DMN_CtrlCtx *ctx, DMN_Handle process);
DMN_EventList (*run)(Arena *arena, DMN_CtrlCtx *ctx, DMN_RunCtrls *ctrls);
//- rjf: halting
void (*halt)(U64 code, U64 user_data);
//- rjf: non-blocking-control-thread access barriers
B32 (*access_open)(void);
void (*access_close)(void);
//- rjf: process memory
U64 (*reserve_memory)(DMN_Handle process, U64 vaddr, U64 size);
void (*commit_memory)(DMN_Handle process, U64 vaddr, U64 size);
void (*decommit_memory)(DMN_Handle process, U64 vaddr, U64 size);
void (*release_memory)(DMN_Handle process, U64 vaddr, U64 size);
void (*protect_memory)(DMN_Handle process, U64 vaddr, U64 size, AccessFlags flags);
U64 (*read_memory)(DMN_Handle process, Rng1U64 range, void *dst);
B32 (*write_memory)(DMN_Handle process, Rng1U64 range, void *src);
//- rjf: threads
B32 (*thread_read_reg_block)(DMN_Handle thread, void *dst);
B32 (*thread_write_reg_block)(DMN_Handle thread, void *src);
B32 (*thread_get_module_tls_vaddr)(DMN_Handle thread, DMN_Handle module, U64 *vaddr_out);
};
typedef struct D_DemonState D_DemonState;
struct D_DemonState
{
D_DemonState *next;
D_DemonState *prev;
D_DemonID id;
D_DemonInterface *fn;
Arena *event_arena;
DMN_EventList events;
};
typedef struct D_DemonStateSlot D_DemonStateSlot;
struct D_DemonStateSlot
{
D_DemonState *first;
D_DemonState *last;
};
typedef struct D_DemonCache D_DemonCache;
struct D_DemonCache
{
U64 slots_count;
D_DemonStateSlot *slots;
};
////////////////////////////////
//~ rjf: Main State Types
@@ -426,8 +488,8 @@ internal D_HandleArray d_handle_array_from_list(Arena *arena, D_HandleList *src
internal String8 d_string_from_handle(Arena *arena, D_Handle handle);
internal D_Handle d_handle_from_string(String8 string);
internal DMN_Handle d_dmn_from_handle(D_Handle handle);
internal D_Handle d_handle_from_dmn(D_MachineID machine_id, DMN_Handle handle);
internal D_Handle d_dump_handle_make(D_MachineID machine_id, U64 id);
internal D_Handle d_handle_from_dmn(D_DemonID demon_id, DMN_Handle handle);
internal D_Handle d_dump_handle_make(D_DemonID demon_id, U64 id);
////////////////////////////////
//~ rjf: Trap Type Functions
+4 -4
View File
@@ -2104,13 +2104,13 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
}break;
case D_CmdKind_FreezeLocalMachine:
{
D_MachineID machine_id = D_MachineID_Local;
d_cmd(D_CmdKind_FreezeMachine, .entity = d_handle_from_dmn(machine_id, dmn_handle_zero()));
D_DemonID demon_id = D_DemonID_LocalHost;
d_cmd(D_CmdKind_FreezeMachine, .entity = d_handle_from_dmn(demon_id, dmn_handle_zero()));
}break;
case D_CmdKind_ThawLocalMachine:
{
D_MachineID machine_id = D_MachineID_Local;
d_cmd(D_CmdKind_ThawMachine, .entity = d_handle_from_dmn(machine_id, dmn_handle_zero()));
D_DemonID demon_id = D_DemonID_LocalHost;
d_cmd(D_CmdKind_ThawMachine, .entity = d_handle_from_dmn(demon_id, dmn_handle_zero()));
}break;
case D_CmdKind_FreezeEntity:
case D_CmdKind_ThawEntity: