Repository: dotnet/runtime
File: src/coreclr/vm/stubmgr.cpp (C++)

Code before:
    LOG_TRACE_DESTINATION(trace, stubStartAddress, "AsyncThunkStubManager::DoTraceStub");

    return TRUE;

#else // !DACCESS_COMPILE
    trace->InitForOther((PCODE)NULL);
    return FALSE;

#endif // !DACCESS_COMPILE
}

#ifndef DACCESS_COMPILE

BOOL AsyncThunkStubManager::TraceManager(Thread *thread,
                                         TraceDestination *trace,
                                         T_CONTEXT *pContext,
                                         BYTE **pRetAddr)
{
    PCODE stubIP = GetIP(pContext);
    *pRetAddr = (BYTE *)StubManagerHelpers::GetReturnAddress(pContext);

    MethodDesc* pMD = NonVirtualEntry2MethodDesc(stubIP);
    if (pMD->IsAsyncThunkMethod())
    {
        MethodDesc* pOtherMD = pMD->GetAsyncOtherVariant();
        if (pOtherMD == NULL)
        {
            LOG((LF_CORDB, LL_INFO1000, "ATSM::TraceManager: Async thunk has no other variant to step through to\n"));
            return FALSE;
        }

        LOG((LF_CORDB, LL_INFO1000, "ATSM::TraceManager: Step through async thunk to target - %p\n", pOtherMD));
        PCODE target = GetStubTarget(pOtherMD);
        if (target == (PCODE)NULL)
        {
            trace->InitForUnjittedMethod(pOtherMD);
            return TRUE;
        }

        trace->InitForManaged(target);
        return TRUE;
    }
    return FALSE;
}
#endif //!DACCESS_COMPILE

#ifdef DACCESS_COMPILE

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
void
PrecodeStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)

Review comment (bug):
Do we ever expect this to be NULL? If it is NULL the stepping is going to fail and we'd need to adjust our algorithm to be even lazier.

Assuming we never expect this to be NULL lets add an ASSERT to make that expectation clear.

Code after:
    LOG_TRACE_DESTINATION(trace, stubStartAddress, "AsyncThunkStubManager::DoTraceStub");

    return TRUE;

#else // !DACCESS_COMPILE
    trace->InitForOther((PCODE)NULL);
    return FALSE;

#endif // !DACCESS_COMPILE
}

#ifndef DACCESS_COMPILE

BOOL AsyncThunkStubManager::TraceManager(Thread *thread,
                                         TraceDestination *trace,
                                         T_CONTEXT *pContext,
                                         BYTE **pRetAddr)
{
    PCODE stubIP = GetIP(pContext);
    *pRetAddr = (BYTE *)StubManagerHelpers::GetReturnAddress(pContext);

    MethodDesc* pMD = NonVirtualEntry2MethodDesc(stubIP);
    if (pMD->IsAsyncThunkMethod())
    {
        MethodDesc* pOtherMD = pMD->GetAsyncOtherVariant();
        _ASSERTE_MSG(pOtherMD != NULL, "ATSM::TraceManager: Async thunk has no non-thunk variant to step through to");

        LOG((LF_CORDB, LL_INFO1000, "ATSM::TraceManager: Step through async thunk to target - %p\n", pOtherMD));
        PCODE target = GetStubTarget(pOtherMD);
        if (target == (PCODE)NULL)
        {
            trace->InitForUnjittedMethod(pOtherMD);
            return TRUE;
        }

        trace->InitForManaged(target);
        return TRUE;
    }
    return FALSE;
}
#endif //!DACCESS_COMPILE

#ifdef DACCESS_COMPILE

#ifndef FEATURE_PORTABLE_ENTRYPOINTS
void
PrecodeStubManager::DoEnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
    SUPPORTS_DAC;
    WRAPPER_NO_CONTRACT;
    DAC_ENUM_VTHIS();