Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 2 additions & 10 deletions src/coreclr/debug/daccess/dacdbiimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4795,7 +4795,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::HasUnhandledException(VMPTR_Threa
{
// most managed exceptions are just a throwable bound to a
// native exception. In that case this handle will be non-null
OBJECTHANDLE ohException = pThread->GetThrowableAsPseudoHandle();
OBJECTHANDLE ohException = pThread->GetThrowableHandle(ThrowableSource::ExInfoOnly);
if (ohException != (OBJECTHANDLE)NULL)
{
// during the UEF we set the unhandled bit, if it is set the exception
Expand Down Expand Up @@ -4932,15 +4932,7 @@ HRESULT STDMETHODCALLTYPE DacDbiInterfaceImpl::GetCurrentException(VMPTR_Thread

Thread * pThread = vmThread.GetDacPtr();

OBJECTHANDLE ohException = pThread->GetThrowableAsPseudoHandle();

if (ohException == (OBJECTHANDLE)NULL)
{
if (pThread->IsLastThrownObjectUnhandled())
{
ohException = pThread->LastThrownObjectHandle();
}
}
OBJECTHANDLE ohException = pThread->GetThrowableHandle(ThrowableSource::ExInfoOrLTOIfUnhandled);

VMPTR_OBJECTHANDLE vmObjHandle;
vmObjHandle.SetDacTargetPtr(ohException);
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@ HRESULT ClrDataAccess::EnumMemDumpAllThreadsStack(CLRDataEnumMemoryFlags flags)
pThread = ((ClrDataTask *)pIXCLRDataTask.GetValue())->GetThread();

// dump the exception object
DumpManagedExcepObject(flags, pThread->LastThrownObject());
DumpManagedExcepObject(flags, pThread->GetThrowableRef(ThrowableSource::ExInfoOrLTO));

// Now probe into the exception info
status = pIXCLRDataTask->GetCurrentExceptionState(&pExcepState);
Expand Down Expand Up @@ -1235,7 +1235,7 @@ HRESULT ClrDataAccess::EnumMemDumpAllThreadsStack(CLRDataEnumMemoryFlags flags)

#ifndef FEATURE_MINIMETADATA_IN_TRIAGEDUMPS
// dump the exception object
DumpManagedExcepObject(flags, pThread->LastThrownObject());
DumpManagedExcepObject(flags, pThread->GetThrowableRef(ThrowableSource::ExInfoOrLTO));
#endif // FEATURE_MINIMETADATA_IN_TRIAGEDUMPS

// Stack Walking
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ HRESULT ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThre
// from the OS thread ID via the debugger's native API (e.g., IDebuggerServices::GetThreadTeb).
threadData->teb = (CLRDATA_ADDRESS)NULL;
threadData->lastThrownObjectHandle =
TO_CDADDR(thread->m_LastThrownObjectHandle);
TO_CDADDR(thread->GetThrowableHandle(ThrowableSource::ExInfoOrLTO));
threadData->nextThread =
HOST_CDADDR(ThreadStore::s_pThreadStore->m_ThreadList.GetNext(thread));
if (thread->m_ExceptionState.m_pCurrentTracker)
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/debug/daccess/task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ ClrDataTask::GetLastExceptionState(

EX_TRY
{
if (m_thread->m_LastThrownObjectHandle)
if (!m_thread->IsThrowableNull(ThrowableSource::ExInfoOrLTO))
{
*exception = new (nothrow)
ClrDataExceptionState(m_dac,
AppDomain::GetCurrentDomain(),
m_thread,
CLRDATA_EXCEPTION_PARTIAL,
NULL,
m_thread->m_LastThrownObjectHandle,
m_thread->GetThrowableHandle(ThrowableSource::ExInfoOrLTO),
NULL);
status = *exception ? S_OK : E_OUTOFMEMORY;
}
Expand Down Expand Up @@ -4910,7 +4910,7 @@ ClrDataExceptionState::NewFromThread(ClrDataAccess* dac,
ClrDataExceptionState** exception,
IXCLRDataExceptionState** pubException)
{
if (!thread->HasException())
if (thread->IsThrowableNull(ThrowableSource::ExInfoOrLTO))
{
return E_NOINTERFACE;
}
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/debug/ee/debugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7449,7 +7449,7 @@ HRESULT Debugger::SendException(Thread *pThread,
(fFirstChance && (!pExState->GetFlags()->SentDebugFirstChance() || !pExState->GetFlags()->SentDebugUserFirstChance())));

// There must be a managed exception object to send a managed exception event
if (g_pEEInterface->IsThreadExceptionNull(pThread) && (pThread->LastThrownObjectHandle() == NULL))
if (pThread->IsThrowableNull(ThrowableSource::ExInfoOrLTO))
{
managedEventNeeded = FALSE;
}
Expand Down Expand Up @@ -7878,7 +7878,7 @@ BOOL Debugger::ShouldSendCatchHandlerFound(Thread* pThread)
else
{
BOOL forceSendCatchHandlerFound = FALSE;
OBJECTHANDLE objHandle = pThread->GetThrowableAsPseudoHandle();
OBJECTHANDLE objHandle = pThread->GetThrowableHandle(ThrowableSource::ExInfoOnly);
OBJECTHANDLE retrievedHandle = m_pForceCatchHandlerFoundEventsTable->Lookup(objHandle);
if (retrievedHandle != NULL)
{
Expand Down
16 changes: 8 additions & 8 deletions src/coreclr/vm/clrex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ OBJECTREF CLRException::GetThrowable()
}

if ((IsType(CLRLastThrownObjectException::GetType()) &&
pThread->LastThrownObject() == GetPreallocatedStackOverflowException()))
pThread->GetThrowableRef(ThrowableSource::LTOOnly) == GetPreallocatedStackOverflowException()))
{
return GetPreallocatedStackOverflowException();
}
Expand Down Expand Up @@ -596,7 +596,7 @@ OBJECTREF CLRException::GetThrowableFromException(Exception *pException)

if (NULL == pException)
{
return pThread->LastThrownObject();
return pThread->GetThrowableRef(ThrowableSource::LTOOnly);
}

if (pException->IsType(CLRException::GetType()))
Expand Down Expand Up @@ -624,7 +624,7 @@ OBJECTREF CLRException::GetThrowableFromException(Exception *pException)
// as an unrelated unmanaged exception.
if (IsComPlusException(&(pSEHException->m_exception)))
{
return pThread->LastThrownObject();
return pThread->GetThrowableRef(ThrowableSource::LTOOnly);
}
else
{
Expand Down Expand Up @@ -725,11 +725,11 @@ OBJECTREF CLRException::GetThrowableFromException(Exception *pException)
}
else
if (pNewException->IsType(CLRLastThrownObjectException::GetType()) &&
(pThread->LastThrownObject() != NULL))
!pThread->IsThrowableNull(ThrowableSource::LTOOnly))
{
STRESS_LOG0(LF_EH, LL_INFO100, "CLRException::GetThrowableFromException: LTO Exception creating throwable; getting LastThrownObject.\n");
if (oRetVal == NULL)
oRetVal = pThread->LastThrownObject();
oRetVal = pThread->GetThrowableRef(ThrowableSource::LTOOnly);
}
else
{
Expand Down Expand Up @@ -770,7 +770,7 @@ OBJECTREF CLRException::GetThrowableFromExceptionRecord(EXCEPTION_RECORD *pExcep

if (IsComPlusException(pExceptionRecord))
{
return GetThread()->LastThrownObject();
return GetThread()->GetThrowableRef(ThrowableSource::LTOOnly);
}

return NULL;
Expand Down Expand Up @@ -2004,7 +2004,7 @@ OBJECTREF CLRLastThrownObjectException::CreateThrowable()

DEBUG_STMT(Validate());

return GetThread()->LastThrownObject();
return GetThread()->GetThrowableRef(ThrowableSource::LTOOnly);
} // OBJECTREF CLRLastThrownObjectException::CreateThrowable()

#if defined(_DEBUG)
Expand All @@ -2025,7 +2025,7 @@ CLRLastThrownObjectException* CLRLastThrownObjectException::Validate()
GCPROTECT_BEGIN(throwable);

Thread * pThread = GetThread();
throwable = pThread->LastThrownObject();
throwable = pThread->GetThrowableRef(ThrowableSource::LTOOnly);

DWORD dwCurrentExceptionCode = GetCurrentExceptionCode();

Expand Down
6 changes: 1 addition & 5 deletions src/coreclr/vm/dwbucketmanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,7 @@ OBJECTREF BaseBucketParamsManager::GetRealExceptionObject()
// If it is an exception, see if there is a Throwable object.
if (m_pThread != NULL)
{
throwable = m_pThread->GetThrowable();

// If the "Throwable" is null, try the "LastThrownObject"
if (throwable == NULL)
throwable = m_pThread->LastThrownObject();
throwable = m_pThread->GetThrowableRef(ThrowableSource::ExInfoOrLTO);
}
}

Expand Down
9 changes: 3 additions & 6 deletions src/coreclr/vm/dwreport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,9 @@ UINT_PTR GetIPOfThrowSite(
// trace, it will start with the topmost (lowest address, newest) managed
// code, which is what we want.
GCX_COOP();
OBJECTREF throwable = pThread->GetThrowable();

// If there was no managed code on the stack and we are on 64-bit, then we won't have propagated
// the LastThrownObject into the Throwable yet.
if (throwable == NULL)
throwable = pThread->LastThrownObject();
// ExInfo first; fall back to LTO when no managed code was on the stack
// (e.g., 64-bit native-only callstack didn't propagate LTO into the Throwable).
OBJECTREF throwable = pThread->GetThrowableRef(ThrowableSource::ExInfoOrLTO);

_ASSERTE(throwable != NULL);
_ASSERTE(IsException(throwable->GetMethodTable()));
Expand Down
12 changes: 2 additions & 10 deletions src/coreclr/vm/eedbginterfaceimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,16 +239,8 @@ OBJECTHANDLE EEDbgInterfaceImpl::GetThreadException(Thread *pThread)
}
CONTRACTL_END;

OBJECTHANDLE oh = pThread->GetThrowableAsPseudoHandle();

if (oh != NULL)
{
return oh;
}

// Return the last thrown object if there's no current throwable.
// This logic is similar to UpdateCurrentThrowable().
return pThread->m_LastThrownObjectHandle;
return pThread->GetThrowableHandle(ThrowableSource::ExInfoOrLTO);
}

bool EEDbgInterfaceImpl::IsThreadExceptionNull(Thread *pThread)
Expand All @@ -261,7 +253,7 @@ bool EEDbgInterfaceImpl::IsThreadExceptionNull(Thread *pThread)
}
CONTRACTL_END;

return pThread->IsThrowableNull();
return pThread->IsThrowableNull(ThrowableSource::ExInfoOnly);
}

void EEDbgInterfaceImpl::ClearThreadException(Thread *pThread)
Expand Down
5 changes: 2 additions & 3 deletions src/coreclr/vm/eepolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ void EEPolicy::LogFatalError(UINT exitCode, UINT_PTR address, LPCWSTR pszMessage
// for fail-fast, if there's a LTO available then use that as the inner exception object
// for the FEEE we'll be reporting. this can help the Watson back-end to generate better
// buckets for apps that call Environment.FailFast() and supply an exception object.
OBJECTREF lto = pThread->LastThrownObject();
OBJECTREF lto = pThread->GetThrowableRef(ThrowableSource::LTOOnly);

if (exitCode == static_cast<UINT>(COR_E_FAILFAST) && lto != NULL)
{
Expand Down Expand Up @@ -789,8 +789,7 @@ void DECLSPEC_NORETURN EEPolicy::HandleFatalStackOverflow(EXCEPTION_POINTERS *pE
OBJECTHANDLE ohSO = CLRException::GetPreallocatedStackOverflowExceptionHandle();
if (ohSO != NULL)
{
pThread->SafeSetThrowables(ObjectFromHandle(ohSO),
TRUE);
pThread->SetLastThrownObject(ObjectFromHandle(ohSO), TRUE);
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/eetoprofinterfacewrapper.inl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class EEToProfilerExceptionInterfaceWrapper
_ASSERTE(pThread->PreemptiveGCDisabled());

// Get a reference to the object that won't move
OBJECTREF thrown = pThread->GetThrowable();
OBJECTREF thrown = pThread->GetThrowableRef(ThrowableSource::ExInfoOnly);

(&g_profControlBlock)->ExceptionThrown(
reinterpret_cast<ObjectID>((*(BYTE **)&thrown)));
Expand Down Expand Up @@ -195,7 +195,7 @@ class EEToProfilerExceptionInterfaceWrapper
// passed CAN change when gc happens.
OBJECTREF thrown = NULL;
GCPROTECT_BEGIN(thrown);
thrown = pThread->GetThrowable();
thrown = pThread->GetThrowableRef(ThrowableSource::ExInfoOnly);
{
(&g_profControlBlock)->ExceptionCatcherEnter(
(FunctionID) pFunc,
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/eventtrace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2782,7 +2782,7 @@ VOID ETW::ExceptionLog::ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownExcept
NOTHROW;
GC_TRIGGERS;
PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(GetThread()->GetThrowable() != NULL);
PRECONDITION(!GetThread()->IsThrowableNull(ThrowableSource::ExInfoOnly));
} CONTRACTL_END;

if(!(bIsReThrownException || bIsNewException))
Expand Down Expand Up @@ -2814,7 +2814,7 @@ VOID ETW::ExceptionLog::ExceptionThrown(CrawlFrame *pCf, BOOL bIsReThrownExcept
gc.exceptionMessageRef = NULL;
GCPROTECT_BEGIN(gc);

gc.exceptionObj = pThread->GetThrowable();
gc.exceptionObj = pThread->GetThrowableRef(ThrowableSource::ExInfoOnly);
gc.innerExceptionObj = ((EXCEPTIONREF)gc.exceptionObj)->GetInnerException();

ThreadExceptionState *pExState = pThread->GetExceptionState();
Expand Down
Loading