adjust thread-selection-on-stop & thread-snapping rules, to prevent useless disasm snaps & incorrect thread selections in some edge cases

This commit is contained in:
Ryan Fleury
2024-12-02 09:44:50 -08:00
parent 0c86580e1e
commit a827c74501
3 changed files with 39 additions and 44 deletions
+14 -3
View File
@@ -1716,12 +1716,23 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
// rjf: push stop event to caller, if this is not a soft-halt
if(should_snap)
{
CTRL_Entity *thread = ctrl_entity_from_handle(d_state->ctrl_entity_store, event->entity);
D_EventCause cause = D_EventCause_Null;
switch(event->cause)
{
default:{}break;
case CTRL_EventCause_InterruptedByHalt:{cause = D_EventCause_Halt;}break;
case CTRL_EventCause_UserBreakpoint:{cause = D_EventCause_UserBreakpoint;}break;
case CTRL_EventCause_InterruptedByHalt:
{
if(should_snap)
{
cause = D_EventCause_Halt;
}
else
{
cause = D_EventCause_SoftHalt;
}
}break;
case CTRL_EventCause_UserBreakpoint: {cause = D_EventCause_UserBreakpoint;}break;
}
D_EventNode *n = push_array(arena, D_EventNode, 1);
SLLQueuePush(result.first, result.last, n);
@@ -1729,7 +1740,7 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, D_P
D_Event *evt = &n->v;
evt->kind = D_EventKind_Stop;
evt->cause = cause;
evt->thread = event->entity;
evt->thread = thread->kind == CTRL_EntityKind_Thread ? thread->handle : ctrl_handle_zero();
evt->vaddr = event->rip_vaddr;
}
}break;
+1
View File
@@ -76,6 +76,7 @@ typedef enum D_EventCause
D_EventCause_Null,
D_EventCause_UserBreakpoint,
D_EventCause_Halt,
D_EventCause_SoftHalt,
D_EventCause_COUNT
}
D_EventCause;