mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-06 16:05:42 +00:00
ctrl -> d type pass
This commit is contained in:
+108
-182
@@ -204,7 +204,7 @@ d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *
|
||||
// of debug events which it is passed from the OS.
|
||||
//
|
||||
// These are "high-level traps" because they can have specific behavioral info
|
||||
// attached to them. These are encoded via the `CTRL_TrapFlags` type, which
|
||||
// attached to them. These are encoded via the `D_TrapFlags` type, which
|
||||
// allow expression of the following behaviors:
|
||||
//
|
||||
// - end-stepping: when this trap is hit, it will end the stepping operation,
|
||||
@@ -286,13 +286,13 @@ d_cmd_list_push_new(Arena *arena, D_CmdList *cmds, D_CmdKind kind, D_CmdParams *
|
||||
// at them with the "save-stack-pointer | single-step-after" behaviors.
|
||||
|
||||
internal D_TrapNet
|
||||
d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
|
||||
d_trap_net_from_thread__step_over_inst(Arena *arena, D_Entity *thread)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
D_TrapNet result = {0};
|
||||
|
||||
// rjf: thread => unpacked info
|
||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process);
|
||||
Arch arch = thread->arch;
|
||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||
|
||||
@@ -300,7 +300,7 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
|
||||
String8 machine_code = {0};
|
||||
{
|
||||
Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch));
|
||||
CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, rng, 0, os_now_microseconds()+5000);
|
||||
D_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, rng, 0, os_now_microseconds()+5000);
|
||||
machine_code = machine_code_slice.data;
|
||||
}
|
||||
|
||||
@@ -315,7 +315,7 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
|
||||
// rjf: call => run until call returns
|
||||
if(inst.flags & DASM_InstFlag_Call || inst.flags & DASM_InstFlag_Repeats)
|
||||
{
|
||||
CTRL_Trap trap = {CTRL_TrapFlag_EndStepping, ip_vaddr+inst.size};
|
||||
D_Trap trap = {D_TrapFlag_EndStepping, ip_vaddr+inst.size};
|
||||
ctrl_trap_list_push(arena, &result.traps, &trap);
|
||||
}
|
||||
}
|
||||
@@ -325,7 +325,7 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
|
||||
}
|
||||
|
||||
internal D_TrapNet
|
||||
d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
log_infof("step_over_line:\n{\n");
|
||||
@@ -334,8 +334,8 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
// rjf: thread => info
|
||||
Arch arch = thread->arch;
|
||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process);
|
||||
D_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||
log_infof("ip_vaddr: 0x%I64x\n", ip_vaddr);
|
||||
log_infof("dbgi_key: {0x%I64x, 0x%I64x}\n", dbgi_key.u64[0], dbgi_key.u64[1]);
|
||||
@@ -393,7 +393,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
B32 good_machine_code = 0;
|
||||
if(good_line_info)
|
||||
{
|
||||
CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+50000);
|
||||
D_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+50000);
|
||||
machine_code = machine_code_slice.data;
|
||||
good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
|
||||
LogInfoNamedBlockF("machine_code_slice")
|
||||
@@ -440,7 +440,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
if(good_machine_code) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next)
|
||||
{
|
||||
DASM_CtrlFlowPoint *point = &n->v;
|
||||
CTRL_TrapFlags flags = 0;
|
||||
D_TrapFlags flags = 0;
|
||||
B32 add = 1;
|
||||
U64 trap_addr = point->vaddr;
|
||||
|
||||
@@ -449,7 +449,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
DASM_InstFlag_UnconditionalJump|
|
||||
DASM_InstFlag_Return))
|
||||
{
|
||||
flags |= (CTRL_TrapFlag_SingleStepAfterHit|CTRL_TrapFlag_EndStepping);
|
||||
flags |= (D_TrapFlag_SingleStepAfterHit|D_TrapFlag_EndStepping);
|
||||
|
||||
// rjf: omit if this jump stays inside of this line
|
||||
if(contains_1u64(line_vaddr_rng, point->jump_dest_vaddr))
|
||||
@@ -471,7 +471,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
if(point->jump_dest_vaddr != 0)
|
||||
{
|
||||
trap_addr = point->jump_dest_vaddr;
|
||||
flags &= ~CTRL_TrapFlag_SingleStepAfterHit;
|
||||
flags &= ~D_TrapFlag_SingleStepAfterHit;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -479,19 +479,19 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
// rjf: call => place spoof at return spot in stack, single-step after hitting
|
||||
else if(point->inst_flags & DASM_InstFlag_Call)
|
||||
{
|
||||
flags |= (CTRL_TrapFlag_BeginSpoofMode|CTRL_TrapFlag_SingleStepAfterHit);
|
||||
flags |= (D_TrapFlag_BeginSpoofMode|D_TrapFlag_SingleStepAfterHit);
|
||||
}
|
||||
|
||||
// rjf: instruction changes stack pointer => save off the stack pointer, single-step over, keep stepping
|
||||
else if(point->inst_flags & DASM_InstFlag_ChangesStackPointer)
|
||||
{
|
||||
flags |= (CTRL_TrapFlag_SingleStepAfterHit|CTRL_TrapFlag_SaveStackPointer);
|
||||
flags |= (D_TrapFlag_SingleStepAfterHit|D_TrapFlag_SaveStackPointer);
|
||||
}
|
||||
|
||||
// rjf: add if appropriate
|
||||
if(add)
|
||||
{
|
||||
CTRL_Trap trap = {flags, trap_addr};
|
||||
D_Trap trap = {flags, trap_addr};
|
||||
ctrl_trap_list_push(arena, &result.traps, &trap);
|
||||
}
|
||||
}
|
||||
@@ -514,7 +514,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
}
|
||||
if(!opl_in_line)
|
||||
{
|
||||
CTRL_Trap trap = {CTRL_TrapFlag_EndStepping, opl};
|
||||
D_Trap trap = {D_TrapFlag_EndStepping, opl};
|
||||
ctrl_trap_list_push(arena, &result.traps, &trap);
|
||||
}
|
||||
}
|
||||
@@ -528,7 +528,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
}
|
||||
|
||||
// rjf: log
|
||||
LogInfoNamedBlockF("traps") for(CTRL_TrapNode *n = result.traps.first; n != 0; n = n->next)
|
||||
LogInfoNamedBlockF("traps") for(D_TrapNode *n = result.traps.first; n != 0; n = n->next)
|
||||
{
|
||||
log_infof("{flags:0x%x, vaddr:0x%I64x}\n", n->v.flags, n->v.vaddr);
|
||||
}
|
||||
@@ -539,7 +539,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
||||
}
|
||||
|
||||
internal D_TrapNet
|
||||
d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
D_TrapNet result = {0};
|
||||
@@ -547,8 +547,8 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
// rjf: thread => info
|
||||
Arch arch = thread->arch;
|
||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process);
|
||||
D_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||
|
||||
// rjf: ip => line info
|
||||
@@ -604,7 +604,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
B32 good_machine_code = 0;
|
||||
if(good_line_info)
|
||||
{
|
||||
CTRL_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+5000);
|
||||
D_ProcessMemorySlice machine_code_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+5000);
|
||||
machine_code = machine_code_slice.data;
|
||||
good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
|
||||
}
|
||||
@@ -638,7 +638,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
if(good_machine_code) for(DASM_CtrlFlowPointNode *n = ctrl_flow_info.exit_points.first; n != 0; n = n->next)
|
||||
{
|
||||
DASM_CtrlFlowPoint *point = &n->v;
|
||||
CTRL_TrapFlags flags = 0;
|
||||
D_TrapFlags flags = 0;
|
||||
B32 add = 1;
|
||||
U64 trap_addr = point->vaddr;
|
||||
|
||||
@@ -649,7 +649,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
point->jump_dest_vaddr != 0)
|
||||
{
|
||||
U64 jump_dest_vaddr = point->jump_dest_vaddr;
|
||||
CTRL_Entity *jump_dest_module = ctrl_module_from_process_vaddr(process, jump_dest_vaddr);
|
||||
D_Entity *jump_dest_module = ctrl_module_from_process_vaddr(process, jump_dest_vaddr);
|
||||
U64 jump_dest_voff = ctrl_voff_from_vaddr(jump_dest_module, jump_dest_vaddr);
|
||||
DI_Key jump_dest_dbgi_key = ctrl_dbgi_key_from_module(jump_dest_module);
|
||||
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, jump_dest_dbgi_key, jump_dest_voff);
|
||||
@@ -665,7 +665,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
DASM_InstFlag_UnconditionalJump|
|
||||
DASM_InstFlag_Return))
|
||||
{
|
||||
flags |= (CTRL_TrapFlag_SingleStepAfterHit|CTRL_TrapFlag_EndStepping|CTRL_TrapFlag_IgnoreStackPointerCheck);
|
||||
flags |= (D_TrapFlag_SingleStepAfterHit|D_TrapFlag_EndStepping|D_TrapFlag_IgnoreStackPointerCheck);
|
||||
|
||||
// rjf: omit if this jump stays inside of this line
|
||||
if(contains_1u64(line_vaddr_rng, point->jump_dest_vaddr))
|
||||
@@ -687,20 +687,20 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
if(point->jump_dest_vaddr != 0)
|
||||
{
|
||||
trap_addr = point->jump_dest_vaddr;
|
||||
flags &= ~CTRL_TrapFlag_SingleStepAfterHit;
|
||||
flags &= ~D_TrapFlag_SingleStepAfterHit;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: instruction changes stack pointer => save off the stack pointer, single-step over, keep stepping
|
||||
else if(point->inst_flags & DASM_InstFlag_ChangesStackPointer)
|
||||
{
|
||||
flags |= (CTRL_TrapFlag_SingleStepAfterHit|CTRL_TrapFlag_SaveStackPointer);
|
||||
flags |= (D_TrapFlag_SingleStepAfterHit|D_TrapFlag_SaveStackPointer);
|
||||
}
|
||||
|
||||
// rjf: add if appropriate
|
||||
if(add)
|
||||
{
|
||||
CTRL_Trap trap = {flags, trap_addr};
|
||||
D_Trap trap = {flags, trap_addr};
|
||||
ctrl_trap_list_push(arena, &result.traps, &trap);
|
||||
}
|
||||
}
|
||||
@@ -723,7 +723,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
||||
}
|
||||
if(!opl_in_line)
|
||||
{
|
||||
CTRL_Trap trap = {CTRL_TrapFlag_EndStepping, opl};
|
||||
D_Trap trap = {D_TrapFlag_EndStepping, opl};
|
||||
ctrl_trap_list_push(arena, &result.traps, &trap);
|
||||
}
|
||||
}
|
||||
@@ -1064,7 +1064,7 @@ d_lines_from_file_path_line_num(Arena *arena, String8 file_path, S64 line_num)
|
||||
//~ rjf: Process/Thread/Module Info Lookups
|
||||
|
||||
internal U64
|
||||
d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
||||
d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
U64 base_vaddr = 0;
|
||||
@@ -1073,18 +1073,18 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
|
||||
//- rjf: unpack module info
|
||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
|
||||
D_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
|
||||
U64 addr_size = byte_size_from_arch(process->arch);
|
||||
|
||||
switch(process->tls_model)
|
||||
{
|
||||
case CTRL_TlsModel_Null: {}break;
|
||||
case CTRL_TlsModel_WinodwsNt:
|
||||
case D_TlsModel_Null: {}break;
|
||||
case D_TlsModel_WinodwsNt:
|
||||
{
|
||||
// read thread local base pointer out of TEB
|
||||
U64 thread_local_base = root_vaddr;
|
||||
U64 tls_addr_array = 0;
|
||||
CTRL_ProcessMemorySlice tls_addr_array_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(thread_local_base, thread_local_base + addr_size), 0, 0);
|
||||
D_ProcessMemorySlice tls_addr_array_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(thread_local_base, thread_local_base + addr_size), 0, 0);
|
||||
String8 tls_array_vaddr_data = tls_addr_array_slice.data;
|
||||
if(tls_array_vaddr_data.size == addr_size)
|
||||
{
|
||||
@@ -1093,7 +1093,7 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
||||
|
||||
// read thread local storage pointer (array of TLS pointers, one per module)
|
||||
U64 tls_ptr_vaddr = tls_array_vaddr + module->tls_index * addr_size;
|
||||
CTRL_ProcessMemorySlice result_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(tls_ptr_vaddr, tls_ptr_vaddr + addr_size), 0, 0);
|
||||
D_ProcessMemorySlice result_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(tls_ptr_vaddr, tls_ptr_vaddr + addr_size), 0, 0);
|
||||
String8 result_data = result_slice.data;
|
||||
if(result_data.size == addr_size)
|
||||
{
|
||||
@@ -1101,7 +1101,7 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
||||
}
|
||||
}
|
||||
}break;
|
||||
case CTRL_TlsModel_Gnu:
|
||||
case D_TlsModel_Gnu:
|
||||
{
|
||||
if(module->tls_index > 0) // zero is reserved for the generation counter
|
||||
{
|
||||
@@ -1109,7 +1109,7 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
||||
U64 dtv_base = root_vaddr;
|
||||
U64 dtv_size = addr_size * 2; // union dtv { size_t counter; struct dtv_pointer { void *val, *to_free; }; };
|
||||
U64 dtv_pointer_vaddr = dtv_base + module->tls_index * dtv_size;
|
||||
CTRL_ProcessMemorySlice dtv_pointer_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(dtv_pointer_vaddr, dtv_pointer_vaddr + dtv_size), 0, 0);
|
||||
D_ProcessMemorySlice dtv_pointer_slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, r1u64(dtv_pointer_vaddr, dtv_pointer_vaddr + dtv_size), 0, 0);
|
||||
String8 dtv_pointer_data = dtv_pointer_slice.data;
|
||||
if(dtv_pointer_data.size == dtv_size)
|
||||
{
|
||||
@@ -1139,7 +1139,7 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
||||
|
||||
//- rjf: stopped info from the control thread
|
||||
|
||||
internal CTRL_Event
|
||||
internal D_Event
|
||||
d_ctrl_last_stop_event(void)
|
||||
{
|
||||
return d_user_state->ctrl_last_stop_event;
|
||||
@@ -1182,10 +1182,10 @@ internal DI_KeyList
|
||||
d_push_active_dbgi_key_list(Arena *arena)
|
||||
{
|
||||
DI_KeyList dbgis = {0};
|
||||
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
||||
D_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module);
|
||||
for EachIndex(idx, modules.count)
|
||||
{
|
||||
CTRL_Entity *module = modules.v[idx];
|
||||
D_Entity *module = modules.v[idx];
|
||||
DI_Key key = ctrl_dbgi_key_from_module(module);
|
||||
di_key_list_push(arena, &dbgis, key);
|
||||
}
|
||||
@@ -1195,14 +1195,14 @@ d_push_active_dbgi_key_list(Arena *arena)
|
||||
//- rjf: per-run caches
|
||||
|
||||
internal U64
|
||||
d_query_cached_rip_from_thread(CTRL_Entity *thread)
|
||||
d_query_cached_rip_from_thread(D_Entity *thread)
|
||||
{
|
||||
U64 result = d_query_cached_rip_from_thread_unwind(thread, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count)
|
||||
d_query_cached_rip_from_thread_unwind(D_Entity *thread, U64 unwind_count)
|
||||
{
|
||||
U64 result = 0;
|
||||
if(unwind_count == 0)
|
||||
@@ -1212,7 +1212,7 @@ d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count)
|
||||
else
|
||||
{
|
||||
Access *access = access_open();
|
||||
CTRL_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0);
|
||||
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0);
|
||||
if(callstack.concrete_frames_count != 0)
|
||||
{
|
||||
result = regs_rip_from_arch_block(thread->arch, callstack.concrete_frames[unwind_count%callstack.concrete_frames_count]->regs);
|
||||
@@ -1223,11 +1223,11 @@ d_query_cached_rip_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count)
|
||||
}
|
||||
|
||||
internal U64
|
||||
d_query_cached_cfa_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count)
|
||||
d_query_cached_cfa_from_thread_unwind(D_Entity *thread, U64 unwind_count)
|
||||
{
|
||||
U64 cfa = 0;
|
||||
Access *access = access_open();
|
||||
CTRL_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0);
|
||||
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0);
|
||||
if(callstack.concrete_frames_count != 0)
|
||||
{
|
||||
cfa = callstack.concrete_frames[unwind_count%callstack.concrete_frames_count]->cfa;
|
||||
@@ -1237,7 +1237,7 @@ d_query_cached_cfa_from_thread_unwind(CTRL_Entity *thread, U64 unwind_count)
|
||||
}
|
||||
|
||||
internal U64
|
||||
d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
||||
d_query_cached_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
||||
{
|
||||
U64 result = 0;
|
||||
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_user_state->tls_base_caches); cache_idx += 1)
|
||||
@@ -1252,7 +1252,7 @@ d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 ro
|
||||
{
|
||||
break;
|
||||
}
|
||||
CTRL_Handle handle = process->handle;
|
||||
D_Handle handle = process->handle;
|
||||
U64 hash = d_hash_from_seed_string(d_hash_from_string(str8_struct(&handle)), str8_struct(&rip_vaddr));
|
||||
U64 slot_idx = hash%cache->slots_count;
|
||||
D_RunTLSBaseCacheSlot *slot = &cache->slots[slot_idx];
|
||||
@@ -1426,16 +1426,16 @@ d_next_cmd(D_Cmd **cmd)
|
||||
//~ rjf: Main Layer Top-Level Calls
|
||||
|
||||
internal D_EventList
|
||||
d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64])
|
||||
d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(D_ExceptionCodeKind_COUNT+63)/64])
|
||||
{
|
||||
ProfBeginFunction();
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
D_EventList result = {0};
|
||||
d_user_state->frame_index += 1;
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: sync with ctrl thread
|
||||
//
|
||||
D_EventList events = {0};
|
||||
ProfScope("sync with ctrl thread")
|
||||
{
|
||||
//- rjf: grab next reggen/memgen
|
||||
@@ -1443,13 +1443,13 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
U64 new_reg_gen = ctrl_reg_gen();
|
||||
|
||||
//- rjf: consume & process events
|
||||
CTRL_EventList events = ctrl_c2u_pop_events(scratch.arena);
|
||||
events = ctrl_c2u_pop_events(arena);
|
||||
ctrl_entity_store_apply_events(d_user_state->ctrl_entity_store, &events);
|
||||
for(CTRL_EventNode *event_n = events.first;
|
||||
for(D_EventNode *event_n = events.first;
|
||||
event_n != 0;
|
||||
event_n = event_n->next)
|
||||
{
|
||||
CTRL_Event *event = &event_n->v;
|
||||
D_Event *event = &event_n->v;
|
||||
log_infof("ctrl_event:\n{\n");
|
||||
log_infof("kind: \"%S\"\n", ctrl_string_from_event_kind(event->kind));
|
||||
log_infof("entity_id: %u\n", event->entity_id);
|
||||
@@ -1457,31 +1457,26 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
{
|
||||
default:{}break;
|
||||
|
||||
//- rjf: errors
|
||||
|
||||
case CTRL_EventKind_Error:
|
||||
case D_EventKind_Error:
|
||||
{
|
||||
log_user_error(event->string);
|
||||
}break;
|
||||
|
||||
//- rjf: starts/stops
|
||||
|
||||
case CTRL_EventKind_Started:
|
||||
case D_EventKind_Started:
|
||||
{
|
||||
d_user_state->ctrl_is_running = 1;
|
||||
d_user_state->ctrl_thread_run_state = 1;
|
||||
}break;
|
||||
|
||||
case CTRL_EventKind_Stopped:
|
||||
case D_EventKind_Stopped:
|
||||
{
|
||||
B32 should_snap = !(d_user_state->ctrl_soft_halt_issued);
|
||||
d_user_state->ctrl_is_running = 0;
|
||||
d_user_state->ctrl_thread_run_state = 0;
|
||||
d_user_state->ctrl_soft_halt_issued = 0;
|
||||
|
||||
// rjf: exception or unexpected trap -> push error
|
||||
if(event->cause == CTRL_EventCause_InterruptedByException ||
|
||||
event->cause == CTRL_EventCause_InterruptedByTrap)
|
||||
if(event->cause == D_EventCause_InterruptedByException ||
|
||||
event->cause == D_EventCause_InterruptedByTrap)
|
||||
{
|
||||
log_user_error(str8_zero());
|
||||
}
|
||||
@@ -1492,46 +1487,12 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
MemoryCopyStruct(&d_user_state->ctrl_last_stop_event, event);
|
||||
d_user_state->ctrl_last_stop_event.string = push_str8_copy(d_user_state->ctrl_stop_arena, d_user_state->ctrl_last_stop_event.string);
|
||||
}
|
||||
|
||||
// rjf: push stop event to caller, if this is not a soft-halt
|
||||
if(should_snap)
|
||||
{
|
||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, event->entity);
|
||||
D_EventCause cause = D_EventCause_Null;
|
||||
switch(event->cause)
|
||||
{
|
||||
default:{}break;
|
||||
case CTRL_EventCause_InterruptedByHalt:
|
||||
{
|
||||
if(should_snap)
|
||||
{
|
||||
cause = D_EventCause_Halt;
|
||||
}
|
||||
else
|
||||
{
|
||||
cause = D_EventCause_SoftHalt;
|
||||
}
|
||||
}break;
|
||||
case CTRL_EventCause_UserBreakpoint: {cause = D_EventCause_UserBreakpoint;}break;
|
||||
}
|
||||
D_EventNode *n = push_array(arena, D_EventNode, 1);
|
||||
SLLQueuePush(result.first, result.last, n);
|
||||
result.count += 1;
|
||||
D_Event *evt = &n->v;
|
||||
evt->kind = D_EventKind_Stop;
|
||||
evt->cause = cause;
|
||||
evt->thread = thread->kind == CTRL_EntityKind_Thread ? thread->handle : ctrl_handle_zero();
|
||||
evt->vaddr = event->rip_vaddr;
|
||||
evt->id = event->u64_code;
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: entity creation/deletion
|
||||
|
||||
case CTRL_EventKind_NewProc:
|
||||
case D_EventKind_NewProc:
|
||||
{
|
||||
// rjf: the first process? -> clear session output
|
||||
CTRL_EntityArray existing_processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||
D_EntityArray existing_processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
|
||||
if(existing_processes.count == 1)
|
||||
{
|
||||
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
|
||||
@@ -1539,40 +1500,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}
|
||||
}break;
|
||||
|
||||
case CTRL_EventKind_EndProc:
|
||||
{
|
||||
D_EventNode *n = push_array(arena, D_EventNode, 1);
|
||||
SLLQueuePush(result.first, result.last, n);
|
||||
result.count += 1;
|
||||
D_Event *evt = &n->v;
|
||||
evt->kind = D_EventKind_ProcessEnd;
|
||||
evt->code = event->u64_code;
|
||||
}break;
|
||||
|
||||
case CTRL_EventKind_NewModule:
|
||||
{
|
||||
D_EventNode *n = push_array(arena, D_EventNode, 1);
|
||||
SLLQueuePush(result.first, result.last, n);
|
||||
result.count += 1;
|
||||
D_Event *evt = &n->v;
|
||||
evt->kind = D_EventKind_ModuleLoad;
|
||||
evt->module = event->entity;
|
||||
}break;
|
||||
|
||||
//- rjf: debug strings
|
||||
|
||||
case CTRL_EventKind_DebugString:
|
||||
case D_EventKind_DebugString:
|
||||
{
|
||||
MTX_Op op = {r1u64(max_U64, max_U64), event->string};
|
||||
mtx_push_op(d_user_state->output_log_key, op);
|
||||
}break;
|
||||
|
||||
//- rjf: memory
|
||||
|
||||
case CTRL_EventKind_MemReserve:{}break;
|
||||
case CTRL_EventKind_MemCommit:{}break;
|
||||
case CTRL_EventKind_MemDecommit:{}break;
|
||||
case CTRL_EventKind_MemRelease:{}break;
|
||||
}
|
||||
log_infof("}\n\n");
|
||||
}
|
||||
@@ -1624,10 +1556,10 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
// rjf: build data strings of all param data
|
||||
String8List strings = {0};
|
||||
{
|
||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
|
||||
for EachIndex(idx, threads.count)
|
||||
{
|
||||
CTRL_Entity *thread = threads.v[idx];
|
||||
D_Entity *thread = threads.v[idx];
|
||||
if(thread->is_frozen)
|
||||
{
|
||||
str8_list_push(scratch.arena, &strings, str8_struct(&thread->id));
|
||||
@@ -1665,7 +1597,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
//- rjf: process top-level commands
|
||||
//
|
||||
D_CmdList deferred_cmds = {0};
|
||||
CTRL_MsgList ctrl_msgs = {0};
|
||||
D_MsgList ctrl_msgs = {0};
|
||||
ProfScope("process top-level commands")
|
||||
{
|
||||
D_BreakpointArray run_extra_bps = {0};
|
||||
@@ -1677,9 +1609,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
// rjf: prep ctrl running arguments
|
||||
B32 need_run = 0;
|
||||
D_RunKind run_kind = D_RunKind_Run;
|
||||
CTRL_Entity *run_thread = &ctrl_entity_nil;
|
||||
CTRL_RunFlags run_flags = 0;
|
||||
CTRL_TrapList run_traps = {0};
|
||||
D_Entity *run_thread = &d_entity_nil;
|
||||
D_RunFlags run_flags = 0;
|
||||
D_TrapList run_traps = {0};
|
||||
|
||||
// rjf: process command
|
||||
switch(cmd->kind)
|
||||
@@ -1749,8 +1681,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
|
||||
// rjf: push message to launch
|
||||
{
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = CTRL_MsgKind_Launch;
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = D_MsgKind_Launch;
|
||||
msg->path = working_directory;
|
||||
msg->cmd_line_string_list = cmdln_strings;
|
||||
msg->stdout_path = stdout_path;
|
||||
@@ -1767,8 +1699,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
// rjf: run
|
||||
need_run = 1;
|
||||
run_kind = D_RunKind_Run;
|
||||
run_thread = &ctrl_entity_nil;
|
||||
run_flags = (cmd->kind == D_CmdKind_LaunchAndStepInto) ? CTRL_RunFlag_StopOnEntryPoint : 0;
|
||||
run_thread = &d_entity_nil;
|
||||
run_flags = (cmd->kind == D_CmdKind_LaunchAndStepInto) ? D_RunFlag_StopOnEntryPoint : 0;
|
||||
}
|
||||
|
||||
// rjf: no targets -> error
|
||||
@@ -1779,15 +1711,15 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_Kill:
|
||||
{
|
||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||
if(process == &ctrl_entity_nil)
|
||||
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||
if(process == &d_entity_nil)
|
||||
{
|
||||
log_user_error(str8_lit("Cannot kill; no process was specified."));
|
||||
}
|
||||
else
|
||||
{
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = CTRL_MsgKind_Kill;
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = D_MsgKind_Kill;
|
||||
msg->exit_code = 1;
|
||||
msg->entity = process->handle;
|
||||
MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
|
||||
@@ -1795,22 +1727,22 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_KillAll:
|
||||
{
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = CTRL_MsgKind_KillAll;
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = D_MsgKind_KillAll;
|
||||
msg->exit_code = 1;
|
||||
MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
|
||||
}break;
|
||||
case D_CmdKind_Detach:
|
||||
{
|
||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||
if(process == &ctrl_entity_nil)
|
||||
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||
if(process == &d_entity_nil)
|
||||
{
|
||||
log_user_error(str8_lit("Cannot detach; no process specified."));
|
||||
}
|
||||
else
|
||||
{
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = CTRL_MsgKind_Detach;
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = D_MsgKind_Detach;
|
||||
msg->entity = process->handle;
|
||||
MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
|
||||
}
|
||||
@@ -1818,12 +1750,12 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
case D_CmdKind_Continue:
|
||||
{
|
||||
B32 good_to_run = 0;
|
||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
|
||||
if(threads.count > 0)
|
||||
{
|
||||
for EachIndex(idx, threads.count)
|
||||
{
|
||||
CTRL_Entity *thread = threads.v[idx];
|
||||
D_Entity *thread = threads.v[idx];
|
||||
if(!thread->is_frozen)
|
||||
{
|
||||
good_to_run = 1;
|
||||
@@ -1848,8 +1780,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
case D_CmdKind_StepOverLine:
|
||||
case D_CmdKind_StepOut:
|
||||
{
|
||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||
if(thread == &ctrl_entity_nil)
|
||||
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||
if(thread == &d_entity_nil)
|
||||
{
|
||||
log_user_error(str8_lit("Must have a selected thread to step."));
|
||||
}
|
||||
@@ -1879,13 +1811,13 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
Access *access = access_open();
|
||||
|
||||
// rjf: thread => call stack
|
||||
CTRL_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||
|
||||
// rjf: use first unwind frame to generate trap
|
||||
if(callstack.concrete_frames_count > 1)
|
||||
{
|
||||
U64 vaddr = regs_rip_from_arch_block(thread->arch, callstack.concrete_frames[1]->regs);
|
||||
CTRL_Trap trap = {CTRL_TrapFlag_EndStepping|CTRL_TrapFlag_IgnoreStackPointerCheck, vaddr};
|
||||
D_Trap trap = {D_TrapFlag_EndStepping|D_TrapFlag_IgnoreStackPointerCheck, vaddr};
|
||||
ctrl_trap_list_push(scratch.arena, &trap_net.traps, &trap);
|
||||
trap_net.good_read = 1;
|
||||
}
|
||||
@@ -1942,7 +1874,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_SetThreadIP:
|
||||
{
|
||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||
U64 vaddr = params->vaddr;
|
||||
void *block = ctrl_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||
regs_arch_block_write_rip(thread->arch, block, vaddr);
|
||||
@@ -1968,7 +1900,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_Run:
|
||||
{
|
||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
|
||||
if(processes.count != 0)
|
||||
{
|
||||
d_cmd(D_CmdKind_Continue, .machine = params->machine, .process = params->process, .thread = params->thread);
|
||||
@@ -1980,7 +1912,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_Restart:
|
||||
{
|
||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
|
||||
if(processes.count != 0)
|
||||
{
|
||||
d_cmd(D_CmdKind_KillAll);
|
||||
@@ -1990,7 +1922,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
case D_CmdKind_StepInto:
|
||||
case D_CmdKind_StepOver:
|
||||
{
|
||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
|
||||
if(processes.count != 0)
|
||||
{
|
||||
D_CmdKind step_cmd_kind = (cmd->kind == D_CmdKind_StepInto
|
||||
@@ -2028,26 +1960,26 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}break;
|
||||
case D_CmdKind_FreezeLocalMachine:
|
||||
{
|
||||
CTRL_MachineID machine_id = CTRL_MachineID_Local;
|
||||
D_MachineID machine_id = D_MachineID_Local;
|
||||
d_cmd(D_CmdKind_FreezeMachine, .entity = ctrl_handle_make(machine_id, dmn_handle_zero()));
|
||||
}break;
|
||||
case D_CmdKind_ThawLocalMachine:
|
||||
{
|
||||
CTRL_MachineID machine_id = CTRL_MachineID_Local;
|
||||
D_MachineID machine_id = D_MachineID_Local;
|
||||
d_cmd(D_CmdKind_ThawMachine, .entity = ctrl_handle_make(machine_id, dmn_handle_zero()));
|
||||
}break;
|
||||
case D_CmdKind_FreezeEntity:
|
||||
case D_CmdKind_ThawEntity:
|
||||
{
|
||||
B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity);
|
||||
CTRL_Entity *root = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
for(CTRL_Entity *e = root; e != &ctrl_entity_nil; e = ctrl_entity_rec_depth_first_pre(e, root).next)
|
||||
D_Entity *root = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
for(D_Entity *e = root; e != &d_entity_nil; e = ctrl_entity_rec_depth_first_pre(e, root).next)
|
||||
{
|
||||
if(e->kind == CTRL_EntityKind_Thread)
|
||||
if(e->kind == D_EntityKind_Thread)
|
||||
{
|
||||
e->is_frozen = should_freeze;
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = (should_freeze ? CTRL_MsgKind_FreezeThread : CTRL_MsgKind_ThawThread);
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = (should_freeze ? D_MsgKind_FreezeThread : D_MsgKind_ThawThread);
|
||||
msg->entity = e->handle;
|
||||
}
|
||||
}
|
||||
@@ -2064,12 +1996,12 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
//- rjf: entity decoration
|
||||
case D_CmdKind_SetEntityColor:
|
||||
{
|
||||
CTRL_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
D_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
entity->rgba = params->rgba;
|
||||
}break;
|
||||
case D_CmdKind_SetEntityName:
|
||||
{
|
||||
CTRL_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
D_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||
ctrl_entity_equip_string(d_user_state->ctrl_entity_store, entity, params->string);
|
||||
}break;
|
||||
|
||||
@@ -2079,8 +2011,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
U32 pid = params->pid;
|
||||
if(pid != 0)
|
||||
{
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = CTRL_MsgKind_Attach;
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
msg->kind = D_MsgKind_Attach;
|
||||
msg->entity_id = pid;
|
||||
MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
|
||||
}
|
||||
@@ -2096,10 +2028,10 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}
|
||||
|
||||
// rjf: push & fill run message
|
||||
CTRL_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs);
|
||||
{
|
||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(run_thread, CTRL_EntityKind_Process);
|
||||
msg->kind = (run_kind == D_RunKind_Run || run_kind == D_RunKind_Step) ? CTRL_MsgKind_Run : CTRL_MsgKind_SingleStep;
|
||||
D_Entity *process = ctrl_entity_ancestor_from_kind(run_thread, D_EntityKind_Process);
|
||||
msg->kind = (run_kind == D_RunKind_Run || run_kind == D_RunKind_Step) ? D_MsgKind_Run : D_MsgKind_SingleStep;
|
||||
msg->run_flags = run_flags;
|
||||
msg->entity = run_thread->handle;
|
||||
msg->parent = process->handle;
|
||||
@@ -2118,12 +2050,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
// rjf: unpack user breakpoint entity
|
||||
D_Breakpoint *bp = &batch_breakpoints->v[idx];
|
||||
|
||||
// rjf: d -> ctrl flags
|
||||
CTRL_UserBreakpointFlags ctrl_bp_flags = 0;
|
||||
if(bp->flags & D_BreakpointFlag_BreakOnWrite) { ctrl_bp_flags |= CTRL_UserBreakpointFlag_BreakOnWrite; }
|
||||
if(bp->flags & D_BreakpointFlag_BreakOnRead) { ctrl_bp_flags |= CTRL_UserBreakpointFlag_BreakOnRead; }
|
||||
if(bp->flags & D_BreakpointFlag_BreakOnExecute) { ctrl_bp_flags |= CTRL_UserBreakpointFlag_BreakOnExecute; }
|
||||
|
||||
// rjf: textual location -> add breakpoints for all possible override locations
|
||||
if(bp->file_path.size != 0 && bp->pt.line != 0)
|
||||
{
|
||||
@@ -2131,7 +2057,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
for(String8Node *n = overrides.first; n != 0; n = n->next)
|
||||
{
|
||||
CTRL_UserBreakpoint ctrl_user_bp = {CTRL_UserBreakpointKind_FileNameAndLineColNumber};
|
||||
ctrl_user_bp.flags = ctrl_bp_flags;
|
||||
ctrl_user_bp.flags = bp->flags;
|
||||
ctrl_user_bp.id = bp->id;
|
||||
ctrl_user_bp.string = n->string;
|
||||
ctrl_user_bp.pt = bp->pt;
|
||||
@@ -2145,7 +2071,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
else if(bp->vaddr_expr.size != 0)
|
||||
{
|
||||
CTRL_UserBreakpoint ctrl_user_bp = {CTRL_UserBreakpointKind_Expression};
|
||||
ctrl_user_bp.flags = ctrl_bp_flags;
|
||||
ctrl_user_bp.flags = bp->flags;
|
||||
ctrl_user_bp.id = bp->id;
|
||||
ctrl_user_bp.string = bp->vaddr_expr;
|
||||
ctrl_user_bp.condition = bp->condition;
|
||||
@@ -2157,7 +2083,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
}
|
||||
|
||||
// rjf: copy run traps to scratch (needed, if run_traps can be `d_user_state->ctrl_last_run_traps`)
|
||||
CTRL_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps);
|
||||
D_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps);
|
||||
D_BreakpointArray run_extra_bps_copy = d_breakpoint_array_copy(scratch.arena, &run_extra_bps);
|
||||
|
||||
// rjf: store last run info
|
||||
@@ -2195,7 +2121,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
// the next tick)
|
||||
//
|
||||
{
|
||||
CTRL_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_user_state->ctrl_msg_arena, &ctrl_msgs);
|
||||
D_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_user_state->ctrl_msg_arena, &ctrl_msgs);
|
||||
ctrl_msg_list_concat_in_place(&d_user_state->ctrl_msgs, &msgs_copy);
|
||||
if(d_user_state->ctrl_msgs.count != 0)
|
||||
{
|
||||
@@ -2214,5 +2140,5 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
|
||||
ProfEnd();
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
return events;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user