ctrl -> d

This commit is contained in:
Ryan Fleury
2026-04-22 14:53:37 -07:00
parent 0e3c821e28
commit 2eb0b8b233
14 changed files with 988 additions and 1051 deletions
+6 -6
View File
@@ -115,13 +115,13 @@ D_EntityKindTable:
COUNT, COUNT,
} }
@data(String8) ctrl_entity_kind_code_name_table: @data(String8) d_entity_kind_code_name_table:
{ {
`{0}`, `{0}`,
@expand(D_EntityKindTable a) `str8_lit_comp("$(a.code_name)")` @expand(D_EntityKindTable a) `str8_lit_comp("$(a.code_name)")`
} }
@data(String8) ctrl_entity_kind_display_string_table: @data(String8) d_entity_kind_display_string_table:
{ {
`{0}`, `{0}`,
@expand(D_EntityKindTable a) `str8_lit_comp("$(a.display_name)")` @expand(D_EntityKindTable a) `str8_lit_comp("$(a.display_name)")`
@@ -179,25 +179,25 @@ D_ExceptionCodeKindTable:
COUNT, COUNT,
} }
@data(U32) ctrl_exception_code_kind_code_table: @data(U32) d_exception_code_kind_code_table:
{ {
`0`; `0`;
@expand(D_ExceptionCodeKindTable a) `$(a.code)`; @expand(D_ExceptionCodeKindTable a) `$(a.code)`;
} }
@data(String8) ctrl_exception_code_kind_display_string_table: @data(String8) d_exception_code_kind_display_string_table:
{ {
`{0}`; `{0}`;
@expand(D_ExceptionCodeKindTable a) `str8_lit_comp("$(a.display_string)")`; @expand(D_ExceptionCodeKindTable a) `str8_lit_comp("$(a.display_string)")`;
} }
@data(String8) ctrl_exception_code_kind_lowercase_code_string_table: @data(String8) d_exception_code_kind_lowercase_code_string_table:
{ {
`{0}`; `{0}`;
@expand(D_ExceptionCodeKindTable a) `str8_lit_comp("$(a.lower_name)")`; @expand(D_ExceptionCodeKindTable a) `str8_lit_comp("$(a.lower_name)")`;
} }
@data(B8) ctrl_exception_code_kind_default_enable_table: @data(B8) d_exception_code_kind_default_enable_table:
{ {
`0`; `0`;
@expand(D_ExceptionCodeKindTable a) `$(a.default)`; @expand(D_ExceptionCodeKindTable a) `$(a.default)`;
+4 -4
View File
@@ -71,7 +71,7 @@ d_init(void)
scratch_end(scratch); scratch_end(scratch);
} }
d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex = rw_mutex_alloc(); d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex = rw_mutex_alloc();
d_ctrl_state->ctrl_thread_entity_store = ctrl_entity_ctx_rw_store_alloc(); d_ctrl_state->ctrl_thread_entity_store = d_entity_ctx_rw_store_alloc();
d_ctrl_state->ctrl_thread_eval_cache = e_cache_alloc(); d_ctrl_state->ctrl_thread_eval_cache = e_cache_alloc();
d_ctrl_state->ctrl_thread_msg_process_arena = arena_alloc(); d_ctrl_state->ctrl_thread_msg_process_arena = arena_alloc();
d_ctrl_state->dmn_event_arena = arena_alloc(); d_ctrl_state->dmn_event_arena = arena_alloc();
@@ -79,13 +79,13 @@ d_init(void)
d_ctrl_state->dbg_dir_arena = arena_alloc(); d_ctrl_state->dbg_dir_arena = arena_alloc();
for(D_ExceptionCodeKind k = (D_ExceptionCodeKind)0; k < D_ExceptionCodeKind_COUNT; k = (D_ExceptionCodeKind)(k+1)) for(D_ExceptionCodeKind k = (D_ExceptionCodeKind)0; k < D_ExceptionCodeKind_COUNT; k = (D_ExceptionCodeKind)(k+1))
{ {
if(ctrl_exception_code_kind_default_enable_table[k]) if(d_exception_code_kind_default_enable_table[k])
{ {
d_ctrl_state->exception_code_filters[k/64] |= 1ull<<(k%64); d_ctrl_state->exception_code_filters[k/64] |= 1ull<<(k%64);
} }
} }
d_ctrl_state->ctrl_thread_log = log_alloc(); d_ctrl_state->ctrl_thread_log = log_alloc();
d_ctrl_state->ctrl_thread = thread_launch(ctrl_thread__entry_point, 0); d_ctrl_state->ctrl_thread = thread_launch(d_ctrl_thread__entry_point, 0);
} }
//- rjf: set up user state //- rjf: set up user state
@@ -96,7 +96,7 @@ d_init(void)
d_user_state->cmds_arena = arena_alloc(); d_user_state->cmds_arena = arena_alloc();
d_user_state->output_log_key = c_key_make(c_root_alloc(), c_id_make(0, 0)); d_user_state->output_log_key = c_key_make(c_root_alloc(), c_id_make(0, 0));
c_submit_data(d_user_state->output_log_key, 0, str8_zero()); c_submit_data(d_user_state->output_log_key, 0, str8_zero());
d_user_state->ctrl_entity_store = ctrl_entity_ctx_rw_store_alloc(); d_user_state->ctrl_entity_store = d_entity_ctx_rw_store_alloc();
d_user_state->ctrl_stop_arena = arena_alloc(); d_user_state->ctrl_stop_arena = arena_alloc();
d_user_state->ctrl_msg_arena = arena_alloc(); d_user_state->ctrl_msg_arena = arena_alloc();
+5 -5
View File
@@ -179,14 +179,14 @@ struct D_EntityHashSlot
D_EntityHashNode *last; D_EntityHashNode *last;
}; };
typedef struct CTRL_EntityStringChunkNode CTRL_EntityStringChunkNode; typedef struct D_EntityStringChunkNode D_EntityStringChunkNode;
struct CTRL_EntityStringChunkNode struct D_EntityStringChunkNode
{ {
CTRL_EntityStringChunkNode *next; D_EntityStringChunkNode *next;
U64 size; U64 size;
}; };
read_only global U64 ctrl_entity_string_bucket_chunk_sizes[] = read_only global U64 d_entity_string_bucket_chunk_sizes[] =
{ {
16, 16,
64, 64,
@@ -215,7 +215,7 @@ struct D_EntityCtxRWStore
D_EntityCtx ctx; D_EntityCtx ctx;
D_Entity *free; D_Entity *free;
D_EntityHashNode *hash_node_free; D_EntityHashNode *hash_node_free;
CTRL_EntityStringChunkNode *free_string_chunks[ArrayCount(ctrl_entity_string_bucket_chunk_sizes)]; D_EntityStringChunkNode *free_string_chunks[ArrayCount(d_entity_string_bucket_chunk_sizes)];
}; };
typedef struct D_EntityCtxLookupAccel D_EntityCtxLookupAccel; typedef struct D_EntityCtxLookupAccel D_EntityCtxLookupAccel;
File diff suppressed because it is too large Load Diff
+124 -133
View File
@@ -349,267 +349,258 @@ thread_static D_EntityCtxLookupAccel *d_entity_ctx_lookup_accel = 0;
//////////////////////////////// ////////////////////////////////
//~ rjf: Basic Type Functions //~ rjf: Basic Type Functions
internal U64 ctrl_hash_from_string(String8 string); internal U64 d_hash_from_handle(D_Handle handle);
internal U64 ctrl_hash_from_handle(D_Handle handle); internal D_EventCause d_event_cause_from_dmn_event_kind(DMN_EventKind event_kind);
internal D_EventCause ctrl_event_cause_from_dmn_event_kind(DMN_EventKind event_kind); internal D_ExceptionKind d_exception_kind_from_dmn(DMN_ExceptionKind kind);
internal D_ExceptionKind ctrl_exception_kind_from_dmn(DMN_ExceptionKind kind); internal D_TlsModel d_dynamic_linker_type_from_dmn(DMN_TlsModel type);
internal D_TlsModel ctrl_dynamic_linker_type_from_dmn(DMN_TlsModel type); internal String8 d_string_from_event_kind(D_EventKind kind);
internal String8 ctrl_string_from_event_kind(D_EventKind kind); internal String8 d_string_from_msg_kind(D_MsgKind kind);
internal String8 ctrl_string_from_msg_kind(D_MsgKind kind); internal D_EntityKind d_entity_kind_from_string(String8 string);
internal D_EntityKind ctrl_entity_kind_from_string(String8 string); internal DMN_TrapFlags d_dmn_trap_flags_from_breakpoint_flags(D_BreakpointFlags flags);
internal DMN_TrapFlags ctrl_dmn_trap_flags_from_user_breakpoint_flags(D_BreakpointFlags flags); internal D_BreakpointFlags d_breakpoint_flags_from_dmn_trap_flags(DMN_TrapFlags flags);
internal D_BreakpointFlags ctrl_user_breakpoint_flags_from_dmn_trap_flags(DMN_TrapFlags flags);
//////////////////////////////// ////////////////////////////////
//~ rjf: Handle Type Functions //~ rjf: Handle Type Functions
internal D_Handle ctrl_handle_zero(void); internal D_Handle d_handle_zero(void);
internal D_Handle ctrl_handle_make(D_MachineID machine_id, DMN_Handle dmn_handle); internal D_Handle d_handle_make(D_MachineID machine_id, DMN_Handle dmn_handle);
internal B32 ctrl_handle_match(D_Handle a, D_Handle b); internal B32 d_handle_match(D_Handle a, D_Handle b);
internal void ctrl_handle_list_push(Arena *arena, D_HandleList *list, D_Handle *pair); internal void d_handle_list_push(Arena *arena, D_HandleList *list, D_Handle *pair);
internal D_HandleList ctrl_handle_list_copy(Arena *arena, D_HandleList *src); internal D_HandleList d_handle_list_copy(Arena *arena, D_HandleList *src);
internal D_HandleArray ctrl_handle_array_from_list(Arena *arena, D_HandleList *src); internal D_HandleArray d_handle_array_from_list(Arena *arena, D_HandleList *src);
internal String8 ctrl_string_from_handle(Arena *arena, D_Handle handle); internal String8 d_string_from_handle(Arena *arena, D_Handle handle);
internal D_Handle ctrl_handle_from_string(String8 string); internal D_Handle d_handle_from_string(String8 string);
//////////////////////////////// ////////////////////////////////
//~ rjf: Trap Type Functions //~ rjf: Trap Type Functions
internal void ctrl_trap_list_push(Arena *arena, D_TrapList *list, D_Trap *trap); internal void d_trap_list_push(Arena *arena, D_TrapList *list, D_Trap *trap);
internal D_TrapList ctrl_trap_list_copy(Arena *arena, D_TrapList *src); internal D_TrapList d_trap_list_copy(Arena *arena, D_TrapList *src);
//////////////////////////////// ////////////////////////////////
//~ rjf: User Breakpoint Type Functions //~ rjf: User Breakpoint Type Functions
internal void ctrl_user_breakpoint_list_push(Arena *arena, D_BreakpointList *list, D_Breakpoint *bp); internal void d_breakpoint_list_push(Arena *arena, D_BreakpointList *list, D_Breakpoint *bp);
internal D_BreakpointList ctrl_user_breakpoint_list_copy(Arena *arena, D_BreakpointList *src); internal D_BreakpointList d_breakpoint_list_copy(Arena *arena, D_BreakpointList *src);
//////////////////////////////// ////////////////////////////////
//~ rjf: Message Type Functions //~ rjf: Message Type Functions
//- rjf: deep copying //- rjf: deep copying
internal void ctrl_msg_deep_copy(Arena *arena, D_Msg *dst, D_Msg *src); internal void d_msg_deep_copy(Arena *arena, D_Msg *dst, D_Msg *src);
//- rjf: list building //- rjf: list building
internal D_Msg *ctrl_msg_list_push(Arena *arena, D_MsgList *list); internal D_Msg *d_msg_list_push(Arena *arena, D_MsgList *list);
internal D_MsgList ctrl_msg_list_deep_copy(Arena *arena, D_MsgList *src); internal D_MsgList d_msg_list_deep_copy(Arena *arena, D_MsgList *src);
internal void ctrl_msg_list_concat_in_place(D_MsgList *dst, D_MsgList *src); internal void d_msg_list_concat_in_place(D_MsgList *dst, D_MsgList *src);
//- rjf: serialization //- rjf: serialization
internal String8 ctrl_serialized_string_from_msg_list(Arena *arena, D_MsgList *msgs); internal String8 d_serialized_string_from_msg_list(Arena *arena, D_MsgList *msgs);
internal D_MsgList ctrl_msg_list_from_serialized_string(Arena *arena, String8 string); internal D_MsgList d_msg_list_from_serialized_string(Arena *arena, String8 string);
//////////////////////////////// ////////////////////////////////
//~ rjf: Event Type Functions //~ rjf: Event Type Functions
//- rjf: list building //- rjf: list building
internal D_Event *ctrl_event_list_push(Arena *arena, D_EventList *list); internal D_Event *d_event_list_push(Arena *arena, D_EventList *list);
internal void ctrl_event_list_concat_in_place(D_EventList *dst, D_EventList *to_push); internal void d_event_list_concat_in_place(D_EventList *dst, D_EventList *to_push);
//- rjf: serialization //- rjf: serialization
internal String8 ctrl_serialized_string_from_event(Arena *arena, D_Event *event, U64 max); internal String8 d_serialized_string_from_event(Arena *arena, D_Event *event, U64 max);
internal D_Event ctrl_event_from_serialized_string(Arena *arena, String8 string); internal D_Event d_event_from_serialized_string(Arena *arena, String8 string);
//////////////////////////////// ////////////////////////////////
//~ rjf: Entity Type Functions //~ rjf: Entity Type Functions
//- rjf: entity list data structures //- rjf: entity list data structures
internal void ctrl_entity_list_push(Arena *arena, D_EntityList *list, D_Entity *entity); internal void d_entity_list_push(Arena *arena, D_EntityList *list, D_Entity *entity);
internal D_EntityList ctrl_entity_list_from_handle_list(Arena *arena, D_EntityCtx *ctx, D_HandleList *list); internal D_EntityList d_entity_list_from_handle_list(Arena *arena, D_EntityCtx *ctx, D_HandleList *list);
#define ctrl_entity_list_first(list) ((list)->first ? (list)->first->v : &d_entity_nil) #define d_entity_list_first(list) ((list)->first ? (list)->first->v : &d_entity_nil)
//- rjf: entity array data structure //- rjf: entity array data structure
internal D_EntityArray ctrl_entity_array_from_list(Arena *arena, D_EntityList *list); internal D_EntityArray d_entity_array_from_list(Arena *arena, D_EntityList *list);
#define ctrl_entity_array_first(array) ((array)->count != 0 ? (array)->v[0] : &d_entity_nil) #define d_entity_array_first(array) ((array)->count != 0 ? (array)->v[0] : &d_entity_nil)
//- rjf: entity context (entity group read-only) functions //- rjf: entity context (entity group read-only) functions
internal D_Entity *ctrl_entity_from_handle(D_EntityCtx *ctx, D_Handle handle); internal D_Entity *d_entity_from_handle(D_EntityCtx *ctx, D_Handle handle);
internal D_Entity *ctrl_entity_child_from_kind(D_Entity *parent, D_EntityKind kind); internal D_Entity *d_entity_child_from_kind(D_Entity *parent, D_EntityKind kind);
internal D_Entity *ctrl_entity_ancestor_from_kind(D_Entity *entity, D_EntityKind kind); internal D_Entity *d_entity_ancestor_from_kind(D_Entity *entity, D_EntityKind kind);
internal D_Entity *ctrl_process_from_entity(D_Entity *entity); internal D_Entity *d_process_from_entity(D_Entity *entity);
internal D_Entity *ctrl_module_from_process_vaddr(D_Entity *process, U64 vaddr); internal D_Entity *d_module_from_process_vaddr(D_Entity *process, U64 vaddr);
internal DI_Key ctrl_dbgi_key_from_module(D_Entity *module); internal DI_Key d_dbgi_key_from_module(D_Entity *module);
internal D_Entity *ctrl_module_from_thread_candidates(D_EntityCtx *ctx, D_Entity *thread, D_EntityList *candidates); internal D_Entity *d_module_from_thread_candidates(D_EntityCtx *ctx, D_Entity *thread, D_EntityList *candidates);
internal U64 ctrl_vaddr_from_voff(D_Entity *module, U64 voff); internal U64 d_vaddr_from_voff(D_Entity *module, U64 voff);
internal U64 ctrl_voff_from_vaddr(D_Entity *module, U64 vaddr); internal U64 d_voff_from_vaddr(D_Entity *module, U64 vaddr);
internal Rng1U64 ctrl_vaddr_range_from_voff_range(D_Entity *module, Rng1U64 voff_range); internal Rng1U64 d_vaddr_range_from_voff_range(D_Entity *module, Rng1U64 voff_range);
internal Rng1U64 ctrl_voff_range_from_vaddr_range(D_Entity *module, Rng1U64 vaddr_range); internal Rng1U64 d_voff_range_from_vaddr_range(D_Entity *module, Rng1U64 vaddr_range);
internal B32 ctrl_entity_tree_is_frozen(D_Entity *root); internal B32 d_entity_tree_is_frozen(D_Entity *root);
//- rjf: entity tree iteration //- rjf: entity tree iteration
internal D_EntityRec ctrl_entity_rec_depth_first(D_Entity *entity, D_Entity *subtree_root, U64 sib_off, U64 child_off); internal D_EntityRec d_entity_rec_depth_first(D_Entity *entity, D_Entity *subtree_root, U64 sib_off, U64 child_off);
#define ctrl_entity_rec_depth_first_pre(entity, subtree_root) ctrl_entity_rec_depth_first((entity), (subtree_root), OffsetOf(D_Entity, next), OffsetOf(D_Entity, first)) #define d_entity_rec_depth_first_pre(entity, subtree_root) d_entity_rec_depth_first((entity), (subtree_root), OffsetOf(D_Entity, next), OffsetOf(D_Entity, first))
#define ctrl_entity_rec_depth_first_post(entity, subtree_root) ctrl_entity_rec_depth_first((entity), (subtree_root), OffsetOf(D_Entity, prev), OffsetOf(D_Entity, last))
//- rjf: entity ctx r/w store state functions //- rjf: entity ctx r/w store state functions
internal D_EntityCtxRWStore *ctrl_entity_ctx_rw_store_alloc(void); internal D_EntityCtxRWStore *d_entity_ctx_rw_store_alloc(void);
internal void ctrl_entity_ctx_rw_store_release(D_EntityCtxRWStore *store); internal void d_entity_ctx_rw_store_release(D_EntityCtxRWStore *store);
//- rjf: string allocation/deletion //- rjf: string allocation/deletion
internal U64 ctrl_name_bucket_num_from_string_size(U64 size); internal U64 d_name_bucket_num_from_string_size(U64 size);
internal String8 ctrl_entity_string_alloc(D_EntityCtxRWStore *store, String8 string); internal String8 d_entity_string_alloc(D_EntityCtxRWStore *store, String8 string);
internal void ctrl_entity_string_release(D_EntityCtxRWStore *store, String8 string); internal void d_entity_string_release(D_EntityCtxRWStore *store, String8 string);
//- rjf: entity construction/deletion //- rjf: entity construction/deletion
internal D_Entity *ctrl_entity_alloc(D_EntityCtxRWStore *store, D_Entity *parent, D_EntityKind kind, Arch arch, D_Handle handle, U64 id); internal D_Entity *d_entity_alloc(D_EntityCtxRWStore *store, D_Entity *parent, D_EntityKind kind, Arch arch, D_Handle handle, U64 id);
internal void ctrl_entity_release(D_EntityCtxRWStore *store, D_Entity *entity); internal void d_entity_release(D_EntityCtxRWStore *store, D_Entity *entity);
//- rjf: entity equipment //- rjf: entity equipment
internal void ctrl_entity_equip_string(D_EntityCtxRWStore *store, D_Entity *entity, String8 string); internal void d_entity_equip_string(D_EntityCtxRWStore *store, D_Entity *entity, String8 string);
//- rjf: accelerated entity context lookups //- rjf: accelerated entity context lookups
internal D_EntityCtxLookupAccel *ctrl_thread_entity_ctx_lookup_accel(void); internal D_EntityCtxLookupAccel *d_thread_entity_ctx_lookup_accel(void);
internal D_EntityArray ctrl_entity_array_from_kind(D_EntityCtx *ctx, D_EntityKind kind); internal D_EntityArray d_entity_array_from_kind(D_EntityCtx *ctx, D_EntityKind kind);
internal D_EntityList ctrl_modules_from_dbgi_key(Arena *arena, D_EntityCtx *ctx, DI_Key dbgi_key); internal D_EntityList d_modules_from_dbgi_key(Arena *arena, D_EntityCtx *ctx, DI_Key dbgi_key);
internal D_Entity *ctrl_thread_from_id(D_EntityCtx *ctx, U64 id); internal D_Entity *d_thread_from_id(D_EntityCtx *ctx, U64 id);
//- rjf: applying events to entity caches //- rjf: applying events to entity caches
internal void ctrl_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list); internal void d_entity_store_apply_events(D_EntityCtxRWStore *store, D_EventList *list);
//////////////////////////////// ////////////////////////////////
//~ rjf: Wakeup Callback Registration //~ rjf: Wakeup Callback Registration
internal void ctrl_set_wakeup_hook(D_WakeupFunctionType *wakeup_hook); internal void d_set_wakeup_hook(D_WakeupFunctionType *wakeup_hook);
//////////////////////////////// ////////////////////////////////
//~ rjf: Thread Register Functions //~ rjf: Thread Register Functions
//- rjf: thread register cache reading //- rjf: thread register cache reading
internal void *ctrl_reg_block_from_thread(Arena *arena, D_EntityCtx *ctx, D_Handle handle); internal void *d_reg_block_from_thread(Arena *arena, D_EntityCtx *ctx, D_Handle handle);
internal U64 ctrl_tls_root_vaddr_from_thread(D_EntityCtx *ctx, D_Handle handle); internal U64 d_tls_root_vaddr_from_thread(D_EntityCtx *ctx, D_Handle handle);
internal U64 ctrl_rip_from_thread(D_EntityCtx *ctx, D_Handle handle); internal U64 d_rip_from_thread(D_EntityCtx *ctx, D_Handle handle);
internal U64 ctrl_rsp_from_thread(D_EntityCtx *ctx, D_Handle handle); internal U64 d_rsp_from_thread(D_EntityCtx *ctx, D_Handle handle);
//- rjf: thread register writing //- rjf: thread register writing
internal B32 ctrl_thread_write_reg_block(D_Handle thread, void *block); internal B32 d_thread_write_reg_block(D_Handle thread, void *block);
//////////////////////////////// ////////////////////////////////
//~ rjf: Module Image Info Functions //~ rjf: Module Image Info Functions
//- rjf: cache lookups //- rjf: cache lookups
internal PE_IntelPdata *ctrl_intel_pdata_from_module_voff(Arena *arena, D_Handle module_handle, U64 voff); internal PE_IntelPdata *d_intel_pdata_from_module_voff(Arena *arena, D_Handle module_handle, U64 voff);
internal U64 ctrl_entry_point_voff_from_module(D_Handle module_handle); internal U64 d_entry_point_voff_from_module(D_Handle module_handle);
internal String8 ctrl_initial_debug_info_path_from_module(Arena *arena, D_Handle module_handle); internal String8 d_initial_debug_info_path_from_module(Arena *arena, D_Handle module_handle);
internal String8 ctrl_raddbg_data_from_module(Arena *arena, D_Handle module_handle); internal String8 d_raddbg_data_from_module(Arena *arena, D_Handle module_handle);
////////////////////////////////
//~ Process Info Functions
internal Arch ctrl_arch_from_process_handle(D_Handle process_handle);
//////////////////////////////// ////////////////////////////////
//~ rjf: Unwinding Functions //~ rjf: Unwinding Functions
//- rjf: unwind deep copier //- rjf: [dwarf]
internal D_Unwind ctrl_unwind_deep_copy(Arena *arena, Arch arch, D_Unwind *src); internal D_UnwindStepResult d_unwind_step_result_from_machine_op_result(MachineOpResult s);
internal D_UnwindStepResult d_establish_frame_unwind_context__dwarf(Arena *arena, D_Handle process_handle, D_Handle module_handle, Arch arch, void *regs, U64 endt_us, D_FrameUnwindContext *ctx_out);
//- DWARF internal D_UnwindStepResult d_unwind_step__dwarf(D_Handle process_handle, Arch arch, void *regs, D_FrameUnwindContext *frame_ctx, U64 endt_us);
internal D_UnwindStepResult ctrl_establish_frame_unwind_context__dwarf(Arena *arena, D_Handle process_handle, D_Handle module_handle, Arch arch, void *regs, U64 endt_us, D_FrameUnwindContext *ctx_out);
internal D_UnwindStepResult ctrl_unwind_step__dwarf(D_Handle process_handle, Arch arch, void *regs, D_FrameUnwindContext *frame_ctx, U64 endt_us);
//- rjf: [x64] //- rjf: [x64]
internal REGS_Reg64 *ctrl_unwind_reg_from_pe_gpr_reg__pe_x64(REGS_RegBlockX64 *regs, PE_UnwindGprRegX64 gpr_reg); internal REGS_Reg64 *d_unwind_reg_from_pe_gpr_reg__pe_x64(REGS_RegBlockX64 *regs, PE_UnwindGprRegX64 gpr_reg);
internal D_UnwindStepResult ctrl_unwind_step__pe_x64(D_Handle process_handle, D_Handle module_handle, U64 module_base_vaddr, REGS_RegBlockX64 *regs, U64 endt_us); internal D_UnwindStepResult d_unwind_step__pe_x64(D_Handle process_handle, D_Handle module_handle, U64 module_base_vaddr, REGS_RegBlockX64 *regs, U64 endt_us);
//- rjf: abstracted full unwind //- rjf: abstracted full unwind
internal D_Unwind ctrl_unwind_from_thread(Arena *arena, D_EntityCtx *ctx, D_Handle thread, U64 endt_us); internal D_Unwind d_unwind_from_thread(Arena *arena, D_EntityCtx *ctx, D_Handle thread, U64 endt_us);
//////////////////////////////// ////////////////////////////////
//~ rjf: Call Stack Building Functions //~ rjf: Call Stack Building Functions
internal D_CallStack ctrl_call_stack_from_unwind(Arena *arena, D_Entity *process, D_Unwind *base_unwind); internal D_CallStack d_call_stack_from_unwind(Arena *arena, D_Entity *process, D_Unwind *base_unwind);
internal D_CallStackFrame *ctrl_call_stack_frame_from_unwind_and_inline_depth(D_CallStack *call_stack, U64 unwind_count, U64 inline_depth); internal D_CallStackFrame *d_call_stack_frame_from_unwind_and_inline_depth(D_CallStack *call_stack, U64 unwind_count, U64 inline_depth);
//////////////////////////////// ////////////////////////////////
//~ rjf: Halting All Attached Processes //~ rjf: Halting All Attached Processes
internal void ctrl_halt(void); internal void d_halt(void);
//////////////////////////////// ////////////////////////////////
//~ rjf: Shared Accessor Functions //~ rjf: Shared Accessor Functions
//- rjf: generation counters //- rjf: generation counters
internal U64 ctrl_run_gen(void); internal U64 d_run_gen(void);
internal U64 ctrl_mem_gen(void); internal U64 d_mem_gen(void);
internal U64 ctrl_reg_gen(void); internal U64 d_reg_gen(void);
//- rjf: name -> register/alias hash tables, for eval //- rjf: name -> register/alias hash tables, for eval
internal E_String2NumMap *ctrl_string2reg_from_arch(Arch arch); internal E_String2NumMap *d_string2reg_from_arch(Arch arch);
internal E_String2NumMap *ctrl_string2alias_from_arch(Arch arch); internal E_String2NumMap *d_string2alias_from_arch(Arch arch);
//////////////////////////////// ////////////////////////////////
//~ rjf: Control-Thread Functions //~ rjf: Control-Thread Functions
//- rjf: user -> control thread communication //- rjf: user -> control thread communication
internal B32 ctrl_u2c_push_msgs(D_MsgList *msgs, U64 endt_us); internal B32 d_u2c_push_msgs(D_MsgList *msgs, U64 endt_us);
internal D_MsgList ctrl_u2c_pop_msgs(Arena *arena); internal D_MsgList d_u2c_pop_msgs(Arena *arena);
//- rjf: control -> user thread communication //- rjf: control -> user thread communication
internal void ctrl_c2u_push_events(D_EventList *events); internal void d_c2u_push_events(D_EventList *events);
internal D_EventList ctrl_c2u_pop_events(Arena *arena); internal D_EventList d_c2u_pop_events(Arena *arena);
//- rjf: entry point //- rjf: entry point
internal void ctrl_thread__entry_point(void *p); internal void d_ctrl_thread__entry_point(void *p);
//- rjf: breakpoint resolution //- rjf: breakpoint resolution
internal void ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, D_EvalScope *eval_scope, D_Handle process, D_Handle module, D_BreakpointList *user_bps, DMN_TrapChunkList *traps_out); internal void d_ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, D_EvalScope *eval_scope, D_Handle process, D_Handle module, D_BreakpointList *user_bps, DMN_TrapChunkList *traps_out);
internal void ctrl_thread__append_resolved_process_user_bp_traps(Arena *arena, D_EvalScope *eval_scope, D_Handle process, D_BreakpointList *user_bps, DMN_TrapChunkList *traps_out); internal void d_ctrl_thread__append_resolved_process_user_bp_traps(Arena *arena, D_EvalScope *eval_scope, D_Handle process, D_BreakpointList *user_bps, DMN_TrapChunkList *traps_out);
internal void ctrl_thread__append_program_defined_bp_traps(Arena *arena, D_Entity *bp, DMN_TrapChunkList *traps_out); internal void d_ctrl_thread__append_program_defined_bp_traps(Arena *arena, D_Entity *bp, DMN_TrapChunkList *traps_out);
//- rjf: module lifetime open/close work //- rjf: module lifetime open/close work
internal void ctrl_thread__module_open(D_Handle process, D_Handle module, Rng1U64 vaddr_range, String8 path, Rng1U64 elf_phdr_vrange, U64 elf_phdr_entsize); internal void d_ctrl_thread__module_open(D_Handle process, D_Handle module, Rng1U64 vaddr_range, String8 path, Rng1U64 elf_phdr_vrange, U64 elf_phdr_entsize);
internal void ctrl_thread__module_close(D_Handle process, D_Handle module, Rng1U64 vaddr_range); internal void d_ctrl_thread__module_close(D_Handle process, D_Handle module, Rng1U64 vaddr_range);
//- rjf: attached process running/event gathering //- rjf: attached process running/event gathering
internal DMN_Event *ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, DMN_RunCtrls *run_ctrls, D_Spoof *spoof); internal DMN_Event *d_ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, D_Msg *msg, DMN_RunCtrls *run_ctrls, D_Spoof *spoof);
//- rjf: eval helpers //- rjf: eval helpers
internal U64 ctrl_eval_space_gen(E_Space space); internal U64 d_ctrl_eval_space_gen(E_Space space);
internal B32 ctrl_eval_space_read(E_Space space, void *out, Rng1U64 vaddr_range); internal B32 d_ctrl_eval_space_read(E_Space space, void *out, Rng1U64 vaddr_range);
//- rjf: control thread eval scopes //- rjf: control thread eval scopes
internal D_EvalScope *ctrl_thread__eval_scope_begin(Arena *arena, D_BreakpointList *user_bps, D_Entity *thread); internal D_EvalScope *d_ctrl_thread__eval_scope_begin(Arena *arena, D_BreakpointList *user_bps, D_Entity *thread);
internal void ctrl_thread__eval_scope_end(D_EvalScope *scope); internal void d_ctrl_thread__eval_scope_end(D_EvalScope *scope);
//- rjf: log flusher //- rjf: log flusher
internal void ctrl_thread__end_and_flush_log(void); internal void d_ctrl_thread__end_and_flush_log(void);
//- rjf: msg kind implementations //- rjf: msg kind implementations
internal void ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__attach(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__attach(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__kill(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__kill(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__kill_all(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__kill_all(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__detach(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__detach(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
internal void ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg); internal void d_ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, D_Msg *msg);
//////////////////////////////// ////////////////////////////////
//~ rjf: Process Memory Artifact Cache Hooks / Lookups //~ rjf: Process Memory Artifact Cache Hooks / Lookups
internal AC_Artifact ctrl_memory_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out); internal AC_Artifact d_memory_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out);
internal void ctrl_memory_artifact_destroy(AC_Artifact artifact); internal void d_memory_artifact_destroy(AC_Artifact artifact);
internal C_Key ctrl_key_from_process_vaddr_range(D_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, B32 wait_for_fresh, U64 endt_us, B32 *out_is_stale); internal C_Key d_key_from_process_vaddr_range(D_Handle process, Rng1U64 vaddr_range, B32 zero_terminated, B32 wait_for_fresh, U64 endt_us, B32 *out_is_stale);
//- rjf: process memory reading helpers //- rjf: process memory reading helpers
internal D_ProcessMemorySlice ctrl_process_memory_slice_from_vaddr_range(Arena *arena, D_Handle process, Rng1U64 range, B32 wait_for_fresh, U64 endt_us); internal D_ProcessMemorySlice d_process_memory_slice_from_vaddr_range(Arena *arena, D_Handle process, Rng1U64 range, B32 wait_for_fresh, U64 endt_us);
internal B32 ctrl_process_memory_read(D_Handle process, Rng1U64 range, B32 *is_stale_out, void *out, U64 endt_us); internal B32 d_process_memory_read(D_Handle process, Rng1U64 range, B32 *is_stale_out, void *out, U64 endt_us);
#define ctrl_process_memory_read_struct(process, vaddr, is_stale_out, ptr, endt_us) ctrl_process_memory_read((process), r1u64((vaddr), (vaddr)+(sizeof(*(ptr)))), (is_stale_out), (ptr), (endt_us)) #define d_process_memory_read_struct(process, vaddr, is_stale_out, ptr, endt_us) d_process_memory_read((process), r1u64((vaddr), (vaddr)+(sizeof(*(ptr)))), (is_stale_out), (ptr), (endt_us))
//- rjf: process memory writing //- rjf: process memory writing
internal B32 ctrl_process_write(D_Handle process, Rng1U64 range, void *src); internal B32 d_process_write(D_Handle process, Rng1U64 range, void *src);
//////////////////////////////// ////////////////////////////////
//~ rjf: Call Stack Artifact Cache Hooks / Lookups //~ rjf: Call Stack Artifact Cache Hooks / Lookups
internal AC_Artifact ctrl_call_stack_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out); internal AC_Artifact d_call_stack_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out);
internal void ctrl_call_stack_artifact_destroy(AC_Artifact artifact); internal void d_call_stack_artifact_destroy(AC_Artifact artifact);
internal D_CallStack ctrl_call_stack_from_thread(Access *access, D_Handle thread_handle, B32 high_priority, U64 endt_us); internal D_CallStack d_call_stack_from_thread(Access *access, D_Handle thread_handle, B32 high_priority, U64 endt_us);
//////////////////////////////// ////////////////////////////////
//~ rjf: Call Stack Tree Artifact Cache Hooks / Lookups //~ rjf: Call Stack Tree Artifact Cache Hooks / Lookups
internal AC_Artifact ctrl_call_stack_tree_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out); internal AC_Artifact d_call_stack_tree_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out);
internal void ctrl_call_stack_tree_artifact_destroy(AC_Artifact artifact); internal void d_call_stack_tree_artifact_destroy(AC_Artifact artifact);
internal D_CallStackTree ctrl_call_stack_tree(Access *access, U64 endt_us); internal D_CallStackTree d_call_stack_tree(Access *access, U64 endt_us);
#endif // DBG_ENGINE_CTRL_H #endif // DBG_ENGINE_CTRL_H
+88 -88
View File
@@ -292,15 +292,15 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, D_Entity *thread)
D_TrapNet result = {0}; D_TrapNet result = {0};
// rjf: thread => unpacked info // rjf: thread => unpacked info
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
Arch arch = thread->arch; Arch arch = thread->arch;
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); U64 ip_vaddr = d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
// rjf: ip => machine code // rjf: ip => machine code
String8 machine_code = {0}; String8 machine_code = {0};
{ {
Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch)); Rng1U64 rng = r1u64(ip_vaddr, ip_vaddr+max_instruction_size_from_arch(arch));
D_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 = d_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, rng, 0, os_now_microseconds()+5000);
machine_code = machine_code_slice.data; machine_code = machine_code_slice.data;
} }
@@ -316,7 +316,7 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, D_Entity *thread)
if(inst.flags & DASM_InstFlag_Call || inst.flags & DASM_InstFlag_Repeats) if(inst.flags & DASM_InstFlag_Call || inst.flags & DASM_InstFlag_Repeats)
{ {
D_Trap trap = {D_TrapFlag_EndStepping, ip_vaddr+inst.size}; D_Trap trap = {D_TrapFlag_EndStepping, ip_vaddr+inst.size};
ctrl_trap_list_push(arena, &result.traps, &trap); d_trap_list_push(arena, &result.traps, &trap);
} }
} }
@@ -333,10 +333,10 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
// rjf: thread => info // rjf: thread => info
Arch arch = thread->arch; Arch arch = thread->arch;
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); U64 ip_vaddr = d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, ip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
log_infof("ip_vaddr: 0x%I64x\n", ip_vaddr); 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]); log_infof("dbgi_key: {0x%I64x, 0x%I64x}\n", dbgi_key.u64[0], dbgi_key.u64[1]);
@@ -345,7 +345,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
S64 line_num = 0; S64 line_num = 0;
Rng1U64 line_vaddr_rng = {0}; Rng1U64 line_vaddr_rng = {0};
{ {
U64 ip_voff = ctrl_voff_from_vaddr(module, ip_vaddr); U64 ip_voff = d_voff_from_vaddr(module, ip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff);
Rng1U64 line_voff_rng = {0}; Rng1U64 line_voff_rng = {0};
if(lines.first != 0) if(lines.first != 0)
@@ -353,7 +353,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
line_voff_rng = lines.first->v.voff_range; line_voff_rng = lines.first->v.voff_range;
file_path = lines.first->v.file_path; file_path = lines.first->v.file_path;
line_num = lines.first->v.pt.line; line_num = lines.first->v.pt.line;
line_vaddr_rng = ctrl_vaddr_range_from_voff_range(module, line_voff_rng); line_vaddr_rng = d_vaddr_range_from_voff_range(module, line_voff_rng);
log_infof("line: {%S:%I64i}\n", lines.first->v.file_path, lines.first->v.pt.line); log_infof("line: {%S:%I64i}\n", lines.first->v.file_path, lines.first->v.pt.line);
} }
log_infof("voff_range: {0x%I64x, 0x%I64x}\n", line_voff_rng.min, line_voff_rng.max); log_infof("voff_range: {0x%I64x, 0x%I64x}\n", line_voff_rng.min, line_voff_rng.max);
@@ -367,7 +367,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
for EachNode(n, D_LineNode, lines.first) for EachNode(n, D_LineNode, lines.first)
{ {
Rng1U64 voff_range = n->v.voff_range; Rng1U64 voff_range = n->v.voff_range;
Rng1U64 vaddr_range = ctrl_vaddr_range_from_voff_range(module, voff_range); Rng1U64 vaddr_range = d_vaddr_range_from_voff_range(module, voff_range);
rng1u64_list_push(scratch.arena, &all_vaddr_ranges_on_same_line, vaddr_range); rng1u64_list_push(scratch.arena, &all_vaddr_ranges_on_same_line, vaddr_range);
} }
} }
@@ -377,11 +377,11 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
// MSVC exports line info at these line numbers when /JMC (Just My Code) debugging // MSVC exports line info at these line numbers when /JMC (Just My Code) debugging
// is enabled. This is enabled by default normally. // is enabled. This is enabled by default normally.
{ {
U64 opl_line_voff_rng = ctrl_voff_from_vaddr(module, line_vaddr_rng.max); U64 opl_line_voff_rng = d_voff_from_vaddr(module, line_vaddr_rng.max);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng);
if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee)) if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee))
{ {
line_vaddr_rng.max = ctrl_vaddr_from_voff(module, lines.first->v.voff_range.max); line_vaddr_rng.max = d_vaddr_from_voff(module, lines.first->v.voff_range.max);
} }
} }
@@ -393,7 +393,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
B32 good_machine_code = 0; B32 good_machine_code = 0;
if(good_line_info) if(good_line_info)
{ {
D_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 = d_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+50000);
machine_code = machine_code_slice.data; machine_code = machine_code_slice.data;
good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad); good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
LogInfoNamedBlockF("machine_code_slice") LogInfoNamedBlockF("machine_code_slice")
@@ -492,7 +492,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
if(add) if(add)
{ {
D_Trap trap = {flags, trap_addr}; D_Trap trap = {flags, trap_addr};
ctrl_trap_list_push(arena, &result.traps, &trap); d_trap_list_push(arena, &result.traps, &trap);
} }
} }
@@ -515,7 +515,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, D_Entity *thread)
if(!opl_in_line) if(!opl_in_line)
{ {
D_Trap trap = {D_TrapFlag_EndStepping, opl}; D_Trap trap = {D_TrapFlag_EndStepping, opl};
ctrl_trap_list_push(arena, &result.traps, &trap); d_trap_list_push(arena, &result.traps, &trap);
} }
} }
} }
@@ -546,17 +546,17 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
// rjf: thread => info // rjf: thread => info
Arch arch = thread->arch; Arch arch = thread->arch;
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); U64 ip_vaddr = d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, ip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
// rjf: ip => line info // rjf: ip => line info
String8 file_path = {0}; String8 file_path = {0};
S64 line_num = 0; S64 line_num = 0;
Rng1U64 line_vaddr_rng = {0}; Rng1U64 line_vaddr_rng = {0};
{ {
U64 ip_voff = ctrl_voff_from_vaddr(module, ip_vaddr); U64 ip_voff = d_voff_from_vaddr(module, ip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, ip_voff);
Rng1U64 line_voff_rng = {0}; Rng1U64 line_voff_rng = {0};
if(lines.first != 0) if(lines.first != 0)
@@ -564,7 +564,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
line_voff_rng = lines.first->v.voff_range; line_voff_rng = lines.first->v.voff_range;
file_path = lines.first->v.file_path; file_path = lines.first->v.file_path;
line_num = lines.first->v.pt.line; line_num = lines.first->v.pt.line;
line_vaddr_rng = ctrl_vaddr_range_from_voff_range(module, line_voff_rng); line_vaddr_rng = d_vaddr_range_from_voff_range(module, line_voff_rng);
log_infof("line: {%S:%I64i}\n", lines.first->v.file_path, lines.first->v.pt.line); log_infof("line: {%S:%I64i}\n", lines.first->v.file_path, lines.first->v.pt.line);
} }
log_infof("voff_range: {0x%I64x, 0x%I64x}\n", line_voff_rng.min, line_voff_rng.max); log_infof("voff_range: {0x%I64x, 0x%I64x}\n", line_voff_rng.min, line_voff_rng.max);
@@ -578,7 +578,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
for EachNode(n, D_LineNode, lines.first) for EachNode(n, D_LineNode, lines.first)
{ {
Rng1U64 voff_range = n->v.voff_range; Rng1U64 voff_range = n->v.voff_range;
Rng1U64 vaddr_range = ctrl_vaddr_range_from_voff_range(module, voff_range); Rng1U64 vaddr_range = d_vaddr_range_from_voff_range(module, voff_range);
rng1u64_list_push(scratch.arena, &all_vaddr_ranges_on_same_line, vaddr_range); rng1u64_list_push(scratch.arena, &all_vaddr_ranges_on_same_line, vaddr_range);
} }
} }
@@ -588,11 +588,11 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
// MSVC exports line info at these line numbers when /JMC (Just My Code) debugging // MSVC exports line info at these line numbers when /JMC (Just My Code) debugging
// is enabled. This is enabled by default normally. // is enabled. This is enabled by default normally.
{ {
U64 opl_line_voff_rng = ctrl_voff_from_vaddr(module, line_vaddr_rng.max); U64 opl_line_voff_rng = d_voff_from_vaddr(module, line_vaddr_rng.max);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, opl_line_voff_rng);
if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee)) if(lines.first != 0 && (lines.first->v.pt.line == 0xf00f00 || lines.first->v.pt.line == 0xfeefee))
{ {
line_vaddr_rng.max = ctrl_vaddr_from_voff(module, lines.first->v.voff_range.max); line_vaddr_rng.max = d_vaddr_from_voff(module, lines.first->v.voff_range.max);
} }
} }
@@ -604,7 +604,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
B32 good_machine_code = 0; B32 good_machine_code = 0;
if(good_line_info) if(good_line_info)
{ {
D_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 = d_process_memory_slice_from_vaddr_range(scratch.arena, process->handle, line_vaddr_rng, 0, os_now_microseconds()+5000);
machine_code = machine_code_slice.data; machine_code = machine_code_slice.data;
good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad); good_machine_code = (machine_code.size >= dim_1u64(line_vaddr_rng) && !machine_code_slice.any_byte_bad);
} }
@@ -649,9 +649,9 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
point->jump_dest_vaddr != 0) point->jump_dest_vaddr != 0)
{ {
U64 jump_dest_vaddr = point->jump_dest_vaddr; U64 jump_dest_vaddr = point->jump_dest_vaddr;
D_Entity *jump_dest_module = ctrl_module_from_process_vaddr(process, jump_dest_vaddr); D_Entity *jump_dest_module = d_module_from_process_vaddr(process, jump_dest_vaddr);
U64 jump_dest_voff = ctrl_voff_from_vaddr(jump_dest_module, jump_dest_vaddr); U64 jump_dest_voff = d_voff_from_vaddr(jump_dest_module, jump_dest_vaddr);
DI_Key jump_dest_dbgi_key = ctrl_dbgi_key_from_module(jump_dest_module); DI_Key jump_dest_dbgi_key = d_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); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, jump_dest_dbgi_key, jump_dest_voff);
if(lines.count == 0) if(lines.count == 0)
{ {
@@ -701,7 +701,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
if(add) if(add)
{ {
D_Trap trap = {flags, trap_addr}; D_Trap trap = {flags, trap_addr};
ctrl_trap_list_push(arena, &result.traps, &trap); d_trap_list_push(arena, &result.traps, &trap);
} }
} }
@@ -724,7 +724,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, D_Entity *thread)
if(!opl_in_line) if(!opl_in_line)
{ {
D_Trap trap = {D_TrapFlag_EndStepping, opl}; D_Trap trap = {D_TrapFlag_EndStepping, opl};
ctrl_trap_list_push(arena, &result.traps, &trap); d_trap_list_push(arena, &result.traps, &trap);
} }
} }
} }
@@ -1073,8 +1073,8 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
//- rjf: unpack module info //- rjf: unpack module info
D_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
U64 addr_size = byte_size_from_arch(process->arch); U64 addr_size = byte_size_from_arch(process->arch);
switch(process->tls_model) switch(process->tls_model)
{ {
@@ -1084,7 +1084,7 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
// read thread local base pointer out of TEB // read thread local base pointer out of TEB
U64 thread_local_base = root_vaddr; U64 thread_local_base = root_vaddr;
U64 tls_addr_array = 0; U64 tls_addr_array = 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); D_ProcessMemorySlice tls_addr_array_slice = d_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; String8 tls_array_vaddr_data = tls_addr_array_slice.data;
if(tls_array_vaddr_data.size == addr_size) if(tls_array_vaddr_data.size == addr_size)
{ {
@@ -1093,7 +1093,7 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
// read thread local storage pointer (array of TLS pointers, one per module) // read thread local storage pointer (array of TLS pointers, one per module)
U64 tls_ptr_vaddr = tls_array_vaddr + module->tls_index * addr_size; U64 tls_ptr_vaddr = tls_array_vaddr + module->tls_index * addr_size;
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); D_ProcessMemorySlice result_slice = d_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; String8 result_data = result_slice.data;
if(result_data.size == addr_size) if(result_data.size == addr_size)
{ {
@@ -1109,7 +1109,7 @@ d_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_vaddr, U64 ri
U64 dtv_base = root_vaddr; 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_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; U64 dtv_pointer_vaddr = dtv_base + module->tls_index * dtv_size;
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); D_ProcessMemorySlice dtv_pointer_slice = d_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; String8 dtv_pointer_data = dtv_pointer_slice.data;
if(dtv_pointer_data.size == dtv_size) if(dtv_pointer_data.size == dtv_size)
{ {
@@ -1182,11 +1182,11 @@ internal DI_KeyList
d_push_active_dbgi_key_list(Arena *arena) d_push_active_dbgi_key_list(Arena *arena)
{ {
DI_KeyList dbgis = {0}; DI_KeyList dbgis = {0};
D_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module); D_EntityArray modules = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module);
for EachIndex(idx, modules.count) for EachIndex(idx, modules.count)
{ {
D_Entity *module = modules.v[idx]; D_Entity *module = modules.v[idx];
DI_Key key = ctrl_dbgi_key_from_module(module); DI_Key key = d_dbgi_key_from_module(module);
di_key_list_push(arena, &dbgis, key); di_key_list_push(arena, &dbgis, key);
} }
return dbgis; return dbgis;
@@ -1207,12 +1207,12 @@ d_query_cached_rip_from_thread_unwind(D_Entity *thread, U64 unwind_count)
U64 result = 0; U64 result = 0;
if(unwind_count == 0) if(unwind_count == 0)
{ {
result = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); result = d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
} }
else else
{ {
Access *access = access_open(); Access *access = access_open();
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0); D_CallStack callstack = d_call_stack_from_thread(access, thread->handle, 1, 0);
if(callstack.concrete_frames_count != 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); result = regs_rip_from_arch_block(thread->arch, callstack.concrete_frames[unwind_count%callstack.concrete_frames_count]->regs);
@@ -1227,7 +1227,7 @@ d_query_cached_cfa_from_thread_unwind(D_Entity *thread, U64 unwind_count)
{ {
U64 cfa = 0; U64 cfa = 0;
Access *access = access_open(); Access *access = access_open();
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, 0); D_CallStack callstack = d_call_stack_from_thread(access, thread->handle, 1, 0);
if(callstack.concrete_frames_count != 0) if(callstack.concrete_frames_count != 0)
{ {
cfa = callstack.concrete_frames[unwind_count%callstack.concrete_frames_count]->cfa; cfa = callstack.concrete_frames[unwind_count%callstack.concrete_frames_count]->cfa;
@@ -1259,7 +1259,7 @@ d_query_cached_tls_base_vaddr_from_process_root_rip(D_Entity *process, U64 root_
D_RunTLSBaseCacheNode *node = 0; D_RunTLSBaseCacheNode *node = 0;
for(D_RunTLSBaseCacheNode *n = slot->first; n != 0; n = n->hash_next) for(D_RunTLSBaseCacheNode *n = slot->first; n != 0; n = n->hash_next)
{ {
if(ctrl_handle_match(n->process, handle) && n->root_vaddr == root_vaddr && n->rip_vaddr == rip_vaddr) if(d_handle_match(n->process, handle) && n->root_vaddr == root_vaddr && n->rip_vaddr == rip_vaddr)
{ {
node = n; node = n;
break; break;
@@ -1439,19 +1439,19 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
ProfScope("sync with ctrl thread") ProfScope("sync with ctrl thread")
{ {
//- rjf: grab next reggen/memgen //- rjf: grab next reggen/memgen
U64 new_mem_gen = ctrl_mem_gen(); U64 new_mem_gen = d_mem_gen();
U64 new_reg_gen = ctrl_reg_gen(); U64 new_reg_gen = d_reg_gen();
//- rjf: consume & process events //- rjf: consume & process events
events = ctrl_c2u_pop_events(arena); events = d_c2u_pop_events(arena);
ctrl_entity_store_apply_events(d_user_state->ctrl_entity_store, &events); d_entity_store_apply_events(d_user_state->ctrl_entity_store, &events);
for(D_EventNode *event_n = events.first; for(D_EventNode *event_n = events.first;
event_n != 0; event_n != 0;
event_n = event_n->next) event_n = event_n->next)
{ {
D_Event *event = &event_n->v; D_Event *event = &event_n->v;
log_infof("ctrl_event:\n{\n"); log_infof("ctrl_event:\n{\n");
log_infof("kind: \"%S\"\n", ctrl_string_from_event_kind(event->kind)); log_infof("kind: \"%S\"\n", d_string_from_event_kind(event->kind));
log_infof("entity_id: %u\n", event->entity_id); log_infof("entity_id: %u\n", event->entity_id);
switch(event->kind) switch(event->kind)
{ {
@@ -1492,7 +1492,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_EventKind_NewProc: case D_EventKind_NewProc:
{ {
// rjf: the first process? -> clear session output // rjf: the first process? -> clear session output
D_EntityArray existing_processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray existing_processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(existing_processes.count == 1) if(existing_processes.count == 1)
{ {
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")}; MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("[new session]\n")};
@@ -1556,7 +1556,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
// rjf: build data strings of all param data // rjf: build data strings of all param data
String8List strings = {0}; String8List strings = {0};
{ {
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread); D_EntityArray threads = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
for EachIndex(idx, threads.count) for EachIndex(idx, threads.count)
{ {
D_Entity *thread = threads.v[idx]; D_Entity *thread = threads.v[idx];
@@ -1681,7 +1681,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
// rjf: push message to launch // rjf: push message to launch
{ {
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = D_MsgKind_Launch; msg->kind = D_MsgKind_Launch;
msg->path = working_directory; msg->path = working_directory;
msg->cmd_line_string_list = cmdln_strings; msg->cmd_line_string_list = cmdln_strings;
@@ -1711,14 +1711,14 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
}break; }break;
case D_CmdKind_Kill: case D_CmdKind_Kill:
{ {
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process); D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
if(process == &d_entity_nil) if(process == &d_entity_nil)
{ {
log_user_error(str8_lit("Cannot kill; no process was specified.")); log_user_error(str8_lit("Cannot kill; no process was specified."));
} }
else else
{ {
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = D_MsgKind_Kill; msg->kind = D_MsgKind_Kill;
msg->exit_code = 1; msg->exit_code = 1;
msg->entity = process->handle; msg->entity = process->handle;
@@ -1727,21 +1727,21 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
}break; }break;
case D_CmdKind_KillAll: case D_CmdKind_KillAll:
{ {
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = D_MsgKind_KillAll; msg->kind = D_MsgKind_KillAll;
msg->exit_code = 1; msg->exit_code = 1;
MemoryCopyArray(msg->exception_code_filters, exception_code_filters); MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
}break; }break;
case D_CmdKind_Detach: case D_CmdKind_Detach:
{ {
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process); D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
if(process == &d_entity_nil) if(process == &d_entity_nil)
{ {
log_user_error(str8_lit("Cannot detach; no process specified.")); log_user_error(str8_lit("Cannot detach; no process specified."));
} }
else else
{ {
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = D_MsgKind_Detach; msg->kind = D_MsgKind_Detach;
msg->entity = process->handle; msg->entity = process->handle;
MemoryCopyArray(msg->exception_code_filters, exception_code_filters); MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
@@ -1750,7 +1750,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_CmdKind_Continue: case D_CmdKind_Continue:
{ {
B32 good_to_run = 0; B32 good_to_run = 0;
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread); D_EntityArray threads = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
if(threads.count > 0) if(threads.count > 0)
{ {
for EachIndex(idx, threads.count) for EachIndex(idx, threads.count)
@@ -1766,7 +1766,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
{ {
need_run = 1; need_run = 1;
run_kind = D_RunKind_Run; run_kind = D_RunKind_Run;
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread); run_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
} }
else else
{ {
@@ -1780,7 +1780,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_CmdKind_StepOverLine: case D_CmdKind_StepOverLine:
case D_CmdKind_StepOut: case D_CmdKind_StepOut:
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
if(thread == &d_entity_nil) if(thread == &d_entity_nil)
{ {
log_user_error(str8_lit("Must have a selected thread to step.")); log_user_error(str8_lit("Must have a selected thread to step."));
@@ -1811,14 +1811,14 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
Access *access = access_open(); Access *access = access_open();
// rjf: thread => call stack // rjf: thread => call stack
D_CallStack callstack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000); D_CallStack callstack = d_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
// rjf: use first unwind frame to generate trap // rjf: use first unwind frame to generate trap
if(callstack.concrete_frames_count > 1) if(callstack.concrete_frames_count > 1)
{ {
U64 vaddr = regs_rip_from_arch_block(thread->arch, callstack.concrete_frames[1]->regs); U64 vaddr = regs_rip_from_arch_block(thread->arch, callstack.concrete_frames[1]->regs);
D_Trap trap = {D_TrapFlag_EndStepping|D_TrapFlag_IgnoreStackPointerCheck, vaddr}; D_Trap trap = {D_TrapFlag_EndStepping|D_TrapFlag_IgnoreStackPointerCheck, vaddr};
ctrl_trap_list_push(scratch.arena, &trap_net.traps, &trap); d_trap_list_push(scratch.arena, &trap_net.traps, &trap);
trap_net.good_read = 1; trap_net.good_read = 1;
} }
else else
@@ -1861,24 +1861,24 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_CmdKind_Halt: case D_CmdKind_Halt:
if(d_ctrl_targets_running()) if(d_ctrl_targets_running())
{ {
ctrl_halt(); d_halt();
}break; }break;
case D_CmdKind_SoftHaltRefresh: case D_CmdKind_SoftHaltRefresh:
if(d_ctrl_targets_running()) if(d_ctrl_targets_running())
{ {
need_run = 1; need_run = 1;
run_kind = d_user_state->ctrl_last_run_kind; run_kind = d_user_state->ctrl_last_run_kind;
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle); run_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle);
run_flags = d_user_state->ctrl_last_run_flags; run_flags = d_user_state->ctrl_last_run_flags;
run_traps = d_user_state->ctrl_last_run_traps; run_traps = d_user_state->ctrl_last_run_traps;
}break; }break;
case D_CmdKind_SetThreadIP: case D_CmdKind_SetThreadIP:
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
U64 vaddr = params->vaddr; U64 vaddr = params->vaddr;
void *block = ctrl_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, thread->handle); void *block = d_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, thread->handle);
regs_arch_block_write_rip(thread->arch, block, vaddr); regs_arch_block_write_rip(thread->arch, block, vaddr);
B32 result = ctrl_thread_write_reg_block(thread->handle, block); B32 result = d_thread_write_reg_block(thread->handle, block);
(void)result; (void)result;
}break; }break;
@@ -1900,7 +1900,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
}break; }break;
case D_CmdKind_Run: case D_CmdKind_Run:
{ {
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(processes.count != 0) if(processes.count != 0)
{ {
d_cmd(D_CmdKind_Continue, .machine = params->machine, .process = params->process, .thread = params->thread); d_cmd(D_CmdKind_Continue, .machine = params->machine, .process = params->process, .thread = params->thread);
@@ -1912,7 +1912,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
}break; }break;
case D_CmdKind_Restart: case D_CmdKind_Restart:
{ {
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(processes.count != 0) if(processes.count != 0)
{ {
d_cmd(D_CmdKind_KillAll); d_cmd(D_CmdKind_KillAll);
@@ -1922,7 +1922,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_CmdKind_StepInto: case D_CmdKind_StepInto:
case D_CmdKind_StepOver: case D_CmdKind_StepOver:
{ {
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(processes.count != 0) if(processes.count != 0)
{ {
D_CmdKind step_cmd_kind = (cmd->kind == D_CmdKind_StepInto D_CmdKind step_cmd_kind = (cmd->kind == D_CmdKind_StepInto
@@ -1961,24 +1961,24 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
case D_CmdKind_FreezeLocalMachine: case D_CmdKind_FreezeLocalMachine:
{ {
D_MachineID machine_id = D_MachineID_Local; D_MachineID machine_id = D_MachineID_Local;
d_cmd(D_CmdKind_FreezeMachine, .entity = ctrl_handle_make(machine_id, dmn_handle_zero())); d_cmd(D_CmdKind_FreezeMachine, .entity = d_handle_make(machine_id, dmn_handle_zero()));
}break; }break;
case D_CmdKind_ThawLocalMachine: case D_CmdKind_ThawLocalMachine:
{ {
D_MachineID machine_id = D_MachineID_Local; D_MachineID machine_id = D_MachineID_Local;
d_cmd(D_CmdKind_ThawMachine, .entity = ctrl_handle_make(machine_id, dmn_handle_zero())); d_cmd(D_CmdKind_ThawMachine, .entity = d_handle_make(machine_id, dmn_handle_zero()));
}break; }break;
case D_CmdKind_FreezeEntity: case D_CmdKind_FreezeEntity:
case D_CmdKind_ThawEntity: case D_CmdKind_ThawEntity:
{ {
B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity); B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity);
D_Entity *root = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity); D_Entity *root = d_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) for(D_Entity *e = root; e != &d_entity_nil; e = d_entity_rec_depth_first_pre(e, root).next)
{ {
if(e->kind == D_EntityKind_Thread) if(e->kind == D_EntityKind_Thread)
{ {
e->is_frozen = should_freeze; e->is_frozen = should_freeze;
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = (should_freeze ? D_MsgKind_FreezeThread : D_MsgKind_ThawThread); msg->kind = (should_freeze ? D_MsgKind_FreezeThread : D_MsgKind_ThawThread);
msg->entity = e->handle; msg->entity = e->handle;
} }
@@ -1987,7 +1987,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
{ {
need_run = 1; need_run = 1;
run_kind = d_user_state->ctrl_last_run_kind; run_kind = d_user_state->ctrl_last_run_kind;
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle); run_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle);
run_flags = d_user_state->ctrl_last_run_flags; run_flags = d_user_state->ctrl_last_run_flags;
run_traps = d_user_state->ctrl_last_run_traps; run_traps = d_user_state->ctrl_last_run_traps;
} }
@@ -1996,13 +1996,13 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
//- rjf: entity decoration //- rjf: entity decoration
case D_CmdKind_SetEntityColor: case D_CmdKind_SetEntityColor:
{ {
D_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity); D_Entity *entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
entity->rgba = params->rgba; entity->rgba = params->rgba;
}break; }break;
case D_CmdKind_SetEntityName: case D_CmdKind_SetEntityName:
{ {
D_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity); D_Entity *entity = d_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); d_entity_equip_string(d_user_state->ctrl_entity_store, entity, params->string);
}break; }break;
//- rjf: attaching //- rjf: attaching
@@ -2011,7 +2011,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
U32 pid = params->pid; U32 pid = params->pid;
if(pid != 0) if(pid != 0)
{ {
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
msg->kind = D_MsgKind_Attach; msg->kind = D_MsgKind_Attach;
msg->entity_id = pid; msg->entity_id = pid;
MemoryCopyArray(msg->exception_code_filters, exception_code_filters); MemoryCopyArray(msg->exception_code_filters, exception_code_filters);
@@ -2028,9 +2028,9 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
} }
// rjf: push & fill run message // rjf: push & fill run message
D_Msg *msg = ctrl_msg_list_push(scratch.arena, &ctrl_msgs); D_Msg *msg = d_msg_list_push(scratch.arena, &ctrl_msgs);
{ {
D_Entity *process = ctrl_entity_ancestor_from_kind(run_thread, D_EntityKind_Process); D_Entity *process = d_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->kind = (run_kind == D_RunKind_Run || run_kind == D_RunKind_Step) ? D_MsgKind_Run : D_MsgKind_SingleStep;
msg->run_flags = run_flags; msg->run_flags = run_flags;
msg->entity = run_thread->handle; msg->entity = run_thread->handle;
@@ -2059,21 +2059,21 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
D_Breakpoint dst_bp = {0}; D_Breakpoint dst_bp = {0};
MemoryCopyStruct(&dst_bp, bp); MemoryCopyStruct(&dst_bp, bp);
dst_bp.file_path = n->string; dst_bp.file_path = n->string;
ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, &dst_bp); d_breakpoint_list_push(scratch.arena, &msg->user_bps, &dst_bp);
} }
} }
// rjf: all other cases - just copy the breakpoint info // rjf: all other cases - just copy the breakpoint info
else else
{ {
ctrl_user_breakpoint_list_push(scratch.arena, &msg->user_bps, bp); d_breakpoint_list_push(scratch.arena, &msg->user_bps, bp);
} }
} }
} }
} }
// rjf: copy run traps to scratch (needed, if run_traps can be `d_user_state->ctrl_last_run_traps`) // rjf: copy run traps to scratch (needed, if run_traps can be `d_user_state->ctrl_last_run_traps`)
D_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps); D_TrapList run_traps_copy = d_trap_list_copy(scratch.arena, &run_traps);
D_BreakpointArray run_extra_bps_copy = d_breakpoint_array_copy(scratch.arena, &run_extra_bps); D_BreakpointArray run_extra_bps_copy = d_breakpoint_array_copy(scratch.arena, &run_extra_bps);
// rjf: store last run info // rjf: store last run info
@@ -2082,7 +2082,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
d_user_state->ctrl_last_run_frame_idx = d_frame_index(); d_user_state->ctrl_last_run_frame_idx = d_frame_index();
d_user_state->ctrl_last_run_thread_handle = run_thread->handle; d_user_state->ctrl_last_run_thread_handle = run_thread->handle;
d_user_state->ctrl_last_run_flags = run_flags; d_user_state->ctrl_last_run_flags = run_flags;
d_user_state->ctrl_last_run_traps = ctrl_trap_list_copy(d_user_state->ctrl_last_run_arena, &run_traps_copy); d_user_state->ctrl_last_run_traps = d_trap_list_copy(d_user_state->ctrl_last_run_arena, &run_traps_copy);
d_user_state->ctrl_last_run_extra_bps = d_breakpoint_array_copy(d_user_state->ctrl_last_run_arena, &run_extra_bps_copy); d_user_state->ctrl_last_run_extra_bps = d_breakpoint_array_copy(d_user_state->ctrl_last_run_arena, &run_extra_bps_copy);
d_user_state->ctrl_is_running = 1; d_user_state->ctrl_is_running = 1;
} }
@@ -2111,16 +2111,16 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
// the next tick) // the next tick)
// //
{ {
D_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_user_state->ctrl_msg_arena, &ctrl_msgs); D_MsgList msgs_copy = d_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); d_msg_list_concat_in_place(&d_user_state->ctrl_msgs, &msgs_copy);
if(d_user_state->ctrl_msgs.count != 0) if(d_user_state->ctrl_msgs.count != 0)
{ {
if(!d_user_state->ctrl_soft_halt_issued && d_user_state->ctrl_thread_run_state) if(!d_user_state->ctrl_soft_halt_issued && d_user_state->ctrl_thread_run_state)
{ {
d_user_state->ctrl_soft_halt_issued = 1; d_user_state->ctrl_soft_halt_issued = 1;
ctrl_halt(); d_halt();
} }
if(ctrl_u2c_push_msgs(&d_user_state->ctrl_msgs, os_now_microseconds()+100)) if(d_u2c_push_msgs(&d_user_state->ctrl_msgs, os_now_microseconds()+100))
{ {
MemoryZeroStruct(&d_user_state->ctrl_msgs); MemoryZeroStruct(&d_user_state->ctrl_msgs);
arena_clear(d_user_state->ctrl_msg_arena); arena_clear(d_user_state->ctrl_msg_arena);
+6 -6
View File
@@ -4,7 +4,7 @@
//- GENERATED CODE //- GENERATED CODE
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
String8 ctrl_entity_kind_code_name_table[12] = String8 d_entity_kind_code_name_table[12] =
{ {
{0}, {0},
str8_lit_comp("root"), str8_lit_comp("root"),
@@ -20,7 +20,7 @@ str8_lit_comp("breakpoint"),
str8_lit_comp("address_range_annotation"), str8_lit_comp("address_range_annotation"),
}; };
String8 ctrl_entity_kind_display_string_table[12] = String8 d_entity_kind_display_string_table[12] =
{ {
{0}, {0},
str8_lit_comp("Root"), str8_lit_comp("Root"),
@@ -36,7 +36,7 @@ str8_lit_comp("Breakpoint"),
str8_lit_comp("AddressRangeAnnotation"), str8_lit_comp("AddressRangeAnnotation"),
}; };
U32 ctrl_exception_code_kind_code_table[38] = U32 d_exception_code_kind_code_table[38] =
{ {
0, 0,
0x40010005, 0x40010005,
@@ -78,7 +78,7 @@ U32 ctrl_exception_code_kind_code_table[38] =
0x0000087a, 0x0000087a,
}; };
String8 ctrl_exception_code_kind_display_string_table[38] = String8 d_exception_code_kind_display_string_table[38] =
{ {
{0}, {0},
str8_lit_comp("(Win32) Control-C"), str8_lit_comp("(Win32) Control-C"),
@@ -120,7 +120,7 @@ str8_lit_comp("(Win32) Sanitizer Raw Access Violation"),
str8_lit_comp("(Win32) DirectX Debug Layer"), str8_lit_comp("(Win32) DirectX Debug Layer"),
}; };
String8 ctrl_exception_code_kind_lowercase_code_string_table[38] = String8 d_exception_code_kind_lowercase_code_string_table[38] =
{ {
{0}, {0},
str8_lit_comp("win32_ctrl_c"), str8_lit_comp("win32_ctrl_c"),
@@ -162,7 +162,7 @@ str8_lit_comp("win32_sanitizer_raw_access_violation"),
str8_lit_comp("win32_directx_debug_layer"), str8_lit_comp("win32_directx_debug_layer"),
}; };
B8 ctrl_exception_code_kind_default_enable_table[38] = B8 d_exception_code_kind_default_enable_table[38] =
{ {
0, 0,
1, 1,
+6 -6
View File
@@ -126,12 +126,12 @@ struct {B32 *value_ptr; String8 name;} DEV_toggle_table[] =
{&DEV_updating_indicator, str8_lit_comp("updating_indicator")}, {&DEV_updating_indicator, str8_lit_comp("updating_indicator")},
}; };
C_LINKAGE_BEGIN C_LINKAGE_BEGIN
extern String8 ctrl_entity_kind_code_name_table[12]; extern String8 d_entity_kind_code_name_table[12];
extern String8 ctrl_entity_kind_display_string_table[12]; extern String8 d_entity_kind_display_string_table[12];
extern U32 ctrl_exception_code_kind_code_table[38]; extern U32 d_exception_code_kind_code_table[38];
extern String8 ctrl_exception_code_kind_display_string_table[38]; extern String8 d_exception_code_kind_display_string_table[38];
extern String8 ctrl_exception_code_kind_lowercase_code_string_table[38]; extern String8 d_exception_code_kind_lowercase_code_string_table[38];
extern B8 ctrl_exception_code_kind_default_enable_table[38]; extern B8 d_exception_code_kind_default_enable_table[38];
C_LINKAGE_END C_LINKAGE_END
+1 -1
View File
@@ -2683,7 +2683,7 @@ e_list_gather_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U
//- rjf: read next offset, advance //- rjf: read next offset, advance
B32 read_stale = 0; B32 read_stale = 0;
B32 read_good = ctrl_process_memory_read(process, r1u64(off + member_element_off, off + member_element_off + member_size), &read_stale, &next_off, 0); B32 read_good = d_process_memory_read(process, r1u64(off + member_element_off, off + member_element_off + member_size), &read_stale, &next_off, 0);
if(read_stale) if(read_stale)
{ {
retry = 1; retry = 1;
+119 -119
View File
@@ -621,8 +621,8 @@ rd_color_from_ctrl_entity(D_Entity *entity)
default:{}break; default:{}break;
case D_EntityKind_Thread: case D_EntityKind_Thread:
{ {
D_Entity *process = ctrl_entity_ancestor_from_kind(entity, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(entity, D_EntityKind_Process);
D_Entity *main_thread = ctrl_entity_child_from_kind(process, D_EntityKind_Thread); D_Entity *main_thread = d_entity_child_from_kind(process, D_EntityKind_Thread);
if(main_thread != entity) if(main_thread != entity)
{ {
result = ui_color_from_name(str8_lit("thread_1")); result = ui_color_from_name(str8_lit("thread_1"));
@@ -689,7 +689,7 @@ rd_ctrl_entity_from_eval_space(E_Space space)
D_Handle handle; D_Handle handle;
handle.machine_id = space.u64s[0]; handle.machine_id = space.u64s[0];
handle.dmn_handle.u64[0] = space.u64s[1]; handle.dmn_handle.u64[0] = space.u64s[1];
entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle); entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle);
} }
return entity; return entity;
} }
@@ -726,7 +726,7 @@ rd_eval_space_gen(E_Space space)
{ {
default: default:
{ {
result = ctrl_eval_space_gen(space); result = d_ctrl_eval_space_gen(space);
}break; }break;
case RD_EvalSpaceKind_MetaCfg: case RD_EvalSpaceKind_MetaCfg:
case RD_EvalSpaceKind_MetaQuery: case RD_EvalSpaceKind_MetaQuery:
@@ -746,7 +746,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
{ {
default: default:
{ {
result = ctrl_eval_space_read(space, out, range); result = d_ctrl_eval_space_read(space, out, range);
}break; }break;
//- rjf: interior control entity reads (inside process address space or thread register block) //- rjf: interior control entity reads (inside process address space or thread register block)
@@ -758,7 +758,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
default:{}break; default:{}break;
case D_EntityKind_Process: case D_EntityKind_Process:
{ {
D_ProcessMemorySlice slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, entity->handle, range, 0, rd_state->frame_eval_memread_endt_us); D_ProcessMemorySlice slice = d_process_memory_slice_from_vaddr_range(scratch.arena, entity->handle, range, 0, rd_state->frame_eval_memread_endt_us);
String8 data = slice.data; String8 data = slice.data;
if(data.size == dim_1u64(range)) if(data.size == dim_1u64(range))
{ {
@@ -769,7 +769,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
case D_EntityKind_Thread: case D_EntityKind_Thread:
{ {
Access *access = access_open(); Access *access = access_open();
D_CallStack call_stack = ctrl_call_stack_from_thread(access, entity->handle, 1, rd_state->frame_eval_memread_endt_us); D_CallStack call_stack = d_call_stack_from_thread(access, entity->handle, 1, rd_state->frame_eval_memread_endt_us);
U64 concrete_frame_idx = e_interpret_ctx->reg_unwind_count; U64 concrete_frame_idx = e_interpret_ctx->reg_unwind_count;
if(concrete_frame_idx < call_stack.concrete_frames_count) if(concrete_frame_idx < call_stack.concrete_frames_count)
{ {
@@ -935,7 +935,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
String8 read_data = {0}; String8 read_data = {0};
if(child_key.size != 0) if(child_key.size != 0)
{ {
MD_NodePtrList schemas = cfg_schemas_from_name(scratch.arena, rd_state->cfg_schema_table, ctrl_entity_kind_code_name_table[entity->kind]); MD_NodePtrList schemas = cfg_schemas_from_name(scratch.arena, rd_state->cfg_schema_table, d_entity_kind_code_name_table[entity->kind]);
MD_Node *child_schema = &md_nil_node; MD_Node *child_schema = &md_nil_node;
for(MD_NodePtrNode *n = schemas.first; n != 0 && child_schema == &md_nil_node; n = n->next) for(MD_NodePtrNode *n = schemas.first; n != 0 && child_schema == &md_nil_node; n = n->next)
{ {
@@ -948,7 +948,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
} }
else if(str8_match(child_schema->string, str8_lit("dbg"), 0)) else if(str8_match(child_schema->string, str8_lit("dbg"), 0))
{ {
read_data = ctrl_entity_child_from_kind(entity, D_EntityKind_DebugInfoPath)->string; read_data = d_entity_child_from_kind(entity, D_EntityKind_DebugInfoPath)->string;
} }
else if(str8_match(child_schema->string, str8_lit("vaddr_range"), 0)) else if(str8_match(child_schema->string, str8_lit("vaddr_range"), 0))
{ {
@@ -960,7 +960,7 @@ rd_eval_space_read(E_Space space, void *out, Rng1U64 range)
} }
else if(str8_match(child_schema->string, str8_lit("active"), 0)) else if(str8_match(child_schema->string, str8_lit("active"), 0))
{ {
B32 is_frozen = ctrl_entity_tree_is_frozen(entity); B32 is_frozen = d_entity_tree_is_frozen(entity);
B32 is_active = !is_frozen; B32 is_active = !is_frozen;
read_data = push_str8_copy(scratch.arena, str8_struct(&is_active)); read_data = push_str8_copy(scratch.arena, str8_struct(&is_active));
} }
@@ -998,7 +998,7 @@ rd_eval_space_write(E_Space space, void *in, Rng1U64 range)
default:{}break; default:{}break;
case D_EntityKind_Process: case D_EntityKind_Process:
{ {
result = ctrl_process_write(entity->handle, range, in); result = d_process_write(entity->handle, range, in);
}break; }break;
case D_EntityKind_Thread: case D_EntityKind_Thread:
{ {
@@ -1007,9 +1007,9 @@ rd_eval_space_write(E_Space space, void *in, Rng1U64 range)
Rng1U64 legal_range = r1u64(0, regs_size); Rng1U64 legal_range = r1u64(0, regs_size);
Rng1U64 write_range = intersect_1u64(legal_range, range); Rng1U64 write_range = intersect_1u64(legal_range, range);
U64 write_size = dim_1u64(write_range); U64 write_size = dim_1u64(write_range);
void *new_regs = ctrl_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, entity->handle); void *new_regs = d_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, entity->handle);
MemoryCopy((U8 *)new_regs + write_range.min, in, write_size); MemoryCopy((U8 *)new_regs + write_range.min, in, write_size);
result = ctrl_thread_write_reg_block(entity->handle, new_regs); result = d_thread_write_reg_block(entity->handle, new_regs);
scratch_end(scratch); scratch_end(scratch);
}break; }break;
} }
@@ -1081,7 +1081,7 @@ rd_eval_space_write(E_Space space, void *in, Rng1U64 range)
// rjf: perform write, based on child name in schema // rjf: perform write, based on child name in schema
if(child_key.size != 0) if(child_key.size != 0)
{ {
MD_NodePtrList schemas = cfg_schemas_from_name(scratch.arena, rd_state->cfg_schema_table, ctrl_entity_kind_code_name_table[entity->kind]); MD_NodePtrList schemas = cfg_schemas_from_name(scratch.arena, rd_state->cfg_schema_table, d_entity_kind_code_name_table[entity->kind]);
MD_Node *child_schema = &md_nil_node; MD_Node *child_schema = &md_nil_node;
for(MD_NodePtrNode *n = schemas.first; n != 0 && child_schema == &md_nil_node; n = n->next) for(MD_NodePtrNode *n = schemas.first; n != 0 && child_schema == &md_nil_node; n = n->next)
{ {
@@ -1090,7 +1090,7 @@ rd_eval_space_write(E_Space space, void *in, Rng1U64 range)
if(str8_match(child_schema->string, str8_lit("label"), 0)) if(str8_match(child_schema->string, str8_lit("label"), 0))
{ {
result = 1; result = 1;
ctrl_entity_equip_string(d_user_state->ctrl_entity_store, entity, write_string); d_entity_equip_string(d_user_state->ctrl_entity_store, entity, write_string);
rd_cmd(D_CmdKind_SetEntityName, .ctrl_entity = entity->handle, .string = write_string); rd_cmd(D_CmdKind_SetEntityName, .ctrl_entity = entity->handle, .string = write_string);
} }
else if(str8_match(child_schema->string, str8_lit("dbg"), 0)) else if(str8_match(child_schema->string, str8_lit("dbg"), 0))
@@ -1144,7 +1144,7 @@ rd_key_from_eval_space_range(E_Space space, Rng1U64 range, B32 zero_terminated)
D_Entity *entity = rd_ctrl_entity_from_eval_space(space); D_Entity *entity = rd_ctrl_entity_from_eval_space(space);
if(entity->kind == D_EntityKind_Process) if(entity->kind == D_EntityKind_Process)
{ {
result = ctrl_key_from_process_vaddr_range(entity->handle, range, zero_terminated, 0, 0, 0); result = d_key_from_process_vaddr_range(entity->handle, range, zero_terminated, 0, 0, 0);
} }
}break; }break;
} }
@@ -1703,7 +1703,7 @@ rd_view_ui(Rng2F32 rect)
UI_Padding(ui_pct(1, 0)) UI_Focus(UI_FocusKind_Null) UI_Padding(ui_pct(1, 0)) UI_Focus(UI_FocusKind_Null)
{ {
CFG_NodePtrList targets = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("target")); CFG_NodePtrList targets = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("target"));
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
//- rjf: icon & info //- rjf: icon & info
UI_Padding(ui_em(2.f, 1.f)) UI_TagF("weak") UI_Padding(ui_em(2.f, 1.f)) UI_TagF("weak")
@@ -2268,9 +2268,9 @@ rd_view_ui(Rng2F32 rect)
{ {
U64 vaddr = eval.value.u64; U64 vaddr = eval.value.u64;
D_Entity *process = rd_ctrl_entity_from_eval_space(eval.space); D_Entity *process = rd_ctrl_entity_from_eval_space(eval.space);
D_Entity *module = ctrl_module_from_process_vaddr(process, vaddr); D_Entity *module = d_module_from_process_vaddr(process, vaddr);
dbgi_key = ctrl_dbgi_key_from_module(module); dbgi_key = d_dbgi_key_from_module(module);
voff = ctrl_voff_from_vaddr(module, vaddr); voff = d_voff_from_vaddr(module, vaddr);
} }
else else
{ {
@@ -2361,10 +2361,10 @@ rd_view_ui(Rng2F32 rect)
String8 name = {0}; String8 name = {0};
{ {
U64 vaddr = eval.value.u64; U64 vaddr = eval.value.u64;
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process); D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
D_Entity *module = ctrl_module_from_process_vaddr(process, vaddr); D_Entity *module = d_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr); U64 voff = d_voff_from_vaddr(module, vaddr);
{ {
Access *access = access_open(); Access *access = access_open();
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 1, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 1, 0);
@@ -2432,7 +2432,7 @@ rd_view_ui(Rng2F32 rect)
case RD_EvalSpaceKind_MetaCtrlEntity: case RD_EvalSpaceKind_MetaCtrlEntity:
{ {
D_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space); D_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
rd_cmd(RD_CmdKind_PushQuery, .expr = push_str8f(scratch.arena, "query:control.%S", ctrl_string_from_handle(scratch.arena, entity->handle))); rd_cmd(RD_CmdKind_PushQuery, .expr = push_str8f(scratch.arena, "query:control.%S", d_string_from_handle(scratch.arena, entity->handle)));
}break; }break;
} }
if(did_cmd) if(did_cmd)
@@ -3644,7 +3644,7 @@ rd_view_ui(Rng2F32 rect)
D_Entity *space_entity = rd_ctrl_entity_from_eval_space(cell->eval.space); D_Entity *space_entity = rd_ctrl_entity_from_eval_space(cell->eval.space);
if(cell->eval.space.kind == D_EvalSpaceKind_Entity && space_entity->kind == D_EntityKind_Process) if(cell->eval.space.kind == D_EvalSpaceKind_Entity && space_entity->kind == D_EntityKind_Process)
{ {
D_ProcessMemorySlice slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, space_entity->handle, cell_vaddr_rng, 0, rd_state->frame_eval_memread_endt_us); D_ProcessMemorySlice slice = d_process_memory_slice_from_vaddr_range(scratch.arena, space_entity->handle, cell_vaddr_rng, 0, rd_state->frame_eval_memread_endt_us);
for(U64 idx = 0; idx < (slice.data.size+63)/64; idx += 1) for(U64 idx = 0; idx < (slice.data.size+63)/64; idx += 1)
{ {
if(slice.byte_changed_flags[idx] != 0) if(slice.byte_changed_flags[idx] != 0)
@@ -3719,7 +3719,7 @@ rd_view_ui(Rng2F32 rect)
rgba.w *= ui_anim(ui_key_from_stringf(ui_key_zero(), "###cfg_hover_t_%p", cfg), 1.f, .rate = entity_hover_t_rate); rgba.w *= ui_anim(ui_key_from_stringf(ui_key_zero(), "###cfg_hover_t_%p", cfg), 1.f, .rate = entity_hover_t_rate);
cell_background_color_override = rgba; cell_background_color_override = rgba;
} }
else if(ctrl_handle_match(cell_info.entity->handle, rd_get_hover_regs()->ctrl_entity) && else if(d_handle_match(cell_info.entity->handle, rd_get_hover_regs()->ctrl_entity) &&
rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity) rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity)
{ {
D_Entity *entity = cell_info.entity; D_Entity *entity = cell_info.entity;
@@ -3854,7 +3854,7 @@ rd_view_ui(Rng2F32 rect)
{ {
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "###%I64x_%I64x", cell_id, row_hash); UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable, "###%I64x_%I64x", cell_id, row_hash);
sig = ui_signal_from_box(box); sig = ui_signal_from_box(box);
if(ctrl_handle_match(row_info->callstack_thread->handle, rd_base_regs()->thread) && if(d_handle_match(row_info->callstack_thread->handle, rd_base_regs()->thread) &&
row_info->callstack_unwind_index == rd_base_regs()->unwind_count && row_info->callstack_unwind_index == rd_base_regs()->unwind_count &&
row_info->callstack_inline_depth == rd_base_regs()->inline_depth) row_info->callstack_inline_depth == rd_base_regs()->inline_depth)
{ {
@@ -4332,13 +4332,13 @@ rd_view_ui(Rng2F32 rect)
else if(cell->eval.space.kind == D_EvalSpaceKind_Entity) else if(cell->eval.space.kind == D_EvalSpaceKind_Entity)
{ {
D_Entity *entity = rd_ctrl_entity_from_eval_space(cell->eval.space); D_Entity *entity = rd_ctrl_entity_from_eval_space(cell->eval.space);
D_Entity *process = ctrl_process_from_entity(entity); D_Entity *process = d_process_from_entity(entity);
if(process != &d_entity_nil) if(process != &d_entity_nil)
{ {
U64 vaddr = cell->eval.value.u64; U64 vaddr = cell->eval.value.u64;
D_Entity *module = ctrl_module_from_process_vaddr(process, vaddr); D_Entity *module = d_module_from_process_vaddr(process, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
U64 voff = ctrl_voff_from_vaddr(module, vaddr); U64 voff = d_voff_from_vaddr(module, vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff);
String8 file_path = {0}; String8 file_path = {0};
TxtPt pt = {0}; TxtPt pt = {0};
@@ -4737,10 +4737,10 @@ rd_arch_from_eval(E_Eval eval)
{ {
// rjf: try implicitly from either `eval` itself, or from context // rjf: try implicitly from either `eval` itself, or from context
D_Entity *ctrl_entity = rd_ctrl_entity_from_eval_space(eval.space); D_Entity *ctrl_entity = rd_ctrl_entity_from_eval_space(eval.space);
D_Entity *process = ctrl_process_from_entity(ctrl_entity); D_Entity *process = d_process_from_entity(ctrl_entity);
if(process == &d_entity_nil) if(process == &d_entity_nil)
{ {
process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process); process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
} }
Arch arch = process->arch; Arch arch = process->arch;
if(arch == Arch_Null) if(arch == Arch_Null)
@@ -5498,11 +5498,11 @@ rd_window_frame(void)
//////////////////////// ////////////////////////
//- rjf: control entity tooltips //- rjf: control entity tooltips
// //
case RD_RegSlot_Machine: {ctrl_entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->machine); }goto ctrl_entity_tooltip; case RD_RegSlot_Machine: {ctrl_entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->machine); }goto ctrl_entity_tooltip;
case RD_RegSlot_Process: {ctrl_entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->process); }goto ctrl_entity_tooltip; case RD_RegSlot_Process: {ctrl_entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->process); }goto ctrl_entity_tooltip;
case RD_RegSlot_Module: {ctrl_entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->module); }goto ctrl_entity_tooltip; case RD_RegSlot_Module: {ctrl_entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->module); }goto ctrl_entity_tooltip;
case RD_RegSlot_Thread: {ctrl_entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->thread); }goto ctrl_entity_tooltip; case RD_RegSlot_Thread: {ctrl_entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->thread); }goto ctrl_entity_tooltip;
case RD_RegSlot_CtrlEntity:{ctrl_entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->ctrl_entity); }goto ctrl_entity_tooltip; case RD_RegSlot_CtrlEntity:{ctrl_entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, regs->ctrl_entity); }goto ctrl_entity_tooltip;
ctrl_entity_tooltip:; ctrl_entity_tooltip:;
UI_Tooltip UI_Tooltip
{ {
@@ -5534,8 +5534,8 @@ rd_window_frame(void)
if(ctrl_entity->kind == D_EntityKind_Module) UI_TagF("weak") if(ctrl_entity->kind == D_EntityKind_Module) UI_TagF("weak")
{ {
Access *access = access_open(); Access *access = access_open();
D_Entity *dbg_info_entity = ctrl_entity_child_from_kind(ctrl_entity, D_EntityKind_DebugInfoPath); D_Entity *dbg_info_entity = d_entity_child_from_kind(ctrl_entity, D_EntityKind_DebugInfoPath);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(ctrl_entity); DI_Key dbgi_key = d_dbgi_key_from_module(ctrl_entity);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi->raw_data_size != 0) if(rdi->raw_data_size != 0)
{ {
@@ -5558,15 +5558,15 @@ rd_window_frame(void)
Access *access = access_open(); Access *access = access_open();
Vec4F32 code_color = ui_color_from_name(str8_lit("code_default")); Vec4F32 code_color = ui_color_from_name(str8_lit("code_default"));
Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol")); Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol"));
D_Entity *process = ctrl_entity_ancestor_from_kind(ctrl_entity, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(ctrl_entity, D_EntityKind_Process);
B32 call_stack_high_priority = ctrl_handle_match(ctrl_entity->handle, rd_base_regs()->thread); B32 call_stack_high_priority = d_handle_match(ctrl_entity->handle, rd_base_regs()->thread);
D_CallStack call_stack = ctrl_call_stack_from_thread(access, ctrl_entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); D_CallStack call_stack = d_call_stack_from_thread(access, ctrl_entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
if(call_stack.frames_count != 0) if(call_stack.frames_count != 0)
{ {
ui_spacer(ui_em(1.5f, 1.f)); ui_spacer(ui_em(1.5f, 1.f));
} }
EV_StringParams string_params = {EV_StringFlag_ReadOnlyDisplayRules|rd_state->eval_viz_base_string_flags, .radix = 16}; EV_StringParams string_params = {EV_StringFlag_ReadOnlyDisplayRules|rd_state->eval_viz_base_string_flags, .radix = 16};
String8 thread_handle_string = ctrl_string_from_handle(scratch.arena, ctrl_entity->handle); String8 thread_handle_string = d_string_from_handle(scratch.arena, ctrl_entity->handle);
for(U64 idx = 0; idx < 16; idx += 1) for(U64 idx = 0; idx < 16; idx += 1)
{ {
E_Eval rip_eval = e_eval_from_stringf("query:control.%S.call_stack[%I64u]", thread_handle_string, idx); E_Eval rip_eval = e_eval_from_stringf("query:control.%S.call_stack[%I64u]", thread_handle_string, idx);
@@ -5767,8 +5767,8 @@ rd_window_frame(void)
avg_ui_hash_chain_length = chain_length_sum / chain_count; avg_ui_hash_chain_length = chain_length_sum / chain_count;
} }
ui_labelf("Target Hz: %.2f", 1.f/rd_state->frame_dt); ui_labelf("Target Hz: %.2f", 1.f/rd_state->frame_dt);
ui_labelf("Ctrl Run Index: %I64u", ctrl_run_gen()); ui_labelf("Ctrl Run Index: %I64u", d_run_gen());
ui_labelf("Ctrl Mem Gen Index: %I64u", ctrl_mem_gen()); ui_labelf("Ctrl Mem Gen Index: %I64u", d_mem_gen());
ui_labelf("Window %p", w); ui_labelf("Window %p", w);
ui_set_next_pref_width(ui_children_sum(1)); ui_set_next_pref_width(ui_children_sum(1));
ui_set_next_pref_height(ui_children_sum(1)); ui_set_next_pref_height(ui_children_sum(1));
@@ -7037,7 +7037,7 @@ rd_window_frame(void)
{ {
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
CFG_NodePtrList targets = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("target")); CFG_NodePtrList targets = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("target"));
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
B32 can_send_signal = !d_ctrl_targets_running(); B32 can_send_signal = !d_ctrl_targets_running();
typedef struct CenterButtonTask CenterButtonTask; typedef struct CenterButtonTask CenterButtonTask;
struct CenterButtonTask struct CenterButtonTask
@@ -9565,9 +9565,9 @@ rd_string_from_exception_code(U32 code)
String8 string = {0}; String8 string = {0};
for EachNonZeroEnumVal(D_ExceptionCodeKind, k) for EachNonZeroEnumVal(D_ExceptionCodeKind, k)
{ {
if(code == ctrl_exception_code_kind_code_table[k]) if(code == d_exception_code_kind_code_table[k])
{ {
string = ctrl_exception_code_kind_display_string_table[k]; string = d_exception_code_kind_display_string_table[k];
break; break;
} }
} }
@@ -9577,7 +9577,7 @@ rd_string_from_exception_code(U32 code)
internal DR_FStrList internal DR_FStrList
rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, D_Event *event) rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, D_Event *event)
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, event->entity); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, event->entity);
DR_FStrList thread_fstrs = rd_title_fstrs_from_ctrl_entity(arena, thread, 0); DR_FStrList thread_fstrs = rd_title_fstrs_from_ctrl_entity(arena, thread, 0);
DR_FStrList fstrs = {0}; DR_FStrList fstrs = {0};
DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_color_from_name(str8_lit("text")), ui_top_font_size()}; DR_FStrParams params = {ui_top_font(), ui_top_text_raster_flags(), ui_color_from_name(str8_lit("text")), ui_top_font_size()};
@@ -11102,14 +11102,14 @@ rd_frame(void)
//- rjf: unpack basic evaluation context //- rjf: unpack basic evaluation context
// //
ProfBegin("unpack eval-dependent info"); ProfBegin("unpack eval-dependent info");
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process); D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
Arch arch = thread->arch; Arch arch = thread->arch;
U64 unwind_count = rd_regs()->unwind_count; U64 unwind_count = rd_regs()->unwind_count;
U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
D_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr); U64 rip_voff = d_voff_from_vaddr(module, rip_vaddr);
U64 tls_root_vaddr = ctrl_tls_root_vaddr_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); U64 tls_root_vaddr = d_tls_root_vaddr_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
ProfEnd(); ProfEnd();
//////////////////////////// ////////////////////////////
@@ -11132,7 +11132,7 @@ rd_frame(void)
//////////////////////////// ////////////////////////////
//- rjf: produce all eval modules //- rjf: produce all eval modules
// //
D_EntityArray all_modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module); D_EntityArray all_modules = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module);
U64 eval_modules_count = Max(1, all_modules.count); U64 eval_modules_count = Max(1, all_modules.count);
E_Module *eval_modules = push_array(scratch.arena, E_Module, eval_modules_count); E_Module *eval_modules = push_array(scratch.arena, E_Module, eval_modules_count);
E_Module *eval_modules_primary = &eval_modules[0]; E_Module *eval_modules_primary = &eval_modules[0];
@@ -11142,7 +11142,7 @@ rd_frame(void)
for EachIndex(eval_module_idx, all_modules.count) for EachIndex(eval_module_idx, all_modules.count)
{ {
D_Entity *m = all_modules.v[eval_module_idx]; D_Entity *m = all_modules.v[eval_module_idx];
DI_Key dbgi_key = ctrl_dbgi_key_from_module(m); DI_Key dbgi_key = d_dbgi_key_from_module(m);
// rjf: dbgi key -> eval dbg info num // rjf: dbgi key -> eval dbg info num
U32 dbg_info_num = 0; U32 dbg_info_num = 0;
@@ -11163,7 +11163,7 @@ rd_frame(void)
eval_modules[eval_module_idx].vaddr_range = m->vaddr_range; eval_modules[eval_module_idx].vaddr_range = m->vaddr_range;
eval_modules[eval_module_idx].arch = m->arch; eval_modules[eval_module_idx].arch = m->arch;
eval_modules[eval_module_idx].dbg_info_num = dbg_info_num; eval_modules[eval_module_idx].dbg_info_num = dbg_info_num;
eval_modules[eval_module_idx].space = rd_eval_space_from_ctrl_entity(ctrl_entity_ancestor_from_kind(m, D_EntityKind_Process), D_EvalSpaceKind_Entity); eval_modules[eval_module_idx].space = rd_eval_space_from_ctrl_entity(d_entity_ancestor_from_kind(m, D_EntityKind_Process), D_EvalSpaceKind_Entity);
if(module == m) if(module == m)
{ {
eval_modules_primary = &eval_modules[eval_module_idx]; eval_modules_primary = &eval_modules[eval_module_idx];
@@ -11513,8 +11513,8 @@ rd_frame(void)
for EachElement(idx, evallable_ctrl_names) for EachElement(idx, evallable_ctrl_names)
{ {
String8 name = evallable_ctrl_names[idx]; String8 name = evallable_ctrl_names[idx];
D_EntityKind kind = ctrl_entity_kind_from_string(name); D_EntityKind kind = d_entity_kind_from_string(name);
D_EntityArray array = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, kind); D_EntityArray array = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, kind);
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name); E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name);
for EachIndex(idx, array.count) for EachIndex(idx, array.count)
{ {
@@ -11532,15 +11532,15 @@ rd_frame(void)
{ {
e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("local_machine"), expr); e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("local_machine"), expr);
} }
if(kind == D_EntityKind_Thread && ctrl_handle_match(rd_base_regs()->thread, entity->handle)) if(kind == D_EntityKind_Thread && d_handle_match(rd_base_regs()->thread, entity->handle))
{ {
e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_thread"), expr); e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_thread"), expr);
} }
if(kind == D_EntityKind_Process && ctrl_handle_match(rd_base_regs()->process, entity->handle)) if(kind == D_EntityKind_Process && d_handle_match(rd_base_regs()->process, entity->handle))
{ {
e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_process"), expr); e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_process"), expr);
} }
if(kind == D_EntityKind_Module && ctrl_handle_match(rd_base_regs()->module, entity->handle)) if(kind == D_EntityKind_Module && d_handle_match(rd_base_regs()->module, entity->handle))
{ {
e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_module"), expr); e_string2expr_map_insert(scratch.arena, macro_map, str8_lit("current_module"), expr);
} }
@@ -11880,13 +11880,13 @@ rd_frame(void)
//- rjf: gather config from loaded modules //- rjf: gather config from loaded modules
// //
CFG_NodePtrList immediate_type_views = {0}; CFG_NodePtrList immediate_type_views = {0};
D_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module); D_EntityArray modules = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Module);
ProfScope("gather config from loaded modules") ProfScope("gather config from loaded modules")
{ {
for EachIndex(idx, modules.count) for EachIndex(idx, modules.count)
{ {
D_Entity *module = modules.v[idx]; D_Entity *module = modules.v[idx];
String8 raddbg_data = ctrl_raddbg_data_from_module(scratch.arena, module->handle); String8 raddbg_data = d_raddbg_data_from_module(scratch.arena, module->handle);
U8 split_char = 0; U8 split_char = 0;
String8List raddbg_data_text_parts = str8_split(scratch.arena, raddbg_data, &split_char, 1, 0); String8List raddbg_data_text_parts = str8_split(scratch.arena, raddbg_data, &split_char, 1, 0);
U64 cfg_idx = 0; U64 cfg_idx = 0;
@@ -11894,7 +11894,7 @@ rd_frame(void)
{ {
String8 text = text_n->string; String8 text = text_n->string;
CFG_NodePtrList cfgs = cfg_node_ptr_list_from_string(scratch.arena, rd_state->cfg, rd_state->cfg_schema_table, str8_zero(), text); CFG_NodePtrList cfgs = cfg_node_ptr_list_from_string(scratch.arena, rd_state->cfg, rd_state->cfg_schema_table, str8_zero(), text);
String8 module_name = ctrl_string_from_handle(scratch.arena, module->handle); String8 module_name = d_string_from_handle(scratch.arena, module->handle);
for(CFG_NodePtrNode *n = cfgs.first; n != 0; n = n->next, cfg_idx += 1) for(CFG_NodePtrNode *n = cfgs.first; n != 0; n = n->next, cfg_idx += 1)
{ {
CFG_Node *immediate_root = rd_immediate_cfg_from_keyf("module_%S_cfg_%I64x", module_name, cfg_idx); CFG_Node *immediate_root = rd_immediate_cfg_from_keyf("module_%S_cfg_%I64x", module_name, cfg_idx);
@@ -11984,8 +11984,8 @@ rd_frame(void)
E_IRCtx *ir_ctx = push_array(scratch.arena, E_IRCtx, 1); E_IRCtx *ir_ctx = push_array(scratch.arena, E_IRCtx, 1);
{ {
E_IRCtx *ctx = ir_ctx; E_IRCtx *ctx = ir_ctx;
ctx->regs_map = ctrl_string2reg_from_arch(eval_base_ctx->primary_module->arch); ctx->regs_map = d_string2reg_from_arch(eval_base_ctx->primary_module->arch);
ctx->reg_alias_map = ctrl_string2alias_from_arch(eval_base_ctx->primary_module->arch); ctx->reg_alias_map = d_string2alias_from_arch(eval_base_ctx->primary_module->arch);
ctx->locals_map = d_query_cached_locals_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff); ctx->locals_map = d_query_cached_locals_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff);
ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff); ctx->member_map = d_query_cached_member_map_from_dbgi_key_voff(eval_base_ctx->primary_dbg_info->dbgi_key, rip_voff);
ctx->macro_map = macro_map; ctx->macro_map = macro_map;
@@ -12072,7 +12072,7 @@ rd_frame(void)
case RD_CmdKind_Restart: case RD_CmdKind_Restart:
{ {
// rjf: reset hit counts // rjf: reset hit counts
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(processes.count == 0 || kind == RD_CmdKind_Restart) if(processes.count == 0 || kind == RD_CmdKind_Restart)
{ {
CFG_NodePtrList bps = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("breakpoint")); CFG_NodePtrList bps = cfg_node_top_level_list_from_string(scratch.arena, str8_lit("breakpoint"));
@@ -12292,7 +12292,7 @@ rd_frame(void)
{ {
// rjf: if control processes are live, but this is not force-confirmed, then // rjf: if control processes are live, but this is not force-confirmed, then
// get confirmation from user // get confirmation from user
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
UI_Key key = ui_key_from_string(ui_key_zero(), str8_lit("lossy_exit_confirmation")); UI_Key key = ui_key_from_string(ui_key_zero(), str8_lit("lossy_exit_confirmation"));
if(processes.count != 0 && !rd_regs()->force_confirm && !ui_key_match(rd_state->popup_key, key)) if(processes.count != 0 && !rd_regs()->force_confirm && !ui_key_match(rd_state->popup_key, key))
{ {
@@ -13679,19 +13679,19 @@ rd_frame(void)
//- rjf: source <-> disasm //- rjf: source <-> disasm
case RD_CmdKind_GoToDisassembly: case RD_CmdKind_GoToDisassembly:
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
U64 vaddr = 0; U64 vaddr = 0;
for(D_LineNode *n = rd_regs()->lines.first; n != 0; n = n->next) for(D_LineNode *n = rd_regs()->lines.first; n != 0; n = n->next)
{ {
D_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key); D_EntityList modules = d_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
D_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules); D_Entity *module = d_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &d_entity_nil) if(module != &d_entity_nil)
{ {
vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min); vaddr = d_vaddr_from_voff(module, n->v.voff_range.min);
break; break;
} }
} }
rd_cmd(RD_CmdKind_FindCodeLocation, .process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process)->handle, .vaddr = vaddr, .prefer_disasm = 1); rd_cmd(RD_CmdKind_FindCodeLocation, .process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process)->handle, .vaddr = vaddr, .prefer_disasm = 1);
}break; }break;
case RD_CmdKind_GoToSource: case RD_CmdKind_GoToSource:
{ {
@@ -13701,7 +13701,7 @@ rd_frame(void)
.file_path = rd_regs()->lines.first->v.file_path, .file_path = rd_regs()->lines.first->v.file_path,
.cursor = rd_regs()->lines.first->v.pt, .cursor = rd_regs()->lines.first->v.pt,
.vaddr = 0, .vaddr = 0,
.process = ctrl_handle_zero(), .process = d_handle_zero(),
.prefer_disasm = 0); .prefer_disasm = 0);
} }
}break; }break;
@@ -13967,15 +13967,15 @@ rd_frame(void)
Access *access = access_open(); Access *access = access_open();
//- rjf: unpack thread info //- rjf: unpack thread info
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
U64 unwind_index = rd_regs()->unwind_count; U64 unwind_index = rd_regs()->unwind_count;
U64 inline_depth = rd_regs()->inline_depth; U64 inline_depth = rd_regs()->inline_depth;
U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_index); U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_index);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr); U64 rip_voff = d_voff_from_vaddr(module, rip_vaddr);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff);
D_Line line = {0}; D_Line line = {0};
{ {
@@ -14031,7 +14031,7 @@ rd_frame(void)
}break; }break;
case RD_CmdKind_FindSelectedThread: case RD_CmdKind_FindSelectedThread:
{ {
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
rd_cmd(RD_CmdKind_FindThread, rd_cmd(RD_CmdKind_FindThread,
.thread = selected_thread->handle, .thread = selected_thread->handle,
.unwind_count = rd_base_regs()->unwind_count, .unwind_count = rd_base_regs()->unwind_count,
@@ -14140,9 +14140,9 @@ rd_frame(void)
{ {
D_Entity *process = &d_entity_nil; D_Entity *process = &d_entity_nil;
U64 vaddr = 0; U64 vaddr = 0;
D_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, voff_dbgi_key); D_EntityList modules = d_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, voff_dbgi_key);
D_Entity *module = ctrl_entity_list_first(&modules); D_Entity *module = d_entity_list_first(&modules);
process = ctrl_entity_ancestor_from_kind(module, D_EntityKind_Process); process = d_entity_ancestor_from_kind(module, D_EntityKind_Process);
if(process != &d_entity_nil) if(process != &d_entity_nil)
{ {
vaddr = module->vaddr_range.min + lines.first->v.voff_range.min; vaddr = module->vaddr_range.min + lines.first->v.voff_range.min;
@@ -14220,8 +14220,8 @@ rd_frame(void)
{ {
file_path = rd_mapped_from_file_path(scratch.arena, rd_regs()->file_path); file_path = rd_mapped_from_file_path(scratch.arena, rd_regs()->file_path);
point = rd_regs()->cursor; point = rd_regs()->cursor;
thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process); process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
vaddr = rd_regs()->vaddr; vaddr = rd_regs()->vaddr;
prefer_new_tab = rd_regs()->prefer_new_tab; prefer_new_tab = rd_regs()->prefer_new_tab;
if(file_path.size == 0) if(file_path.size == 0)
@@ -14237,9 +14237,9 @@ rd_frame(void)
D_LineList lines = d_lines_from_file_path_line_num(scratch.arena, file_path, point.line); D_LineList lines = d_lines_from_file_path_line_num(scratch.arena, file_path, point.line);
for(D_LineNode *n = lines.first; n != 0; n = n->next) for(D_LineNode *n = lines.first; n != 0; n = n->next)
{ {
D_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key); D_EntityList modules = d_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
D_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules); D_Entity *module = d_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min); vaddr = d_vaddr_from_voff(module, n->v.voff_range.min);
break; break;
} }
} }
@@ -15441,7 +15441,7 @@ rd_frame(void)
}break; }break;
case RD_CmdKind_SetNextStatement: case RD_CmdKind_SetNextStatement:
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
String8 file_path = rd_regs()->file_path; String8 file_path = rd_regs()->file_path;
U64 new_rip_vaddr = rd_regs()->vaddr_range.min; U64 new_rip_vaddr = rd_regs()->vaddr_range.min;
if(file_path.size != 0) if(file_path.size != 0)
@@ -15449,11 +15449,11 @@ rd_frame(void)
D_LineList *lines = &rd_regs()->lines; D_LineList *lines = &rd_regs()->lines;
for(D_LineNode *n = lines->first; n != 0; n = n->next) for(D_LineNode *n = lines->first; n != 0; n = n->next)
{ {
D_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key); D_EntityList modules = d_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
D_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules); D_Entity *module = d_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &d_entity_nil) if(module != &d_entity_nil)
{ {
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min); new_rip_vaddr = d_vaddr_from_voff(module, n->v.voff_range.min);
break; break;
} }
} }
@@ -15566,10 +15566,10 @@ rd_frame(void)
}break; }break;
case RD_CmdKind_SelectThread: case RD_CmdKind_SelectThread:
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle)); D_Entity *module = d_module_from_process_vaddr(process, d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle));
D_Entity *machine = ctrl_entity_ancestor_from_kind(process, D_EntityKind_Machine); D_Entity *machine = d_entity_ancestor_from_kind(process, D_EntityKind_Machine);
rd_state->base_regs.v.unwind_count = 0; rd_state->base_regs.v.unwind_count = 0;
rd_state->base_regs.v.inline_depth = 0; rd_state->base_regs.v.inline_depth = 0;
rd_state->base_regs.v.thread = thread->handle; rd_state->base_regs.v.thread = thread->handle;
@@ -15581,12 +15581,12 @@ rd_frame(void)
case RD_CmdKind_SelectUnwind: case RD_CmdKind_SelectUnwind:
{ {
Access *access = access_open(); Access *access = access_open();
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
D_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000); D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
D_CallStackFrame *frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth); D_CallStackFrame *frame = d_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
if(frame == 0) if(frame == 0)
{ {
frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, 0); frame = d_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, 0);
} }
if(frame) if(frame)
{ {
@@ -15600,9 +15600,9 @@ rd_frame(void)
case RD_CmdKind_DownOneFrame: case RD_CmdKind_DownOneFrame:
{ {
Access *access = access_open(); Access *access = access_open();
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
D_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000); D_CallStack call_stack = d_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
D_CallStackFrame *current_frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth); D_CallStackFrame *current_frame = d_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
D_CallStackFrame *next_frame = current_frame; D_CallStackFrame *next_frame = current_frame;
if(current_frame != 0) switch(kind) if(current_frame != 0) switch(kind)
{ {
@@ -16304,7 +16304,7 @@ rd_frame(void)
{ {
for EachNonZeroEnumVal(D_ExceptionCodeKind, k) for EachNonZeroEnumVal(D_ExceptionCodeKind, k)
{ {
String8 name = ctrl_exception_code_kind_lowercase_code_string_table[k]; String8 name = d_exception_code_kind_lowercase_code_string_table[k];
B32 setting = rd_setting_b32_from_name(name); B32 setting = rd_setting_b32_from_name(name);
if(setting) if(setting)
{ {
@@ -16331,8 +16331,8 @@ rd_frame(void)
default:{}break; default:{}break;
case D_EventKind_NewModule: case D_EventKind_NewModule:
{ {
D_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->entity); D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->entity);
D_Entity *debug_info_path = ctrl_entity_child_from_kind(module, D_EntityKind_DebugInfoPath); D_Entity *debug_info_path = d_entity_child_from_kind(module, D_EntityKind_DebugInfoPath);
String8 new_path = debug_info_path->string; String8 new_path = debug_info_path->string;
if(new_path.size != 0 && os_file_path_exists(new_path)) if(new_path.size != 0 && os_file_path_exists(new_path))
{ {
@@ -16369,7 +16369,7 @@ rd_frame(void)
case D_EventKind_EndProc: case D_EventKind_EndProc:
if(rd_state->quit_after_success) if(rd_state->quit_after_success)
{ {
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(evt->u64_code == 0 && processes.count == 0) if(evt->u64_code == 0 && processes.count == 0)
{ {
rd_cmd(RD_CmdKind_Exit); rd_cmd(RD_CmdKind_Exit);
@@ -16382,12 +16382,12 @@ rd_frame(void)
case D_EventKind_Stopped: case D_EventKind_Stopped:
{ {
B32 need_refocus = (evt->cause != D_EventCause_InterruptedByHalt || !soft_halt_issued); B32 need_refocus = (evt->cause != D_EventCause_InterruptedByHalt || !soft_halt_issued);
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->entity); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->entity);
U64 vaddr = evt->rip_vaddr; U64 vaddr = evt->rip_vaddr;
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, vaddr); D_Entity *module = d_module_from_process_vaddr(process, vaddr);
U64 voff = ctrl_voff_from_vaddr(module, vaddr); U64 voff = d_voff_from_vaddr(module, vaddr);
U64 test_cached_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle); U64 test_cached_vaddr = d_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
// rjf: valid stop thread? -> select & snap // rjf: valid stop thread? -> select & snap
if(need_refocus && thread != &d_entity_nil && evt->cause != D_EventCause_InterruptedByHalt) if(need_refocus && thread != &d_entity_nil && evt->cause != D_EventCause_InterruptedByHalt)
@@ -16396,7 +16396,7 @@ rd_frame(void)
} }
// rjf: no stop-causing thread, but have selected thread? -> snap to selected // rjf: no stop-causing thread, but have selected thread? -> snap to selected
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
if(need_refocus && (evt->cause == D_EventCause_InterruptedByHalt || thread == &d_entity_nil) && selected_thread != &d_entity_nil) if(need_refocus && (evt->cause == D_EventCause_InterruptedByHalt || thread == &d_entity_nil) && selected_thread != &d_entity_nil)
{ {
rd_cmd(RD_CmdKind_SelectThread, .thread = selected_thread->handle); rd_cmd(RD_CmdKind_SelectThread, .thread = selected_thread->handle);
@@ -16405,8 +16405,8 @@ rd_frame(void)
// rjf: no stop-causing thread, but don't have selected thread? -> snap to first available thread // rjf: no stop-causing thread, but don't have selected thread? -> snap to first available thread
if(need_refocus && thread == &d_entity_nil && selected_thread == &d_entity_nil) if(need_refocus && thread == &d_entity_nil && selected_thread == &d_entity_nil)
{ {
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread); D_EntityArray threads = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
D_Entity *first_available_thread = ctrl_entity_array_first(&threads); D_Entity *first_available_thread = d_entity_array_first(&threads);
rd_cmd(RD_CmdKind_SelectThread, .thread = first_available_thread->handle); rd_cmd(RD_CmdKind_SelectThread, .thread = first_available_thread->handle);
} }
@@ -16469,7 +16469,7 @@ rd_frame(void)
////////////////////////////// //////////////////////////////
//- rjf: retry find-thread //- rjf: retry find-thread
// //
if(!ctrl_handle_match(ctrl_handle_zero(), find_thread_retry)) if(!d_handle_match(d_handle_zero(), find_thread_retry))
{ {
rd_cmd(RD_CmdKind_FindThread, .thread = find_thread_retry); rd_cmd(RD_CmdKind_FindThread, .thread = find_thread_retry);
} }
+26 -26
View File
@@ -205,7 +205,7 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(locals)
E_TYPE_EXPAND_INFO_FUNCTION_DEF(registers) E_TYPE_EXPAND_INFO_FUNCTION_DEF(registers)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
Arch arch = thread->arch; Arch arch = thread->arch;
U64 reg_count = regs_reg_code_count_from_arch(arch); U64 reg_count = regs_reg_code_count_from_arch(arch);
String8 *reg_strings = regs_reg_code_string_table_from_arch(arch); String8 *reg_strings = regs_reg_code_string_table_from_arch(arch);
@@ -309,7 +309,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(schema)
} }
else if(entity != &d_entity_nil && str8_match(child_schema->string, str8_lit("dbg"), 0)) else if(entity != &d_entity_nil && str8_match(child_schema->string, str8_lit("dbg"), 0))
{ {
D_Entity *dbg = ctrl_entity_child_from_kind(entity, D_EntityKind_DebugInfoPath); D_Entity *dbg = d_entity_child_from_kind(entity, D_EntityKind_DebugInfoPath);
child_type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), dbg->string.size, type_flags|E_TypeFlag_IsPathText); child_type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), dbg->string.size, type_flags|E_TypeFlag_IsPathText);
} }
@@ -658,11 +658,11 @@ E_TYPE_ACCESS_FUNCTION_DEF(control)
if(rhs->kind == E_ExprKind_LeafIdentifier && if(rhs->kind == E_ExprKind_LeafIdentifier &&
str8_match(str8_prefix(rhs->string, 1), str8_lit("$"), 0)) str8_match(str8_prefix(rhs->string, 1), str8_lit("$"), 0))
{ {
D_Handle handle = ctrl_handle_from_string(rhs->string); D_Handle handle = d_handle_from_string(rhs->string);
D_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle); D_Entity *entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle);
E_Space space = rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity); E_Space space = rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity);
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, 0)); result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, 0));
result.type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]); result.type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, d_entity_kind_code_name_table[entity->kind]);
result.mode = E_Mode_Offset; result.mode = E_Mode_Offset;
} }
return result; return result;
@@ -957,10 +957,10 @@ E_TYPE_IREXT_FUNCTION_DEF(call_stack)
D_Entity *entity = rd_ctrl_entity_from_eval_space(interp.space); D_Entity *entity = rd_ctrl_entity_from_eval_space(interp.space);
if(entity->kind == D_EntityKind_Thread) if(entity->kind == D_EntityKind_Thread)
{ {
B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); B32 call_stack_high_priority = d_handle_match(entity->handle, rd_base_regs()->thread);
accel->arch = entity->arch; accel->arch = entity->arch;
accel->process = ctrl_process_from_entity(entity)->handle; accel->process = d_process_from_entity(entity)->handle;
accel->call_stack = ctrl_call_stack_from_thread(rd_state->frame_access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); accel->call_stack = d_call_stack_from_thread(rd_state->frame_access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
} }
scratch_end(scratch); scratch_end(scratch);
} }
@@ -978,7 +978,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(call_stack)
D_CallStack *call_stack = &accel->call_stack; D_CallStack *call_stack = &accel->call_stack;
if(0 <= rhs_value.u64 && rhs_value.u64 < call_stack->frames_count) if(0 <= rhs_value.u64 && rhs_value.u64 < call_stack->frames_count)
{ {
D_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, accel->process); D_Entity *process = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, accel->process);
D_CallStackFrame *f = &call_stack->frames[rhs_value.u64]; D_CallStackFrame *f = &call_stack->frames[rhs_value.u64];
result.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, D_EvalSpaceKind_Entity), e_irtree_const_u(arena, regs_rip_from_arch_block(accel->arch, f->regs))); result.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, D_EvalSpaceKind_Entity), e_irtree_const_u(arena, regs_rip_from_arch_block(accel->arch, f->regs)));
result.type_key = e_type_key_cons(.arch = process->arch, .kind = E_TypeKind_Ptr, .direct_key = e_type_key_basic(E_TypeKind_Function), .count = 1, .depth = f->inline_depth); result.type_key = e_type_key_cons(.arch = process->arch, .kind = E_TypeKind_Ptr, .direct_key = e_type_key_basic(E_TypeKind_Function), .count = 1, .depth = f->inline_depth);
@@ -1438,7 +1438,7 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(unattached_processes)
} }
else else
{ {
machines = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Machine); machines = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Machine);
} }
//- rjf: gather system processes from this machine //- rjf: gather system processes from this machine
@@ -1516,7 +1516,7 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(unattached_processes)
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1) for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
{ {
D_Entity *machine = accel->machines[idx]; D_Entity *machine = accel->machines[idx];
String8 string = ctrl_string_from_handle(arena, machine->handle); String8 string = d_string_from_handle(arena, machine->handle);
evals_out[out_idx] = e_eval_wrapf(eval, "query:control.%S.unattached_processes.$%I64x$%I64x", string, accel->infos[idx].pid, e_id_from_string(accel->infos[idx].name)); evals_out[out_idx] = e_eval_wrapf(eval, "query:control.%S.unattached_processes.$%I64x$%I64x", string, accel->infos[idx].pid, e_id_from_string(accel->infos[idx].name));
} }
} }
@@ -1534,16 +1534,16 @@ E_TYPE_ACCESS_FUNCTION_DEF(ctrl_entities)
case E_ExprKind_MemberAccess: case E_ExprKind_MemberAccess:
{ {
String8 rhs_name = expr->first->next->string; String8 rhs_name = expr->first->next->string;
D_Handle handle = ctrl_handle_from_string(rhs_name); D_Handle handle = d_handle_from_string(rhs_name);
entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle); entity = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle);
}break; }break;
case E_ExprKind_ArrayIndex: case E_ExprKind_ArrayIndex:
{ {
E_Type *type = e_type_from_key(lhs_irtree->type_key); E_Type *type = e_type_from_key(lhs_irtree->type_key);
D_EntityKind kind = ctrl_entity_kind_from_string(rd_singular_from_code_name_plural(type->name)); D_EntityKind kind = d_entity_kind_from_string(rd_singular_from_code_name_plural(type->name));
E_Value rhs_value = e_value_from_expr(expr->first->next); E_Value rhs_value = e_value_from_expr(expr->first->next);
U64 rhs_idx = rhs_value.u64; U64 rhs_idx = rhs_value.u64;
D_EntityArray entities = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, kind); D_EntityArray entities = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, kind);
if(0 <= rhs_idx && rhs_idx < entities.count) if(0 <= rhs_idx && rhs_idx < entities.count)
{ {
entity = entities.v[rhs_idx]; entity = entities.v[rhs_idx];
@@ -1553,7 +1553,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(ctrl_entities)
if(entity != &d_entity_nil) if(entity != &d_entity_nil)
{ {
E_Space space = rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity); E_Space space = rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity);
String8 name = ctrl_entity_kind_code_name_table[entity->kind]; String8 name = d_entity_kind_code_name_table[entity->kind];
E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name); E_TypeKey type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, name);
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, 0)); result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, 0));
result.type_key = type_key; result.type_key = type_key;
@@ -1579,13 +1579,13 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(ctrl_entities)
E_TypeKey lhs_type_key = eval.irtree.type_key; E_TypeKey lhs_type_key = eval.irtree.type_key;
E_Type *lhs_type = e_type_from_key(lhs_type_key); E_Type *lhs_type = e_type_from_key(lhs_type_key);
String8 name = rd_singular_from_code_name_plural(lhs_type->name); String8 name = rd_singular_from_code_name_plural(lhs_type->name);
D_EntityKind entity_kind = ctrl_entity_kind_from_string(name); D_EntityKind entity_kind = d_entity_kind_from_string(name);
//- rjf: gather array of all entities which fit the bill //- rjf: gather array of all entities which fit the bill
D_EntityArray array = {0}; D_EntityArray array = {0};
if(scoping_entity == &d_entity_nil) if(scoping_entity == &d_entity_nil)
{ {
array = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, entity_kind); array = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, entity_kind);
} }
else else
{ {
@@ -1594,10 +1594,10 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(ctrl_entities)
{ {
if(child->kind == entity_kind) if(child->kind == entity_kind)
{ {
ctrl_entity_list_push(scratch.arena, &list, child); d_entity_list_push(scratch.arena, &list, child);
} }
} }
array = ctrl_entity_array_from_list(arena, &list); array = d_entity_array_from_list(arena, &list);
} }
//- rjf: filter the array //- rjf: filter the array
@@ -1613,10 +1613,10 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(ctrl_entities)
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, title_string); FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, title_string);
if(matches.count == matches.needle_part_count) if(matches.count == matches.needle_part_count)
{ {
ctrl_entity_list_push(scratch.arena, &list__filtered, entity); d_entity_list_push(scratch.arena, &list__filtered, entity);
} }
} }
array__filtered = ctrl_entity_array_from_list(arena, &list__filtered); array__filtered = d_entity_array_from_list(arena, &list__filtered);
} }
//- rjf: list -> array & fill //- rjf: list -> array & fill
@@ -1639,7 +1639,7 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(ctrl_entities)
{ {
Temp scratch = scratch_begin(&arena, 1); Temp scratch = scratch_begin(&arena, 1);
D_Entity *entity = entities->v[out_idx + read_range.min]; D_Entity *entity = entities->v[out_idx + read_range.min];
evals_out[out_idx] = e_eval_from_stringf("query:control.%S", ctrl_string_from_handle(scratch.arena, entity->handle)); evals_out[out_idx] = e_eval_from_stringf("query:control.%S", d_string_from_handle(scratch.arena, entity->handle));
scratch_end(scratch); scratch_end(scratch);
} }
} }
@@ -1675,7 +1675,7 @@ struct RD_CallStackTreeExpandAccel
E_TYPE_EXPAND_INFO_FUNCTION_DEF(call_stack_tree) E_TYPE_EXPAND_INFO_FUNCTION_DEF(call_stack_tree)
{ {
Access *access = access_open(); Access *access = access_open();
D_CallStackTree call_stack_tree = ctrl_call_stack_tree(access, 0); D_CallStackTree call_stack_tree = d_call_stack_tree(access, 0);
access_close(access); access_close(access);
RD_CallStackTreeExpandAccel *accel = push_array(arena, RD_CallStackTreeExpandAccel, 1); RD_CallStackTreeExpandAccel *accel = push_array(arena, RD_CallStackTreeExpandAccel, 1);
accel->node = &d_call_stack_tree_node_nil; accel->node = &d_call_stack_tree_node_nil;
@@ -1703,7 +1703,7 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(call_stack_tree)
accel->children[idx] = n; accel->children[idx] = n;
} }
} }
accel->threads = ctrl_handle_array_from_list(arena, &accel->node->threads); accel->threads = d_handle_array_from_list(arena, &accel->node->threads);
E_TypeExpandInfo result = {accel}; E_TypeExpandInfo result = {accel};
result.expr_count = accel->node->child_count + accel->threads.count; result.expr_count = accel->node->child_count + accel->threads.count;
return result; return result;
@@ -1724,7 +1724,7 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(call_stack_tree)
} }
else if(node->child_count <= idx && idx < node->child_count + accel->threads.count) else if(node->child_count <= idx && idx < node->child_count + accel->threads.count)
{ {
eval = e_eval_from_stringf("query:control.%S", ctrl_string_from_handle(scratch.arena, accel->threads.v[idx - node->child_count])); eval = e_eval_from_stringf("query:control.%S", d_string_from_handle(scratch.arena, accel->threads.v[idx - node->child_count]));
} }
evals_out[idx] = eval; evals_out[idx] = eval;
} }
+1 -1
View File
@@ -545,7 +545,7 @@ entry_point(CmdLine *cmd_line)
r_init(cmd_line); r_init(cmd_line);
fnt_init(); fnt_init();
rd_init(cmd_line); rd_init(cmd_line);
ctrl_set_wakeup_hook(wakeup_hook_ctrl); d_set_wakeup_hook(wakeup_hook_ctrl);
} }
//- rjf: set up shared resources for ipc to this instance; launch IPC signaler thread //- rjf: set up shared resources for ipc to this instance; launch IPC signaler thread
+51 -51
View File
@@ -44,8 +44,8 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
F32 scroll_bar_dim = floor_f32(main_font_size*1.5f); F32 scroll_bar_dim = floor_f32(main_font_size*1.5f);
Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim); Vec2F32 code_area_dim = v2f32(panel_box_dim.x - scroll_bar_dim, panel_box_dim.y - scroll_bar_dim);
S64 num_possible_visible_lines = (S64)(code_area_dim.y/code_line_height)+1; S64 num_possible_visible_lines = (S64)(code_area_dim.y/code_line_height)+1;
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
B32 do_line_numbers = rd_setting_b32_from_name(str8_lit("show_line_numbers")); B32 do_line_numbers = rd_setting_b32_from_name(str8_lit("show_line_numbers"));
////////////////////////////// //////////////////////////////
@@ -277,19 +277,19 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
// rjf: find live threads mapping to source code // rjf: find live threads mapping to source code
if(!dasm_lines) ProfScope("find live threads mapping to this file") if(!dasm_lines) ProfScope("find live threads mapping to this file")
{ {
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread); D_EntityArray threads = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
for EachIndex(idx, threads.count) for EachIndex(idx, threads.count)
{ {
D_Entity *thread = threads.v[idx]; D_Entity *thread = threads.v[idx];
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0; U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0;
U64 inline_depth = (thread == selected_thread) ? rd_regs()->inline_depth : 0; U64 inline_depth = (thread == selected_thread) ? rd_regs()->inline_depth : 0;
U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count; U64 last_inst_on_unwound_rip_vaddr = rip_vaddr - !!unwind_count;
D_Entity *module = ctrl_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, last_inst_on_unwound_rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, last_inst_on_unwound_rip_vaddr); U64 rip_voff = d_voff_from_vaddr(module, last_inst_on_unwound_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff); D_LineList lines = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, rip_voff);
for(D_LineNode *n = lines.first; n != 0; n = n->next) for(D_LineNode *n = lines.first; n != 0; n = n->next)
{ {
@@ -302,7 +302,7 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
if(path_match_normalized(n->v.file_path, override_n->string)) if(path_match_normalized(n->v.file_path, override_n->string))
{ {
U64 slice_line_idx = n->v.pt.line-visible_line_num_range.min; U64 slice_line_idx = n->v.pt.line-visible_line_num_range.min;
ctrl_entity_list_push(scratch.arena, &code_slice_params.line_ips[slice_line_idx], thread); d_entity_list_push(scratch.arena, &code_slice_params.line_ips[slice_line_idx], thread);
break; break;
} }
} }
@@ -340,8 +340,8 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
if(!dasm_lines) ProfScope("find all src -> dasm info for source code") if(!dasm_lines) ProfScope("find all src -> dasm info for source code")
{ {
String8 file_path = rd_regs()->file_path; String8 file_path = rd_regs()->file_path;
D_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module); D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
D_LineListArray lines_array = d_lines_array_from_dbgi_key_file_path_line_range(scratch.arena, dbgi_key, file_path, visible_line_num_range); D_LineListArray lines_array = d_lines_array_from_dbgi_key_file_path_line_range(scratch.arena, dbgi_key, file_path, visible_line_num_range);
if(lines_array.count != 0) if(lines_array.count != 0)
{ {
@@ -353,21 +353,21 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
// rjf: find live threads mapping to disasm // rjf: find live threads mapping to disasm
if(dasm_lines) ProfScope("find live threads mapping to this disassembly") if(dasm_lines) ProfScope("find live threads mapping to this disassembly")
{ {
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread); D_EntityArray threads = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Thread);
for EachIndex(idx, threads.count) for EachIndex(idx, threads.count)
{ {
D_Entity *thread = threads.v[idx]; D_Entity *thread = threads.v[idx];
U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0; U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0;
U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
if(ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process) == process && contains_1u64(dasm_vaddr_range, rip_vaddr)) if(d_entity_ancestor_from_kind(thread, D_EntityKind_Process) == process && contains_1u64(dasm_vaddr_range, rip_vaddr))
{ {
U64 rip_off = rip_vaddr - dasm_vaddr_range.min; U64 rip_off = rip_vaddr - dasm_vaddr_range.min;
S64 line_num = dasm_line_array_idx_from_code_off__linear_scan(dasm_lines, rip_off)+1; S64 line_num = dasm_line_array_idx_from_code_off__linear_scan(dasm_lines, rip_off)+1;
if(contains_1s64(visible_line_num_range, line_num)) if(contains_1s64(visible_line_num_range, line_num))
{ {
U64 slice_line_idx = (line_num-visible_line_num_range.min); U64 slice_line_idx = (line_num-visible_line_num_range.min);
ctrl_entity_list_push(scratch.arena, &code_slice_params.line_ips[slice_line_idx], thread); d_entity_list_push(scratch.arena, &code_slice_params.line_ips[slice_line_idx], thread);
} }
} }
} }
@@ -422,12 +422,12 @@ rd_code_view_build(Arena *arena, RD_CodeViewState *cv, RD_CodeViewBuildFlags fla
// rjf: fill dasm -> src info // rjf: fill dasm -> src info
if(dasm_lines) if(dasm_lines)
{ {
D_Entity *module = ctrl_module_from_process_vaddr(process, dasm_vaddr_range.min); D_Entity *module = d_module_from_process_vaddr(process, dasm_vaddr_range.min);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
for(S64 line_num = visible_line_num_range.min; line_num < visible_line_num_range.max; line_num += 1) for(S64 line_num = visible_line_num_range.min; line_num < visible_line_num_range.max; line_num += 1)
{ {
U64 vaddr = dasm_vaddr_range.min + dasm_line_array_code_off_from_idx(dasm_lines, line_num-1); U64 vaddr = dasm_vaddr_range.min + dasm_line_array_code_off_from_idx(dasm_lines, line_num-1);
U64 voff = ctrl_voff_from_vaddr(module, vaddr); U64 voff = d_voff_from_vaddr(module, vaddr);
U64 slice_idx = line_num-visible_line_num_range.min; U64 slice_idx = line_num-visible_line_num_range.min;
code_slice_params.line_vaddrs[slice_idx] = vaddr; code_slice_params.line_vaddrs[slice_idx] = vaddr;
code_slice_params.line_infos[slice_idx] = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff); code_slice_params.line_infos[slice_idx] = d_lines_from_dbgi_key_voff(scratch.arena, dbgi_key, voff);
@@ -977,7 +977,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
} }
if(evalled_entity != &d_entity_nil) if(evalled_entity != &d_entity_nil)
{ {
String8 top_level_name = ctrl_entity_kind_code_name_table[evalled_entity->kind]; String8 top_level_name = d_entity_kind_code_name_table[evalled_entity->kind];
E_TypeKey top_level_type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, top_level_name); E_TypeKey top_level_type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, top_level_name);
is_top_level = (row->eval.value.u64 == 0 && e_type_key_match(top_level_type_key, row->eval.irtree.type_key)); is_top_level = (row->eval.value.u64 == 0 && e_type_key_match(top_level_type_key, row->eval.irtree.type_key));
} }
@@ -1002,13 +1002,13 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
case D_EntityKind_Process: case D_EntityKind_Process:
if(row->eval.irtree.mode == E_Mode_Offset) if(row->eval.irtree.mode == E_Mode_Offset)
{ {
info.module = ctrl_module_from_process_vaddr(row_ctrl_entity, row->eval.value.u64); info.module = d_module_from_process_vaddr(row_ctrl_entity, row->eval.value.u64);
}break; }break;
case D_EntityKind_Thread: case D_EntityKind_Thread:
if(row->eval.irtree.mode == E_Mode_Value) if(row->eval.irtree.mode == E_Mode_Value)
{ {
D_Entity *process = ctrl_process_from_entity(row_ctrl_entity); D_Entity *process = d_process_from_entity(row_ctrl_entity);
info.module = ctrl_module_from_process_vaddr(process, d_query_cached_rip_from_thread(row_ctrl_entity)); info.module = d_module_from_process_vaddr(process, d_query_cached_rip_from_thread(row_ctrl_entity));
}break; }break;
} }
} }
@@ -1024,8 +1024,8 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
Access *access = access_open(); Access *access = access_open();
info.callstack_thread = entity; info.callstack_thread = entity;
U64 frame_num = ev_block_num_from_id(block, key.child_id); U64 frame_num = ev_block_num_from_id(block, key.child_id);
B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); B32 call_stack_high_priority = d_handle_match(entity->handle, rd_base_regs()->thread);
D_CallStack call_stack = ctrl_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); D_CallStack call_stack = d_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
if(1 <= frame_num && frame_num <= call_stack.frames_count) if(1 <= frame_num && frame_num <= call_stack.frames_count)
{ {
D_CallStackFrame *f = &call_stack.frames[frame_num-1]; D_CallStackFrame *f = &call_stack.frames[frame_num-1];
@@ -1313,7 +1313,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
if(entity->kind == D_EntityKind_Thread) if(entity->kind == D_EntityKind_Thread)
{ {
RD_CmdKind cmd_kind = RD_CmdKind_SelectEntity; RD_CmdKind cmd_kind = RD_CmdKind_SelectEntity;
if(ctrl_handle_match(entity->handle, rd_base_regs()->thread)) if(d_handle_match(entity->handle, rd_base_regs()->thread))
{ {
cmd_kind = RD_CmdKind_DeselectEntity; cmd_kind = RD_CmdKind_DeselectEntity;
} }
@@ -1408,9 +1408,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
else if(info.callstack_thread != &d_entity_nil) else if(info.callstack_thread != &d_entity_nil)
{ {
info.cell_style_key = str8_lit("call_stack_frame"); info.cell_style_key = str8_lit("call_stack_frame");
D_Entity *process = ctrl_process_from_entity(info.callstack_thread); D_Entity *process = d_process_from_entity(info.callstack_thread);
D_Entity *module = ctrl_module_from_process_vaddr(process, info.callstack_vaddr); D_Entity *module = d_module_from_process_vaddr(process, info.callstack_vaddr);
E_Eval module_eval = e_eval_from_stringf("query:control.%S", ctrl_string_from_handle(scratch.arena, module->handle)); E_Eval module_eval = e_eval_from_stringf("query:control.%S", d_string_from_handle(scratch.arena, module->handle));
CFG_Node *view = cfg_node_from_id(rd_regs()->view); CFG_Node *view = cfg_node_from_id(rd_regs()->view);
CFG_Node *style = cfg_node_child_from_string(view, info.cell_style_key); CFG_Node *style = cfg_node_child_from_string(view, info.cell_style_key);
CFG_Node *w_cfg = style->first; CFG_Node *w_cfg = style->first;
@@ -2099,8 +2099,8 @@ RD_VIEW_UI_FUNCTION_DEF(text)
if(rd_regs()->lang_kind == TXT_LangKind_Null) if(rd_regs()->lang_kind == TXT_LangKind_Null)
{ {
Access *access = access_open(); Access *access = access_open();
D_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module); D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi != &rdi_parsed_nil) if(rdi != &rdi_parsed_nil)
{ {
@@ -2223,8 +2223,8 @@ RD_VIEW_UI_FUNCTION_DEF(text)
// //
if(rd_regs()->file_path.size != 0) if(rd_regs()->file_path.size != 0)
{ {
D_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module); D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->module);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
rd_regs()->lines = d_lines_from_dbgi_key_file_path_line_num(rd_frame_arena(), dbgi_key, rd_regs()->file_path, rd_regs()->cursor.line); rd_regs()->lines = d_lines_from_dbgi_key_file_path_line_num(rd_frame_arena(), dbgi_key, rd_regs()->file_path, rd_regs()->cursor.line);
} }
@@ -2430,16 +2430,16 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
E_Space auto_space = {0}; E_Space auto_space = {0};
if(eval.expr == &e_expr_nil) if(eval.expr == &e_expr_nil)
{ {
if(dv->temp_look_vaddr != 0 && dv->temp_look_run_gen == ctrl_run_gen()) if(dv->temp_look_vaddr != 0 && dv->temp_look_run_gen == d_run_gen())
{ {
auto_selected = 1; auto_selected = 1;
auto_space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, dv->temp_look_process), D_EvalSpaceKind_Entity); auto_space = rd_eval_space_from_ctrl_entity(d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, dv->temp_look_process), D_EvalSpaceKind_Entity);
eval = e_eval_from_stringf("(0x%I64x & (~(0x4000 - 1)))", dv->temp_look_vaddr); eval = e_eval_from_stringf("(0x%I64x & (~(0x4000 - 1)))", dv->temp_look_vaddr);
} }
else else
{ {
auto_selected = 1; auto_selected = 1;
auto_space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), D_EvalSpaceKind_Entity); auto_space = rd_eval_space_from_ctrl_entity(d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), D_EvalSpaceKind_Entity);
eval = e_eval_from_stringf("(reg:rip & (~(0x4000 - 1)))"); eval = e_eval_from_stringf("(reg:rip & (~(0x4000 - 1)))");
} }
} }
@@ -2468,7 +2468,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
{ {
dv->temp_look_process = cmd->regs->process; dv->temp_look_process = cmd->regs->process;
dv->temp_look_vaddr = cmd->regs->vaddr; dv->temp_look_vaddr = cmd->regs->vaddr;
dv->temp_look_run_gen = ctrl_run_gen(); dv->temp_look_run_gen = d_run_gen();
dv->goto_vaddr = cmd->regs->vaddr; dv->goto_vaddr = cmd->regs->vaddr;
}break; }break;
} }
@@ -2494,8 +2494,8 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
case D_EntityKind_Process: case D_EntityKind_Process:
{ {
if(arch == Arch_Null) { arch = space_entity->arch; } if(arch == Arch_Null) { arch = space_entity->arch; }
dasm_module = ctrl_module_from_process_vaddr(space_entity, range.min); dasm_module = d_module_from_process_vaddr(space_entity, range.min);
dbgi_key = ctrl_dbgi_key_from_module(dasm_module); dbgi_key = d_dbgi_key_from_module(dasm_module);
base_vaddr = dasm_module->vaddr_range.min; base_vaddr = dasm_module->vaddr_range.min;
}break; }break;
} }
@@ -2584,7 +2584,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
rd_regs()->prefer_disasm = 1; rd_regs()->prefer_disasm = 1;
rd_regs()->vaddr = range.min+off; rd_regs()->vaddr = range.min+off;
rd_regs()->vaddr_range = r1u64(range.min+off, range.min+off); rd_regs()->vaddr_range = r1u64(range.min+off, range.min+off);
rd_regs()->voff_range = ctrl_voff_range_from_vaddr_range(dasm_module, rd_regs()->vaddr_range); rd_regs()->voff_range = d_voff_range_from_vaddr_range(dasm_module, rd_regs()->vaddr_range);
rd_regs()->lines = d_lines_from_dbgi_key_voff(rd_frame_arena(), dbgi_key, rd_regs()->voff_range.min); rd_regs()->lines = d_lines_from_dbgi_key_voff(rd_frame_arena(), dbgi_key, rd_regs()->voff_range.min);
} }
@@ -2680,7 +2680,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
Rng1U64 view_range = rd_space_range_from_eval(eval); Rng1U64 view_range = rd_space_range_from_eval(eval);
if(eval.space.kind == 0) if(eval.space.kind == 0)
{ {
eval.space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), D_EvalSpaceKind_Entity); eval.space = rd_eval_space_from_ctrl_entity(d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), D_EvalSpaceKind_Entity);
view_range = rd_whole_range_from_eval_space(eval.space); view_range = rd_whole_range_from_eval_space(eval.space);
} }
@@ -3223,7 +3223,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
D_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space); D_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
if(entity->kind == D_EntityKind_Process) if(entity->kind == D_EntityKind_Process)
{ {
D_ProcessMemorySlice slice = ctrl_process_memory_slice_from_vaddr_range(scratch.arena, entity->handle, viz_range_bytes, 0, 0); D_ProcessMemorySlice slice = d_process_memory_slice_from_vaddr_range(scratch.arena, entity->handle, viz_range_bytes, 0, 0);
visible_memory_change_flags = slice.byte_changed_flags; visible_memory_change_flags = slice.byte_changed_flags;
visible_memory_bad_flags = slice.byte_bad_flags; visible_memory_bad_flags = slice.byte_bad_flags;
} }
@@ -3258,9 +3258,9 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
AnnotationList *visible_memory_annotations = push_array(scratch.arena, AnnotationList, visible_memory_size); AnnotationList *visible_memory_annotations = push_array(scratch.arena, AnnotationList, visible_memory_size);
{ {
Access *access = access_open(); Access *access = access_open();
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_Entity *selected_process = ctrl_entity_ancestor_from_kind(selected_thread, D_EntityKind_Process); D_Entity *selected_process = d_entity_ancestor_from_kind(selected_thread, D_EntityKind_Process);
D_CallStack selected_call_stack = ctrl_call_stack_from_thread(access, selected_thread->handle, 1, 0); D_CallStack selected_call_stack = d_call_stack_from_thread(access, selected_thread->handle, 1, 0);
D_Entity *eval_process = &d_entity_nil; D_Entity *eval_process = &d_entity_nil;
if(eval.space.kind == D_EvalSpaceKind_Entity) if(eval.space.kind == D_EvalSpaceKind_Entity)
{ {
@@ -3309,9 +3309,9 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
Access *access = access_open(); Access *access = access_open();
U64 f_rip_vaddr = last_rip; U64 f_rip_vaddr = last_rip;
last_rip = regs_rip_from_arch_block(selected_thread->arch, f->regs); last_rip = regs_rip_from_arch_block(selected_thread->arch, f->regs);
D_Entity *module = ctrl_module_from_process_vaddr(selected_process, f_rip_vaddr); D_Entity *module = d_module_from_process_vaddr(selected_process, f_rip_vaddr);
U64 f_rip_voff = ctrl_voff_from_vaddr(module, f_rip_vaddr); U64 f_rip_voff = d_voff_from_vaddr(module, f_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, f_rip_voff); RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, f_rip_voff);
String8 procedure_name = {0}; String8 procedure_name = {0};
@@ -3352,11 +3352,11 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
{ {
next_vaddr = vaddr+1; next_vaddr = vaddr+1;
Access *access = access_open(); Access *access = access_open();
D_Entity *module = ctrl_module_from_process_vaddr(eval_process, vaddr); D_Entity *module = d_module_from_process_vaddr(eval_process, vaddr);
if(module != &d_entity_nil) if(module != &d_entity_nil)
{ {
U64 voff = ctrl_voff_from_vaddr(module, vaddr); U64 voff = d_voff_from_vaddr(module, vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, voff); RDI_Symbol *procedure = rdi_procedure_from_voff(rdi, voff);
RDI_Scope *root_scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx); RDI_Scope *root_scope = rdi_element_from_name_idx(rdi, Scopes, procedure->root_scope_idx);
@@ -3364,7 +3364,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
{ {
Rng1U64 voff_range = r1u64(rdi_first_voff_from_scope(rdi, root_scope), Rng1U64 voff_range = r1u64(rdi_first_voff_from_scope(rdi, root_scope),
rdi_opl_voff_from_scope(rdi, root_scope)); rdi_opl_voff_from_scope(rdi, root_scope));
Rng1U64 vaddr_range = ctrl_vaddr_range_from_voff_range(module, voff_range); Rng1U64 vaddr_range = d_vaddr_range_from_voff_range(module, voff_range);
next_vaddr = vaddr_range.max; next_vaddr = vaddr_range.max;
next_vaddr = Max(next_vaddr, vaddr+1); next_vaddr = Max(next_vaddr, vaddr+1);
Rng1U64 vaddr_range_in_visible = intersect_1u64(vaddr_range, viz_range_bytes); Rng1U64 vaddr_range_in_visible = intersect_1u64(vaddr_range, viz_range_bytes);
+35 -35
View File
@@ -108,7 +108,7 @@ rd_title_fstrs_from_cfg(Arena *arena, CFG_Node *cfg, B32 include_extras)
CFG_Node *bp = cfg_node_from_id(stop_event.u64_code); CFG_Node *bp = cfg_node_from_id(stop_event.u64_code);
if(bp == cfg) if(bp == cfg)
{ {
D_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, stop_event.entity); D_Entity *thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, stop_event.entity);
Vec4F32 thread_color = rd_color_from_ctrl_entity(thread); Vec4F32 thread_color = rd_color_from_ctrl_entity(thread);
if(thread_color.w == 0) if(thread_color.w == 0)
{ {
@@ -487,7 +487,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
if((entity->kind == D_EntityKind_Machine || if((entity->kind == D_EntityKind_Machine ||
entity->kind == D_EntityKind_Process || entity->kind == D_EntityKind_Process ||
entity->kind == D_EntityKind_Thread) && entity->kind == D_EntityKind_Thread) &&
ctrl_entity_tree_is_frozen(entity)) d_entity_tree_is_frozen(entity))
UI_TagF("bad") UI_TagF("bad")
{ {
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_Locked], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = ui_color_from_name(str8_lit("text"))); dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_Locked], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = ui_color_from_name(str8_lit("text")));
@@ -497,7 +497,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
//- rjf: push selected icon, if selected thread //- rjf: push selected icon, if selected thread
if(entity->kind == D_EntityKind_Thread) if(entity->kind == D_EntityKind_Thread)
{ {
B32 is_selected = ctrl_handle_match(entity->handle, rd_base_regs()->thread); B32 is_selected = d_handle_match(entity->handle, rd_base_regs()->thread);
if(is_selected) if(is_selected)
{ {
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = color); dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = color);
@@ -509,10 +509,10 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
if(entity->kind == D_EntityKind_Thread || if(entity->kind == D_EntityKind_Thread ||
entity->kind == D_EntityKind_Module) entity->kind == D_EntityKind_Module)
{ {
D_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process); D_EntityArray processes = d_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, D_EntityKind_Process);
if(processes.count > 1) if(processes.count > 1)
{ {
D_Entity *process = ctrl_entity_ancestor_from_kind(entity, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(entity, D_EntityKind_Process);
String8 process_name = rd_name_from_ctrl_entity(arena, process); String8 process_name = rd_name_from_ctrl_entity(arena, process);
Vec4F32 process_color = rd_color_from_ctrl_entity(process); Vec4F32 process_color = rd_color_from_ctrl_entity(process);
if(process_color.w == 0) if(process_color.w == 0)
@@ -548,10 +548,10 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol")); Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol"));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" ")); dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
Access *access = access_open(); Access *access = access_open();
D_Entity *process = ctrl_entity_ancestor_from_kind(entity, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(entity, D_EntityKind_Process);
Arch arch = entity->arch; Arch arch = entity->arch;
B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); B32 call_stack_high_priority = d_handle_match(entity->handle, rd_base_regs()->thread);
D_CallStack call_stack = ctrl_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); D_CallStack call_stack = d_call_stack_from_thread(access, entity->handle, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0);
B32 did_first_known = 0; B32 did_first_known = 0;
for(U64 idx = 0, limit = 10; for(U64 idx = 0, limit = 10;
idx < call_stack.frames_count && idx < limit; idx < call_stack.frames_count && idx < limit;
@@ -559,11 +559,11 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
{ {
D_CallStackFrame *f = &call_stack.frames[call_stack.frames_count - 1 - idx]; D_CallStackFrame *f = &call_stack.frames[call_stack.frames_count - 1 - idx];
U64 rip_vaddr = regs_rip_from_arch_block(arch, f->regs); U64 rip_vaddr = regs_rip_from_arch_block(arch, f->regs);
D_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, rip_vaddr);
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr); U64 rip_voff = d_voff_from_vaddr(module, rip_vaddr);
String8 name = {0}; String8 name = {0};
{ {
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi != &rdi_parsed_nil) if(rdi != &rdi_parsed_nil)
{ {
@@ -597,7 +597,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, D_Entity *entity, B32 include_extr
if(entity->kind == D_EntityKind_Module && include_extras) if(entity->kind == D_EntityKind_Module && include_extras)
{ {
Access *access = access_open(); Access *access = access_open();
DI_Key dbgi_key = ctrl_dbgi_key_from_module(entity); DI_Key dbgi_key = d_dbgi_key_from_module(entity);
RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0); RDI_Parsed *rdi = di_rdi_from_key(access, dbgi_key, 0, 0);
if(rdi->raw_data_size == 0) if(rdi->raw_data_size == 0)
{ {
@@ -1254,12 +1254,12 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
RD_CodeSliceSignal result = {0}; RD_CodeSliceSignal result = {0};
ProfBeginFunction(); ProfBeginFunction();
Temp scratch = scratch_begin(0, 0); Temp scratch = scratch_begin(0, 0);
D_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread); D_Entity *selected_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
D_Entity *selected_thread_process = ctrl_entity_ancestor_from_kind(selected_thread, D_EntityKind_Process); D_Entity *selected_thread_process = d_entity_ancestor_from_kind(selected_thread, D_EntityKind_Process);
U64 selected_thread_rip_unwind_vaddr = d_query_cached_rip_from_thread_unwind(selected_thread, rd_regs()->unwind_count); U64 selected_thread_rip_unwind_vaddr = d_query_cached_rip_from_thread_unwind(selected_thread, rd_regs()->unwind_count);
D_Entity *selected_thread_module = ctrl_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr); D_Entity *selected_thread_module = d_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr);
D_Event stop_event = d_ctrl_last_stop_event(); D_Event stop_event = d_ctrl_last_stop_event();
D_Entity *stopper_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, stop_event.entity); D_Entity *stopper_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, stop_event.entity);
B32 is_focused = ui_is_focus_active(); B32 is_focused = ui_is_focus_active();
B32 ctrlified = (os_get_modifiers() & OS_Modifier_Ctrl); B32 ctrlified = (os_get_modifiers() & OS_Modifier_Ctrl);
Vec4F32 code_line_bgs[] = Vec4F32 code_line_bgs[] =
@@ -1336,7 +1336,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread) if(rd_state->drag_drop_regs_slot == RD_RegSlot_Thread)
{ {
drop_can_hit_lines = 1; drop_can_hit_lines = 1;
drop_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_state->drag_drop_regs->thread); drop_thread = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_state->drag_drop_regs->thread);
drop_color = rd_color_from_ctrl_entity(drop_thread); drop_color = rd_color_from_ctrl_entity(drop_thread);
if(drop_color.w == 0) if(drop_color.w == 0)
{ {
@@ -1420,10 +1420,10 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
} }
U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0; U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0;
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, thread_rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, thread_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr); U64 thread_rip_voff = d_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color // rjf: thread info => color
Vec4F32 color = rd_color_from_ctrl_entity(thread); Vec4F32 color = rd_color_from_ctrl_entity(thread);
@@ -1473,7 +1473,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
// rjf: custom draw // rjf: custom draw
{ {
RD_Regs *hover_regs = rd_get_hover_regs(); RD_Regs *hover_regs = rd_get_hover_regs();
B32 is_hovering = (ctrl_handle_match(hover_regs->ctrl_entity, thread->handle) && B32 is_hovering = (d_handle_match(hover_regs->ctrl_entity, thread->handle) &&
rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity); rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity);
RD_ThreadBoxDrawExtData *u = push_array(ui_build_arena(), RD_ThreadBoxDrawExtData, 1); RD_ThreadBoxDrawExtData *u = push_array(ui_build_arena(), RD_ThreadBoxDrawExtData, 1);
u->thread_color = color; u->thread_color = color;
@@ -1520,7 +1520,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{ {
rd_cmd(RD_CmdKind_PushQuery, rd_cmd(RD_CmdKind_PushQuery,
.ui_key = thread_box->key, .ui_key = thread_box->key,
.expr = push_str8f(scratch.arena, "query:control.%S", ctrl_string_from_handle(scratch.arena, thread->handle))); .expr = push_str8f(scratch.arena, "query:control.%S", d_string_from_handle(scratch.arena, thread->handle)));
} }
if(ui_dragging(thread_sig) && !contains_2f32(thread_box->rect, ui_mouse())) if(ui_dragging(thread_sig) && !contains_2f32(thread_box->rect, ui_mouse()))
{ {
@@ -1576,10 +1576,10 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
} }
U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0; U64 unwind_count = (thread == selected_thread) ? rd_regs()->unwind_count : 0;
U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count); U64 thread_rip_vaddr = d_query_cached_rip_from_thread_unwind(thread, unwind_count);
D_Entity *process = ctrl_entity_ancestor_from_kind(thread, D_EntityKind_Process); D_Entity *process = d_entity_ancestor_from_kind(thread, D_EntityKind_Process);
D_Entity *module = ctrl_module_from_process_vaddr(process, thread_rip_vaddr); D_Entity *module = d_module_from_process_vaddr(process, thread_rip_vaddr);
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module); DI_Key dbgi_key = d_dbgi_key_from_module(module);
U64 thread_rip_voff = ctrl_voff_from_vaddr(module, thread_rip_vaddr); U64 thread_rip_voff = d_voff_from_vaddr(module, thread_rip_vaddr);
// rjf: thread info => color // rjf: thread info => color
Vec4F32 color = rd_color_from_ctrl_entity(thread); Vec4F32 color = rd_color_from_ctrl_entity(thread);
@@ -1629,7 +1629,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
// rjf: custom draw // rjf: custom draw
{ {
RD_Regs *hover_regs = rd_get_hover_regs(); RD_Regs *hover_regs = rd_get_hover_regs();
B32 is_hovering = (ctrl_handle_match(hover_regs->ctrl_entity, thread->handle) && B32 is_hovering = (d_handle_match(hover_regs->ctrl_entity, thread->handle) &&
rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity); rd_state->hover_regs_slot == RD_RegSlot_CtrlEntity);
RD_ThreadBoxDrawExtData *u = push_array(ui_build_arena(), RD_ThreadBoxDrawExtData, 1); RD_ThreadBoxDrawExtData *u = push_array(ui_build_arena(), RD_ThreadBoxDrawExtData, 1);
u->thread_color = color; u->thread_color = color;
@@ -1674,7 +1674,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
{ {
rd_cmd(RD_CmdKind_PushQuery, rd_cmd(RD_CmdKind_PushQuery,
.ui_key = thread_box->key, .ui_key = thread_box->key,
.expr = push_str8f(scratch.arena, "query:control.%S", ctrl_string_from_handle(scratch.arena, thread->handle))); .expr = push_str8f(scratch.arena, "query:control.%S", d_string_from_handle(scratch.arena, thread->handle)));
} }
if(ui_dragging(thread_sig) && !contains_2f32(thread_box->rect, ui_mouse())) if(ui_dragging(thread_sig) && !contains_2f32(thread_box->rect, ui_mouse()))
{ {
@@ -2272,11 +2272,11 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
D_LineList *lines = &params->line_infos[line_idx]; D_LineList *lines = &params->line_infos[line_idx];
for(D_LineNode *n = lines->first; n != 0; n = n->next) for(D_LineNode *n = lines->first; n != 0; n = n->next)
{ {
D_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key); D_EntityList modules = d_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
D_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules); D_Entity *module = d_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
if(module != &d_entity_nil) if(module != &d_entity_nil)
{ {
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min); new_rip_vaddr = d_vaddr_from_voff(module, n->v.voff_range.min);
break; break;
} }
} }
@@ -2558,7 +2558,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
if(lines->first != 0 && (params->line_vaddrs[line_slice_idx] != 0 || lines->first->v.pt.line == mouse_pt.line)) if(lines->first != 0 && (params->line_vaddrs[line_slice_idx] != 0 || lines->first->v.pt.line == mouse_pt.line))
{ {
RD_RegsScope(.process = selected_thread_process->handle, RD_RegsScope(.process = selected_thread_process->handle,
.vaddr_range = ctrl_vaddr_range_from_voff_range(selected_thread_module, lines->first->v.voff_range), .vaddr_range = d_vaddr_range_from_voff_range(selected_thread_module, lines->first->v.voff_range),
.module = selected_thread_module->handle, .module = selected_thread_module->handle,
.dbgi_key = lines->first->v.dbgi_key, .dbgi_key = lines->first->v.dbgi_key,
.voff_range = lines->first->v.voff_range) .voff_range = lines->first->v.voff_range)
@@ -2659,8 +2659,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
Rng1U64 hover_voff_range = hover_regs->voff_range; Rng1U64 hover_voff_range = hover_regs->voff_range;
if(hover_voff_range.min == 0 && hover_voff_range.max == 0) if(hover_voff_range.min == 0 && hover_voff_range.max == 0)
{ {
D_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, hover_regs->module); D_Entity *module = d_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, hover_regs->module);
hover_voff_range = ctrl_voff_range_from_vaddr_range(module, hover_regs->vaddr_range); hover_voff_range = d_voff_range_from_vaddr_range(module, hover_regs->vaddr_range);
} }
ui_set_next_pref_height(ui_px(params->line_height_px*(dim_1s64(params->line_num_range)+1), 1.f)); ui_set_next_pref_height(ui_px(params->line_height_px*(dim_1s64(params->line_num_range)+1), 1.f));
UI_WidthFill UI_WidthFill