mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-07 22:38:41 +00:00
extend process memory cache queries with output channel for staleness detection - in some cases this is crucial, in other cases you don't care & want to passively accept stale redsults
This commit is contained in:
+24
-15
@@ -896,7 +896,7 @@ ctrl_hash_store_key_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Hand
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U128
|
internal U128
|
||||||
ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated, U64 endt_us)
|
ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated, B32 *out_is_stale, U64 endt_us)
|
||||||
{
|
{
|
||||||
U128 result = {0};
|
U128 result = {0};
|
||||||
U64 size = dim_1u64(range);
|
U64 size = dim_1u64(range);
|
||||||
@@ -1033,6 +1033,10 @@ ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle
|
|||||||
//- rjf: out of time? -> exit
|
//- rjf: out of time? -> exit
|
||||||
if(os_now_microseconds() >= endt_us)
|
if(os_now_microseconds() >= endt_us)
|
||||||
{
|
{
|
||||||
|
if(is_good && is_stale && out_is_stale)
|
||||||
|
{
|
||||||
|
out_is_stale[0] = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,8 +1076,10 @@ ctrl_query_cached_data_from_process_vaddr_range(Arena *arena, CTRL_MachineID mac
|
|||||||
{
|
{
|
||||||
U64 page_base_vaddr = page_range.min + page_idx*page_size;
|
U64 page_base_vaddr = page_range.min + page_idx*page_size;
|
||||||
U128 page_key = ctrl_hash_store_key_from_process_vaddr_range(machine_id, process, r1u64(page_base_vaddr, page_base_vaddr+page_size), 0);
|
U128 page_key = ctrl_hash_store_key_from_process_vaddr_range(machine_id, process, r1u64(page_base_vaddr, page_base_vaddr+page_size), 0);
|
||||||
U128 page_hash = ctrl_stored_hash_from_process_vaddr_range(machine_id, process, r1u64(page_base_vaddr, page_base_vaddr+page_size), 0, endt_us);
|
B32 page_is_stale = 0;
|
||||||
|
U128 page_hash = ctrl_stored_hash_from_process_vaddr_range(machine_id, process, r1u64(page_base_vaddr, page_base_vaddr+page_size), 0, &page_is_stale, endt_us);
|
||||||
U128 page_last_hash = hs_hash_from_key(page_key, 1);
|
U128 page_last_hash = hs_hash_from_key(page_key, 1);
|
||||||
|
result.stale = (result.stale || page_is_stale);
|
||||||
page_hashes[page_idx] = page_hash;
|
page_hashes[page_idx] = page_hash;
|
||||||
page_last_hashes[page_idx] = page_last_hash;
|
page_last_hashes[page_idx] = page_last_hash;
|
||||||
}
|
}
|
||||||
@@ -1399,21 +1405,19 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID ma
|
|||||||
ProfBeginFunction();
|
ProfBeginFunction();
|
||||||
Temp scratch = scratch_begin(&arena, 1);
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
DBGI_Scope *scope = dbgi_scope_open();
|
DBGI_Scope *scope = dbgi_scope_open();
|
||||||
|
CTRL_Unwind unwind = {0};
|
||||||
|
unwind.error = 1;
|
||||||
|
|
||||||
|
//- rjf: unpack args
|
||||||
CTRL_Entity *thread_entity = ctrl_entity_from_machine_id_handle(store, machine_id, thread);
|
CTRL_Entity *thread_entity = ctrl_entity_from_machine_id_handle(store, machine_id, thread);
|
||||||
CTRL_Entity *process_entity = thread_entity->parent;
|
CTRL_Entity *process_entity = thread_entity->parent;
|
||||||
Architecture arch = thread_entity->arch;
|
Architecture arch = thread_entity->arch;
|
||||||
U64 arch_reg_block_size = regs_block_size_from_architecture(arch);
|
U64 arch_reg_block_size = regs_block_size_from_architecture(arch);
|
||||||
CTRL_Unwind unwind = {0};
|
|
||||||
unwind.error = 1;
|
//- rjf: grab initial register block
|
||||||
switch(arch)
|
|
||||||
{
|
|
||||||
default:{}break;
|
|
||||||
case Architecture_x64:
|
|
||||||
{
|
|
||||||
// rjf: grab initial register block
|
|
||||||
void *regs_block = ctrl_query_cached_reg_block_from_thread(scratch.arena, machine_id, thread);
|
void *regs_block = ctrl_query_cached_reg_block_from_thread(scratch.arena, machine_id, thread);
|
||||||
|
|
||||||
// rjf: grab initial memory view
|
//- rjf: grab initial memory view
|
||||||
B32 stack_memview_good = 0;
|
B32 stack_memview_good = 0;
|
||||||
UNW_MemView stack_memview = {0};
|
UNW_MemView stack_memview = {0};
|
||||||
{
|
{
|
||||||
@@ -1426,7 +1430,7 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID ma
|
|||||||
{
|
{
|
||||||
CTRL_ProcessMemorySlice stack_memory_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, machine_id, process_entity->handle, r1u64(stack_top, stack_top+stack_size), endt_us);
|
CTRL_ProcessMemorySlice stack_memory_slice = ctrl_query_cached_data_from_process_vaddr_range(scratch.arena, machine_id, process_entity->handle, r1u64(stack_top, stack_top+stack_size), endt_us);
|
||||||
String8 stack_memory = stack_memory_slice.data;
|
String8 stack_memory = stack_memory_slice.data;
|
||||||
if(stack_memory.size != 0 && !stack_memory_slice.any_byte_bad)
|
if(stack_memory.size != 0 && !stack_memory_slice.any_byte_bad && !stack_memory_slice.stale)
|
||||||
{
|
{
|
||||||
stack_memview_good = 1;
|
stack_memview_good = 1;
|
||||||
stack_memview.data = stack_memory.str;
|
stack_memview.data = stack_memory.str;
|
||||||
@@ -1436,12 +1440,16 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID ma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: loop & unwind
|
//- rjf: loop & unwind
|
||||||
UNW_MemView memview = stack_memview;
|
UNW_MemView memview = stack_memview;
|
||||||
if(stack_memview_good) for(;;)
|
if(stack_memview_good) switch(arch)
|
||||||
|
{
|
||||||
|
default:{}break;
|
||||||
|
case Architecture_x64:
|
||||||
{
|
{
|
||||||
unwind.error = 0;
|
unwind.error = 0;
|
||||||
|
for(;;)
|
||||||
|
{
|
||||||
// rjf: regs -> rip*module
|
// rjf: regs -> rip*module
|
||||||
U64 rip = regs_rip_from_arch_block(arch, regs_block);
|
U64 rip = regs_rip_from_arch_block(arch, regs_block);
|
||||||
DMN_Handle module = {0};
|
DMN_Handle module = {0};
|
||||||
@@ -1504,6 +1512,7 @@ ctrl_unwind_from_thread(Arena *arena, CTRL_EntityStore *store, CTRL_MachineID ma
|
|||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbgi_scope_close(scope);
|
dbgi_scope_close(scope);
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
ProfEnd();
|
ProfEnd();
|
||||||
|
|||||||
@@ -429,6 +429,7 @@ struct CTRL_ProcessMemorySlice
|
|||||||
String8 data;
|
String8 data;
|
||||||
U64 *byte_bad_flags;
|
U64 *byte_bad_flags;
|
||||||
U64 *byte_changed_flags;
|
U64 *byte_changed_flags;
|
||||||
|
B32 stale;
|
||||||
B32 any_byte_bad;
|
B32 any_byte_bad;
|
||||||
B32 any_byte_changed;
|
B32 any_byte_changed;
|
||||||
};
|
};
|
||||||
@@ -636,7 +637,7 @@ internal void ctrl_set_wakeup_hook(CTRL_WakeupFunctionType *wakeup_hook);
|
|||||||
|
|
||||||
//- rjf: process memory cache interaction
|
//- rjf: process memory cache interaction
|
||||||
internal U128 ctrl_hash_store_key_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated);
|
internal U128 ctrl_hash_store_key_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated);
|
||||||
internal U128 ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated, U64 endt_us);
|
internal U128 ctrl_stored_hash_from_process_vaddr_range(CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, B32 zero_terminated, B32 *out_is_stale, U64 endt_us);
|
||||||
|
|
||||||
//- rjf: process memory cache reading helpers
|
//- rjf: process memory cache reading helpers
|
||||||
internal CTRL_ProcessMemorySlice ctrl_query_cached_data_from_process_vaddr_range(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, U64 endt_us);
|
internal CTRL_ProcessMemorySlice ctrl_query_cached_data_from_process_vaddr_range(Arena *arena, CTRL_MachineID machine_id, DMN_Handle process, Rng1U64 range, U64 endt_us);
|
||||||
|
|||||||
@@ -6867,7 +6867,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: collect s top info
|
// rjf: collect stop info
|
||||||
arena_clear(df_state->ctrl_stop_arena);
|
arena_clear(df_state->ctrl_stop_arena);
|
||||||
MemoryCopyStruct(&df_state->ctrl_last_stop_event, event);
|
MemoryCopyStruct(&df_state->ctrl_last_stop_event, event);
|
||||||
df_state->ctrl_last_stop_event.string = push_str8_copy(df_state->ctrl_stop_arena, df_state->ctrl_last_stop_event.string);
|
df_state->ctrl_last_stop_event.string = push_str8_copy(df_state->ctrl_stop_arena, df_state->ctrl_last_stop_event.string);
|
||||||
|
|||||||
@@ -700,7 +700,7 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: address range -> hash
|
//- rjf: address range -> hash
|
||||||
U128 hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vaddr_range, 1, 0);
|
U128 hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vaddr_range, 1, 0, 0);
|
||||||
|
|
||||||
//- rjf: hash -> data
|
//- rjf: hash -> data
|
||||||
String8 data = hs_data_from_hash(hs_scope, hash);
|
String8 data = hs_data_from_hash(hs_scope, hash);
|
||||||
@@ -891,7 +891,7 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(bitmap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: address range -> hash
|
//- rjf: address range -> hash
|
||||||
U128 hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vaddr_range, 0, 0);
|
U128 hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vaddr_range, 0, 0, 0);
|
||||||
|
|
||||||
//- rjf: hash & topology -> texture
|
//- rjf: hash & topology -> texture
|
||||||
TEX_Topology topology = tex_topology_make(v2s32((S32)topology_info.width, (S32)topology_info.height), topology_info.fmt);
|
TEX_Topology topology = tex_topology_make(v2s32((S32)topology_info.width, (S32)topology_info.height), topology_info.fmt);
|
||||||
@@ -1151,8 +1151,8 @@ DF_GFX_VIEW_RULE_BLOCK_UI_FUNCTION_DEF(geo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//- rjf: address range -> hash
|
//- rjf: address range -> hash
|
||||||
U128 index_buffer_hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, index_buffer_vaddr_range, 0, 0);
|
U128 index_buffer_hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, index_buffer_vaddr_range, 0, 0, 0);
|
||||||
U128 vertex_buffer_hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vertex_buffer_vaddr_range, 0, 0);
|
U128 vertex_buffer_hash = ctrl_stored_hash_from_process_vaddr_range(process->ctrl_machine_id, process->ctrl_handle, vertex_buffer_vaddr_range, 0, 0, 0);
|
||||||
|
|
||||||
//- rjf: get gpu buffers
|
//- rjf: get gpu buffers
|
||||||
R_Handle index_buffer = geo_buffer_from_key_hash(geo_scope, index_buffer_key, index_buffer_hash);
|
R_Handle index_buffer = geo_buffer_from_key_hash(geo_scope, index_buffer_key, index_buffer_hash);
|
||||||
|
|||||||
Reference in New Issue
Block a user