From 7a44cbbd0dda029bf8c22cd8901012cb012b4883 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Sat, 17 May 2025 08:41:51 -0700 Subject: [PATCH] adjust high priority call stack timeout threshold --- src/ctrl/ctrl_core.c | 2 +- src/ctrl/ctrl_core.h | 2 +- src/raddbg/raddbg_core.c | 5 +++-- src/raddbg/raddbg_eval.c | 3 ++- src/raddbg/raddbg_views.c | 3 ++- src/raddbg/raddbg_widgets.c | 3 ++- 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ctrl/ctrl_core.c b/src/ctrl/ctrl_core.c index ee65d2ec..249fbb5f 100644 --- a/src/ctrl/ctrl_core.c +++ b/src/ctrl/ctrl_core.c @@ -6907,7 +6907,7 @@ ASYNC_WORK_DEF(ctrl_call_stack_build_work) { pre_reg_gen = ctrl_reg_gen(); pre_mem_gen = ctrl_mem_gen(); - unwind = ctrl_unwind_from_thread(arena, entity_ctx, thread_handle, os_now_microseconds()+1000); + unwind = ctrl_unwind_from_thread(arena, entity_ctx, thread_handle, os_now_microseconds()+5000); call_stack = ctrl_call_stack_from_unwind(arena, process, &unwind); post_reg_gen = ctrl_reg_gen(); post_mem_gen = ctrl_mem_gen(); diff --git a/src/ctrl/ctrl_core.h b/src/ctrl/ctrl_core.h index 00c83aae..3b2e1405 100644 --- a/src/ctrl/ctrl_core.h +++ b/src/ctrl/ctrl_core.h @@ -617,7 +617,7 @@ struct CTRL_CallStackCacheNode U64 reg_gen; U64 mem_gen; - // rjf: refcounts + // rjf: counters U64 scope_touch_count; U64 working_count; diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index a68fb50d..6dece756 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1816,7 +1816,7 @@ rd_eval_space_read(void *u, E_Space space, void *out, Rng1U64 range) case CTRL_EntityKind_Thread: { CTRL_Scope *ctrl_scope = ctrl_scope_open(); - CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, 1, 0); + CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, 1, rd_state->frame_eval_memread_endt_us); U64 concrete_frame_idx = e_interpret_ctx->reg_unwind_count; if(concrete_frame_idx < call_stack.concrete_frames_count) { @@ -6399,7 +6399,8 @@ rd_window_frame(void) Vec4F32 code_color = ui_color_from_name(str8_lit("code_default")); Vec4F32 symbol_color = ui_color_from_name(str8_lit("code_symbol")); CTRL_Entity *process = ctrl_entity_ancestor_from_kind(ctrl_entity, CTRL_EntityKind_Process); - CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, ctrl_entity, ctrl_handle_match(ctrl_entity->handle, rd_base_regs()->thread), 0); + B32 call_stack_high_priority = ctrl_handle_match(ctrl_entity->handle, rd_base_regs()->thread); + CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, ctrl_entity, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); if(call_stack.frames_count != 0) { ui_spacer(ui_em(1.5f, 1.f)); diff --git a/src/raddbg/raddbg_eval.c b/src/raddbg/raddbg_eval.c index 6e68bc68..f67da862 100644 --- a/src/raddbg/raddbg_eval.c +++ b/src/raddbg/raddbg_eval.c @@ -955,9 +955,10 @@ E_TYPE_IREXT_FUNCTION_DEF(call_stack) CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(interp.space); if(entity->kind == CTRL_EntityKind_Thread) { + B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); accel->arch = entity->arch; accel->process = ctrl_process_from_entity(entity)->handle; - accel->call_stack = ctrl_call_stack_from_thread(rd_state->frame_ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, ctrl_handle_match(entity->handle, rd_base_regs()->thread), 0); + accel->call_stack = ctrl_call_stack_from_thread(rd_state->frame_ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); } scratch_end(scratch); } diff --git a/src/raddbg/raddbg_views.c b/src/raddbg/raddbg_views.c index 2f4a461e..177f9bd5 100644 --- a/src/raddbg/raddbg_views.c +++ b/src/raddbg/raddbg_views.c @@ -1011,7 +1011,8 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row) CTRL_Scope *ctrl_scope = ctrl_scope_open(); info.callstack_thread = entity; U64 frame_num = ev_block_num_from_id(block, key.child_id); - CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, ctrl_handle_match(entity->handle, rd_base_regs()->thread), 0); + B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); + CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); if(1 <= frame_num && frame_num <= call_stack.frames_count) { CTRL_CallStackFrame *f = &call_stack.frames[frame_num-1]; diff --git a/src/raddbg/raddbg_widgets.c b/src/raddbg/raddbg_widgets.c index 44a0dfc4..5cd62bbc 100644 --- a/src/raddbg/raddbg_widgets.c +++ b/src/raddbg/raddbg_widgets.c @@ -525,7 +525,8 @@ rd_title_fstrs_from_ctrl_entity(Arena *arena, CTRL_Entity *entity, B32 include_e DI_Scope *di_scope = di_scope_open(); CTRL_Entity *process = ctrl_entity_ancestor_from_kind(entity, CTRL_EntityKind_Process); Arch arch = entity->arch; - CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, ctrl_handle_match(entity->handle, rd_base_regs()->thread), 0); + B32 call_stack_high_priority = ctrl_handle_match(entity->handle, rd_base_regs()->thread); + CTRL_CallStack call_stack = ctrl_call_stack_from_thread(ctrl_scope, &d_state->ctrl_entity_store->ctx, entity, call_stack_high_priority, call_stack_high_priority ? rd_state->frame_eval_memread_endt_us : 0); for(U64 idx = 0, limit = 6; idx < call_stack.frames_count && idx < limit; idx += 1) { CTRL_CallStackFrame *f = &call_stack.frames[call_stack.frames_count - 1 - idx];