Skip to content

Commit

Permalink
Adjust IP after an AV during an STEP with FEATURE_EMULATE_SINGLESTEP …
Browse files Browse the repository at this point in the history
…enabled (dotnet#105633)

Fix step in a line that will throw an AV
  • Loading branch information
thaystg authored Jul 31, 2024
1 parent 91154ba commit 0f05719
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/debug/ee/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3232,7 +3232,7 @@ void DebuggerController::UnapplyTraceFlag(Thread *thread)
// so there should be nothing to do. However, we still assert b/c we want to know how
// we'd actually hit this.
// @todo - is there a path if TriggerUnwind() calls DisableAll(). But why would
CONSISTENCY_CHECK_MSGF(false, ("How did we get here?. thread=%p\n", thread));
//CONSISTENCY_CHECK_MSGF(false, ("How did we get here?. thread=%p\n", thread)); it can be caused in a scenario where we are stepping and an AV is thrown
LOG((LF_CORDB,LL_INFO1000, "DC::UnapplyTraceFlag couldn't get context.\n"));
return;
}
Expand Down
11 changes: 11 additions & 0 deletions src/coreclr/vm/exceptionhandling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,17 @@ BOOL IsSafeToCallExecutionManager()

BOOL IsSafeToHandleHardwareException(PCONTEXT contextRecord, PEXCEPTION_RECORD exceptionRecord)
{
#ifdef FEATURE_EMULATE_SINGLESTEP
Thread *pThread = GetThreadNULLOk();
if (pThread && pThread->IsSingleStepEnabled() &&
exceptionRecord->ExceptionCode != STATUS_BREAKPOINT &&
exceptionRecord->ExceptionCode != STATUS_SINGLE_STEP &&
exceptionRecord->ExceptionCode != STATUS_STACK_OVERFLOW)
{
pThread->HandleSingleStep(contextRecord, exceptionRecord->ExceptionCode);
}
#endif

PCODE controlPc = GetIP(contextRecord);

if (IsIPInWriteBarrierCodeCopy(controlPc))
Expand Down

0 comments on commit 0f05719

Please sign in to comment.