ctrl layer defined handle system, to replace machine-id/demon-handle pairs used everywhere by users

This commit is contained in:
Ryan Fleury
2024-09-11 14:01:38 -07:00
parent e6872cb71e
commit be6458690f
7 changed files with 399 additions and 430 deletions
+275 -280
View File
File diff suppressed because it is too large Load Diff
+54 -57
View File
@@ -15,25 +15,25 @@ typedef U64 CTRL_MachineID;
////////////////////////////////
//~ rjf: Entity Handle Types
typedef struct CTRL_MachineIDHandlePair CTRL_MachineIDHandlePair;
struct CTRL_MachineIDHandlePair
typedef struct CTRL_Handle CTRL_Handle;
struct CTRL_Handle
{
CTRL_MachineID machine_id;
DMN_Handle handle;
DMN_Handle dmn_handle;
};
typedef struct CTRL_MachineIDHandlePairNode CTRL_MachineIDHandlePairNode;
struct CTRL_MachineIDHandlePairNode
typedef struct CTRL_HandleNode CTRL_HandleNode;
struct CTRL_HandleNode
{
CTRL_MachineIDHandlePairNode *next;
CTRL_MachineIDHandlePair v;
CTRL_HandleNode *next;
CTRL_Handle v;
};
typedef struct CTRL_MachineIDHandlePairList CTRL_MachineIDHandlePairList;
struct CTRL_MachineIDHandlePairList
typedef struct CTRL_HandleList CTRL_HandleList;
struct CTRL_HandleList
{
CTRL_MachineIDHandlePairNode *first;
CTRL_MachineIDHandlePairNode *last;
CTRL_HandleNode *first;
CTRL_HandleNode *last;
U64 count;
};
@@ -65,8 +65,7 @@ struct CTRL_Entity
CTRL_EntityKind kind;
Arch arch;
B32 is_frozen;
CTRL_MachineID machine_id;
DMN_Handle handle;
CTRL_Handle handle;
U64 id;
Rng1U64 vaddr_range;
U64 timestamp;
@@ -297,9 +296,8 @@ struct CTRL_Msg
CTRL_MsgKind kind;
CTRL_RunFlags run_flags;
CTRL_MsgID msg_id;
CTRL_MachineID machine_id;
DMN_Handle entity;
DMN_Handle parent;
CTRL_Handle entity;
CTRL_Handle parent;
U32 entity_id;
U32 exit_code;
B32 env_inherit;
@@ -400,9 +398,8 @@ struct CTRL_Event
CTRL_EventCause cause;
CTRL_ExceptionKind exception_kind;
CTRL_MsgID msg_id;
CTRL_MachineID machine_id;
DMN_Handle entity;
DMN_Handle parent;
CTRL_Handle entity;
CTRL_Handle parent;
Arch arch;
U64 u64_code;
U32 entity_id;
@@ -459,8 +456,7 @@ struct CTRL_ProcessMemoryCacheNode
CTRL_ProcessMemoryCacheNode *next;
CTRL_ProcessMemoryCacheNode *prev;
Arena *arena;
CTRL_MachineID machine_id;
DMN_Handle process;
CTRL_Handle handle;
U64 range_hash_slots_count;
CTRL_ProcessMemoryRangeHashSlot *range_hash_slots;
};
@@ -507,8 +503,7 @@ struct CTRL_ThreadRegCacheNode
{
CTRL_ThreadRegCacheNode *next;
CTRL_ThreadRegCacheNode *prev;
CTRL_MachineID machine_id;
DMN_Handle thread;
CTRL_Handle handle;
U64 block_size;
void *block;
U64 reg_gen;
@@ -545,8 +540,7 @@ struct CTRL_ModuleImageInfoCacheNode
{
CTRL_ModuleImageInfoCacheNode *next;
CTRL_ModuleImageInfoCacheNode *prev;
CTRL_MachineID machine_id;
DMN_Handle module;
CTRL_Handle module;
Arena *arena;
PE_IntelPdata *pdatas;
U64 pdatas_count;
@@ -668,16 +662,19 @@ read_only global CTRL_Entity ctrl_entity_nil =
//~ rjf: Basic Type Functions
internal U64 ctrl_hash_from_string(String8 string);
internal U64 ctrl_hash_from_machine_id_handle(CTRL_MachineID machine_id, DMN_Handle handle);
internal U64 ctrl_hash_from_handle(CTRL_Handle handle);
internal CTRL_EventCause ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind);
internal String8 ctrl_string_from_event_kind(CTRL_EventKind kind);
internal String8 ctrl_string_from_msg_kind(CTRL_MsgKind kind);
////////////////////////////////
//~ rjf: Machine/Handle Pair Type Functions
//~ rjf: Handle Type Functions
internal void ctrl_machine_id_handle_pair_list_push(Arena *arena, CTRL_MachineIDHandlePairList *list, CTRL_MachineIDHandlePair *pair);
internal CTRL_MachineIDHandlePairList ctrl_machine_id_handle_pair_list_copy(Arena *arena, CTRL_MachineIDHandlePairList *src);
internal CTRL_Handle ctrl_handle_zero(void);
internal CTRL_Handle ctrl_handle_make(CTRL_MachineID machine_id, DMN_Handle dmn_handle);
internal B32 ctrl_handle_match(CTRL_Handle a, CTRL_Handle b);
internal void ctrl_handle_list_push(Arena *arena, CTRL_HandleList *list, CTRL_Handle *pair);
internal CTRL_HandleList ctrl_handle_list_copy(Arena *arena, CTRL_HandleList *src);
////////////////////////////////
//~ rjf: Trap Type Functions
@@ -731,14 +728,14 @@ internal String8 ctrl_entity_string_alloc(CTRL_EntityStore *store, String8 strin
internal void ctrl_entity_string_release(CTRL_EntityStore *store, String8 string);
//- rjf: entity construction/deletion
internal CTRL_Entity *ctrl_entity_alloc(CTRL_EntityStore *store, CTRL_Entity *parent, CTRL_EntityKind kind, Arch arch, CTRL_MachineID machine_id, DMN_Handle handle, U64 id);
internal CTRL_Entity *ctrl_entity_alloc(CTRL_EntityStore *store, CTRL_Entity *parent, CTRL_EntityKind kind, Arch arch, CTRL_Handle handle, U64 id);
internal void ctrl_entity_release(CTRL_EntityStore *store, CTRL_Entity *entity);
//- rjf: entity equipment
internal void ctrl_entity_equip_string(CTRL_EntityStore *store, CTRL_Entity *entity, String8 string);
//- rjf: entity store lookups
internal CTRL_Entity *ctrl_entity_from_machine_id_handle(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle handle);
internal CTRL_Entity *ctrl_entity_from_handle(CTRL_EntityStore *store, CTRL_Handle handle);
internal CTRL_Entity *ctrl_entity_child_from_kind(CTRL_Entity *parent, CTRL_EntityKind kind);
internal CTRL_Entity *ctrl_entity_ancestor_from_kind(CTRL_Entity *entity, CTRL_EntityKind kind);
internal CTRL_Entity *ctrl_module_from_process_vaddr(CTRL_Entity *process, U64 vaddr);
@@ -774,41 +771,41 @@ internal void ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook);
//~ rjf: Process Memory Functions
//- rjf: process memory cache interaction
internal U128 ctrl_calc_hash_store_key_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated);
internal U128 ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated, B32 *out_is_stale, U64 endt_us);
internal U128 ctrl_calc_hash_store_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 range, B32 zero_terminated);
internal U128 ctrl_stored_hash_from_process_vaddr_range(CTRL_Handle process, Rng1U64 range, B32 zero_terminated, B32 *out_is_stale, U64 endt_us);
//- rjf: bundled key/stream helper
internal U128 ctrl_hash_store_key_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated);
internal U128 ctrl_hash_store_key_from_process_vaddr_range(CTRL_Handle process, Rng1U64 range, B32 zero_terminated);
//- rjf: process memory cache reading helpers
internal CTRL_ProcessMemorySlice ctrl_query_cached_data_from_process_vaddr_range(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, U64 endt_us);
internal CTRL_ProcessMemorySlice ctrl_query_cached_zero_terminated_data_from_process_vaddr_limit(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, U64 vaddr, U64 limit, U64 element_size, U64 endt_us);
internal B32 ctrl_read_cached_process_memory(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 *is_stale_out, void *out, U64 endt_us);
#define ctrl_read_cached_process_memory_struct(machine_id, process, vaddr, is_stale_out, ptr, endt_us) ctrl_read_cached_process_memory((machine_id), (process), r1u64((vaddr), (vaddr)+(sizeof(*(ptr)))), (is_stale_out), (ptr), (endt_us))
internal CTRL_ProcessMemorySlice ctrl_query_cached_data_from_process_vaddr_range(Arena *arena, CTRL_Handle process, Rng1U64 range, U64 endt_us);
internal CTRL_ProcessMemorySlice ctrl_query_cached_zero_terminated_data_from_process_vaddr_limit(Arena *arena, CTRL_Handle process, U64 vaddr, U64 limit, U64 element_size, U64 endt_us);
internal B32 ctrl_read_cached_process_memory(CTRL_Handle process, Rng1U64 range, B32 *is_stale_out, void *out, U64 endt_us);
#define ctrl_read_cached_process_memory_struct(process, vaddr, is_stale_out, ptr, endt_us) ctrl_read_cached_process_memory((process), r1u64((vaddr), (vaddr)+(sizeof(*(ptr)))), (is_stale_out), (ptr), (endt_us))
//- rjf: process memory writing
internal B32 ctrl_process_write(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, void *src);
internal B32 ctrl_process_write(CTRL_Handle process, Rng1U64 range, void *src);
////////////////////////////////
//~ rjf: Thread Register Functions
//- rjf: thread register cache reading
internal void *ctrl_query_cached_reg_block_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle thread);
internal U64 ctrl_query_cached_tls_root_vaddr_from_thread(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle thread);
internal U64 ctrl_query_cached_rip_from_thread(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle thread);
internal U64 ctrl_query_cached_rsp_from_thread(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle thread);
internal void *ctrl_query_cached_reg_block_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_Handle handle);
internal U64 ctrl_query_cached_tls_root_vaddr_from_thread(CTRL_EntityStore *store, CTRL_Handle handle);
internal U64 ctrl_query_cached_rip_from_thread(CTRL_EntityStore *store, CTRL_Handle handle);
internal U64 ctrl_query_cached_rsp_from_thread(CTRL_EntityStore *store, CTRL_Handle handle);
//- rjf: thread register writing
internal B32 ctrl_thread_write_reg_block(CTRL_MachineID machine_id, DMN_Handle thread, void *block);
internal B32 ctrl_thread_write_reg_block(CTRL_Handle thread, void *block);
////////////////////////////////
//~ rjf: Module Image Info Functions
//- rjf: cache lookups
internal PE_IntelPdata *ctrl_intel_pdata_from_module_voff(Arena *arena, CTRL_MachineID machine_id, DMN_Handle module_handle, U64 voff);
internal U64 ctrl_entry_point_voff_from_module(CTRL_MachineID machine_id, DMN_Handle module_handle);
internal Rng1U64 ctrl_tls_vaddr_range_from_module(CTRL_MachineID machine_id, DMN_Handle module_handle);
internal String8 ctrl_initial_debug_info_path_from_module(Arena *arena, CTRL_MachineID machine_id, DMN_Handle module_handle);
internal PE_IntelPdata *ctrl_intel_pdata_from_module_voff(Arena *arena, CTRL_Handle module_handle, U64 voff);
internal U64 ctrl_entry_point_voff_from_module(CTRL_Handle module_handle);
internal Rng1U64 ctrl_tls_vaddr_range_from_module(CTRL_Handle module_handle);
internal String8 ctrl_initial_debug_info_path_from_module(Arena *arena, CTRL_Handle module_handle);
////////////////////////////////
//~ rjf: Unwinding Functions
@@ -818,13 +815,13 @@ internal CTRL_Unwind ctrl_unwind_deep_copy(Arena *arena, Arch arch, CTRL_Unwind
//- rjf: [x64]
internal REGS_Reg64 *ctrl_unwind_reg_from_pe_gpr_reg__pe_x64(REGS_RegBlockX64 *regs, PE_UnwindGprRegX64 gpr_reg);
internal CTRL_UnwindStepResult ctrl_unwind_step__pe_x64(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle process_handle, DMN_Handle module, REGS_RegBlockX64 *regs, U64 endt_us);
internal CTRL_UnwindStepResult ctrl_unwind_step__pe_x64(CTRL_EntityStore *store, CTRL_Handle process_handle, CTRL_Handle module_handle, REGS_RegBlockX64 *regs, U64 endt_us);
//- rjf: abstracted unwind step
internal CTRL_UnwindStepResult ctrl_unwind_step(CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle process_handle, DMN_Handle module, Arch arch, void *reg_block, U64 endt_us);
internal CTRL_UnwindStepResult ctrl_unwind_step(CTRL_EntityStore *store, CTRL_Handle process, CTRL_Handle module, Arch arch, void *reg_block, U64 endt_us);
//- rjf: abstracted full unwind
internal CTRL_Unwind ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID machine_id, DMN_Handle thread, U64 endt_us);
internal CTRL_Unwind ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_Handle thread, U64 endt_us);
////////////////////////////////
//~ rjf: Halting All Attached Processes
@@ -858,12 +855,12 @@ internal CTRL_EventList ctrl_c2u_pop_events(Arena *arena);
internal void ctrl_thread__entry_point(void *p);
//- rjf: breakpoint resolution
internal void ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, DMN_Handle module, CTRL_UserBreakpointList *user_bps, DMN_TrapChunkList *traps_out);
internal void ctrl_thread__append_resolved_process_user_bp_traps(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, CTRL_UserBreakpointList *user_bps, DMN_TrapChunkList *traps_out);
internal void ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_Handle process, CTRL_Handle module, CTRL_UserBreakpointList *user_bps, DMN_TrapChunkList *traps_out);
internal void ctrl_thread__append_resolved_process_user_bp_traps(Arena *arena, CTRL_Handle process, CTRL_UserBreakpointList *user_bps, DMN_TrapChunkList *traps_out);
//- rjf: module lifetime open/close work
internal void ctrl_thread__module_open(CTRL_MachineID machine_id, DMN_Handle process, DMN_Handle module, Rng1U64 vaddr_range, String8 path);
internal void ctrl_thread__module_close(CTRL_MachineID machine_id, DMN_Handle module);
internal void ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_range, String8 path);
internal void ctrl_thread__module_close(CTRL_Handle module);
//- rjf: attached process running/event gathering
internal DMN_Event *ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg, DMN_RunCtrls *run_ctrls, CTRL_Spoof *spoof);
@@ -887,8 +884,8 @@ internal void ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg);
//~ rjf: Memory-Stream Thread Functions
//- rjf: user -> memory stream communication
internal B32 ctrl_u2ms_enqueue_req(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, U64 endt_us);
internal void ctrl_u2ms_dequeue_req(CTRL_MachineID *out_machine_id, DMN_Handle *out_process, Rng1U64 *out_vaddr_range, B32 *out_zero_terminated);
internal B32 ctrl_u2ms_enqueue_req(CTRL_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, U64 endt_us);
internal void ctrl_u2ms_dequeue_req(CTRL_Handle *out_process, Rng1U64 *out_vaddr_range, B32 *out_zero_terminated);
//- rjf: entry point
internal void ctrl_mem_stream_thread__entry_point(void *p);
+46 -65
View File
@@ -1378,15 +1378,7 @@ d_entity_equip_timestamp(D_Entity *entity, U64 timestamp)
//- rjf: control layer correllation equipment
internal void
d_entity_equip_ctrl_machine_id(D_Entity *entity, CTRL_MachineID machine_id)
{
d_require_entity_nonnil(entity, return);
entity->ctrl_machine_id = machine_id;
entity->flags |= D_EntityFlag_HasCtrlMachineID;
}
internal void
d_entity_equip_ctrl_handle(D_Entity *entity, DMN_Handle handle)
d_entity_equip_ctrl_handle(D_Entity *entity, CTRL_Handle handle)
{
d_require_entity_nonnil(entity, return);
entity->ctrl_handle = handle;
@@ -1788,7 +1780,7 @@ d_machine_entity_from_machine_id(CTRL_MachineID machine_id)
!d_entity_is_nil(e);
e = d_entity_rec_depth_first_pre(e, &d_nil_entity).next)
{
if(e->kind == D_EntityKind_Machine && e->ctrl_machine_id == machine_id)
if(e->kind == D_EntityKind_Machine && e->ctrl_handle.machine_id == machine_id)
{
result = e;
break;
@@ -1797,25 +1789,23 @@ d_machine_entity_from_machine_id(CTRL_MachineID machine_id)
if(d_entity_is_nil(result))
{
result = d_entity_alloc(d_entity_root(), D_EntityKind_Machine);
d_entity_equip_ctrl_machine_id(result, machine_id);
d_entity_equip_ctrl_handle(result, ctrl_handle_make(machine_id, dmn_handle_zero()));
}
return result;
}
internal D_Entity *
d_entity_from_ctrl_handle(CTRL_MachineID machine_id, DMN_Handle handle)
d_entity_from_ctrl_handle(CTRL_Handle handle)
{
D_Entity *result = &d_nil_entity;
if(handle.u64[0] != 0)
if(handle.machine_id != 0 || handle.dmn_handle.u64[0] != 0)
{
for(D_Entity *e = d_entity_root();
!d_entity_is_nil(e);
e = d_entity_rec_depth_first_pre(e, &d_nil_entity).next)
{
if(e->flags & D_EntityFlag_HasCtrlMachineID &&
e->flags & D_EntityFlag_HasCtrlHandle &&
e->ctrl_machine_id == machine_id &&
MemoryMatchStruct(&e->ctrl_handle, &handle))
if(e->flags & D_EntityFlag_HasCtrlHandle &&
ctrl_handle_match(e->ctrl_handle, handle))
{
result = e;
break;
@@ -1835,9 +1825,9 @@ d_entity_from_ctrl_id(CTRL_MachineID machine_id, U32 id)
!d_entity_is_nil(e);
e = d_entity_rec_depth_first_pre(e, &d_nil_entity).next)
{
if(e->flags & D_EntityFlag_HasCtrlMachineID &&
if(e->flags & D_EntityFlag_HasCtrlHandle &&
e->flags & D_EntityFlag_HasCtrlID &&
e->ctrl_machine_id == machine_id &&
e->ctrl_handle.machine_id == machine_id &&
e->ctrl_id == id)
{
result = e;
@@ -2111,13 +2101,13 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
// rjf: thread => unpacked info
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
Arch arch = thread->arch;
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->machine_id, thread->handle);
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->handle);
// rjf: ip => machine code
String8 machine_code = {0};
{
Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch));
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->machine_id, process->handle, rng, os_now_microseconds()+5000);
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->handle, rng, os_now_microseconds()+5000);
machine_code = machine_code_slice.data;
}
@@ -2148,7 +2138,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
// rjf: thread => info
Arch arch = thread->arch;
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->machine_id, thread->handle);
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, 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);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
@@ -2191,7 +2181,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
String8 machine_code = {0};
if(good_line_info)
{
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->machine_id, process->handle, line_vaddr_rng, os_now_microseconds()+50000);
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+50000);
machine_code = machine_code_slice.data;
LogInfoNamedBlockF("machine_code_slice")
{
@@ -2309,7 +2299,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
// rjf: thread => info
Arch arch = thread->arch;
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->machine_id, thread->handle);
U64 ip_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, 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);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
@@ -2347,7 +2337,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
String8 machine_code = {0};
if(good_line_info)
{
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->machine_id, process->handle, line_vaddr_rng, os_now_microseconds()+5000);
CTRL_ProcessMemorySlice machine_code_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, os_now_microseconds()+5000);
machine_code = machine_code_slice.data;
}
@@ -2922,14 +2912,14 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
{
//- rjf: unpack module info
D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
Rng1U64 tls_vaddr_range = ctrl_tls_vaddr_range_from_module(module->ctrl_machine_id, module->ctrl_handle);
Rng1U64 tls_vaddr_range = ctrl_tls_vaddr_range_from_module(module->ctrl_handle);
U64 addr_size = bit_size_from_arch(process->arch)/8;
//- rjf: read module's TLS index
U64 tls_index = 0;
if(addr_size != 0)
{
CTRL_ProcessMemorySlice tls_index_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, tls_vaddr_range, 0);
CTRL_ProcessMemorySlice tls_index_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_handle, tls_vaddr_range, 0);
if(tls_index_slice.data.size >= addr_size)
{
tls_index = *(U64 *)tls_index_slice.data.str;
@@ -2942,13 +2932,13 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
U64 thread_info_addr = root_vaddr;
U64 tls_addr_off = tls_index*addr_size;
U64 tls_addr_array = 0;
CTRL_ProcessMemorySlice tls_addr_array_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, r1u64(thread_info_addr, thread_info_addr+addr_size), 0);
CTRL_ProcessMemorySlice tls_addr_array_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_handle, r1u64(thread_info_addr, thread_info_addr+addr_size), 0);
String8 tls_addr_array_data = tls_addr_array_slice.data;
if(tls_addr_array_data.size >= 8)
{
MemoryCopy(&tls_addr_array, tls_addr_array_data.str, sizeof(U64));
}
CTRL_ProcessMemorySlice result_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_machine_id, process->ctrl_handle, r1u64(tls_addr_array + tls_addr_off, tls_addr_array + tls_addr_off + addr_size), 0);
CTRL_ProcessMemorySlice result_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, process->ctrl_handle, r1u64(tls_addr_array + tls_addr_off, tls_addr_array + tls_addr_off + addr_size), 0);
String8 result_data = result_slice.data;
if(result_data.size >= 8)
{
@@ -3184,7 +3174,7 @@ d_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range)
case D_EntityKind_Process:
{
Temp scratch = scratch_begin(0, 0);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, entity->ctrl_machine_id, entity->ctrl_handle, range, d_state->frame_eval_memread_endt_us);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, entity->ctrl_handle, range, d_state->frame_eval_memread_endt_us);
String8 data = slice.data;
if(data.size == dim_1u64(range))
{
@@ -3261,7 +3251,7 @@ d_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range)
//- rjf: process -> commit to process memory
case D_EntityKind_Process:
{
result = ctrl_process_write(entity->ctrl_machine_id, entity->ctrl_handle, range, in);
result = ctrl_process_write(entity->ctrl_handle, range, in);
}break;
//- rjf: thread -> commit to thread's register block
@@ -3280,7 +3270,7 @@ d_eval_space_write(void *u, E_Space space, void *in, Rng1U64 range)
void *new_regs = push_array(scratch.arena, U8, regs_size);
MemoryCopy(new_regs, f->regs, regs_size);
MemoryCopy((U8 *)new_regs + write_range.min, in, write_size);
result = ctrl_thread_write_reg_block(entity->ctrl_machine_id, entity->ctrl_handle, new_regs);
result = ctrl_thread_write_reg_block(entity->ctrl_handle, new_regs);
scratch_end(scratch);
}
}break;
@@ -3306,7 +3296,7 @@ d_key_from_eval_space_range(E_Space space, Rng1U64 range, B32 zero_terminated)
//- rjf: process space -> query
case D_EntityKind_Process:
{
result = ctrl_hash_store_key_from_process_vaddr_range(entity->ctrl_machine_id, entity->ctrl_handle, range, zero_terminated);
result = ctrl_hash_store_key_from_process_vaddr_range(entity->ctrl_handle, range, zero_terminated);
}break;
}
return result;
@@ -4194,7 +4184,7 @@ d_query_cached_unwind_from_thread(D_Entity *thread)
if(node->reggen != reg_gen ||
node->memgen != mem_gen)
{
CTRL_Unwind new_unwind = ctrl_unwind_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle, os_now_microseconds()+100);
CTRL_Unwind new_unwind = ctrl_unwind_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->ctrl_handle, os_now_microseconds()+100);
if(!(new_unwind.flags & (CTRL_UnwindFlag_Error|CTRL_UnwindFlag_Stale)) && new_unwind.frames.count != 0)
{
node->unwind = ctrl_unwind_deep_copy(node->arena, thread->arch, &new_unwind);
@@ -4221,7 +4211,7 @@ d_query_cached_rip_from_thread_unwind(D_Entity *thread, U64 unwind_count)
U64 result = 0;
if(unwind_count == 0)
{
result = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
result = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, thread->ctrl_handle);
}
else
{
@@ -4465,7 +4455,7 @@ d_init(void)
// rjf: set up initial entities
{
D_Entity *local_machine = d_entity_alloc(d_state->entities_root, D_EntityKind_Machine);
d_entity_equip_ctrl_machine_id(local_machine, CTRL_MachineID_Local);
d_entity_equip_ctrl_handle(local_machine, ctrl_handle_make(CTRL_MachineID_Local, dmn_handle_zero()));
d_entity_equip_name(local_machine, str8_lit("This PC"));
}
@@ -4570,7 +4560,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
B32 should_snap = !(d_state->ctrl_soft_halt_issued);
d_state->ctrl_is_running = 0;
d_state->ctrl_soft_halt_issued = 0;
D_Entity *stop_thread = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *stop_thread = d_entity_from_ctrl_handle(event->entity);
// rjf: gather stop info
{
@@ -4603,7 +4593,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
// rjf: thread hit user breakpoint -> increment breakpoint hit count
if(should_snap && event->cause == CTRL_EventCause_UserBreakpoint)
{
U64 stop_thread_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, stop_thread->ctrl_machine_id, stop_thread->ctrl_handle);
U64 stop_thread_vaddr = ctrl_query_cached_rip_from_thread(d_state->ctrl_entity_store, stop_thread->ctrl_handle);
D_Entity *process = d_entity_ancestor_from_kind(stop_thread, D_EntityKind_Process);
D_Entity *module = d_module_from_process_vaddr(process, stop_thread_vaddr);
DI_Key dbgi_key = d_dbgi_key_from_module(module);
@@ -4683,10 +4673,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
}
// rjf: create entity
D_Entity *machine = d_machine_entity_from_machine_id(event->machine_id);
D_Entity *machine = d_machine_entity_from_machine_id(event->entity.machine_id);
D_Entity *entity = d_entity_alloc(machine, D_EntityKind_Process);
d_entity_equip_u64(entity, event->msg_id);
d_entity_equip_ctrl_machine_id(entity, event->machine_id);
d_entity_equip_ctrl_handle(entity, event->entity);
d_entity_equip_ctrl_id(entity, event->entity_id);
d_entity_equip_arch(entity, event->arch);
@@ -4695,9 +4684,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case CTRL_EventKind_NewThread:
{
// rjf: create entity
D_Entity *parent = d_entity_from_ctrl_handle(event->machine_id, event->parent);
D_Entity *parent = d_entity_from_ctrl_handle(event->parent);
D_Entity *entity = d_entity_alloc(parent, D_EntityKind_Thread);
d_entity_equip_ctrl_machine_id(entity, event->machine_id);
d_entity_equip_ctrl_handle(entity, event->entity);
d_entity_equip_arch(entity, event->arch);
d_entity_equip_ctrl_id(entity, event->entity_id);
@@ -4714,7 +4702,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
for(D_EntityNode *n = pending_thread_names.first; n != 0; n = n->next)
{
D_Entity *pending_thread_name = n->entity;
if(event->machine_id == pending_thread_name->ctrl_machine_id && event->entity_id == pending_thread_name->ctrl_id)
if(event->entity.machine_id == pending_thread_name->ctrl_handle.machine_id && event->entity_id == pending_thread_name->ctrl_id)
{
d_entity_mark_for_deletion(pending_thread_name);
d_entity_equip_name(entity, pending_thread_name->string);
@@ -4777,7 +4765,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case CTRL_EventKind_NewModule:
{
// rjf: grab process
D_Entity *parent = d_entity_from_ctrl_handle(event->machine_id, event->parent);
D_Entity *parent = d_entity_from_ctrl_handle(event->parent);
// rjf: determine if this is the first module
B32 is_first = 0;
@@ -4788,7 +4776,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
// rjf: create module entity
D_Entity *module = d_entity_alloc(parent, D_EntityKind_Module);
d_entity_equip_ctrl_machine_id(module, event->machine_id);
d_entity_equip_ctrl_handle(module, event->entity);
d_entity_equip_arch(module, event->arch);
d_entity_equip_name(module, event->string);
@@ -4824,19 +4811,19 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case CTRL_EventKind_EndProc:
{
U32 pid = event->entity_id;
D_Entity *process = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *process = d_entity_from_ctrl_handle(event->entity);
d_entity_mark_for_deletion(process);
}break;
case CTRL_EventKind_EndThread:
{
D_Entity *thread = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *thread = d_entity_from_ctrl_handle(event->entity);
d_entity_mark_for_deletion(thread);
}break;
case CTRL_EventKind_EndModule:
{
D_Entity *module = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *module = d_entity_from_ctrl_handle(event->entity);
d_entity_mark_for_deletion(module);
}break;
@@ -4844,7 +4831,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case CTRL_EventKind_ModuleDebugInfoPathChange:
{
D_Entity *module = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *module = d_entity_from_ctrl_handle(event->entity);
D_Entity *debug_info = d_entity_child_from_kind(module, D_EntityKind_DebugInfoPath);
if(d_entity_is_nil(debug_info))
{
@@ -4865,19 +4852,19 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case CTRL_EventKind_ThreadName:
{
String8 string = event->string;
D_Entity *entity = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *entity = d_entity_from_ctrl_handle(event->entity);
if(event->entity_id != 0)
{
entity = d_entity_from_ctrl_id(event->machine_id, event->entity_id);
entity = d_entity_from_ctrl_id(event->entity.machine_id, event->entity_id);
}
if(d_entity_is_nil(entity))
{
D_Entity *process = d_entity_from_ctrl_handle(event->machine_id, event->parent);
D_Entity *process = d_entity_from_ctrl_handle(event->parent);
if(!d_entity_is_nil(process))
{
entity = d_entity_alloc(process, D_EntityKind_PendingThreadName);
d_entity_equip_name(entity, string);
d_entity_equip_ctrl_machine_id(entity, event->machine_id);
d_entity_equip_ctrl_handle(entity, ctrl_handle_make(event->entity.machine_id, dmn_handle_zero()));
d_entity_equip_ctrl_id(entity, event->entity_id);
}
}
@@ -5207,7 +5194,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
CTRL_Msg msg = {CTRL_MsgKind_Kill};
{
msg.exit_code = 1;
msg.machine_id = process->ctrl_machine_id;
msg.entity = process->ctrl_handle;
MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters);
}
@@ -5232,7 +5218,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
CTRL_Msg msg = {CTRL_MsgKind_Kill};
{
msg.exit_code = 1;
msg.machine_id = process->ctrl_machine_id;
msg.entity = process->ctrl_handle;
MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters);
}
@@ -5252,7 +5237,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
if(entity->kind == D_EntityKind_Process)
{
CTRL_Msg msg = {CTRL_MsgKind_Detach};
msg.machine_id = entity->ctrl_machine_id;
msg.entity = entity->ctrl_handle;
MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters);
d_push_ctrl_msg(&msg);
@@ -5289,7 +5273,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case D_CmdKind_StepOut:
{
D_Entity *d_thread = d_entity_from_handle(params.entity);
CTRL_Entity *thread = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, d_thread->ctrl_machine_id, d_thread->ctrl_handle);
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, d_thread->ctrl_handle);
if(d_ctrl_targets_running())
{
if(d_ctrl_last_run_kind() == D_RunKind_Run)
@@ -5315,7 +5299,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
case D_CmdKind_StepOut:
{
// rjf: thread => full unwind
CTRL_Unwind unwind = ctrl_unwind_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->machine_id, thread->handle, os_now_microseconds()+10000);
CTRL_Unwind unwind = ctrl_unwind_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->handle, os_now_microseconds()+10000);
// rjf: use first unwind frame to generate trap
if(unwind.flags == 0 && unwind.frames.count > 1)
@@ -5360,7 +5344,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
{
need_run = 1;
run_kind = d_state->ctrl_last_run_kind;
run_thread = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, d_state->ctrl_last_run_thread_machine_id, d_state->ctrl_last_run_thread_handle);
run_thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, d_state->ctrl_last_run_thread_handle);
run_flags = d_state->ctrl_last_run_flags;
run_traps = d_state->ctrl_last_run_traps;
}
@@ -5371,9 +5355,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
U64 vaddr = params.vaddr;
if(thread->kind == D_EntityKind_Thread && vaddr != 0)
{
void *block = ctrl_query_cached_reg_block_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
void *block = ctrl_query_cached_reg_block_from_thread(scratch.arena, d_state->ctrl_entity_store, thread->ctrl_handle);
regs_arch_block_write_rip(thread->arch, block, vaddr);
B32 result = ctrl_thread_write_reg_block(thread->ctrl_machine_id, thread->ctrl_handle, block);
B32 result = ctrl_thread_write_reg_block(thread->ctrl_handle, block);
// rjf: early mutation of unwind cache for immediate frontend effect
if(result)
@@ -5652,10 +5636,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
{
if(e->kind == D_EntityKind_Thread)
{
CTRL_Entity *thread = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, e->ctrl_machine_id, e->ctrl_handle);
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, e->ctrl_handle);
thread->is_frozen = should_freeze;
CTRL_Msg msg = {should_freeze ? CTRL_MsgKind_FreezeThread : CTRL_MsgKind_ThawThread};
msg.machine_id = thread->machine_id;
msg.entity = thread->handle;
d_push_ctrl_msg(&msg);
}
@@ -5689,7 +5672,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
{
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(run_thread, CTRL_EntityKind_Process);
msg.run_flags = run_flags;
msg.machine_id = run_thread->machine_id;
msg.entity = run_thread->handle;
msg.parent = process->handle;
MemoryCopyArray(msg.exception_code_filters, d_state->ctrl_exception_code_filters);
@@ -5743,7 +5725,6 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
arena_clear(d_state->ctrl_last_run_arena);
d_state->ctrl_last_run_kind = run_kind;
d_state->ctrl_last_run_frame_idx = d_frame_index();
d_state->ctrl_last_run_thread_machine_id = run_thread->machine_id;
d_state->ctrl_last_run_thread_handle = run_thread->handle;
d_state->ctrl_last_run_flags = run_flags;
d_state->ctrl_last_run_traps = ctrl_trap_list_copy(d_state->ctrl_last_run_arena, &run_traps_copy);
+13 -17
View File
@@ -310,18 +310,17 @@ enum
D_EntityFlag_DiesOnRunStop = (1<<8),
//- rjf: ctrl entity equipment
D_EntityFlag_HasCtrlMachineID = (1<<9),
D_EntityFlag_HasCtrlHandle = (1<<10),
D_EntityFlag_HasArch = (1<<11),
D_EntityFlag_HasCtrlID = (1<<12),
D_EntityFlag_HasStackBase = (1<<13),
D_EntityFlag_HasTLSRoot = (1<<14),
D_EntityFlag_HasVAddrRng = (1<<15),
D_EntityFlag_HasVAddr = (1<<16),
D_EntityFlag_HasCtrlHandle = (1<<9),
D_EntityFlag_HasArch = (1<<10),
D_EntityFlag_HasCtrlID = (1<<11),
D_EntityFlag_HasStackBase = (1<<12),
D_EntityFlag_HasTLSRoot = (1<<13),
D_EntityFlag_HasVAddrRng = (1<<14),
D_EntityFlag_HasVAddr = (1<<15),
//- rjf: file properties
D_EntityFlag_IsFolder = (1<<17),
D_EntityFlag_IsMissing = (1<<18),
D_EntityFlag_IsFolder = (1<<16),
D_EntityFlag_IsMissing = (1<<17),
//- rjf: deletion
D_EntityFlag_MarkedForDeletion = (1<<31),
@@ -357,8 +356,7 @@ struct D_Entity
U64 timestamp;
// rjf: ctrl equipment
CTRL_MachineID ctrl_machine_id;
DMN_Handle ctrl_handle;
CTRL_Handle ctrl_handle;
Arch arch;
U32 ctrl_id;
U64 stack_base;
@@ -1002,8 +1000,7 @@ struct D_State
Arena *ctrl_last_run_arena;
D_RunKind ctrl_last_run_kind;
U64 ctrl_last_run_frame_idx;
CTRL_MachineID ctrl_last_run_thread_machine_id;
DMN_Handle ctrl_last_run_thread_handle;
CTRL_Handle ctrl_last_run_thread_handle;
CTRL_RunFlags ctrl_last_run_flags;
CTRL_TrapList ctrl_last_run_traps;
U128 ctrl_last_run_param_state_hash;
@@ -1203,8 +1200,7 @@ internal void d_entity_equip_cfg_src(D_Entity *entity, D_CfgSrc cfg_src);
internal void d_entity_equip_timestamp(D_Entity *entity, U64 timestamp);
//- rjf: control layer correllation equipment
internal void d_entity_equip_ctrl_machine_id(D_Entity *entity, CTRL_MachineID machine_id);
internal void d_entity_equip_ctrl_handle(D_Entity *entity, DMN_Handle handle);
internal void d_entity_equip_ctrl_handle(D_Entity *entity, CTRL_Handle handle);
internal void d_entity_equip_arch(D_Entity *entity, Arch arch);
internal void d_entity_equip_ctrl_id(D_Entity *entity, U32 id);
internal void d_entity_equip_stack_base(D_Entity *entity, U64 stack_base);
@@ -1230,7 +1226,7 @@ internal D_Entity *d_entity_root(void);
internal D_EntityList d_push_entity_list_with_kind(Arena *arena, D_EntityKind kind);
internal D_Entity *d_entity_from_id(D_EntityID id);
internal D_Entity *d_machine_entity_from_machine_id(CTRL_MachineID machine_id);
internal D_Entity *d_entity_from_ctrl_handle(CTRL_MachineID machine_id, DMN_Handle handle);
internal D_Entity *d_entity_from_ctrl_handle(CTRL_Handle handle);
internal D_Entity *d_entity_from_ctrl_id(CTRL_MachineID machine_id, U32 id);
internal D_Entity *d_entity_from_name_and_kind(String8 string, D_EntityKind kind);
+4 -4
View File
@@ -1724,7 +1724,7 @@ df_window_frame(DF_Window *ws)
DF_Palette(DF_PaletteCode_ImplicitButton)
{
D_Entity *entity = d_entity_from_handle(ws->entity_ctx_menu_entity);
CTRL_Entity *entity_ctrl = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, entity->ctrl_machine_id, entity->ctrl_handle);
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
DF_IconKind entity_icon = df_entity_kind_icon_kind_table[entity->kind];
D_EntityKindFlags kind_flags = d_entity_kind_flags_table[entity->kind];
String8 display_name = d_display_string_from_entity(scratch.arena, entity);
@@ -4018,7 +4018,7 @@ df_window_frame(DF_Window *ws)
U64 size = e_type_byte_size_from_key(row_eval.type_key);
size = Min(size, 64);
Rng1U64 vaddr_rng = r1u64(row_eval.value.u64, row_eval.value.u64+size);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, space_entity->ctrl_machine_id, space_entity->ctrl_handle, vaddr_rng, 0);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, space_entity->ctrl_handle, vaddr_rng, 0);
for(U64 idx = 0; idx < (slice.data.size+63)/64; idx += 1)
{
if(slice.byte_changed_flags[idx] != 0)
@@ -7283,7 +7283,7 @@ df_stop_explanation_string_icon_from_ctrl_event(Arena *arena, CTRL_Event *event,
DF_IconKind icon = DF_IconKind_Null;
String8 explanation = {0};
Temp scratch = scratch_begin(&arena, 1);
D_Entity *thread = d_entity_from_ctrl_handle(event->machine_id, event->entity);
D_Entity *thread = d_entity_from_ctrl_handle(event->entity);
String8 thread_display_string = d_display_string_from_entity(scratch.arena, thread);
String8 process_thread_string = thread_display_string;
D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
@@ -7868,7 +7868,7 @@ df_frame(void)
CTRL_Unwind unwind = d_query_cached_unwind_from_thread(thread);
D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = d_voff_from_vaddr(module, rip_vaddr);
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(d_state->ctrl_entity_store, thread->ctrl_handle);
D_EntityList all_modules = d_query_cached_entity_list_with_kind(D_EntityKind_Module);
U64 eval_modules_count = Max(1, all_modules.count);
E_Module *eval_modules = push_array(scratch.arena, E_Module, eval_modules_count);
+2 -2
View File
@@ -2218,7 +2218,7 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d
U64 size = e_type_byte_size_from_key(row_eval.type_key);
size = Min(size, 64);
Rng1U64 vaddr_rng = r1u64(row_eval.value.u64, row_eval.value.u64+size);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, space_entity->ctrl_machine_id, space_entity->ctrl_handle, vaddr_rng, 0);
CTRL_ProcessMemorySlice slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, space_entity->ctrl_handle, vaddr_rng, 0);
for(U64 idx = 0; idx < (slice.data.size+63)/64; idx += 1)
{
if(slice.byte_changed_flags[idx] != 0)
@@ -5616,7 +5616,7 @@ DF_VIEW_UI_FUNCTION_DEF(scheduler)
idx += 1)
{
D_Entity *entity = items.v[idx].entity;
CTRL_Entity *entity_ctrl = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, entity->ctrl_machine_id, entity->ctrl_handle);
CTRL_Entity *entity_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, entity->ctrl_handle);
B32 row_is_selected = (cursor.y == (S64)(idx+1));
F32 depth = 0.f;
if(query.size == 0) switch(entity->kind)
+5 -5
View File
@@ -443,7 +443,7 @@ df_entity_tooltips(D_Entity *entity)
}
{
CTRL_Event stop_event = d_ctrl_last_stop_event();
D_Entity *stopper_thread = d_entity_from_ctrl_handle(stop_event.machine_id, stop_event.entity);
D_Entity *stopper_thread = d_entity_from_ctrl_handle(stop_event.entity);
if(stopper_thread == entity)
{
ui_spacer(ui_em(1.5f, 1.f));
@@ -587,7 +587,7 @@ df_entity_desc_button(D_Entity *entity, FuzzyMatchRangeList *name_matches, Strin
if(entity->kind == D_EntityKind_Thread)
{
CTRL_Event stop_event = d_ctrl_last_stop_event();
D_Entity *stopped_thread = d_entity_from_ctrl_handle(stop_event.machine_id, stop_event.entity);
D_Entity *stopped_thread = d_entity_from_ctrl_handle(stop_event.entity);
D_Entity *selected_thread = d_entity_from_handle(d_base_regs()->thread);
if(selected_thread == entity)
{
@@ -952,7 +952,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
U64 selected_thread_rip_unwind_vaddr = d_query_cached_rip_from_thread_unwind(selected_thread, d_regs()->unwind_count);
D_Entity *selected_thread_module = d_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr);
CTRL_Event stop_event = d_ctrl_last_stop_event();
D_Entity *stopper_thread = d_entity_from_ctrl_handle(stop_event.machine_id, stop_event.entity);
D_Entity *stopper_thread = d_entity_from_ctrl_handle(stop_event.entity);
B32 is_focused = ui_is_focus_active();
B32 ctrlified = (os_get_event_flags() & OS_EventFlag_Ctrl);
Vec4F32 code_line_bgs[] =
@@ -1047,7 +1047,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
continue;
}
CTRL_Entity *thread_ctrl = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
CTRL_Entity *thread_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, thread->ctrl_handle);
U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0;
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
@@ -1206,7 +1206,7 @@ df_code_slice(DF_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{
continue;
}
CTRL_Entity *thread_ctrl = ctrl_entity_from_machine_id_handle(d_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
CTRL_Entity *thread_ctrl = ctrl_entity_from_handle(d_state->ctrl_entity_store, thread->ctrl_handle);
U64 unwind_count = (thread == selected_thread) ? d_regs()->unwind_count : 0;
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);