Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@e6d6de4f86] [MERGE #3006 @mrkmarron] TT…
Browse files Browse the repository at this point in the history
…D -- Correct behavior around unhandled exception & debugger

Merge pull request #3006 from mrkmarron:TTDUnhandledException
  • Loading branch information
chakrabot authored and kfarnung committed Jun 5, 2017
1 parent c4062ed commit 13e19f4
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
22 changes: 19 additions & 3 deletions deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ namespace TTD
ExecutionInfoManager::ExecutionInfoManager()
: m_topLevelCallbackEventTime(-1), m_runningFunctionTimeCtr(0), m_callStack(&HeapAllocator::Instance),
m_debuggerNotifiedTopLevelBodies(&HeapAllocator::Instance),
m_lastReturnLocation(),
m_lastReturnLocation(), m_lastExceptionPropagating(false), m_lastExceptionLocation(),
m_breakOnFirstUserCode(false),
m_pendingTTDBP(), m_pendingTTDMoveMode(-1), m_activeBPId(-1), m_shouldRemoveWhenDone(false), m_activeTTDBP(),
m_hitContinueSearchBP(false), m_continueBreakPoint(),
Expand Down Expand Up @@ -537,6 +537,12 @@ namespace TTD
this->m_lastReturnLocation.SetExceptionLocation(this->m_callStack.Last());
}

if(!m_lastExceptionPropagating)
{
this->m_lastExceptionLocation.SetLocationFromFrame(this->m_topLevelCallbackEventTime, this->m_callStack.Last());
this->m_lastExceptionPropagating = true;
}

this->m_runningFunctionTimeCtr++;
this->m_callStack.RemoveAtEnd();

Expand All @@ -545,9 +551,11 @@ namespace TTD
#endif
}

void ExecutionInfoManager::ClearExceptionFrames()
void ExecutionInfoManager::ProcessCatchInfoForLastExecutedStatements()
{
this->m_lastReturnLocation.Clear();

this->m_lastExceptionPropagating = false;
}

void ExecutionInfoManager::SetBreakOnFirstUserCode()
Expand Down Expand Up @@ -579,7 +587,8 @@ namespace TTD

void ExecutionInfoManager::SetPendingTTDUnhandledException()
{
this->GetLastExecutedTimeAndPositionForDebugger(this->m_pendingTTDBP);
this->GetLastExceptionTimeAndPositionForDebugger(this->m_pendingTTDBP);
this->m_lastExceptionPropagating = false;

this->m_pendingTTDMoveMode = 0;
}
Expand Down Expand Up @@ -928,6 +937,12 @@ namespace TTD
}
}

void ExecutionInfoManager::GetLastExceptionTimeAndPositionForDebugger(TTDebuggerSourceLocation& sourceLocation) const
{
//If no exception then this will also clear sourceLocation
sourceLocation.SetLocationCopy(this->m_lastExceptionLocation);
}

void ExecutionInfoManager::ResetCallStackForTopLevelCall(int64 topLevelCallbackEventTime)
{
TTDAssert(this->m_callStack.Count() == 0, "We should be at the top-level entry!!!");
Expand All @@ -936,6 +951,7 @@ namespace TTD

this->m_runningFunctionTimeCtr = 0;
this->m_lastReturnLocation.Clear();
this->m_lastExceptionLocation.Clear();
}

void ExecutionInfoManager::SetBPInfoForActiveSegmentContinueScan(ThreadContextTTD* ttdThreadContext)
Expand Down
7 changes: 6 additions & 1 deletion deps/chakrashim/core/lib/Runtime/Debug/TTExecutionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ namespace TTD
// - Step back *into* possible if either case is true
TTLastReturnLocationInfo m_lastReturnLocation;

//Always keep the last exception location as well -- even if it is caught
bool m_lastExceptionPropagating;
TTDebuggerSourceLocation m_lastExceptionLocation;

//A flag indicating if we want to break on the entry to the user code
bool m_breakOnFirstUserCode;

Expand Down Expand Up @@ -237,7 +241,7 @@ namespace TTD
void PopCallEvent(Js::JavascriptFunction* function, Js::Var result);
void PopCallEventException(Js::JavascriptFunction* function);

void ClearExceptionFrames();
void ProcessCatchInfoForLastExecutedStatements();

//Set that we want to break on the execution of the first user code
void SetBreakOnFirstUserCode();
Expand Down Expand Up @@ -295,6 +299,7 @@ namespace TTD
//Get the last (uncaught or just caught) exception time/position for the debugger -- if the last return action was an exception and we have not made any additional calls
//Otherwise get the last statement executed call time/position for the debugger
void GetLastExecutedTimeAndPositionForDebugger(TTDebuggerSourceLocation& sourceLocation) const;
void GetLastExceptionTimeAndPositionForDebugger(TTDebuggerSourceLocation& sourceLocation) const;

//Ensure the call stack is clear and counters are zeroed appropriately
void ResetCallStackForTopLevelCall(int64 topLevelCallbackEventTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6645,7 +6645,7 @@ const byte * InterpreterStackFrame::OP_ProfiledLoopBodyStart(const byte * ip)
//Clear any previous Exception Info
if(SHOULD_DO_TTD_STACK_STMT_OP(this->scriptContext))
{
this->scriptContext->GetThreadContext()->TTDExecutionInfo->ClearExceptionFrames();
this->scriptContext->GetThreadContext()->TTDExecutionInfo->ProcessCatchInfoForLastExecutedStatements();
}
#endif

Expand Down

0 comments on commit 13e19f4

Please sign in to comment.