HRESULT MicrosoftInstrumentationEngine::CInstruction::GetTerminationType()

in src/InstrumentationEngine/Instruction.cpp [589:650]


HRESULT MicrosoftInstrumentationEngine::CInstruction::GetTerminationType(_Out_ InstructionTerminationType* pTerminationType)
{
    HRESULT hr = S_OK;
    IfNullRetPointer(pTerminationType);

    *pTerminationType = TerminationType_FallThrough;

    // The termination type information comes from InternalApis\Clr\inc\opcode.def.
    switch (m_opcode)
    {
    case Cee_Break:
        *pTerminationType = TerminationType_Trap;
        break;

    case Cee_Switch:
        *pTerminationType = TerminationType_Switch;
        break;

    case Cee_Ret:
    case Cee_Endfinally:
    case Cee_Endfilter:
        *pTerminationType = TerminationType_Return;
        break;

    case Cee_Call:
    case Cee_Jmp:
    case Cee_Newobj:
        *pTerminationType = TerminationType_Call;
        break;

    case Cee_Calli:
    case Cee_Callvirt:
        *pTerminationType = TerminationType_IndirectCall;
        break;

    case Cee_Br_S:
    case Cee_Br:
    case Cee_Leave:
    case Cee_Leave_S:
        *pTerminationType = TerminationType_Branch;
        break;

    case Cee_Throw:
    case Cee_Rethrow:
        *pTerminationType = TerminationType_Throw;
        break;

    default:
        if (m_opcode >= Cee_Brfalse_S && m_opcode < Cee_Switch)
        {
            *pTerminationType = TerminationType_ConditionalBranch;
        }
        else
        {
            // For the rest, use fallthrough.
            *pTerminationType = TerminationType_FallThrough;
        }
    }


    return S_OK;
}