mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
adjust control thread single-step path to be a bit more robust to malformed requests
This commit is contained in:
+11
-7
@@ -5533,10 +5533,12 @@ ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
}
|
||||
|
||||
//- rjf: single step
|
||||
DMN_Handle thread = msg->entity.dmn_handle;
|
||||
B32 thread_is_valid = !dmn_handle_match(thread, dmn_handle_zero());
|
||||
DMN_Event *stop_event = 0;
|
||||
CTRL_EventCause stop_cause = CTRL_EventCause_Null;
|
||||
if(thread_is_valid)
|
||||
{
|
||||
DMN_Handle thread = msg->entity.dmn_handle;
|
||||
U64 thread_pre_rip = dmn_rip_from_thread(thread);
|
||||
U64 thread_post_rip = thread_pre_rip;
|
||||
for(B32 done = 0; done == 0;)
|
||||
@@ -5570,17 +5572,19 @@ ctrl_thread__single_step(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
||||
}
|
||||
|
||||
//- rjf: record stop
|
||||
if(stop_event != 0)
|
||||
{
|
||||
CTRL_EventList evts = {0};
|
||||
CTRL_Event *event = ctrl_event_list_push(scratch.arena, &evts);
|
||||
event->kind = CTRL_EventKind_Stopped;
|
||||
event->cause = stop_cause;
|
||||
event->entity = ctrl_handle_make(CTRL_MachineID_Local, stop_event->thread);
|
||||
event->parent = ctrl_handle_make(CTRL_MachineID_Local, stop_event->process);
|
||||
event->exception_code = stop_event->code;
|
||||
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
|
||||
event->rip_vaddr = stop_event->instruction_pointer;
|
||||
if(stop_event != 0)
|
||||
{
|
||||
event->entity = ctrl_handle_make(CTRL_MachineID_Local, stop_event->thread);
|
||||
event->parent = ctrl_handle_make(CTRL_MachineID_Local, stop_event->process);
|
||||
event->exception_code = stop_event->code;
|
||||
event->vaddr_rng = r1u64(stop_event->address, stop_event->address);
|
||||
event->rip_vaddr = stop_event->instruction_pointer;
|
||||
}
|
||||
ctrl_c2u_push_events(&evts);
|
||||
}
|
||||
|
||||
|
||||
@@ -2148,23 +2148,26 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
{
|
||||
B32 good_to_run = 0;
|
||||
CTRL_EntityList threads = ctrl_entity_list_from_kind(d_state->ctrl_entity_store, CTRL_EntityKind_Thread);
|
||||
for(CTRL_EntityNode *n = threads.first; n != 0; n = n->next)
|
||||
if(threads.count > 0)
|
||||
{
|
||||
if(!n->v->is_frozen)
|
||||
for(CTRL_EntityNode *n = threads.first; n != 0; n = n->next)
|
||||
{
|
||||
good_to_run = 1;
|
||||
break;
|
||||
if(!n->v->is_frozen)
|
||||
{
|
||||
good_to_run = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(good_to_run)
|
||||
{
|
||||
need_run = 1;
|
||||
run_kind = D_RunKind_Run;
|
||||
run_thread = &ctrl_entity_nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_user_error(str8_lit("Cannot run with all threads frozen."));
|
||||
}
|
||||
}
|
||||
if(good_to_run)
|
||||
{
|
||||
need_run = 1;
|
||||
run_kind = D_RunKind_Run;
|
||||
run_thread = &ctrl_entity_nil;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_user_error(str8_lit("Cannot run with all threads frozen."));
|
||||
}
|
||||
}break;
|
||||
case D_CmdKind_StepIntoInst:
|
||||
@@ -2174,7 +2177,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
|
||||
case D_CmdKind_StepOut:
|
||||
{
|
||||
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, params->thread);
|
||||
if(d_ctrl_targets_running())
|
||||
if(thread == &ctrl_entity_nil)
|
||||
{
|
||||
log_user_error(str8_lit("Must have a selected thread to step."));
|
||||
}
|
||||
else if(d_ctrl_targets_running())
|
||||
{
|
||||
if(d_ctrl_last_run_kind() == D_RunKind_Run)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user