mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-14 17:28:07 +00:00
merge ctrl_init / d_init
This commit is contained in:
@@ -72,8 +72,8 @@ main_thread_base_entry_point(int arguments_count, char **arguments)
|
|||||||
#if defined(DEMON_CORE_H) && !defined(DMN_INIT_MANUAL)
|
#if defined(DEMON_CORE_H) && !defined(DMN_INIT_MANUAL)
|
||||||
dmn_init();
|
dmn_init();
|
||||||
#endif
|
#endif
|
||||||
#if defined(CTRL_CORE_H) && !defined(CTRL_INIT_MANUAL)
|
#if defined(DBG_ENGINE_CORE_H) && !defined(D_INIT_MANUAL)
|
||||||
ctrl_init();
|
d_init();
|
||||||
#endif
|
#endif
|
||||||
#if defined(OS_GFX_H) && !defined(OS_GFX_INIT_MANUAL)
|
#if defined(OS_GFX_H) && !defined(OS_GFX_INIT_MANUAL)
|
||||||
os_gfx_init();
|
os_gfx_init();
|
||||||
@@ -87,9 +87,6 @@ main_thread_base_entry_point(int arguments_count, char **arguments)
|
|||||||
#if defined(FONT_CACHE_H) && !defined(FNT_INIT_MANUAL)
|
#if defined(FONT_CACHE_H) && !defined(FNT_INIT_MANUAL)
|
||||||
fnt_init();
|
fnt_init();
|
||||||
#endif
|
#endif
|
||||||
#if defined(DBG_ENGINE_CORE_H) && !defined(D_INIT_MANUAL)
|
|
||||||
d_init();
|
|
||||||
#endif
|
|
||||||
#if defined(RADDBG_CORE_H) && !defined(RD_INIT_MANUAL)
|
#if defined(RADDBG_CORE_H) && !defined(RD_INIT_MANUAL)
|
||||||
rd_init(&cmdline);
|
rd_init(&cmdline);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,3 +5,116 @@
|
|||||||
//~ rjf: Generated Code
|
//~ rjf: Generated Code
|
||||||
|
|
||||||
#include "generated/dbg_engine.meta.c"
|
#include "generated/dbg_engine.meta.c"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Layer Initialization
|
||||||
|
|
||||||
|
internal void
|
||||||
|
d_init(void)
|
||||||
|
{
|
||||||
|
//- rjf: set up ctrl state
|
||||||
|
{
|
||||||
|
Arena *arena = arena_alloc();
|
||||||
|
d_ctrl_state = push_array(arena, D_CtrlState, 1);
|
||||||
|
d_ctrl_state->arena = arena;
|
||||||
|
for(Arch arch = (Arch)0; arch < Arch_COUNT; arch = (Arch)(arch+1))
|
||||||
|
{
|
||||||
|
String8 *reg_names = regs_reg_code_string_table_from_arch(arch);
|
||||||
|
U64 reg_count = regs_reg_code_count_from_arch(arch);
|
||||||
|
String8 *alias_names = regs_alias_code_string_table_from_arch(arch);
|
||||||
|
U64 alias_count = regs_alias_code_count_from_arch(arch);
|
||||||
|
d_ctrl_state->arch_string2reg_tables[arch] = e_string2num_map_make(d_ctrl_state->arena, 256);
|
||||||
|
d_ctrl_state->arch_string2alias_tables[arch] = e_string2num_map_make(d_ctrl_state->arena, 256);
|
||||||
|
for(U64 idx = 1; idx < reg_count; idx += 1)
|
||||||
|
{
|
||||||
|
e_string2num_map_insert(d_ctrl_state->arena, &d_ctrl_state->arch_string2reg_tables[arch], reg_names[idx], idx);
|
||||||
|
}
|
||||||
|
for(U64 idx = 1; idx < alias_count; idx += 1)
|
||||||
|
{
|
||||||
|
e_string2num_map_insert(d_ctrl_state->arena, &d_ctrl_state->arch_string2alias_tables[arch], alias_names[idx], idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d_ctrl_state->thread_reg_cache.slots_count = 1024;
|
||||||
|
d_ctrl_state->thread_reg_cache.slots = push_array(arena, CTRL_ThreadRegCacheSlot, d_ctrl_state->thread_reg_cache.slots_count);
|
||||||
|
d_ctrl_state->thread_reg_cache.stripes_count = os_get_system_info()->logical_processor_count;
|
||||||
|
d_ctrl_state->thread_reg_cache.stripes = push_array(arena, CTRL_ThreadRegCacheStripe, d_ctrl_state->thread_reg_cache.stripes_count);
|
||||||
|
for(U64 idx = 0; idx < d_ctrl_state->thread_reg_cache.stripes_count; idx += 1)
|
||||||
|
{
|
||||||
|
d_ctrl_state->thread_reg_cache.stripes[idx].arena = arena_alloc();
|
||||||
|
d_ctrl_state->thread_reg_cache.stripes[idx].rw_mutex = rw_mutex_alloc();
|
||||||
|
}
|
||||||
|
d_ctrl_state->module_image_info_cache.slots_count = 1024;
|
||||||
|
d_ctrl_state->module_image_info_cache.slots = push_array(arena, CTRL_ModuleImageInfoCacheSlot, d_ctrl_state->module_image_info_cache.slots_count);
|
||||||
|
d_ctrl_state->module_image_info_cache.stripes_count = os_get_system_info()->logical_processor_count;
|
||||||
|
d_ctrl_state->module_image_info_cache.stripes = push_array(arena, CTRL_ModuleImageInfoCacheStripe, d_ctrl_state->module_image_info_cache.stripes_count);
|
||||||
|
for(U64 idx = 0; idx < d_ctrl_state->module_image_info_cache.stripes_count; idx += 1)
|
||||||
|
{
|
||||||
|
d_ctrl_state->module_image_info_cache.stripes[idx].arena = arena_alloc();
|
||||||
|
d_ctrl_state->module_image_info_cache.stripes[idx].rw_mutex = rw_mutex_alloc();
|
||||||
|
}
|
||||||
|
d_ctrl_state->u2c_ring_size = KB(64);
|
||||||
|
d_ctrl_state->u2c_ring_base = push_array_no_zero(arena, U8, d_ctrl_state->u2c_ring_size);
|
||||||
|
d_ctrl_state->u2c_ring_mutex = mutex_alloc();
|
||||||
|
d_ctrl_state->u2c_ring_cv = cond_var_alloc();
|
||||||
|
d_ctrl_state->c2u_ring_size = KB(64);
|
||||||
|
d_ctrl_state->c2u_ring_max_string_size = d_ctrl_state->c2u_ring_size/2;
|
||||||
|
d_ctrl_state->c2u_ring_base = push_array_no_zero(arena, U8, d_ctrl_state->c2u_ring_size);
|
||||||
|
d_ctrl_state->c2u_ring_mutex = mutex_alloc();
|
||||||
|
d_ctrl_state->c2u_ring_cv = cond_var_alloc();
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(0, 0);
|
||||||
|
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
|
||||||
|
String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg/logs", user_program_data_path);
|
||||||
|
os_make_directory(user_data_folder);
|
||||||
|
d_ctrl_state->ctrl_thread_log_path = push_str8f(d_ctrl_state->arena, "%S/ctrl_thread.raddbg_log", user_data_folder);
|
||||||
|
os_write_data_to_file_path(d_ctrl_state->ctrl_thread_log_path, str8_zero());
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
|
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_eval_cache = e_cache_alloc();
|
||||||
|
d_ctrl_state->ctrl_thread_msg_process_arena = arena_alloc();
|
||||||
|
d_ctrl_state->dmn_event_arena = arena_alloc();
|
||||||
|
d_ctrl_state->user_entry_point_arena = arena_alloc();
|
||||||
|
d_ctrl_state->dbg_dir_arena = arena_alloc();
|
||||||
|
for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)0; k < CTRL_ExceptionCodeKind_COUNT; k = (CTRL_ExceptionCodeKind)(k+1))
|
||||||
|
{
|
||||||
|
if(ctrl_exception_code_kind_default_enable_table[k])
|
||||||
|
{
|
||||||
|
d_ctrl_state->exception_code_filters[k/64] |= 1ull<<(k%64);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
d_ctrl_state->ctrl_thread_log = log_alloc();
|
||||||
|
d_ctrl_state->ctrl_thread = thread_launch(ctrl_thread__entry_point, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
//- rjf: set up user state
|
||||||
|
{
|
||||||
|
Arena *arena = arena_alloc();
|
||||||
|
d_user_state = push_array(arena, D_UserState, 1);
|
||||||
|
d_user_state->arena = arena;
|
||||||
|
d_user_state->cmds_arena = arena_alloc();
|
||||||
|
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());
|
||||||
|
d_user_state->ctrl_entity_store = ctrl_entity_ctx_rw_store_alloc();
|
||||||
|
d_user_state->ctrl_stop_arena = arena_alloc();
|
||||||
|
d_user_state->ctrl_msg_arena = arena_alloc();
|
||||||
|
|
||||||
|
// rjf: set up caches
|
||||||
|
for(U64 idx = 0; idx < ArrayCount(d_user_state->tls_base_caches); idx += 1)
|
||||||
|
{
|
||||||
|
d_user_state->tls_base_caches[idx].arena = arena_alloc();
|
||||||
|
}
|
||||||
|
for(U64 idx = 0; idx < ArrayCount(d_user_state->locals_caches); idx += 1)
|
||||||
|
{
|
||||||
|
d_user_state->locals_caches[idx].arena = arena_alloc();
|
||||||
|
}
|
||||||
|
for(U64 idx = 0; idx < ArrayCount(d_user_state->member_caches); idx += 1)
|
||||||
|
{
|
||||||
|
d_user_state->member_caches[idx].arena = arena_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
// rjf: set up run state
|
||||||
|
d_user_state->ctrl_last_run_arena = arena_alloc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -399,4 +399,9 @@ struct D_TrapNet
|
|||||||
B32 good_read;
|
B32 good_read;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Layer Initialization
|
||||||
|
|
||||||
|
internal void d_init(void);
|
||||||
|
|
||||||
#endif // DBG_ENGINE_CORE_H
|
#endif // DBG_ENGINE_CORE_H
|
||||||
|
|||||||
+137
-217
@@ -1465,93 +1465,13 @@ ctrl_entity_store_apply_events(CTRL_EntityCtxRWStore *store, CTRL_EventList *lis
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Main Layer Initialization
|
|
||||||
|
|
||||||
internal void
|
|
||||||
ctrl_init(void)
|
|
||||||
{
|
|
||||||
Arena *arena = arena_alloc();
|
|
||||||
ctrl_state = push_array(arena, CTRL_State, 1);
|
|
||||||
ctrl_state->arena = arena;
|
|
||||||
for(Arch arch = (Arch)0; arch < Arch_COUNT; arch = (Arch)(arch+1))
|
|
||||||
{
|
|
||||||
String8 *reg_names = regs_reg_code_string_table_from_arch(arch);
|
|
||||||
U64 reg_count = regs_reg_code_count_from_arch(arch);
|
|
||||||
String8 *alias_names = regs_alias_code_string_table_from_arch(arch);
|
|
||||||
U64 alias_count = regs_alias_code_count_from_arch(arch);
|
|
||||||
ctrl_state->arch_string2reg_tables[arch] = e_string2num_map_make(ctrl_state->arena, 256);
|
|
||||||
ctrl_state->arch_string2alias_tables[arch] = e_string2num_map_make(ctrl_state->arena, 256);
|
|
||||||
for(U64 idx = 1; idx < reg_count; idx += 1)
|
|
||||||
{
|
|
||||||
e_string2num_map_insert(ctrl_state->arena, &ctrl_state->arch_string2reg_tables[arch], reg_names[idx], idx);
|
|
||||||
}
|
|
||||||
for(U64 idx = 1; idx < alias_count; idx += 1)
|
|
||||||
{
|
|
||||||
e_string2num_map_insert(ctrl_state->arena, &ctrl_state->arch_string2alias_tables[arch], alias_names[idx], idx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctrl_state->thread_reg_cache.slots_count = 1024;
|
|
||||||
ctrl_state->thread_reg_cache.slots = push_array(arena, CTRL_ThreadRegCacheSlot, ctrl_state->thread_reg_cache.slots_count);
|
|
||||||
ctrl_state->thread_reg_cache.stripes_count = os_get_system_info()->logical_processor_count;
|
|
||||||
ctrl_state->thread_reg_cache.stripes = push_array(arena, CTRL_ThreadRegCacheStripe, ctrl_state->thread_reg_cache.stripes_count);
|
|
||||||
for(U64 idx = 0; idx < ctrl_state->thread_reg_cache.stripes_count; idx += 1)
|
|
||||||
{
|
|
||||||
ctrl_state->thread_reg_cache.stripes[idx].arena = arena_alloc();
|
|
||||||
ctrl_state->thread_reg_cache.stripes[idx].rw_mutex = rw_mutex_alloc();
|
|
||||||
}
|
|
||||||
ctrl_state->module_image_info_cache.slots_count = 1024;
|
|
||||||
ctrl_state->module_image_info_cache.slots = push_array(arena, CTRL_ModuleImageInfoCacheSlot, ctrl_state->module_image_info_cache.slots_count);
|
|
||||||
ctrl_state->module_image_info_cache.stripes_count = os_get_system_info()->logical_processor_count;
|
|
||||||
ctrl_state->module_image_info_cache.stripes = push_array(arena, CTRL_ModuleImageInfoCacheStripe, ctrl_state->module_image_info_cache.stripes_count);
|
|
||||||
for(U64 idx = 0; idx < ctrl_state->module_image_info_cache.stripes_count; idx += 1)
|
|
||||||
{
|
|
||||||
ctrl_state->module_image_info_cache.stripes[idx].arena = arena_alloc();
|
|
||||||
ctrl_state->module_image_info_cache.stripes[idx].rw_mutex = rw_mutex_alloc();
|
|
||||||
}
|
|
||||||
ctrl_state->u2c_ring_size = KB(64);
|
|
||||||
ctrl_state->u2c_ring_base = push_array_no_zero(arena, U8, ctrl_state->u2c_ring_size);
|
|
||||||
ctrl_state->u2c_ring_mutex = mutex_alloc();
|
|
||||||
ctrl_state->u2c_ring_cv = cond_var_alloc();
|
|
||||||
ctrl_state->c2u_ring_size = KB(64);
|
|
||||||
ctrl_state->c2u_ring_max_string_size = ctrl_state->c2u_ring_size/2;
|
|
||||||
ctrl_state->c2u_ring_base = push_array_no_zero(arena, U8, ctrl_state->c2u_ring_size);
|
|
||||||
ctrl_state->c2u_ring_mutex = mutex_alloc();
|
|
||||||
ctrl_state->c2u_ring_cv = cond_var_alloc();
|
|
||||||
{
|
|
||||||
Temp scratch = scratch_begin(0, 0);
|
|
||||||
String8 user_program_data_path = os_get_process_info()->user_program_data_path;
|
|
||||||
String8 user_data_folder = push_str8f(scratch.arena, "%S/raddbg/logs", user_program_data_path);
|
|
||||||
os_make_directory(user_data_folder);
|
|
||||||
ctrl_state->ctrl_thread_log_path = push_str8f(ctrl_state->arena, "%S/ctrl_thread.raddbg_log", user_data_folder);
|
|
||||||
os_write_data_to_file_path(ctrl_state->ctrl_thread_log_path, str8_zero());
|
|
||||||
scratch_end(scratch);
|
|
||||||
}
|
|
||||||
ctrl_state->ctrl_thread_entity_ctx_rw_mutex = rw_mutex_alloc();
|
|
||||||
ctrl_state->ctrl_thread_entity_store = ctrl_entity_ctx_rw_store_alloc();
|
|
||||||
ctrl_state->ctrl_thread_eval_cache = e_cache_alloc();
|
|
||||||
ctrl_state->ctrl_thread_msg_process_arena = arena_alloc();
|
|
||||||
ctrl_state->dmn_event_arena = arena_alloc();
|
|
||||||
ctrl_state->user_entry_point_arena = arena_alloc();
|
|
||||||
ctrl_state->dbg_dir_arena = arena_alloc();
|
|
||||||
for(CTRL_ExceptionCodeKind k = (CTRL_ExceptionCodeKind)0; k < CTRL_ExceptionCodeKind_COUNT; k = (CTRL_ExceptionCodeKind)(k+1))
|
|
||||||
{
|
|
||||||
if(ctrl_exception_code_kind_default_enable_table[k])
|
|
||||||
{
|
|
||||||
ctrl_state->exception_code_filters[k/64] |= 1ull<<(k%64);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctrl_state->ctrl_thread_log = log_alloc();
|
|
||||||
ctrl_state->ctrl_thread = thread_launch(ctrl_thread__entry_point, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Wakeup Callback Registration
|
//~ rjf: Wakeup Callback Registration
|
||||||
|
|
||||||
internal void
|
internal void
|
||||||
ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook)
|
ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook)
|
||||||
{
|
{
|
||||||
ctrl_state->wakeup_hook = wakeup_hook;
|
d_ctrl_state->wakeup_hook = wakeup_hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -1562,7 +1482,7 @@ ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook)
|
|||||||
internal void *
|
internal void *
|
||||||
ctrl_reg_block_from_thread(Arena *arena, CTRL_EntityCtx *ctx, CTRL_Handle handle)
|
ctrl_reg_block_from_thread(Arena *arena, CTRL_EntityCtx *ctx, CTRL_Handle handle)
|
||||||
{
|
{
|
||||||
CTRL_ThreadRegCache *cache = &ctrl_state->thread_reg_cache;
|
CTRL_ThreadRegCache *cache = &d_ctrl_state->thread_reg_cache;
|
||||||
CTRL_Entity *thread_entity = ctrl_entity_from_handle(ctx, handle);
|
CTRL_Entity *thread_entity = ctrl_entity_from_handle(ctx, handle);
|
||||||
Arch arch = thread_entity->arch;
|
Arch arch = thread_entity->arch;
|
||||||
U64 reg_block_size = regs_block_size_from_arch(arch);
|
U64 reg_block_size = regs_block_size_from_arch(arch);
|
||||||
@@ -1659,7 +1579,7 @@ ctrl_thread_write_reg_block(CTRL_Handle thread, void *block)
|
|||||||
B32 good = dmn_thread_write_reg_block(thread.dmn_handle, block);
|
B32 good = dmn_thread_write_reg_block(thread.dmn_handle, block);
|
||||||
if(good)
|
if(good)
|
||||||
{
|
{
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->reg_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->reg_gen);
|
||||||
}
|
}
|
||||||
return good;
|
return good;
|
||||||
}
|
}
|
||||||
@@ -1675,10 +1595,10 @@ ctrl_intel_pdata_from_module_voff(Arena *arena, CTRL_Handle module_handle, U64 v
|
|||||||
PE_IntelPdata *first_pdata = 0;
|
PE_IntelPdata *first_pdata = 0;
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module_handle);
|
U64 hash = ctrl_hash_from_handle(module_handle);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
if(ctrl_handle_match(n->module, module_handle))
|
if(ctrl_handle_match(n->module, module_handle))
|
||||||
@@ -1741,10 +1661,10 @@ ctrl_entry_point_voff_from_module(CTRL_Handle module_handle)
|
|||||||
{
|
{
|
||||||
U64 result = 0;
|
U64 result = 0;
|
||||||
U64 hash = ctrl_hash_from_handle(module_handle);
|
U64 hash = ctrl_hash_from_handle(module_handle);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
if(ctrl_handle_match(n->module, module_handle))
|
if(ctrl_handle_match(n->module, module_handle))
|
||||||
@@ -1761,10 +1681,10 @@ ctrl_initial_debug_info_path_from_module(Arena *arena, CTRL_Handle module_handle
|
|||||||
{
|
{
|
||||||
String8 result = {0};
|
String8 result = {0};
|
||||||
U64 hash = ctrl_hash_from_handle(module_handle);
|
U64 hash = ctrl_hash_from_handle(module_handle);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
if(ctrl_handle_match(n->module, module_handle))
|
if(ctrl_handle_match(n->module, module_handle))
|
||||||
@@ -1781,10 +1701,10 @@ ctrl_raddbg_data_from_module(Arena *arena, CTRL_Handle module_handle)
|
|||||||
{
|
{
|
||||||
String8 result = {0};
|
String8 result = {0};
|
||||||
U64 hash = ctrl_hash_from_handle(module_handle);
|
U64 hash = ctrl_hash_from_handle(module_handle);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
MutexScopeR(stripe->rw_mutex) for(CTRL_ModuleImageInfoCacheNode *n = slot->first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
if(ctrl_handle_match(n->module, module_handle))
|
if(ctrl_handle_match(n->module, module_handle))
|
||||||
@@ -1802,7 +1722,7 @@ ctrl_raddbg_data_from_module(Arena *arena, CTRL_Handle module_handle)
|
|||||||
internal Arch
|
internal Arch
|
||||||
ctrl_arch_from_process_handle(CTRL_Handle process_handle)
|
ctrl_arch_from_process_handle(CTRL_Handle process_handle)
|
||||||
{
|
{
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_Entity *process_entity = ctrl_entity_from_handle(entity_ctx, process_handle);
|
CTRL_Entity *process_entity = ctrl_entity_from_handle(entity_ctx, process_handle);
|
||||||
return process_entity->arch;
|
return process_entity->arch;
|
||||||
}
|
}
|
||||||
@@ -1899,10 +1819,10 @@ ctrl_establish_frame_unwind_context__dwarf(Arena *arena, CTRL_Handle process_han
|
|||||||
EH_PtrCtx eh_ptr_ctx = {0};
|
EH_PtrCtx eh_ptr_ctx = {0};
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module_handle);
|
U64 hash = ctrl_hash_from_handle(module_handle);
|
||||||
U64 slot_idx = hash % ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash % d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx % ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx % d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeR(stripe->rw_mutex) for EachNode(n, CTRL_ModuleImageInfoCacheNode, slot->first)
|
MutexScopeR(stripe->rw_mutex) for EachNode(n, CTRL_ModuleImageInfoCacheNode, slot->first)
|
||||||
{
|
{
|
||||||
if(ctrl_handle_match(n->module, module_handle))
|
if(ctrl_handle_match(n->module, module_handle))
|
||||||
@@ -3255,21 +3175,21 @@ ctrl_halt(void)
|
|||||||
internal U64
|
internal U64
|
||||||
ctrl_run_gen(void)
|
ctrl_run_gen(void)
|
||||||
{
|
{
|
||||||
U64 result = ins_atomic_u64_eval(&ctrl_state->run_gen);
|
U64 result = ins_atomic_u64_eval(&d_ctrl_state->run_gen);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
ctrl_mem_gen(void)
|
ctrl_mem_gen(void)
|
||||||
{
|
{
|
||||||
U64 result = ins_atomic_u64_eval(&ctrl_state->mem_gen);
|
U64 result = ins_atomic_u64_eval(&d_ctrl_state->mem_gen);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
ctrl_reg_gen(void)
|
ctrl_reg_gen(void)
|
||||||
{
|
{
|
||||||
U64 result = ins_atomic_u64_eval(&ctrl_state->reg_gen);
|
U64 result = ins_atomic_u64_eval(&d_ctrl_state->reg_gen);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3278,13 +3198,13 @@ ctrl_reg_gen(void)
|
|||||||
internal E_String2NumMap *
|
internal E_String2NumMap *
|
||||||
ctrl_string2reg_from_arch(Arch arch)
|
ctrl_string2reg_from_arch(Arch arch)
|
||||||
{
|
{
|
||||||
return &ctrl_state->arch_string2reg_tables[arch];
|
return &d_ctrl_state->arch_string2reg_tables[arch];
|
||||||
}
|
}
|
||||||
|
|
||||||
internal E_String2NumMap *
|
internal E_String2NumMap *
|
||||||
ctrl_string2alias_from_arch(Arch arch)
|
ctrl_string2alias_from_arch(Arch arch)
|
||||||
{
|
{
|
||||||
return &ctrl_state->arch_string2alias_tables[arch];
|
return &d_ctrl_state->arch_string2alias_tables[arch];
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -3298,15 +3218,15 @@ ctrl_u2c_push_msgs(CTRL_MsgList *msgs, U64 endt_us)
|
|||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
String8 msgs_srlzed_baked = ctrl_serialized_string_from_msg_list(scratch.arena, msgs);
|
String8 msgs_srlzed_baked = ctrl_serialized_string_from_msg_list(scratch.arena, msgs);
|
||||||
B32 good = 0;
|
B32 good = 0;
|
||||||
MutexScope(ctrl_state->u2c_ring_mutex) for(;;)
|
MutexScope(d_ctrl_state->u2c_ring_mutex) for(;;)
|
||||||
{
|
{
|
||||||
U64 unconsumed_size = (ctrl_state->u2c_ring_write_pos-ctrl_state->u2c_ring_read_pos);
|
U64 unconsumed_size = (d_ctrl_state->u2c_ring_write_pos-d_ctrl_state->u2c_ring_read_pos);
|
||||||
U64 available_size = ctrl_state->u2c_ring_size-unconsumed_size;
|
U64 available_size = d_ctrl_state->u2c_ring_size-unconsumed_size;
|
||||||
U64 needed_size = sizeof(msgs_srlzed_baked.size) + msgs_srlzed_baked.size;
|
U64 needed_size = sizeof(msgs_srlzed_baked.size) + msgs_srlzed_baked.size;
|
||||||
if(available_size >= needed_size)
|
if(available_size >= needed_size)
|
||||||
{
|
{
|
||||||
ctrl_state->u2c_ring_write_pos += ring_write_struct(ctrl_state->u2c_ring_base, ctrl_state->u2c_ring_size, ctrl_state->u2c_ring_write_pos, &msgs_srlzed_baked.size);
|
d_ctrl_state->u2c_ring_write_pos += ring_write_struct(d_ctrl_state->u2c_ring_base, d_ctrl_state->u2c_ring_size, d_ctrl_state->u2c_ring_write_pos, &msgs_srlzed_baked.size);
|
||||||
ctrl_state->u2c_ring_write_pos += ring_write(ctrl_state->u2c_ring_base, ctrl_state->u2c_ring_size, ctrl_state->u2c_ring_write_pos, msgs_srlzed_baked.str, msgs_srlzed_baked.size);
|
d_ctrl_state->u2c_ring_write_pos += ring_write(d_ctrl_state->u2c_ring_base, d_ctrl_state->u2c_ring_size, d_ctrl_state->u2c_ring_write_pos, msgs_srlzed_baked.str, msgs_srlzed_baked.size);
|
||||||
good = 1;
|
good = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3314,11 +3234,11 @@ ctrl_u2c_push_msgs(CTRL_MsgList *msgs, U64 endt_us)
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cond_var_wait(ctrl_state->u2c_ring_cv, ctrl_state->u2c_ring_mutex, endt_us);
|
cond_var_wait(d_ctrl_state->u2c_ring_cv, d_ctrl_state->u2c_ring_mutex, endt_us);
|
||||||
}
|
}
|
||||||
if(good)
|
if(good)
|
||||||
{
|
{
|
||||||
cond_var_broadcast(ctrl_state->u2c_ring_cv);
|
cond_var_broadcast(d_ctrl_state->u2c_ring_cv);
|
||||||
}
|
}
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
return good;
|
return good;
|
||||||
@@ -3329,21 +3249,21 @@ ctrl_u2c_pop_msgs(Arena *arena)
|
|||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
String8 msgs_srlzed_baked = {0};
|
String8 msgs_srlzed_baked = {0};
|
||||||
MutexScope(ctrl_state->u2c_ring_mutex) for(;;)
|
MutexScope(d_ctrl_state->u2c_ring_mutex) for(;;)
|
||||||
{
|
{
|
||||||
U64 unconsumed_size = (ctrl_state->u2c_ring_write_pos-ctrl_state->u2c_ring_read_pos);
|
U64 unconsumed_size = (d_ctrl_state->u2c_ring_write_pos-d_ctrl_state->u2c_ring_read_pos);
|
||||||
if(unconsumed_size >= sizeof(U64))
|
if(unconsumed_size >= sizeof(U64))
|
||||||
{
|
{
|
||||||
U64 size_to_decode = 0;
|
U64 size_to_decode = 0;
|
||||||
ctrl_state->u2c_ring_read_pos += ring_read_struct(ctrl_state->u2c_ring_base, ctrl_state->u2c_ring_size, ctrl_state->u2c_ring_read_pos, &size_to_decode);
|
d_ctrl_state->u2c_ring_read_pos += ring_read_struct(d_ctrl_state->u2c_ring_base, d_ctrl_state->u2c_ring_size, d_ctrl_state->u2c_ring_read_pos, &size_to_decode);
|
||||||
msgs_srlzed_baked.size = size_to_decode;
|
msgs_srlzed_baked.size = size_to_decode;
|
||||||
msgs_srlzed_baked.str = push_array_no_zero(scratch.arena, U8, msgs_srlzed_baked.size);
|
msgs_srlzed_baked.str = push_array_no_zero(scratch.arena, U8, msgs_srlzed_baked.size);
|
||||||
ctrl_state->u2c_ring_read_pos += ring_read(ctrl_state->u2c_ring_base, ctrl_state->u2c_ring_size, ctrl_state->u2c_ring_read_pos, msgs_srlzed_baked.str, size_to_decode);
|
d_ctrl_state->u2c_ring_read_pos += ring_read(d_ctrl_state->u2c_ring_base, d_ctrl_state->u2c_ring_size, d_ctrl_state->u2c_ring_read_pos, msgs_srlzed_baked.str, size_to_decode);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cond_var_wait(ctrl_state->u2c_ring_cv, ctrl_state->u2c_ring_mutex, max_U64);
|
cond_var_wait(d_ctrl_state->u2c_ring_cv, d_ctrl_state->u2c_ring_mutex, max_U64);
|
||||||
}
|
}
|
||||||
cond_var_broadcast(ctrl_state->u2c_ring_cv);
|
cond_var_broadcast(d_ctrl_state->u2c_ring_cv);
|
||||||
CTRL_MsgList msgs = ctrl_msg_list_from_serialized_string(arena, msgs_srlzed_baked);
|
CTRL_MsgList msgs = ctrl_msg_list_from_serialized_string(arena, msgs_srlzed_baked);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
return msgs;
|
return msgs;
|
||||||
@@ -3356,31 +3276,31 @@ ctrl_c2u_push_events(CTRL_EventList *events)
|
|||||||
{
|
{
|
||||||
if(events->count != 0) ProfScope("ctrl_c2u_push_events")
|
if(events->count != 0) ProfScope("ctrl_c2u_push_events")
|
||||||
{
|
{
|
||||||
MutexScopeW(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
MutexScopeW(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
||||||
{
|
{
|
||||||
ctrl_entity_store_apply_events(ctrl_state->ctrl_thread_entity_store, events);
|
ctrl_entity_store_apply_events(d_ctrl_state->ctrl_thread_entity_store, events);
|
||||||
}
|
}
|
||||||
for(CTRL_EventNode *n = events->first; n != 0; n = n ->next)
|
for(CTRL_EventNode *n = events->first; n != 0; n = n ->next)
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
String8 event_srlzed = ctrl_serialized_string_from_event(scratch.arena, &n->v, ctrl_state->c2u_ring_size-sizeof(U64));
|
String8 event_srlzed = ctrl_serialized_string_from_event(scratch.arena, &n->v, d_ctrl_state->c2u_ring_size-sizeof(U64));
|
||||||
MutexScope(ctrl_state->c2u_ring_mutex) for(;;)
|
MutexScope(d_ctrl_state->c2u_ring_mutex) for(;;)
|
||||||
{
|
{
|
||||||
U64 unconsumed_size = (ctrl_state->c2u_ring_write_pos-ctrl_state->c2u_ring_read_pos);
|
U64 unconsumed_size = (d_ctrl_state->c2u_ring_write_pos-d_ctrl_state->c2u_ring_read_pos);
|
||||||
U64 available_size = ctrl_state->c2u_ring_size-unconsumed_size;
|
U64 available_size = d_ctrl_state->c2u_ring_size-unconsumed_size;
|
||||||
U64 needed_size = sizeof(event_srlzed.size) + event_srlzed.size;
|
U64 needed_size = sizeof(event_srlzed.size) + event_srlzed.size;
|
||||||
if(available_size >= needed_size)
|
if(available_size >= needed_size)
|
||||||
{
|
{
|
||||||
ctrl_state->c2u_ring_write_pos += ring_write_struct(ctrl_state->c2u_ring_base, ctrl_state->c2u_ring_size, ctrl_state->c2u_ring_write_pos, &event_srlzed.size);
|
d_ctrl_state->c2u_ring_write_pos += ring_write_struct(d_ctrl_state->c2u_ring_base, d_ctrl_state->c2u_ring_size, d_ctrl_state->c2u_ring_write_pos, &event_srlzed.size);
|
||||||
ctrl_state->c2u_ring_write_pos += ring_write(ctrl_state->c2u_ring_base, ctrl_state->c2u_ring_size, ctrl_state->c2u_ring_write_pos, event_srlzed.str, event_srlzed.size);
|
d_ctrl_state->c2u_ring_write_pos += ring_write(d_ctrl_state->c2u_ring_base, d_ctrl_state->c2u_ring_size, d_ctrl_state->c2u_ring_write_pos, event_srlzed.str, event_srlzed.size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cond_var_wait(ctrl_state->c2u_ring_cv, ctrl_state->c2u_ring_mutex, os_now_microseconds()+100);
|
cond_var_wait(d_ctrl_state->c2u_ring_cv, d_ctrl_state->c2u_ring_mutex, os_now_microseconds()+100);
|
||||||
}
|
}
|
||||||
cond_var_broadcast(ctrl_state->c2u_ring_cv);
|
cond_var_broadcast(d_ctrl_state->c2u_ring_cv);
|
||||||
if(ctrl_state->wakeup_hook != 0)
|
if(d_ctrl_state->wakeup_hook != 0)
|
||||||
{
|
{
|
||||||
ctrl_state->wakeup_hook();
|
d_ctrl_state->wakeup_hook();
|
||||||
}
|
}
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
@@ -3393,17 +3313,17 @@ ctrl_c2u_pop_events(Arena *arena)
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
CTRL_EventList events = {0};
|
CTRL_EventList events = {0};
|
||||||
MutexScope(ctrl_state->c2u_ring_mutex) for(;;)
|
MutexScope(d_ctrl_state->c2u_ring_mutex) for(;;)
|
||||||
{
|
{
|
||||||
U64 unconsumed_size = (ctrl_state->c2u_ring_write_pos-ctrl_state->c2u_ring_read_pos);
|
U64 unconsumed_size = (d_ctrl_state->c2u_ring_write_pos-d_ctrl_state->c2u_ring_read_pos);
|
||||||
if(unconsumed_size >= sizeof(U64))
|
if(unconsumed_size >= sizeof(U64))
|
||||||
{
|
{
|
||||||
U64 size_to_decode = 0;
|
U64 size_to_decode = 0;
|
||||||
ctrl_state->c2u_ring_read_pos += ring_read_struct(ctrl_state->c2u_ring_base, ctrl_state->c2u_ring_size, ctrl_state->c2u_ring_read_pos, &size_to_decode);
|
d_ctrl_state->c2u_ring_read_pos += ring_read_struct(d_ctrl_state->c2u_ring_base, d_ctrl_state->c2u_ring_size, d_ctrl_state->c2u_ring_read_pos, &size_to_decode);
|
||||||
String8 event_srlzed = {0};
|
String8 event_srlzed = {0};
|
||||||
event_srlzed.size = size_to_decode;
|
event_srlzed.size = size_to_decode;
|
||||||
event_srlzed.str = push_array_no_zero(scratch.arena, U8, event_srlzed.size);
|
event_srlzed.str = push_array_no_zero(scratch.arena, U8, event_srlzed.size);
|
||||||
ctrl_state->c2u_ring_read_pos += ring_read(ctrl_state->c2u_ring_base, ctrl_state->c2u_ring_size, ctrl_state->c2u_ring_read_pos, event_srlzed.str, event_srlzed.size);
|
d_ctrl_state->c2u_ring_read_pos += ring_read(d_ctrl_state->c2u_ring_base, d_ctrl_state->c2u_ring_size, d_ctrl_state->c2u_ring_read_pos, event_srlzed.str, event_srlzed.size);
|
||||||
CTRL_Event *new_event = ctrl_event_list_push(arena, &events);
|
CTRL_Event *new_event = ctrl_event_list_push(arena, &events);
|
||||||
*new_event = ctrl_event_from_serialized_string(arena, event_srlzed);
|
*new_event = ctrl_event_from_serialized_string(arena, event_srlzed);
|
||||||
}
|
}
|
||||||
@@ -3412,7 +3332,7 @@ ctrl_c2u_pop_events(Arena *arena)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cond_var_broadcast(ctrl_state->c2u_ring_cv);
|
cond_var_broadcast(d_ctrl_state->c2u_ring_cv);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
return events;
|
return events;
|
||||||
@@ -3426,7 +3346,7 @@ ctrl_thread__entry_point(void *p)
|
|||||||
ThreadNameF("ctrl_thread");
|
ThreadNameF("ctrl_thread");
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
DMN_CtrlCtx *ctrl_ctx = dmn_ctrl_begin();
|
DMN_CtrlCtx *ctrl_ctx = dmn_ctrl_begin();
|
||||||
log_select(ctrl_state->ctrl_thread_log);
|
log_select(d_ctrl_state->ctrl_thread_log);
|
||||||
|
|
||||||
//- rjf: loop
|
//- rjf: loop
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
@@ -3441,7 +3361,7 @@ ctrl_thread__entry_point(void *p)
|
|||||||
//- rjf: process messages
|
//- rjf: process messages
|
||||||
DMN_CtrlExclusiveAccessScope
|
DMN_CtrlExclusiveAccessScope
|
||||||
{
|
{
|
||||||
ins_atomic_u64_eval_assign(&ctrl_state->ctrl_thread_run_state, 1);
|
ins_atomic_u64_eval_assign(&d_ctrl_state->ctrl_thread_run_state, 1);
|
||||||
for(CTRL_MsgNode *msg_n = msgs.first; msg_n != 0; msg_n = msg_n->next)
|
for(CTRL_MsgNode *msg_n = msgs.first; msg_n != 0; msg_n = msg_n->next)
|
||||||
{
|
{
|
||||||
CTRL_Msg *msg = &msg_n->v;
|
CTRL_Msg *msg = &msg_n->v;
|
||||||
@@ -3452,12 +3372,12 @@ ctrl_thread__entry_point(void *p)
|
|||||||
//- rjf: reset per-message state
|
//- rjf: reset per-message state
|
||||||
ProfScope("reset per-message state")
|
ProfScope("reset per-message state")
|
||||||
{
|
{
|
||||||
arena_clear(ctrl_state->ctrl_thread_msg_process_arena);
|
arena_clear(d_ctrl_state->ctrl_thread_msg_process_arena);
|
||||||
ctrl_state->module_req_cache_slots_count = 4096;
|
d_ctrl_state->module_req_cache_slots_count = 4096;
|
||||||
ctrl_state->module_req_cache_slots = push_array(ctrl_state->ctrl_thread_msg_process_arena, CTRL_ModuleReqCacheNode *, ctrl_state->module_req_cache_slots_count);
|
d_ctrl_state->module_req_cache_slots = push_array(d_ctrl_state->ctrl_thread_msg_process_arena, CTRL_ModuleReqCacheNode *, d_ctrl_state->module_req_cache_slots_count);
|
||||||
MemoryZeroStruct(&ctrl_state->msg_user_bp_touched_files);
|
MemoryZeroStruct(&d_ctrl_state->msg_user_bp_touched_files);
|
||||||
MemoryZeroStruct(&ctrl_state->msg_user_bp_touched_symbols);
|
MemoryZeroStruct(&d_ctrl_state->msg_user_bp_touched_symbols);
|
||||||
MemoryCopyArray(ctrl_state->exception_code_filters, msg->exception_code_filters);
|
MemoryCopyArray(d_ctrl_state->exception_code_filters, msg->exception_code_filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: gather all touched symbols by user breakpoints
|
//- rjf: gather all touched symbols by user breakpoints
|
||||||
@@ -3491,7 +3411,7 @@ ctrl_thread__entry_point(void *p)
|
|||||||
}
|
}
|
||||||
if(expr->kind == E_ExprKind_LeafIdentifier)
|
if(expr->kind == E_ExprKind_LeafIdentifier)
|
||||||
{
|
{
|
||||||
str8_list_push(ctrl_state->ctrl_thread_msg_process_arena, &ctrl_state->msg_user_bp_touched_symbols, expr->string);
|
str8_list_push(d_ctrl_state->ctrl_thread_msg_process_arena, &d_ctrl_state->msg_user_bp_touched_symbols, expr->string);
|
||||||
}
|
}
|
||||||
if(expr->next != &e_expr_nil)
|
if(expr->next != &e_expr_nil)
|
||||||
{
|
{
|
||||||
@@ -3524,7 +3444,7 @@ ctrl_thread__entry_point(void *p)
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
str8_list_push(ctrl_state->ctrl_thread_msg_process_arena, &ctrl_state->msg_user_bp_touched_files, n->v.string);
|
str8_list_push(d_ctrl_state->ctrl_thread_msg_process_arena, &d_ctrl_state->msg_user_bp_touched_files, n->v.string);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: process message
|
//- rjf: process message
|
||||||
@@ -3545,24 +3465,24 @@ ctrl_thread__entry_point(void *p)
|
|||||||
//- rjf: configuration
|
//- rjf: configuration
|
||||||
case CTRL_MsgKind_SetUserEntryPoints:
|
case CTRL_MsgKind_SetUserEntryPoints:
|
||||||
{
|
{
|
||||||
arena_clear(ctrl_state->user_entry_point_arena);
|
arena_clear(d_ctrl_state->user_entry_point_arena);
|
||||||
MemoryZeroStruct(&ctrl_state->user_entry_points);
|
MemoryZeroStruct(&d_ctrl_state->user_entry_points);
|
||||||
for(String8Node *n = msg->entry_points.first; n != 0; n = n->next)
|
for(String8Node *n = msg->entry_points.first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
str8_list_push(ctrl_state->user_entry_point_arena, &ctrl_state->user_entry_points, n->string);
|
str8_list_push(d_ctrl_state->user_entry_point_arena, &d_ctrl_state->user_entry_points, n->string);
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case CTRL_MsgKind_SetModuleDebugInfoPath:
|
case CTRL_MsgKind_SetModuleDebugInfoPath:
|
||||||
{
|
{
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
String8 path = msg->path;
|
String8 path = msg->path;
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(entity_ctx, msg->entity);
|
CTRL_Entity *module = ctrl_entity_from_handle(entity_ctx, msg->entity);
|
||||||
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
||||||
DI_Key old_dbgi_key = di_key_from_path_timestamp(debug_info_path->string, debug_info_path->timestamp);
|
DI_Key old_dbgi_key = di_key_from_path_timestamp(debug_info_path->string, debug_info_path->timestamp);
|
||||||
di_close(old_dbgi_key, 0);
|
di_close(old_dbgi_key, 0);
|
||||||
MutexScopeW(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
MutexScopeW(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
||||||
{
|
{
|
||||||
ctrl_entity_equip_string(ctrl_state->ctrl_thread_entity_store, debug_info_path, path_normalized_from_string(scratch.arena, path));
|
ctrl_entity_equip_string(d_ctrl_state->ctrl_thread_entity_store, debug_info_path, path_normalized_from_string(scratch.arena, path));
|
||||||
}
|
}
|
||||||
U64 new_dbgi_timestamp = os_properties_from_file_path(path).modified;
|
U64 new_dbgi_timestamp = os_properties_from_file_path(path).modified;
|
||||||
debug_info_path->timestamp = new_dbgi_timestamp;
|
debug_info_path->timestamp = new_dbgi_timestamp;
|
||||||
@@ -3594,16 +3514,16 @@ ctrl_thread__entry_point(void *p)
|
|||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ins_atomic_u64_eval_assign(&ctrl_state->ctrl_thread_run_state, 0);
|
ins_atomic_u64_eval_assign(&d_ctrl_state->ctrl_thread_run_state, 0);
|
||||||
}
|
}
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->run_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->run_gen);
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->mem_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->mem_gen);
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->reg_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->reg_gen);
|
||||||
|
|
||||||
//- rjf: update thread register cache
|
//- rjf: update thread register cache
|
||||||
ProfScope("update thread register cache")
|
ProfScope("update thread register cache")
|
||||||
{
|
{
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(entity_ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(entity_ctx, CTRL_EntityKind_Thread);
|
||||||
REGS_RegBlockX64 *blocks = push_array(scratch.arena, REGS_RegBlockX64, threads.count);
|
REGS_RegBlockX64 *blocks = push_array(scratch.arena, REGS_RegBlockX64, threads.count);
|
||||||
{
|
{
|
||||||
@@ -3633,7 +3553,7 @@ ctrl_thread__append_resolved_module_user_bp_traps(Arena *arena, CTRL_EvalScope *
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
Access *access = eval_scope->access;
|
Access *access = eval_scope->access;
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_Entity *module_entity = ctrl_entity_from_handle(entity_ctx, module);
|
CTRL_Entity *module_entity = ctrl_entity_from_handle(entity_ctx, module);
|
||||||
CTRL_Entity *debug_info_path_entity = ctrl_entity_child_from_kind(module_entity, CTRL_EntityKind_DebugInfoPath);
|
CTRL_Entity *debug_info_path_entity = ctrl_entity_child_from_kind(module_entity, CTRL_EntityKind_DebugInfoPath);
|
||||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module_entity);
|
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module_entity);
|
||||||
@@ -4133,10 +4053,10 @@ ctrl_thread__module_open(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr_
|
|||||||
//
|
//
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module);
|
U64 hash = ctrl_hash_from_handle(module);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeW(stripe->rw_mutex)
|
MutexScopeW(stripe->rw_mutex)
|
||||||
{
|
{
|
||||||
CTRL_ModuleImageInfoCacheNode *node = 0;
|
CTRL_ModuleImageInfoCacheNode *node = 0;
|
||||||
@@ -4180,10 +4100,10 @@ ctrl_thread__module_close(CTRL_Handle process, CTRL_Handle module, Rng1U64 vaddr
|
|||||||
U64 raddbg_attached_marker_voff = 0;
|
U64 raddbg_attached_marker_voff = 0;
|
||||||
{
|
{
|
||||||
U64 hash = ctrl_hash_from_handle(module);
|
U64 hash = ctrl_hash_from_handle(module);
|
||||||
U64 slot_idx = hash%ctrl_state->module_image_info_cache.slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_image_info_cache.slots_count;
|
||||||
U64 stripe_idx = slot_idx%ctrl_state->module_image_info_cache.stripes_count;
|
U64 stripe_idx = slot_idx%d_ctrl_state->module_image_info_cache.stripes_count;
|
||||||
CTRL_ModuleImageInfoCacheSlot *slot = &ctrl_state->module_image_info_cache.slots[slot_idx];
|
CTRL_ModuleImageInfoCacheSlot *slot = &d_ctrl_state->module_image_info_cache.slots[slot_idx];
|
||||||
CTRL_ModuleImageInfoCacheStripe *stripe = &ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
CTRL_ModuleImageInfoCacheStripe *stripe = &d_ctrl_state->module_image_info_cache.stripes[stripe_idx];
|
||||||
MutexScopeW(stripe->rw_mutex)
|
MutexScopeW(stripe->rw_mutex)
|
||||||
{
|
{
|
||||||
CTRL_ModuleImageInfoCacheNode *node = 0;
|
CTRL_ModuleImageInfoCacheNode *node = 0;
|
||||||
@@ -4222,7 +4142,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
DMN_Event *event = push_array(arena, DMN_Event, 1);
|
DMN_Event *event = push_array(arena, DMN_Event, 1);
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
|
|
||||||
//- rjf: loop -> try to get event, run, repeat
|
//- rjf: loop -> try to get event, run, repeat
|
||||||
U64 spoof_old_ip_value = 0;
|
U64 spoof_old_ip_value = 0;
|
||||||
@@ -4232,7 +4152,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
ProfScope("get next event")
|
ProfScope("get next event")
|
||||||
{
|
{
|
||||||
// rjf: grab first event
|
// rjf: grab first event
|
||||||
DMN_EventNode *next_event_node = ctrl_state->first_dmn_event_node;
|
DMN_EventNode *next_event_node = d_ctrl_state->first_dmn_event_node;
|
||||||
|
|
||||||
// rjf: log event
|
// rjf: log event
|
||||||
if(next_event_node != 0)
|
if(next_event_node != 0)
|
||||||
@@ -4282,7 +4202,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
// rjf: exception code kind -> shouldn't stop? if so, do not filter
|
// rjf: exception code kind -> shouldn't stop? if so, do not filter
|
||||||
if(should_filter_event)
|
if(should_filter_event)
|
||||||
{
|
{
|
||||||
B32 shouldnt_filter = !!(ctrl_state->exception_code_filters[code_kind/64] & (1ull<<(code_kind%64)));
|
B32 shouldnt_filter = !!(d_ctrl_state->exception_code_filters[code_kind/64] & (1ull<<(code_kind%64)));
|
||||||
if(should_filter_event && shouldnt_filter)
|
if(should_filter_event && shouldnt_filter)
|
||||||
{
|
{
|
||||||
should_filter_event = 0;
|
should_filter_event = 0;
|
||||||
@@ -4363,7 +4283,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
if(next_event_node != 0 && !should_filter_event)
|
if(next_event_node != 0 && !should_filter_event)
|
||||||
{
|
{
|
||||||
got_event = 1;
|
got_event = 1;
|
||||||
SLLQueuePop(ctrl_state->first_dmn_event_node, ctrl_state->last_dmn_event_node);
|
SLLQueuePop(d_ctrl_state->first_dmn_event_node, d_ctrl_state->last_dmn_event_node);
|
||||||
MemoryCopyStruct(event, &next_event_node->v);
|
MemoryCopyStruct(event, &next_event_node->v);
|
||||||
event->string = push_str8_copy(arena, event->string);
|
event->string = push_str8_copy(arena, event->string);
|
||||||
run_ctrls->ignore_previous_exception = 1;
|
run_ctrls->ignore_previous_exception = 1;
|
||||||
@@ -4372,7 +4292,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
// rjf: good event but filtered? pop from queue
|
// rjf: good event but filtered? pop from queue
|
||||||
if(next_event_node != 0 && should_filter_event)
|
if(next_event_node != 0 && should_filter_event)
|
||||||
{
|
{
|
||||||
SLLQueuePop(ctrl_state->first_dmn_event_node, ctrl_state->last_dmn_event_node);
|
SLLQueuePop(d_ctrl_state->first_dmn_event_node, d_ctrl_state->last_dmn_event_node);
|
||||||
run_ctrls->ignore_previous_exception = 0;
|
run_ctrls->ignore_previous_exception = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4422,23 +4342,23 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DMN_EventList events = dmn_ctrl_run(scratch.arena, ctrl_ctx, run_ctrls);
|
DMN_EventList events = dmn_ctrl_run(scratch.arena, ctrl_ctx, run_ctrls);
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->mem_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->mem_gen);
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->reg_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->reg_gen);
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->run_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->run_gen);
|
||||||
for(DMN_EventNode *src_n = events.first; src_n != 0; src_n = src_n->next)
|
for(DMN_EventNode *src_n = events.first; src_n != 0; src_n = src_n->next)
|
||||||
{
|
{
|
||||||
DMN_EventNode *dst_n = ctrl_state->free_dmn_event_node;
|
DMN_EventNode *dst_n = d_ctrl_state->free_dmn_event_node;
|
||||||
if(dst_n != 0)
|
if(dst_n != 0)
|
||||||
{
|
{
|
||||||
SLLStackPop(ctrl_state->free_dmn_event_node);
|
SLLStackPop(d_ctrl_state->free_dmn_event_node);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dst_n = push_array(ctrl_state->dmn_event_arena, DMN_EventNode, 1);
|
dst_n = push_array(d_ctrl_state->dmn_event_arena, DMN_EventNode, 1);
|
||||||
}
|
}
|
||||||
MemoryCopyStruct(&dst_n->v, &src_n->v);
|
MemoryCopyStruct(&dst_n->v, &src_n->v);
|
||||||
dst_n->v.string = push_str8_copy(ctrl_state->dmn_event_arena, dst_n->v.string);
|
dst_n->v.string = push_str8_copy(d_ctrl_state->dmn_event_arena, dst_n->v.string);
|
||||||
SLLQueuePush(ctrl_state->first_dmn_event_node, ctrl_state->last_dmn_event_node, dst_n);
|
SLLQueuePush(d_ctrl_state->first_dmn_event_node, d_ctrl_state->last_dmn_event_node, dst_n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4482,7 +4402,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
out_evt->entity_id = event->code;
|
out_evt->entity_id = event->code;
|
||||||
out_evt->tls_model = ctrl_dynamic_linker_type_from_dmn(event->tls_model);
|
out_evt->tls_model = ctrl_dynamic_linker_type_from_dmn(event->tls_model);
|
||||||
out_evt->target_os = OperatingSystem_CURRENT; // TODO: operating system of the remote target machine
|
out_evt->target_os = OperatingSystem_CURRENT; // TODO: operating system of the remote target machine
|
||||||
ctrl_state->process_counter += 1;
|
d_ctrl_state->process_counter += 1;
|
||||||
}break;
|
}break;
|
||||||
case DMN_EventKind_CreateThread:
|
case DMN_EventKind_CreateThread:
|
||||||
{
|
{
|
||||||
@@ -4537,7 +4457,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
out_evt->msg_id = msg->msg_id;
|
out_evt->msg_id = msg->msg_id;
|
||||||
out_evt->entity = ctrl_handle_make(CTRL_MachineID_Local, event->process);
|
out_evt->entity = ctrl_handle_make(CTRL_MachineID_Local, event->process);
|
||||||
out_evt->u64_code = event->code;
|
out_evt->u64_code = event->code;
|
||||||
ctrl_state->process_counter -= 1;
|
d_ctrl_state->process_counter -= 1;
|
||||||
}break;
|
}break;
|
||||||
case DMN_EventKind_ExitThread:
|
case DMN_EventKind_ExitThread:
|
||||||
{
|
{
|
||||||
@@ -4565,7 +4485,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
}break;
|
}break;
|
||||||
case DMN_EventKind_DebugString:
|
case DMN_EventKind_DebugString:
|
||||||
{
|
{
|
||||||
U64 num_strings = (event->string.size + ctrl_state->c2u_ring_max_string_size-1) / ctrl_state->c2u_ring_max_string_size;
|
U64 num_strings = (event->string.size + d_ctrl_state->c2u_ring_max_string_size-1) / d_ctrl_state->c2u_ring_max_string_size;
|
||||||
for(U64 string_idx = 0; string_idx < num_strings; string_idx += 1)
|
for(U64 string_idx = 0; string_idx < num_strings; string_idx += 1)
|
||||||
{
|
{
|
||||||
CTRL_Event *out_evt = ctrl_event_list_push(scratch.arena, &evts);
|
CTRL_Event *out_evt = ctrl_event_list_push(scratch.arena, &evts);
|
||||||
@@ -4573,7 +4493,7 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
out_evt->msg_id = msg->msg_id;
|
out_evt->msg_id = msg->msg_id;
|
||||||
out_evt->entity = ctrl_handle_make(CTRL_MachineID_Local, event->thread);
|
out_evt->entity = ctrl_handle_make(CTRL_MachineID_Local, event->thread);
|
||||||
out_evt->parent = ctrl_handle_make(CTRL_MachineID_Local, event->process);
|
out_evt->parent = ctrl_handle_make(CTRL_MachineID_Local, event->process);
|
||||||
out_evt->string = str8_substr(event->string, r1u64(string_idx*ctrl_state->c2u_ring_max_string_size, (string_idx+1)*ctrl_state->c2u_ring_max_string_size));
|
out_evt->string = str8_substr(event->string, r1u64(string_idx*d_ctrl_state->c2u_ring_max_string_size, (string_idx+1)*d_ctrl_state->c2u_ring_max_string_size));
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
case DMN_EventKind_SetThreadName:
|
case DMN_EventKind_SetThreadName:
|
||||||
@@ -4629,17 +4549,17 @@ ctrl_thread__next_dmn_event(Arena *arena, DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg,
|
|||||||
|
|
||||||
//- rjf: if this is the first process in a session, clear the debug directory
|
//- rjf: if this is the first process in a session, clear the debug directory
|
||||||
// cache state
|
// cache state
|
||||||
if(ctrl_state->process_counter == 1 && event->kind == DMN_EventKind_CreateProcess)
|
if(d_ctrl_state->process_counter == 1 && event->kind == DMN_EventKind_CreateProcess)
|
||||||
{
|
{
|
||||||
arena_clear(ctrl_state->dbg_dir_arena);
|
arena_clear(d_ctrl_state->dbg_dir_arena);
|
||||||
ctrl_state->dbg_dir_root = push_array(ctrl_state->dbg_dir_arena, CTRL_DbgDirNode, 1);
|
d_ctrl_state->dbg_dir_root = push_array(d_ctrl_state->dbg_dir_arena, CTRL_DbgDirNode, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: out of queued up demon events -> clear event arena
|
//- rjf: out of queued up demon events -> clear event arena
|
||||||
if(ctrl_state->first_dmn_event_node == 0)
|
if(d_ctrl_state->first_dmn_event_node == 0)
|
||||||
{
|
{
|
||||||
ctrl_state->free_dmn_event_node = 0;
|
d_ctrl_state->free_dmn_event_node = 0;
|
||||||
arena_clear(ctrl_state->dmn_event_arena);
|
arena_clear(d_ctrl_state->dmn_event_arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
@@ -4687,7 +4607,7 @@ ctrl_eval_space_read(E_Space space, void *out, Rng1U64 range)
|
|||||||
case CTRL_EntityKind_Thread:
|
case CTRL_EntityKind_Thread:
|
||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
U64 regs_size = regs_block_size_from_arch(entity->arch);
|
U64 regs_size = regs_block_size_from_arch(entity->arch);
|
||||||
void *regs = ctrl_reg_block_from_thread(scratch.arena, entity_ctx, entity->handle);
|
void *regs = ctrl_reg_block_from_thread(scratch.arena, entity_ctx, entity->handle);
|
||||||
Rng1U64 legal_range = r1u64(0, regs_size);
|
Rng1U64 legal_range = r1u64(0, regs_size);
|
||||||
@@ -4709,7 +4629,7 @@ internal CTRL_EvalScope *
|
|||||||
ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, CTRL_Entity *thread)
|
ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, CTRL_Entity *thread)
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_EvalScope *scope = push_array(arena, CTRL_EvalScope, 1);
|
CTRL_EvalScope *scope = push_array(arena, CTRL_EvalScope, 1);
|
||||||
scope->access = access_open();
|
scope->access = access_open();
|
||||||
|
|
||||||
@@ -4769,8 +4689,8 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
|
|||||||
{
|
{
|
||||||
// rjf: find cached result
|
// rjf: find cached result
|
||||||
U64 hash = ctrl_hash_from_handle(mod->handle);
|
U64 hash = ctrl_hash_from_handle(mod->handle);
|
||||||
U64 slot_idx = hash%ctrl_state->module_req_cache_slots_count;
|
U64 slot_idx = hash%d_ctrl_state->module_req_cache_slots_count;
|
||||||
CTRL_ModuleReqCacheNode *slot = ctrl_state->module_req_cache_slots[slot_idx];
|
CTRL_ModuleReqCacheNode *slot = d_ctrl_state->module_req_cache_slots[slot_idx];
|
||||||
CTRL_ModuleReqCacheNode *node = 0;
|
CTRL_ModuleReqCacheNode *node = 0;
|
||||||
for(CTRL_ModuleReqCacheNode *n = slot; n != 0; n = n->next)
|
for(CTRL_ModuleReqCacheNode *n = slot; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
@@ -4824,16 +4744,16 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
|
|||||||
void *file_base = os_file_map_view_open(map, OS_AccessFlag_Read, r1u64(0, props.size));
|
void *file_base = os_file_map_view_open(map, OS_AccessFlag_Read, r1u64(0, props.size));
|
||||||
String8 file_data = str8(file_base, props.size);
|
String8 file_data = str8(file_base, props.size);
|
||||||
{
|
{
|
||||||
rdi_is_necessary = pdb_has_symbol_or_file_ref(file_data, ctrl_state->msg_user_bp_touched_symbols, ctrl_state->msg_user_bp_touched_files);
|
rdi_is_necessary = pdb_has_symbol_or_file_ref(file_data, d_ctrl_state->msg_user_bp_touched_symbols, d_ctrl_state->msg_user_bp_touched_files);
|
||||||
}
|
}
|
||||||
os_file_map_view_close(map, file_base, r1u64(0, props.size));
|
os_file_map_view_close(map, file_base, r1u64(0, props.size));
|
||||||
os_file_map_close(map);
|
os_file_map_close(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os_file_close(file);
|
os_file_close(file);
|
||||||
node = push_array(ctrl_state->ctrl_thread_msg_process_arena, CTRL_ModuleReqCacheNode, 1);
|
node = push_array(d_ctrl_state->ctrl_thread_msg_process_arena, CTRL_ModuleReqCacheNode, 1);
|
||||||
node->next = slot;
|
node->next = slot;
|
||||||
ctrl_state->module_req_cache_slots[slot_idx] = node;
|
d_ctrl_state->module_req_cache_slots[slot_idx] = node;
|
||||||
node->module = mod->handle;
|
node->module = mod->handle;
|
||||||
node->required = rdi_is_necessary;
|
node->required = rdi_is_necessary;
|
||||||
}
|
}
|
||||||
@@ -4873,7 +4793,7 @@ ctrl_thread__eval_scope_begin(Arena *arena, CTRL_UserBreakpointList *user_bps, C
|
|||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: select evaluation cache
|
//- rjf: select evaluation cache
|
||||||
//
|
//
|
||||||
e_select_cache(ctrl_state->ctrl_thread_eval_cache);
|
e_select_cache(d_ctrl_state->ctrl_thread_eval_cache);
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: build base evaluation context
|
//- rjf: build base evaluation context
|
||||||
@@ -4958,7 +4878,7 @@ ctrl_thread__end_and_flush_log(void)
|
|||||||
{
|
{
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
LogScopeResult log = log_scope_end(scratch.arena);
|
LogScopeResult log = log_scope_end(scratch.arena);
|
||||||
os_append_data_to_file_path(ctrl_state->ctrl_thread_log_path, log.strings[LogMsgKind_Info]);
|
os_append_data_to_file_path(d_ctrl_state->ctrl_thread_log_path, log.strings[LogMsgKind_Info]);
|
||||||
if(log.strings[LogMsgKind_UserError].size != 0)
|
if(log.strings[LogMsgKind_UserError].size != 0)
|
||||||
{
|
{
|
||||||
CTRL_EventList evts = {0};
|
CTRL_EventList evts = {0};
|
||||||
@@ -5023,8 +4943,8 @@ ctrl_thread__launch(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
os_file_close(stdin_handle);
|
os_file_close(stdin_handle);
|
||||||
|
|
||||||
//- rjf: record (id -> entry points), so that we know custom entry points for this PID
|
//- rjf: record (id -> entry points), so that we know custom entry points for this PID
|
||||||
CTRL_EntityCtxRWStore *entity_ctx_rw_store = ctrl_state->ctrl_thread_entity_store;
|
CTRL_EntityCtxRWStore *entity_ctx_rw_store = d_ctrl_state->ctrl_thread_entity_store;
|
||||||
MutexScopeW(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
MutexScopeW(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
||||||
{
|
{
|
||||||
for(String8Node *n = msg->entry_points.first; n != 0; n = n->next)
|
for(String8Node *n = msg->entry_points.first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
@@ -5152,7 +5072,7 @@ ctrl_thread__kill_all(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
U32 exit_code = msg->exit_code;
|
U32 exit_code = msg->exit_code;
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
|
|
||||||
//- rjf: gather all currently existing processes
|
//- rjf: gather all currently existing processes
|
||||||
CTRL_EntityArray initial_processes = ctrl_entity_array_from_kind(entity_ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray initial_processes = ctrl_entity_array_from_kind(entity_ctx, CTRL_EntityKind_Process);
|
||||||
@@ -5289,7 +5209,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
Temp scratch = scratch_begin(0, 0);
|
Temp scratch = scratch_begin(0, 0);
|
||||||
DMN_Event *stop_event = 0;
|
DMN_Event *stop_event = 0;
|
||||||
CTRL_EventCause stop_cause = CTRL_EventCause_Null;
|
CTRL_EventCause stop_cause = CTRL_EventCause_Null;
|
||||||
CTRL_EntityCtx *entity_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *entity_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_Handle target_thread = msg->entity;
|
CTRL_Handle target_thread = msg->entity;
|
||||||
CTRL_Handle target_process = msg->parent;
|
CTRL_Handle target_process = msg->parent;
|
||||||
CTRL_Entity *target_process_entity = ctrl_entity_from_handle(entity_ctx, target_process);
|
CTRL_Entity *target_process_entity = ctrl_entity_from_handle(entity_ctx, target_process);
|
||||||
@@ -5783,7 +5703,7 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
//- rjf: add traps for all custom user entry points
|
//- rjf: add traps for all custom user entry points
|
||||||
if(!entries_found)
|
if(!entries_found)
|
||||||
{
|
{
|
||||||
for(String8Node *n = ctrl_state->user_entry_points.first; n != 0; n = n->next)
|
for(String8Node *n = d_ctrl_state->user_entry_points.first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
U32 procedure_id = 0;
|
U32 procedure_id = 0;
|
||||||
{
|
{
|
||||||
@@ -6476,7 +6396,7 @@ ctrl_memory_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64
|
|||||||
void *range_base = 0;
|
void *range_base = 0;
|
||||||
U64 zero_terminated_size = 0;
|
U64 zero_terminated_size = 0;
|
||||||
U64 pre_read_mem_gen = ctrl_mem_gen();
|
U64 pre_read_mem_gen = ctrl_mem_gen();
|
||||||
B32 pre_run_state = ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state);
|
B32 pre_run_state = ins_atomic_u64_eval(&d_ctrl_state->ctrl_thread_run_state);
|
||||||
if(range_size != 0)
|
if(range_size != 0)
|
||||||
{
|
{
|
||||||
// rjf: set up arena
|
// rjf: set up arena
|
||||||
@@ -6545,7 +6465,7 @@ ctrl_memory_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
U64 post_read_mem_gen = ctrl_mem_gen();
|
U64 post_read_mem_gen = ctrl_mem_gen();
|
||||||
B32 post_run_state = ins_atomic_u64_eval(&ctrl_state->ctrl_thread_run_state);
|
B32 post_run_state = ins_atomic_u64_eval(&d_ctrl_state->ctrl_thread_run_state);
|
||||||
|
|
||||||
//- rjf: form content key
|
//- rjf: form content key
|
||||||
C_Key content_key = {0};
|
C_Key content_key = {0};
|
||||||
@@ -6574,9 +6494,9 @@ ctrl_memory_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64
|
|||||||
//- rjf: wakeup on new submissions
|
//- rjf: wakeup on new submissions
|
||||||
if(!u128_match(u128_zero(), hash))
|
if(!u128_match(u128_zero(), hash))
|
||||||
{
|
{
|
||||||
if(ctrl_state->wakeup_hook != 0)
|
if(d_ctrl_state->wakeup_hook != 0)
|
||||||
{
|
{
|
||||||
ctrl_state->wakeup_hook();
|
d_ctrl_state->wakeup_hook();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6809,7 +6729,7 @@ ctrl_process_write(CTRL_Handle process, Rng1U64 range, void *src)
|
|||||||
//- rjf: success -> bump generation
|
//- rjf: success -> bump generation
|
||||||
if(result)
|
if(result)
|
||||||
{
|
{
|
||||||
ins_atomic_u64_inc_eval(&ctrl_state->mem_gen);
|
ins_atomic_u64_inc_eval(&d_ctrl_state->mem_gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: success -> wait for cache updates, for small regions - prefer relatively seamless
|
//- rjf: success -> wait for cache updates, for small regions - prefer relatively seamless
|
||||||
@@ -6852,9 +6772,9 @@ ctrl_call_stack_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out,
|
|||||||
|
|
||||||
//- rjf: produce mini entity context for just this call stack build
|
//- rjf: produce mini entity context for just this call stack build
|
||||||
CTRL_EntityCtx *entity_ctx = push_array(scratch.arena, CTRL_EntityCtx, 1);
|
CTRL_EntityCtx *entity_ctx = push_array(scratch.arena, CTRL_EntityCtx, 1);
|
||||||
MutexScopeR(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
MutexScopeR(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
||||||
{
|
{
|
||||||
CTRL_EntityCtx *src_ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *src_ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_EntityCtx *dst_ctx = entity_ctx;
|
CTRL_EntityCtx *dst_ctx = entity_ctx;
|
||||||
{
|
{
|
||||||
dst_ctx->root = &ctrl_entity_nil;
|
dst_ctx->root = &ctrl_entity_nil;
|
||||||
@@ -6992,9 +6912,9 @@ ctrl_call_stack_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: broadcast update
|
//- rjf: broadcast update
|
||||||
if(good && ctrl_state->wakeup_hook != 0)
|
if(good && d_ctrl_state->wakeup_hook != 0)
|
||||||
{
|
{
|
||||||
ctrl_state->wakeup_hook();
|
d_ctrl_state->wakeup_hook();
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: bundle call stack as artifact
|
//- rjf: bundle call stack as artifact
|
||||||
@@ -7053,9 +6973,9 @@ ctrl_call_stack_tree_artifact_create(String8 key, B32 *cancel_signal, B32 *retry
|
|||||||
CTRL_Handle *threads = 0;
|
CTRL_Handle *threads = 0;
|
||||||
CTRL_Handle *threads_processes = 0;
|
CTRL_Handle *threads_processes = 0;
|
||||||
Arch *threads_arches = 0;
|
Arch *threads_arches = 0;
|
||||||
MutexScopeR(ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
MutexScopeR(d_ctrl_state->ctrl_thread_entity_ctx_rw_mutex)
|
||||||
{
|
{
|
||||||
CTRL_EntityCtx *ctx = &ctrl_state->ctrl_thread_entity_store->ctx;
|
CTRL_EntityCtx *ctx = &d_ctrl_state->ctrl_thread_entity_store->ctx;
|
||||||
CTRL_EntityArray thread_entities = ctrl_entity_array_from_kind(ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray thread_entities = ctrl_entity_array_from_kind(ctx, CTRL_EntityKind_Thread);
|
||||||
threads_count = thread_entities.count;
|
threads_count = thread_entities.count;
|
||||||
threads = push_array(scratch.arena, CTRL_Handle, threads_count);
|
threads = push_array(scratch.arena, CTRL_Handle, threads_count);
|
||||||
|
|||||||
@@ -263,8 +263,8 @@ typedef CTRL_WAKEUP_FUNCTION_DEF(CTRL_WakeupFunctionType);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Main State Types
|
//~ rjf: Main State Types
|
||||||
|
|
||||||
typedef struct CTRL_State CTRL_State;
|
typedef struct D_CtrlState D_CtrlState;
|
||||||
struct CTRL_State
|
struct D_CtrlState
|
||||||
{
|
{
|
||||||
Arena *arena;
|
Arena *arena;
|
||||||
CTRL_WakeupFunctionType *wakeup_hook;
|
CTRL_WakeupFunctionType *wakeup_hook;
|
||||||
@@ -327,7 +327,7 @@ struct CTRL_State
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Globals
|
//~ rjf: Globals
|
||||||
|
|
||||||
global CTRL_State *ctrl_state = 0;
|
global D_CtrlState *d_ctrl_state = 0;
|
||||||
read_only global CTRL_Entity ctrl_entity_nil =
|
read_only global CTRL_Entity ctrl_entity_nil =
|
||||||
{
|
{
|
||||||
&ctrl_entity_nil,
|
&ctrl_entity_nil,
|
||||||
@@ -471,11 +471,6 @@ internal CTRL_Entity *ctrl_thread_from_id(CTRL_EntityCtx *ctx, U64 id);
|
|||||||
//- rjf: applying events to entity caches
|
//- rjf: applying events to entity caches
|
||||||
internal void ctrl_entity_store_apply_events(CTRL_EntityCtxRWStore *store, CTRL_EventList *list);
|
internal void ctrl_entity_store_apply_events(CTRL_EntityCtxRWStore *store, CTRL_EventList *list);
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Main Layer Initialization
|
|
||||||
|
|
||||||
internal void ctrl_init(void);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Wakeup Callback Registration
|
//~ rjf: Wakeup Callback Registration
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ d_trap_net_from_thread__step_over_inst(Arena *arena, CTRL_Entity *thread)
|
|||||||
// rjf: thread => unpacked info
|
// rjf: thread => unpacked info
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||||
Arch arch = thread->arch;
|
Arch arch = thread->arch;
|
||||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
|
U64 ip_vaddr = ctrl_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};
|
||||||
@@ -333,7 +333,7 @@ d_trap_net_from_thread__step_over_line(Arena *arena, CTRL_Entity *thread)
|
|||||||
|
|
||||||
// rjf: thread => info
|
// rjf: thread => info
|
||||||
Arch arch = thread->arch;
|
Arch arch = thread->arch;
|
||||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
|
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||||
@@ -546,7 +546,7 @@ d_trap_net_from_thread__step_into_line(Arena *arena, CTRL_Entity *thread)
|
|||||||
|
|
||||||
// rjf: thread => info
|
// rjf: thread => info
|
||||||
Arch arch = thread->arch;
|
Arch arch = thread->arch;
|
||||||
U64 ip_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
|
U64 ip_vaddr = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ip_vaddr);
|
||||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||||
@@ -1142,7 +1142,7 @@ d_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64
|
|||||||
internal CTRL_Event
|
internal CTRL_Event
|
||||||
d_ctrl_last_stop_event(void)
|
d_ctrl_last_stop_event(void)
|
||||||
{
|
{
|
||||||
return d_state->ctrl_last_stop_event;
|
return d_user_state->ctrl_last_stop_event;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -1153,7 +1153,7 @@ d_ctrl_last_stop_event(void)
|
|||||||
internal U64
|
internal U64
|
||||||
d_frame_index(void)
|
d_frame_index(void)
|
||||||
{
|
{
|
||||||
return d_state->frame_index;
|
return d_user_state->frame_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: control state
|
//- rjf: control state
|
||||||
@@ -1161,19 +1161,19 @@ d_frame_index(void)
|
|||||||
internal D_RunKind
|
internal D_RunKind
|
||||||
d_ctrl_last_run_kind(void)
|
d_ctrl_last_run_kind(void)
|
||||||
{
|
{
|
||||||
return d_state->ctrl_last_run_kind;
|
return d_user_state->ctrl_last_run_kind;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal U64
|
internal U64
|
||||||
d_ctrl_last_run_frame_idx(void)
|
d_ctrl_last_run_frame_idx(void)
|
||||||
{
|
{
|
||||||
return d_state->ctrl_last_run_frame_idx;
|
return d_user_state->ctrl_last_run_frame_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal B32
|
internal B32
|
||||||
d_ctrl_targets_running(void)
|
d_ctrl_targets_running(void)
|
||||||
{
|
{
|
||||||
return d_state->ctrl_is_running;
|
return d_user_state->ctrl_is_running;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: active entity based queries
|
//- rjf: active entity based queries
|
||||||
@@ -1182,7 +1182,7 @@ 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};
|
||||||
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
||||||
for EachIndex(idx, modules.count)
|
for EachIndex(idx, modules.count)
|
||||||
{
|
{
|
||||||
CTRL_Entity *module = modules.v[idx];
|
CTRL_Entity *module = modules.v[idx];
|
||||||
@@ -1207,7 +1207,7 @@ d_query_cached_rip_from_thread_unwind(CTRL_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_state->ctrl_entity_store->ctx, thread->handle);
|
result = ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1240,9 +1240,9 @@ internal U64
|
|||||||
d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
d_query_cached_tls_base_vaddr_from_process_root_rip(CTRL_Entity *process, U64 root_vaddr, U64 rip_vaddr)
|
||||||
{
|
{
|
||||||
U64 result = 0;
|
U64 result = 0;
|
||||||
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_state->tls_base_caches); cache_idx += 1)
|
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_user_state->tls_base_caches); cache_idx += 1)
|
||||||
{
|
{
|
||||||
D_RunTLSBaseCache *cache = &d_state->tls_base_caches[(d_state->tls_base_cache_gen+cache_idx)%ArrayCount(d_state->tls_base_caches)];
|
D_RunTLSBaseCache *cache = &d_user_state->tls_base_caches[(d_user_state->tls_base_cache_gen+cache_idx)%ArrayCount(d_user_state->tls_base_caches)];
|
||||||
if(cache_idx == 0 && cache->slots_count == 0)
|
if(cache_idx == 0 && cache->slots_count == 0)
|
||||||
{
|
{
|
||||||
cache->slots_count = 256;
|
cache->slots_count = 256;
|
||||||
@@ -1292,9 +1292,9 @@ d_query_cached_locals_map_from_dbgi_key_voff(DI_Key dbgi_key, U64 voff)
|
|||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
E_String2NumMap *map = &e_string2num_map_nil;
|
E_String2NumMap *map = &e_string2num_map_nil;
|
||||||
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_state->locals_caches); cache_idx += 1)
|
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_user_state->locals_caches); cache_idx += 1)
|
||||||
{
|
{
|
||||||
D_RunLocalsCache *cache = &d_state->locals_caches[(d_state->locals_cache_gen+cache_idx)%ArrayCount(d_state->locals_caches)];
|
D_RunLocalsCache *cache = &d_user_state->locals_caches[(d_user_state->locals_cache_gen+cache_idx)%ArrayCount(d_user_state->locals_caches)];
|
||||||
if(cache_idx == 0 && cache->table_size == 0)
|
if(cache_idx == 0 && cache->table_size == 0)
|
||||||
{
|
{
|
||||||
cache->table_size = 256;
|
cache->table_size = 256;
|
||||||
@@ -1346,9 +1346,9 @@ d_query_cached_member_map_from_dbgi_key_voff(DI_Key dbgi_key, U64 voff)
|
|||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
E_String2NumMap *map = &e_string2num_map_nil;
|
E_String2NumMap *map = &e_string2num_map_nil;
|
||||||
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_state->member_caches); cache_idx += 1)
|
for(U64 cache_idx = 0; cache_idx < ArrayCount(d_user_state->member_caches); cache_idx += 1)
|
||||||
{
|
{
|
||||||
D_RunLocalsCache *cache = &d_state->member_caches[(d_state->member_cache_gen+cache_idx)%ArrayCount(d_state->member_caches)];
|
D_RunLocalsCache *cache = &d_user_state->member_caches[(d_user_state->member_cache_gen+cache_idx)%ArrayCount(d_user_state->member_caches)];
|
||||||
if(cache_idx == 0 && cache->table_size == 0)
|
if(cache_idx == 0 && cache->table_size == 0)
|
||||||
{
|
{
|
||||||
cache->table_size = 256;
|
cache->table_size = 256;
|
||||||
@@ -1400,7 +1400,7 @@ d_query_cached_member_map_from_dbgi_key_voff(DI_Key dbgi_key, U64 voff)
|
|||||||
internal void
|
internal void
|
||||||
d_push_cmd(D_CmdKind kind, D_CmdParams *params)
|
d_push_cmd(D_CmdKind kind, D_CmdParams *params)
|
||||||
{
|
{
|
||||||
d_cmd_list_push_new(d_state->cmds_arena, &d_state->cmds, kind, params);
|
d_cmd_list_push_new(d_user_state->cmds_arena, &d_user_state->cmds, kind, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: command iteration
|
//- rjf: command iteration
|
||||||
@@ -1408,7 +1408,7 @@ d_push_cmd(D_CmdKind kind, D_CmdParams *params)
|
|||||||
internal B32
|
internal B32
|
||||||
d_next_cmd(D_Cmd **cmd)
|
d_next_cmd(D_Cmd **cmd)
|
||||||
{
|
{
|
||||||
D_CmdNode *start_node = d_state->cmds.first;
|
D_CmdNode *start_node = d_user_state->cmds.first;
|
||||||
if(cmd[0] != 0)
|
if(cmd[0] != 0)
|
||||||
{
|
{
|
||||||
start_node = CastFromMember(D_CmdNode, cmd, cmd[0]);
|
start_node = CastFromMember(D_CmdNode, cmd, cmd[0]);
|
||||||
@@ -1425,50 +1425,13 @@ d_next_cmd(D_Cmd **cmd)
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Main Layer Top-Level Calls
|
//~ rjf: Main Layer Top-Level Calls
|
||||||
|
|
||||||
#if !defined(XXH_IMPLEMENTATION)
|
|
||||||
# define XXH_IMPLEMENTATION
|
|
||||||
# define XXH_STATIC_LINKING_ONLY
|
|
||||||
# include "third_party/xxHash/xxhash.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
internal void
|
|
||||||
d_init(void)
|
|
||||||
{
|
|
||||||
Arena *arena = arena_alloc();
|
|
||||||
d_state = push_array(arena, D_State, 1);
|
|
||||||
d_state->arena = arena;
|
|
||||||
d_state->cmds_arena = arena_alloc();
|
|
||||||
d_state->output_log_key = c_key_make(c_root_alloc(), c_id_make(0, 0));
|
|
||||||
c_submit_data(d_state->output_log_key, 0, str8_zero());
|
|
||||||
d_state->ctrl_entity_store = ctrl_entity_ctx_rw_store_alloc();
|
|
||||||
d_state->ctrl_stop_arena = arena_alloc();
|
|
||||||
d_state->ctrl_msg_arena = arena_alloc();
|
|
||||||
|
|
||||||
// rjf: set up caches
|
|
||||||
for(U64 idx = 0; idx < ArrayCount(d_state->tls_base_caches); idx += 1)
|
|
||||||
{
|
|
||||||
d_state->tls_base_caches[idx].arena = arena_alloc();
|
|
||||||
}
|
|
||||||
for(U64 idx = 0; idx < ArrayCount(d_state->locals_caches); idx += 1)
|
|
||||||
{
|
|
||||||
d_state->locals_caches[idx].arena = arena_alloc();
|
|
||||||
}
|
|
||||||
for(U64 idx = 0; idx < ArrayCount(d_state->member_caches); idx += 1)
|
|
||||||
{
|
|
||||||
d_state->member_caches[idx].arena = arena_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: set up run state
|
|
||||||
d_state->ctrl_last_run_arena = arena_alloc();
|
|
||||||
}
|
|
||||||
|
|
||||||
internal D_EventList
|
internal D_EventList
|
||||||
d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64])
|
d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64])
|
||||||
{
|
{
|
||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
D_EventList result = {0};
|
D_EventList result = {0};
|
||||||
d_state->frame_index += 1;
|
d_user_state->frame_index += 1;
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
//- rjf: sync with ctrl thread
|
//- rjf: sync with ctrl thread
|
||||||
@@ -1481,7 +1444,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
|
|
||||||
//- rjf: consume & process events
|
//- rjf: consume & process events
|
||||||
CTRL_EventList events = ctrl_c2u_pop_events(scratch.arena);
|
CTRL_EventList events = ctrl_c2u_pop_events(scratch.arena);
|
||||||
ctrl_entity_store_apply_events(d_state->ctrl_entity_store, &events);
|
ctrl_entity_store_apply_events(d_user_state->ctrl_entity_store, &events);
|
||||||
for(CTRL_EventNode *event_n = events.first;
|
for(CTRL_EventNode *event_n = events.first;
|
||||||
event_n != 0;
|
event_n != 0;
|
||||||
event_n = event_n->next)
|
event_n = event_n->next)
|
||||||
@@ -1505,16 +1468,16 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
|
|
||||||
case CTRL_EventKind_Started:
|
case CTRL_EventKind_Started:
|
||||||
{
|
{
|
||||||
d_state->ctrl_is_running = 1;
|
d_user_state->ctrl_is_running = 1;
|
||||||
d_state->ctrl_thread_run_state = 1;
|
d_user_state->ctrl_thread_run_state = 1;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
case CTRL_EventKind_Stopped:
|
case CTRL_EventKind_Stopped:
|
||||||
{
|
{
|
||||||
B32 should_snap = !(d_state->ctrl_soft_halt_issued);
|
B32 should_snap = !(d_user_state->ctrl_soft_halt_issued);
|
||||||
d_state->ctrl_is_running = 0;
|
d_user_state->ctrl_is_running = 0;
|
||||||
d_state->ctrl_thread_run_state = 0;
|
d_user_state->ctrl_thread_run_state = 0;
|
||||||
d_state->ctrl_soft_halt_issued = 0;
|
d_user_state->ctrl_soft_halt_issued = 0;
|
||||||
|
|
||||||
// rjf: exception or unexpected trap -> push error
|
// rjf: exception or unexpected trap -> push error
|
||||||
if(event->cause == CTRL_EventCause_InterruptedByException ||
|
if(event->cause == CTRL_EventCause_InterruptedByException ||
|
||||||
@@ -1525,15 +1488,15 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
|
|
||||||
// rjf: gather stop info
|
// rjf: gather stop info
|
||||||
{
|
{
|
||||||
arena_clear(d_state->ctrl_stop_arena);
|
arena_clear(d_user_state->ctrl_stop_arena);
|
||||||
MemoryCopyStruct(&d_state->ctrl_last_stop_event, event);
|
MemoryCopyStruct(&d_user_state->ctrl_last_stop_event, event);
|
||||||
d_state->ctrl_last_stop_event.string = push_str8_copy(d_state->ctrl_stop_arena, d_state->ctrl_last_stop_event.string);
|
d_user_state->ctrl_last_stop_event.string = push_str8_copy(d_user_state->ctrl_stop_arena, d_user_state->ctrl_last_stop_event.string);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: push stop event to caller, if this is not a soft-halt
|
// rjf: push stop event to caller, if this is not a soft-halt
|
||||||
if(should_snap)
|
if(should_snap)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, event->entity);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, event->entity);
|
||||||
D_EventCause cause = D_EventCause_Null;
|
D_EventCause cause = D_EventCause_Null;
|
||||||
switch(event->cause)
|
switch(event->cause)
|
||||||
{
|
{
|
||||||
@@ -1568,11 +1531,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
case CTRL_EventKind_NewProc:
|
case CTRL_EventKind_NewProc:
|
||||||
{
|
{
|
||||||
// rjf: the first process? -> clear session output
|
// rjf: the first process? -> clear session output
|
||||||
CTRL_EntityArray existing_processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray existing_processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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")};
|
||||||
mtx_push_op(d_state->output_log_key, op);
|
mtx_push_op(d_user_state->output_log_key, op);
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
@@ -1601,7 +1564,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
case CTRL_EventKind_DebugString:
|
case CTRL_EventKind_DebugString:
|
||||||
{
|
{
|
||||||
MTX_Op op = {r1u64(max_U64, max_U64), event->string};
|
MTX_Op op = {r1u64(max_U64, max_U64), event->string};
|
||||||
mtx_push_op(d_state->output_log_key, op);
|
mtx_push_op(d_user_state->output_log_key, op);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
//- rjf: memory
|
//- rjf: memory
|
||||||
@@ -1615,41 +1578,41 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: clear tls base cache
|
//- rjf: clear tls base cache
|
||||||
if((d_state->tls_base_cache_reggen_idx != new_reg_gen ||
|
if((d_user_state->tls_base_cache_reggen_idx != new_reg_gen ||
|
||||||
d_state->tls_base_cache_memgen_idx != new_mem_gen) &&
|
d_user_state->tls_base_cache_memgen_idx != new_mem_gen) &&
|
||||||
!d_ctrl_targets_running())
|
!d_ctrl_targets_running())
|
||||||
{
|
{
|
||||||
d_state->tls_base_cache_gen += 1;
|
d_user_state->tls_base_cache_gen += 1;
|
||||||
D_RunTLSBaseCache *cache = &d_state->tls_base_caches[d_state->tls_base_cache_gen%ArrayCount(d_state->tls_base_caches)];
|
D_RunTLSBaseCache *cache = &d_user_state->tls_base_caches[d_user_state->tls_base_cache_gen%ArrayCount(d_user_state->tls_base_caches)];
|
||||||
arena_clear(cache->arena);
|
arena_clear(cache->arena);
|
||||||
cache->slots_count = 0;
|
cache->slots_count = 0;
|
||||||
cache->slots = 0;
|
cache->slots = 0;
|
||||||
d_state->tls_base_cache_reggen_idx = new_reg_gen;
|
d_user_state->tls_base_cache_reggen_idx = new_reg_gen;
|
||||||
d_state->tls_base_cache_memgen_idx = new_mem_gen;
|
d_user_state->tls_base_cache_memgen_idx = new_mem_gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: clear locals cache
|
//- rjf: clear locals cache
|
||||||
if(d_state->locals_cache_reggen_idx != new_reg_gen &&
|
if(d_user_state->locals_cache_reggen_idx != new_reg_gen &&
|
||||||
!d_ctrl_targets_running())
|
!d_ctrl_targets_running())
|
||||||
{
|
{
|
||||||
d_state->locals_cache_gen += 1;
|
d_user_state->locals_cache_gen += 1;
|
||||||
D_RunLocalsCache *cache = &d_state->locals_caches[d_state->locals_cache_gen%ArrayCount(d_state->locals_caches)];
|
D_RunLocalsCache *cache = &d_user_state->locals_caches[d_user_state->locals_cache_gen%ArrayCount(d_user_state->locals_caches)];
|
||||||
arena_clear(cache->arena);
|
arena_clear(cache->arena);
|
||||||
cache->table_size = 0;
|
cache->table_size = 0;
|
||||||
cache->table = 0;
|
cache->table = 0;
|
||||||
d_state->locals_cache_reggen_idx = new_reg_gen;
|
d_user_state->locals_cache_reggen_idx = new_reg_gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: clear members cache
|
//- rjf: clear members cache
|
||||||
if(d_state->member_cache_reggen_idx != new_reg_gen &&
|
if(d_user_state->member_cache_reggen_idx != new_reg_gen &&
|
||||||
!d_ctrl_targets_running())
|
!d_ctrl_targets_running())
|
||||||
{
|
{
|
||||||
d_state->member_cache_gen += 1;
|
d_user_state->member_cache_gen += 1;
|
||||||
D_RunLocalsCache *cache = &d_state->member_caches[d_state->member_cache_gen%ArrayCount(d_state->member_caches)];
|
D_RunLocalsCache *cache = &d_user_state->member_caches[d_user_state->member_cache_gen%ArrayCount(d_user_state->member_caches)];
|
||||||
arena_clear(cache->arena);
|
arena_clear(cache->arena);
|
||||||
cache->table_size = 0;
|
cache->table_size = 0;
|
||||||
cache->table = 0;
|
cache->table = 0;
|
||||||
d_state->member_cache_reggen_idx = new_reg_gen;
|
d_user_state->member_cache_reggen_idx = new_reg_gen;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1661,7 +1624,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};
|
||||||
{
|
{
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||||
for EachIndex(idx, threads.count)
|
for EachIndex(idx, threads.count)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = threads.v[idx];
|
CTRL_Entity *thread = threads.v[idx];
|
||||||
@@ -1693,7 +1656,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
// halt-refresh to inform the ctrl thread about the updated
|
// halt-refresh to inform the ctrl thread about the updated
|
||||||
// state
|
// state
|
||||||
//
|
//
|
||||||
if(d_ctrl_targets_running() && !u128_match(ctrl_param_state_hash, d_state->ctrl_last_run_param_state_hash))
|
if(d_ctrl_targets_running() && !u128_match(ctrl_param_state_hash, d_user_state->ctrl_last_run_param_state_hash))
|
||||||
{
|
{
|
||||||
d_cmd(D_CmdKind_SoftHaltRefresh);
|
d_cmd(D_CmdKind_SoftHaltRefresh);
|
||||||
}
|
}
|
||||||
@@ -1816,7 +1779,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}break;
|
}break;
|
||||||
case D_CmdKind_Kill:
|
case D_CmdKind_Kill:
|
||||||
{
|
{
|
||||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->process);
|
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||||
if(process == &ctrl_entity_nil)
|
if(process == &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
log_user_error(str8_lit("Cannot kill; no process was specified."));
|
log_user_error(str8_lit("Cannot kill; no process was specified."));
|
||||||
@@ -1839,7 +1802,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}break;
|
}break;
|
||||||
case D_CmdKind_Detach:
|
case D_CmdKind_Detach:
|
||||||
{
|
{
|
||||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->process);
|
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->process);
|
||||||
if(process == &ctrl_entity_nil)
|
if(process == &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
log_user_error(str8_lit("Cannot detach; no process specified."));
|
log_user_error(str8_lit("Cannot detach; no process specified."));
|
||||||
@@ -1855,7 +1818,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;
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||||
if(threads.count > 0)
|
if(threads.count > 0)
|
||||||
{
|
{
|
||||||
for EachIndex(idx, threads.count)
|
for EachIndex(idx, threads.count)
|
||||||
@@ -1871,7 +1834,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_state->ctrl_entity_store->ctx, params->thread);
|
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1885,7 +1848,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:
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->thread);
|
||||||
if(thread == &ctrl_entity_nil)
|
if(thread == &ctrl_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."));
|
||||||
@@ -1972,16 +1935,16 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
if(d_ctrl_targets_running())
|
if(d_ctrl_targets_running())
|
||||||
{
|
{
|
||||||
need_run = 1;
|
need_run = 1;
|
||||||
run_kind = d_state->ctrl_last_run_kind;
|
run_kind = d_user_state->ctrl_last_run_kind;
|
||||||
run_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, d_state->ctrl_last_run_thread_handle);
|
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle);
|
||||||
run_flags = d_state->ctrl_last_run_flags;
|
run_flags = d_user_state->ctrl_last_run_flags;
|
||||||
run_traps = d_state->ctrl_last_run_traps;
|
run_traps = d_user_state->ctrl_last_run_traps;
|
||||||
}break;
|
}break;
|
||||||
case D_CmdKind_SetThreadIP:
|
case D_CmdKind_SetThreadIP:
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->thread);
|
CTRL_Entity *thread = ctrl_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_state->ctrl_entity_store->ctx, thread->handle);
|
void *block = ctrl_reg_block_from_thread(scratch.arena, &d_user_state->ctrl_entity_store->ctx, thread->handle);
|
||||||
regs_arch_block_write_rip(thread->arch, block, vaddr);
|
regs_arch_block_write_rip(thread->arch, block, vaddr);
|
||||||
B32 result = ctrl_thread_write_reg_block(thread->handle, block);
|
B32 result = ctrl_thread_write_reg_block(thread->handle, block);
|
||||||
(void)result;
|
(void)result;
|
||||||
@@ -2005,7 +1968,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}break;
|
}break;
|
||||||
case D_CmdKind_Run:
|
case D_CmdKind_Run:
|
||||||
{
|
{
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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);
|
||||||
@@ -2017,7 +1980,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}break;
|
}break;
|
||||||
case D_CmdKind_Restart:
|
case D_CmdKind_Restart:
|
||||||
{
|
{
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||||
if(processes.count != 0)
|
if(processes.count != 0)
|
||||||
{
|
{
|
||||||
d_cmd(D_CmdKind_KillAll);
|
d_cmd(D_CmdKind_KillAll);
|
||||||
@@ -2027,7 +1990,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:
|
||||||
{
|
{
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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
|
||||||
@@ -2077,7 +2040,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
case D_CmdKind_ThawEntity:
|
case D_CmdKind_ThawEntity:
|
||||||
{
|
{
|
||||||
B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity);
|
B32 should_freeze = (cmd->kind == D_CmdKind_FreezeEntity);
|
||||||
CTRL_Entity *root = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->entity);
|
CTRL_Entity *root = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||||
for(CTRL_Entity *e = root; e != &ctrl_entity_nil; e = ctrl_entity_rec_depth_first_pre(e, root).next)
|
for(CTRL_Entity *e = root; e != &ctrl_entity_nil; e = ctrl_entity_rec_depth_first_pre(e, root).next)
|
||||||
{
|
{
|
||||||
if(e->kind == CTRL_EntityKind_Thread)
|
if(e->kind == CTRL_EntityKind_Thread)
|
||||||
@@ -2091,23 +2054,23 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
if(d_ctrl_targets_running())
|
if(d_ctrl_targets_running())
|
||||||
{
|
{
|
||||||
need_run = 1;
|
need_run = 1;
|
||||||
run_kind = d_state->ctrl_last_run_kind;
|
run_kind = d_user_state->ctrl_last_run_kind;
|
||||||
run_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, d_state->ctrl_last_run_thread_handle);
|
run_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, d_user_state->ctrl_last_run_thread_handle);
|
||||||
run_flags = d_state->ctrl_last_run_flags;
|
run_flags = d_user_state->ctrl_last_run_flags;
|
||||||
run_traps = d_state->ctrl_last_run_traps;
|
run_traps = d_user_state->ctrl_last_run_traps;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
//- rjf: entity decoration
|
//- rjf: entity decoration
|
||||||
case D_CmdKind_SetEntityColor:
|
case D_CmdKind_SetEntityColor:
|
||||||
{
|
{
|
||||||
CTRL_Entity *entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->entity);
|
CTRL_Entity *entity = ctrl_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:
|
||||||
{
|
{
|
||||||
CTRL_Entity *entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, params->entity);
|
CTRL_Entity *entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, params->entity);
|
||||||
ctrl_entity_equip_string(d_state->ctrl_entity_store, entity, params->string);
|
ctrl_entity_equip_string(d_user_state->ctrl_entity_store, entity, params->string);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
//- rjf: attaching
|
//- rjf: attaching
|
||||||
@@ -2129,7 +2092,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
{
|
{
|
||||||
// rjf: compute hash of all run-parameterization entities, store
|
// rjf: compute hash of all run-parameterization entities, store
|
||||||
{
|
{
|
||||||
d_state->ctrl_last_run_param_state_hash = ctrl_param_state_hash;
|
d_user_state->ctrl_last_run_param_state_hash = ctrl_param_state_hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: push & fill run message
|
// rjf: push & fill run message
|
||||||
@@ -2193,19 +2156,19 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: copy run traps to scratch (needed, if run_traps can be `d_state->ctrl_last_run_traps`)
|
// rjf: copy run traps to scratch (needed, if run_traps can be `d_user_state->ctrl_last_run_traps`)
|
||||||
CTRL_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps);
|
CTRL_TrapList run_traps_copy = ctrl_trap_list_copy(scratch.arena, &run_traps);
|
||||||
D_BreakpointArray run_extra_bps_copy = d_breakpoint_array_copy(scratch.arena, &run_extra_bps);
|
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
|
||||||
arena_clear(d_state->ctrl_last_run_arena);
|
arena_clear(d_user_state->ctrl_last_run_arena);
|
||||||
d_state->ctrl_last_run_kind = run_kind;
|
d_user_state->ctrl_last_run_kind = run_kind;
|
||||||
d_state->ctrl_last_run_frame_idx = d_frame_index();
|
d_user_state->ctrl_last_run_frame_idx = d_frame_index();
|
||||||
d_state->ctrl_last_run_thread_handle = run_thread->handle;
|
d_user_state->ctrl_last_run_thread_handle = run_thread->handle;
|
||||||
d_state->ctrl_last_run_flags = run_flags;
|
d_user_state->ctrl_last_run_flags = run_flags;
|
||||||
d_state->ctrl_last_run_traps = ctrl_trap_list_copy(d_state->ctrl_last_run_arena, &run_traps_copy);
|
d_user_state->ctrl_last_run_traps = ctrl_trap_list_copy(d_user_state->ctrl_last_run_arena, &run_traps_copy);
|
||||||
d_state->ctrl_last_run_extra_bps = d_breakpoint_array_copy(d_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_state->ctrl_is_running = 1;
|
d_user_state->ctrl_is_running = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2214,8 +2177,8 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
//- rjf: clear command batch
|
//- rjf: clear command batch
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
arena_clear(d_state->cmds_arena);
|
arena_clear(d_user_state->cmds_arena);
|
||||||
MemoryZeroStruct(&d_state->cmds);
|
MemoryZeroStruct(&d_user_state->cmds);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
@@ -2223,7 +2186,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
//
|
//
|
||||||
for EachNode(n, D_CmdNode, deferred_cmds.first)
|
for EachNode(n, D_CmdNode, deferred_cmds.first)
|
||||||
{
|
{
|
||||||
d_cmd_list_push_new(d_state->cmds_arena, &d_state->cmds, n->cmd.kind, &n->cmd.params);
|
d_cmd_list_push_new(d_user_state->cmds_arena, &d_user_state->cmds, n->cmd.kind, &n->cmd.params);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
@@ -2232,19 +2195,19 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
|||||||
// the next tick)
|
// the next tick)
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
CTRL_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_state->ctrl_msg_arena, &ctrl_msgs);
|
CTRL_MsgList msgs_copy = ctrl_msg_list_deep_copy(d_user_state->ctrl_msg_arena, &ctrl_msgs);
|
||||||
ctrl_msg_list_concat_in_place(&d_state->ctrl_msgs, &msgs_copy);
|
ctrl_msg_list_concat_in_place(&d_user_state->ctrl_msgs, &msgs_copy);
|
||||||
if(d_state->ctrl_msgs.count != 0)
|
if(d_user_state->ctrl_msgs.count != 0)
|
||||||
{
|
{
|
||||||
if(!d_state->ctrl_soft_halt_issued && d_state->ctrl_thread_run_state)
|
if(!d_user_state->ctrl_soft_halt_issued && d_user_state->ctrl_thread_run_state)
|
||||||
{
|
{
|
||||||
d_state->ctrl_soft_halt_issued = 1;
|
d_user_state->ctrl_soft_halt_issued = 1;
|
||||||
ctrl_halt();
|
ctrl_halt();
|
||||||
}
|
}
|
||||||
if(ctrl_u2c_push_msgs(&d_state->ctrl_msgs, os_now_microseconds()+100))
|
if(ctrl_u2c_push_msgs(&d_user_state->ctrl_msgs, os_now_microseconds()+100))
|
||||||
{
|
{
|
||||||
MemoryZeroStruct(&d_state->ctrl_msgs);
|
MemoryZeroStruct(&d_user_state->ctrl_msgs);
|
||||||
arena_clear(d_state->ctrl_msg_arena);
|
arena_clear(d_user_state->ctrl_msg_arena);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -332,8 +332,8 @@ struct CTRL_EventList
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Main State Types
|
//~ rjf: Main State Types
|
||||||
|
|
||||||
typedef struct D_State D_State;
|
typedef struct D_UserState D_UserState;
|
||||||
struct D_State
|
struct D_UserState
|
||||||
{
|
{
|
||||||
// rjf: top-level state
|
// rjf: top-level state
|
||||||
Arena *arena;
|
Arena *arena;
|
||||||
@@ -382,7 +382,7 @@ struct D_State
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Globals
|
//~ rjf: Globals
|
||||||
|
|
||||||
global D_State *d_state = 0;
|
global D_UserState *d_user_state = 0;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic Helpers
|
//~ rjf: Basic Helpers
|
||||||
@@ -480,7 +480,6 @@ internal B32 d_next_cmd(D_Cmd **cmd);
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Main Layer Top-Level Calls
|
//~ rjf: Main Layer Top-Level Calls
|
||||||
|
|
||||||
internal void d_init(void);
|
|
||||||
internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]);
|
internal D_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_PathMapArray *path_maps, U64 exception_code_filters[(CTRL_ExceptionCodeKind_COUNT+63)/64]);
|
||||||
|
|
||||||
#endif // DBG_ENGINE_USER_H
|
#endif // DBG_ENGINE_USER_H
|
||||||
|
|||||||
+46
-46
@@ -689,7 +689,7 @@ rd_ctrl_entity_from_eval_space(E_Space space)
|
|||||||
CTRL_Handle handle;
|
CTRL_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_state->ctrl_entity_store->ctx, handle);
|
entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle);
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@@ -1007,7 +1007,7 @@ 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_state->ctrl_entity_store->ctx, entity->handle);
|
void *new_regs = ctrl_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 = ctrl_thread_write_reg_block(entity->handle, new_regs);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
@@ -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_state->ctrl_entity_store, entity, write_string);
|
ctrl_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))
|
||||||
@@ -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"));
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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")
|
||||||
@@ -2361,7 +2361,7 @@ rd_view_ui(Rng2F32 rect)
|
|||||||
String8 name = {0};
|
String8 name = {0};
|
||||||
{
|
{
|
||||||
U64 vaddr = eval.value.u64;
|
U64 vaddr = eval.value.u64;
|
||||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->process);
|
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
|
||||||
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
DI_Key dbgi_key = ctrl_dbgi_key_from_module(module);
|
||||||
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
|
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
|
||||||
@@ -4740,7 +4740,7 @@ rd_arch_from_eval(E_Eval eval)
|
|||||||
CTRL_Entity *process = ctrl_process_from_entity(ctrl_entity);
|
CTRL_Entity *process = ctrl_process_from_entity(ctrl_entity);
|
||||||
if(process == &ctrl_entity_nil)
|
if(process == &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->process);
|
process = ctrl_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_state->ctrl_entity_store->ctx, regs->machine); }goto ctrl_entity_tooltip;
|
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_Process: {ctrl_entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, regs->process); }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_Module: {ctrl_entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, regs->module); }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_Thread: {ctrl_entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, regs->thread); }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_CtrlEntity:{ctrl_entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, regs->ctrl_entity); }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;
|
||||||
ctrl_entity_tooltip:;
|
ctrl_entity_tooltip:;
|
||||||
UI_Tooltip
|
UI_Tooltip
|
||||||
{
|
{
|
||||||
@@ -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"));
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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
|
||||||
@@ -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, CTRL_Event *event)
|
rd_stop_explanation_fstrs_from_ctrl_event(Arena *arena, CTRL_Event *event)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, event->entity);
|
CTRL_Entity *thread = ctrl_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");
|
||||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->process);
|
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process);
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_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);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, rip_vaddr);
|
||||||
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
|
U64 rip_voff = ctrl_voff_from_vaddr(module, rip_vaddr);
|
||||||
U64 tls_root_vaddr = ctrl_tls_root_vaddr_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
|
U64 tls_root_vaddr = ctrl_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
|
||||||
//
|
//
|
||||||
CTRL_EntityArray all_modules = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
CTRL_EntityArray all_modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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];
|
||||||
@@ -11514,7 +11514,7 @@ rd_frame(void)
|
|||||||
{
|
{
|
||||||
String8 name = evallable_ctrl_names[idx];
|
String8 name = evallable_ctrl_names[idx];
|
||||||
CTRL_EntityKind kind = ctrl_entity_kind_from_string(name);
|
CTRL_EntityKind kind = ctrl_entity_kind_from_string(name);
|
||||||
CTRL_EntityArray array = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, kind);
|
CTRL_EntityArray array = ctrl_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)
|
||||||
{
|
{
|
||||||
@@ -11743,7 +11743,7 @@ rd_frame(void)
|
|||||||
//- rjf: add macro for output log
|
//- rjf: add macro for output log
|
||||||
{
|
{
|
||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
C_Key key = d_state->output_log_key;
|
C_Key key = d_user_state->output_log_key;
|
||||||
U128 hash = c_hash_from_key(key, 0);
|
U128 hash = c_hash_from_key(key, 0);
|
||||||
String8 data = c_data_from_hash(access, hash);
|
String8 data = c_data_from_hash(access, hash);
|
||||||
E_Space space = e_space_make(E_SpaceKind_HashStoreKey);
|
E_Space space = e_space_make(E_SpaceKind_HashStoreKey);
|
||||||
@@ -11880,7 +11880,7 @@ 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};
|
||||||
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
CTRL_EntityArray modules = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Module);
|
||||||
ProfScope("gather config from loaded modules")
|
ProfScope("gather config from loaded modules")
|
||||||
{
|
{
|
||||||
for EachIndex(idx, modules.count)
|
for EachIndex(idx, modules.count)
|
||||||
@@ -12072,7 +12072,7 @@ rd_frame(void)
|
|||||||
case RD_CmdKind_Restart:
|
case RD_CmdKind_Restart:
|
||||||
{
|
{
|
||||||
// rjf: reset hit counts
|
// rjf: reset hit counts
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_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,12 +13679,12 @@ rd_frame(void)
|
|||||||
//- rjf: source <-> disasm
|
//- rjf: source <-> disasm
|
||||||
case RD_CmdKind_GoToDisassembly:
|
case RD_CmdKind_GoToDisassembly:
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_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)
|
||||||
{
|
{
|
||||||
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
||||||
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
|
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
|
||||||
if(module != &ctrl_entity_nil)
|
if(module != &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
||||||
@@ -13967,7 +13967,7 @@ rd_frame(void)
|
|||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
|
|
||||||
//- rjf: unpack thread info
|
//- rjf: unpack thread info
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_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);
|
||||||
@@ -14031,7 +14031,7 @@ rd_frame(void)
|
|||||||
}break;
|
}break;
|
||||||
case RD_CmdKind_FindSelectedThread:
|
case RD_CmdKind_FindSelectedThread:
|
||||||
{
|
{
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_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,7 +14140,7 @@ rd_frame(void)
|
|||||||
{
|
{
|
||||||
CTRL_Entity *process = &ctrl_entity_nil;
|
CTRL_Entity *process = &ctrl_entity_nil;
|
||||||
U64 vaddr = 0;
|
U64 vaddr = 0;
|
||||||
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, voff_dbgi_key);
|
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, voff_dbgi_key);
|
||||||
CTRL_Entity *module = ctrl_entity_list_first(&modules);
|
CTRL_Entity *module = ctrl_entity_list_first(&modules);
|
||||||
process = ctrl_entity_ancestor_from_kind(module, CTRL_EntityKind_Process);
|
process = ctrl_entity_ancestor_from_kind(module, CTRL_EntityKind_Process);
|
||||||
if(process != &ctrl_entity_nil)
|
if(process != &ctrl_entity_nil)
|
||||||
@@ -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_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->process);
|
process = ctrl_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,8 +14237,8 @@ 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)
|
||||||
{
|
{
|
||||||
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
||||||
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
|
CTRL_Entity *module = ctrl_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 = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -15179,7 +15179,7 @@ rd_frame(void)
|
|||||||
case RD_CmdKind_ClearOutput:
|
case RD_CmdKind_ClearOutput:
|
||||||
{
|
{
|
||||||
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("")};
|
MTX_Op op = {r1u64(0, 0xffffffffffffffffull), str8_lit("")};
|
||||||
mtx_push_op(d_state->output_log_key, op);
|
mtx_push_op(d_user_state->output_log_key, op);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
//- rjf: watch pins
|
//- rjf: watch pins
|
||||||
@@ -15441,7 +15441,7 @@ rd_frame(void)
|
|||||||
}break;
|
}break;
|
||||||
case RD_CmdKind_SetNextStatement:
|
case RD_CmdKind_SetNextStatement:
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_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,8 +15449,8 @@ 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)
|
||||||
{
|
{
|
||||||
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
||||||
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
|
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
|
||||||
if(module != &ctrl_entity_nil)
|
if(module != &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
||||||
@@ -15566,9 +15566,9 @@ rd_frame(void)
|
|||||||
}break;
|
}break;
|
||||||
case RD_CmdKind_SelectThread:
|
case RD_CmdKind_SelectThread:
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle));
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, ctrl_rip_from_thread(&d_user_state->ctrl_entity_store->ctx, thread->handle));
|
||||||
CTRL_Entity *machine = ctrl_entity_ancestor_from_kind(process, CTRL_EntityKind_Machine);
|
CTRL_Entity *machine = ctrl_entity_ancestor_from_kind(process, CTRL_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;
|
||||||
@@ -15581,7 +15581,7 @@ rd_frame(void)
|
|||||||
case RD_CmdKind_SelectUnwind:
|
case RD_CmdKind_SelectUnwind:
|
||||||
{
|
{
|
||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
||||||
CTRL_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
CTRL_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||||
CTRL_CallStackFrame *frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
CTRL_CallStackFrame *frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
||||||
if(frame == 0)
|
if(frame == 0)
|
||||||
@@ -15600,7 +15600,7 @@ rd_frame(void)
|
|||||||
case RD_CmdKind_DownOneFrame:
|
case RD_CmdKind_DownOneFrame:
|
||||||
{
|
{
|
||||||
Access *access = access_open();
|
Access *access = access_open();
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
||||||
CTRL_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
CTRL_CallStack call_stack = ctrl_call_stack_from_thread(access, thread->handle, 1, os_now_microseconds()+10000);
|
||||||
CTRL_CallStackFrame *current_frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
CTRL_CallStackFrame *current_frame = ctrl_call_stack_frame_from_unwind_and_inline_depth(&call_stack, rd_regs()->unwind_count, rd_regs()->inline_depth);
|
||||||
CTRL_CallStackFrame *next_frame = current_frame;
|
CTRL_CallStackFrame *next_frame = current_frame;
|
||||||
@@ -16330,7 +16330,7 @@ rd_frame(void)
|
|||||||
default:{}break;
|
default:{}break;
|
||||||
case D_EventKind_ModuleLoad:
|
case D_EventKind_ModuleLoad:
|
||||||
{
|
{
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, evt->module);
|
CTRL_Entity *module = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->module);
|
||||||
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
CTRL_Entity *debug_info_path = ctrl_entity_child_from_kind(module, CTRL_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))
|
||||||
@@ -16368,7 +16368,7 @@ rd_frame(void)
|
|||||||
case D_EventKind_ProcessEnd:
|
case D_EventKind_ProcessEnd:
|
||||||
if(rd_state->quit_after_success)
|
if(rd_state->quit_after_success)
|
||||||
{
|
{
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||||
if(evt->code == 0 && processes.count == 0)
|
if(evt->code == 0 && processes.count == 0)
|
||||||
{
|
{
|
||||||
rd_cmd(RD_CmdKind_Exit);
|
rd_cmd(RD_CmdKind_Exit);
|
||||||
@@ -16381,12 +16381,12 @@ rd_frame(void)
|
|||||||
case D_EventKind_Stop:
|
case D_EventKind_Stop:
|
||||||
{
|
{
|
||||||
B32 need_refocus = (evt->cause != D_EventCause_SoftHalt);
|
B32 need_refocus = (evt->cause != D_EventCause_SoftHalt);
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, evt->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, evt->thread);
|
||||||
U64 vaddr = evt->vaddr;
|
U64 vaddr = evt->vaddr;
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
||||||
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
|
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, vaddr);
|
||||||
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
|
U64 voff = ctrl_voff_from_vaddr(module, vaddr);
|
||||||
U64 test_cached_vaddr = ctrl_rip_from_thread(&d_state->ctrl_entity_store->ctx, thread->handle);
|
U64 test_cached_vaddr = ctrl_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 != &ctrl_entity_nil && evt->cause != D_EventCause_Halt)
|
if(need_refocus && thread != &ctrl_entity_nil && evt->cause != D_EventCause_Halt)
|
||||||
@@ -16395,7 +16395,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
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_base_regs()->thread);
|
||||||
if(need_refocus && (evt->cause == D_EventCause_Halt || thread == &ctrl_entity_nil) && selected_thread != &ctrl_entity_nil)
|
if(need_refocus && (evt->cause == D_EventCause_Halt || thread == &ctrl_entity_nil) && selected_thread != &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
rd_cmd(RD_CmdKind_SelectThread, .thread = selected_thread->handle);
|
rd_cmd(RD_CmdKind_SelectThread, .thread = selected_thread->handle);
|
||||||
@@ -16404,7 +16404,7 @@ 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 == &ctrl_entity_nil && selected_thread == &ctrl_entity_nil)
|
if(need_refocus && thread == &ctrl_entity_nil && selected_thread == &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||||
CTRL_Entity *first_available_thread = ctrl_entity_array_first(&threads);
|
CTRL_Entity *first_available_thread = ctrl_entity_array_first(&threads);
|
||||||
rd_cmd(RD_CmdKind_SelectThread, .thread = first_available_thread->handle);
|
rd_cmd(RD_CmdKind_SelectThread, .thread = first_available_thread->handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_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);
|
||||||
@@ -659,7 +659,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(control)
|
|||||||
str8_match(str8_prefix(rhs->string, 1), str8_lit("$"), 0))
|
str8_match(str8_prefix(rhs->string, 1), str8_lit("$"), 0))
|
||||||
{
|
{
|
||||||
CTRL_Handle handle = ctrl_handle_from_string(rhs->string);
|
CTRL_Handle handle = ctrl_handle_from_string(rhs->string);
|
||||||
CTRL_Entity *entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, handle);
|
CTRL_Entity *entity = ctrl_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, ctrl_entity_kind_code_name_table[entity->kind]);
|
||||||
@@ -978,7 +978,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(call_stack)
|
|||||||
CTRL_CallStack *call_stack = &accel->call_stack;
|
CTRL_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)
|
||||||
{
|
{
|
||||||
CTRL_Entity *process = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, accel->process);
|
CTRL_Entity *process = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, accel->process);
|
||||||
CTRL_CallStackFrame *f = &call_stack->frames[rhs_value.u64];
|
CTRL_CallStackFrame *f = &call_stack->frames[rhs_value.u64];
|
||||||
result.root = e_irtree_set_space(arena, rd_eval_space_from_ctrl_entity(process, CTRL_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, CTRL_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_state->ctrl_entity_store->ctx, CTRL_EntityKind_Machine);
|
machines = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Machine);
|
||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: gather system processes from this machine
|
//- rjf: gather system processes from this machine
|
||||||
@@ -1535,7 +1535,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(ctrl_entities)
|
|||||||
{
|
{
|
||||||
String8 rhs_name = expr->first->next->string;
|
String8 rhs_name = expr->first->next->string;
|
||||||
CTRL_Handle handle = ctrl_handle_from_string(rhs_name);
|
CTRL_Handle handle = ctrl_handle_from_string(rhs_name);
|
||||||
entity = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, handle);
|
entity = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, handle);
|
||||||
}break;
|
}break;
|
||||||
case E_ExprKind_ArrayIndex:
|
case E_ExprKind_ArrayIndex:
|
||||||
{
|
{
|
||||||
@@ -1543,7 +1543,7 @@ E_TYPE_ACCESS_FUNCTION_DEF(ctrl_entities)
|
|||||||
CTRL_EntityKind kind = ctrl_entity_kind_from_string(rd_singular_from_code_name_plural(type->name));
|
CTRL_EntityKind kind = ctrl_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;
|
||||||
CTRL_EntityArray entities = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, kind);
|
CTRL_EntityArray entities = ctrl_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];
|
||||||
@@ -1585,7 +1585,7 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(ctrl_entities)
|
|||||||
CTRL_EntityArray array = {0};
|
CTRL_EntityArray array = {0};
|
||||||
if(scoping_entity == &ctrl_entity_nil)
|
if(scoping_entity == &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
array = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, entity_kind);
|
array = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, entity_kind);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -243,12 +243,11 @@
|
|||||||
#define OS_FEATURE_GRAPHICAL 1
|
#define OS_FEATURE_GRAPHICAL 1
|
||||||
|
|
||||||
#define DMN_INIT_MANUAL 1
|
#define DMN_INIT_MANUAL 1
|
||||||
#define CTRL_INIT_MANUAL 1
|
#define D_INIT_MANUAL 1
|
||||||
#define OS_GFX_INIT_MANUAL 1
|
#define OS_GFX_INIT_MANUAL 1
|
||||||
#define FP_INIT_MANUAL 1
|
#define FP_INIT_MANUAL 1
|
||||||
#define R_INIT_MANUAL 1
|
#define R_INIT_MANUAL 1
|
||||||
#define FNT_INIT_MANUAL 1
|
#define FNT_INIT_MANUAL 1
|
||||||
#define D_INIT_MANUAL 1
|
|
||||||
#define RD_INIT_MANUAL 1
|
#define RD_INIT_MANUAL 1
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
@@ -540,12 +539,11 @@ entry_point(CmdLine *cmd_line)
|
|||||||
//- rjf: manual layer initialization
|
//- rjf: manual layer initialization
|
||||||
{
|
{
|
||||||
dmn_init();
|
dmn_init();
|
||||||
ctrl_init();
|
d_init();
|
||||||
os_gfx_init();
|
os_gfx_init();
|
||||||
fp_init();
|
fp_init();
|
||||||
r_init(cmd_line);
|
r_init(cmd_line);
|
||||||
fnt_init();
|
fnt_init();
|
||||||
d_init();
|
|
||||||
rd_init(cmd_line);
|
rd_init(cmd_line);
|
||||||
ctrl_set_wakeup_hook(wakeup_hook_ctrl);
|
ctrl_set_wakeup_hook(wakeup_hook_ctrl);
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -44,7 +44,7 @@ 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;
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(thread, CTRL_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,8 +277,8 @@ 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")
|
||||||
{
|
{
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||||
for EachIndex(idx, threads.count)
|
for EachIndex(idx, threads.count)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = threads.v[idx];
|
CTRL_Entity *thread = threads.v[idx];
|
||||||
@@ -340,7 +340,7 @@ 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;
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
|
CTRL_Entity *module = ctrl_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 = ctrl_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,8 +353,8 @@ 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")
|
||||||
{
|
{
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
CTRL_EntityArray threads = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Thread);
|
||||||
for EachIndex(idx, threads.count)
|
for EachIndex(idx, threads.count)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = threads.v[idx];
|
CTRL_Entity *thread = threads.v[idx];
|
||||||
@@ -2099,7 +2099,7 @@ 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();
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
|
CTRL_Entity *module = ctrl_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 = ctrl_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,7 +2223,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
|||||||
//
|
//
|
||||||
if(rd_regs()->file_path.size != 0)
|
if(rd_regs()->file_path.size != 0)
|
||||||
{
|
{
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->module);
|
CTRL_Entity *module = ctrl_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 = ctrl_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);
|
||||||
}
|
}
|
||||||
@@ -2433,13 +2433,13 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
|||||||
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 == ctrl_run_gen())
|
||||||
{
|
{
|
||||||
auto_selected = 1;
|
auto_selected = 1;
|
||||||
auto_space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, dv->temp_look_process), CTRL_EvalSpaceKind_Entity);
|
auto_space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, dv->temp_look_process), CTRL_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_state->ctrl_entity_store->ctx, rd_regs()->process), CTRL_EvalSpaceKind_Entity);
|
auto_space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), CTRL_EvalSpaceKind_Entity);
|
||||||
eval = e_eval_from_stringf("(reg:rip & (~(0x4000 - 1)))");
|
eval = e_eval_from_stringf("(reg:rip & (~(0x4000 - 1)))");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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_state->ctrl_entity_store->ctx, rd_regs()->process), CTRL_EvalSpaceKind_Entity);
|
eval.space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->process), CTRL_EvalSpaceKind_Entity);
|
||||||
view_range = rd_whole_range_from_eval_space(eval.space);
|
view_range = rd_whole_range_from_eval_space(eval.space);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3258,7 +3258,7 @@ 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();
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_Entity *selected_process = ctrl_entity_ancestor_from_kind(selected_thread, CTRL_EntityKind_Process);
|
CTRL_Entity *selected_process = ctrl_entity_ancestor_from_kind(selected_thread, CTRL_EntityKind_Process);
|
||||||
CTRL_CallStack selected_call_stack = ctrl_call_stack_from_thread(access, selected_thread->handle, 1, 0);
|
CTRL_CallStack selected_call_stack = ctrl_call_stack_from_thread(access, selected_thread->handle, 1, 0);
|
||||||
CTRL_Entity *eval_process = &ctrl_entity_nil;
|
CTRL_Entity *eval_process = &ctrl_entity_nil;
|
||||||
|
|||||||
@@ -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)
|
||||||
{
|
{
|
||||||
CTRL_Entity *thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, stop_event.entity);
|
CTRL_Entity *thread = ctrl_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)
|
||||||
{
|
{
|
||||||
@@ -509,7 +509,7 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e
|
|||||||
if(entity->kind == CTRL_EntityKind_Thread ||
|
if(entity->kind == CTRL_EntityKind_Thread ||
|
||||||
entity->kind == CTRL_EntityKind_Module)
|
entity->kind == CTRL_EntityKind_Module)
|
||||||
{
|
{
|
||||||
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
CTRL_EntityArray processes = ctrl_entity_array_from_kind(&d_user_state->ctrl_entity_store->ctx, CTRL_EntityKind_Process);
|
||||||
if(processes.count > 1)
|
if(processes.count > 1)
|
||||||
{
|
{
|
||||||
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process);
|
CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process);
|
||||||
@@ -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);
|
||||||
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
CTRL_Entity *selected_thread = ctrl_entity_from_handle(&d_user_state->ctrl_entity_store->ctx, rd_regs()->thread);
|
||||||
CTRL_Entity *selected_thread_process = ctrl_entity_ancestor_from_kind(selected_thread, CTRL_EntityKind_Process);
|
CTRL_Entity *selected_thread_process = ctrl_entity_ancestor_from_kind(selected_thread, CTRL_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);
|
||||||
CTRL_Entity *selected_thread_module = ctrl_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr);
|
CTRL_Entity *selected_thread_module = ctrl_module_from_process_vaddr(selected_thread_process, selected_thread_rip_unwind_vaddr);
|
||||||
CTRL_Event stop_event = d_ctrl_last_stop_event();
|
CTRL_Event stop_event = d_ctrl_last_stop_event();
|
||||||
CTRL_Entity *stopper_thread = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, stop_event.entity);
|
CTRL_Entity *stopper_thread = ctrl_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_state->ctrl_entity_store->ctx, rd_state->drag_drop_regs->thread);
|
drop_thread = ctrl_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)
|
||||||
{
|
{
|
||||||
@@ -2272,8 +2272,8 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
|||||||
D_LineList *lines = ¶ms->line_infos[line_idx];
|
D_LineList *lines = ¶ms->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)
|
||||||
{
|
{
|
||||||
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
CTRL_EntityList modules = ctrl_modules_from_dbgi_key(scratch.arena, &d_user_state->ctrl_entity_store->ctx, n->v.dbgi_key);
|
||||||
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_state->ctrl_entity_store->ctx, thread, &modules);
|
CTRL_Entity *module = ctrl_module_from_thread_candidates(&d_user_state->ctrl_entity_store->ctx, thread, &modules);
|
||||||
if(module != &ctrl_entity_nil)
|
if(module != &ctrl_entity_nil)
|
||||||
{
|
{
|
||||||
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
new_rip_vaddr = ctrl_vaddr_from_voff(module, n->v.voff_range.min);
|
||||||
@@ -2659,7 +2659,7 @@ 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)
|
||||||
{
|
{
|
||||||
CTRL_Entity *module = ctrl_entity_from_handle(&d_state->ctrl_entity_store->ctx, hover_regs->module);
|
CTRL_Entity *module = ctrl_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 = ctrl_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));
|
||||||
|
|||||||
@@ -9,12 +9,11 @@
|
|||||||
#define BUILD_CONSOLE_INTERFACE 1
|
#define BUILD_CONSOLE_INTERFACE 1
|
||||||
#define OS_FEATURE_GRAPHICAL 1
|
#define OS_FEATURE_GRAPHICAL 1
|
||||||
#define DMN_INIT_MANUAL 1
|
#define DMN_INIT_MANUAL 1
|
||||||
#define CTRL_INIT_MANUAL 1
|
#define D_INIT_MANUAL 1
|
||||||
#define OS_GFX_INIT_MANUAL 1
|
#define OS_GFX_INIT_MANUAL 1
|
||||||
#define FP_INIT_MANUAL 1
|
#define FP_INIT_MANUAL 1
|
||||||
#define R_INIT_MANUAL 1
|
#define R_INIT_MANUAL 1
|
||||||
#define FNT_INIT_MANUAL 1
|
#define FNT_INIT_MANUAL 1
|
||||||
#define D_INIT_MANUAL 1
|
|
||||||
#define RD_INIT_MANUAL 1
|
#define RD_INIT_MANUAL 1
|
||||||
#define NO_ASYNC 1
|
#define NO_ASYNC 1
|
||||||
|
|
||||||
@@ -69,14 +68,13 @@
|
|||||||
#include "stap/stap_parse.h"
|
#include "stap/stap_parse.h"
|
||||||
#include "demon/demon_inc.h"
|
#include "demon/demon_inc.h"
|
||||||
#include "eval/eval_inc.h"
|
#include "eval/eval_inc.h"
|
||||||
|
#include "dbg_engine/dbg_engine_inc.h"
|
||||||
#include "eval_visualization/eval_visualization_inc.h"
|
#include "eval_visualization/eval_visualization_inc.h"
|
||||||
#include "ctrl/ctrl_inc.h"
|
|
||||||
#include "font_provider/font_provider_inc.h"
|
#include "font_provider/font_provider_inc.h"
|
||||||
#include "render/render_inc.h"
|
#include "render/render_inc.h"
|
||||||
#include "font_cache/font_cache.h"
|
#include "font_cache/font_cache.h"
|
||||||
#include "draw/draw.h"
|
#include "draw/draw.h"
|
||||||
#include "ui/ui_inc.h"
|
#include "ui/ui_inc.h"
|
||||||
#include "dbg_engine/dbg_engine_inc.h"
|
|
||||||
#include "raddbg/raddbg_inc.h"
|
#include "raddbg/raddbg_inc.h"
|
||||||
#include "linker/base_ext/base_crc32.h"
|
#include "linker/base_ext/base_crc32.h"
|
||||||
#include "linker/base_ext/base_core.h"
|
#include "linker/base_ext/base_core.h"
|
||||||
@@ -142,14 +140,13 @@
|
|||||||
#include "stap/stap_parse.c"
|
#include "stap/stap_parse.c"
|
||||||
#include "demon/demon_inc.c"
|
#include "demon/demon_inc.c"
|
||||||
#include "eval/eval_inc.c"
|
#include "eval/eval_inc.c"
|
||||||
|
#include "dbg_engine/dbg_engine_inc.c"
|
||||||
#include "eval_visualization/eval_visualization_inc.c"
|
#include "eval_visualization/eval_visualization_inc.c"
|
||||||
#include "ctrl/ctrl_inc.c"
|
|
||||||
#include "font_provider/font_provider_inc.c"
|
#include "font_provider/font_provider_inc.c"
|
||||||
#include "render/render_inc.c"
|
#include "render/render_inc.c"
|
||||||
#include "font_cache/font_cache.c"
|
#include "font_cache/font_cache.c"
|
||||||
#include "draw/draw.c"
|
#include "draw/draw.c"
|
||||||
#include "ui/ui_inc.c"
|
#include "ui/ui_inc.c"
|
||||||
#include "dbg_engine/dbg_engine_inc.c"
|
|
||||||
#include "raddbg/raddbg_inc.c"
|
#include "raddbg/raddbg_inc.c"
|
||||||
#include "linker/base_ext/base_core.c"
|
#include "linker/base_ext/base_core.c"
|
||||||
#include "linker/base_ext/base_arena.c"
|
#include "linker/base_ext/base_arena.c"
|
||||||
|
|||||||
Reference in New Issue
Block a user