다음을 통해 공유


Getmethodproperty를 구현합니다.

Visual Studio 호출 디버그 엔진 (DE)의 IDebugStackFrame2::GetDebugProperty를 차례로 호출 IDebugExpressionEvaluator::GetMethodProperty 스택 프레임에서 현재 메서드에 대 한 정보를 얻을 수 있습니다.

이 구현의 IDebugExpressionEvaluator::GetMethodProperty 다음 작업을 수행 합니다.

  1. 호출 IDebugSymbolProvider::GetContainerField, passing에 있는 IDebugAddress 개체입니다. 기호 공급자 (SP) 반환 된 IDebugContainerField 지정 된 주소를 포함 하는 메서드를 나타내는.

  2. 획득은 IDebugMethodField 에서 IDebugContainerField.

  3. 클래스를 인스턴스화합니다 (라는 CFieldProperty 이 예제에서는) 구현 하는 IDebugProperty2 인터페이스 및 포함의 IDebugMethodField SP.에서 반환 된 개체

  4. 반환은 IDebugProperty2 에서 인터페이스는 CFieldProperty 개체입니다.

관리 코드

구현 하는이 예제를 보여 줍니다. IDebugExpressionEvaluator::GetMethodProperty 관리 되는 코드입니다.

namespace EEMC
{
    [GuidAttribute("462D4A3D-B257-4AEE-97CD-5918C7531757")]
    public class EEMCClass : IDebugExpressionEvaluator
    {
        public HRESULT GetMethodProperty(
                IDebugSymbolProvider symbolProvider,
                IDebugAddress        address,
                IDebugBinder         binder,
                int                  includeHiddenLocals,
            out IDebugProperty2      property) 
        {
            IDebugContainerField containerField = null;
            IDebugMethodField methodField       = null;
            property = null;

            // Get the containing method field.
            symbolProvider.GetContainerField(address, out containerField);
            methodField = (IDebugMethodField) containerField;

            // Return the property of method field.
            property = new CFieldProperty(symbolProvider, address, binder, methodField);
            return COM.S_OK;
        }
    }
}

관리 되지 않는 코드

구현 하는이 예제를 보여 줍니다. IDebugExpressionEvaluator::GetMethodProperty 에서 관리 되지 않는 코드입니다.

[CPP]
STDMETHODIMP CExpressionEvaluator::GetMethodProperty(
        in IDebugSymbolProvider *pprovider,
        in IDebugAddress        *paddress,
        in IDebugBinder         *pbinder,
        in BOOL                  includeHiddenLocals,
        out IDebugProperty2    **ppproperty
    )
{
    if (pprovider == NULL)
        return E_INVALIDARG;

    if (ppproperty == NULL)
        return E_INVALIDARG;
    else
        *ppproperty = 0;

    HRESULT hr;
    IDebugContainerField* pcontainer = NULL;

    hr = pprovider->GetContainerField(paddress, &pcontainer);
    if (FAILED(hr))
        return hr;

    IDebugMethodField*    pmethod    = NULL;
    hr = pcontainer->QueryInterface( IID_IDebugMethodField,
            reinterpret_cast<void**>(&pmethod));
    pcontainer->Release();
    if (FAILED(hr))
        return hr;

    CFieldProperty* pfieldProperty = new CFieldProperty( pprovider,
                                                         paddress,
                                                         pbinder,
                                                         pmethod );
    pmethod->Release();
    if (!pfieldProperty)
        return E_OUTOFMEMORY;

    hr = pfieldProperty->Init();
    if (FAILED(hr))
    {
        pfieldProperty->Release();
        return hr;
    }

    hr = pfieldProperty->QueryInterface( IID_IDebugProperty2,
            reinterpret_cast<void**>(ppproperty));
    pfieldProperty->Release();

    return hr;
}

참고 항목

개념

지역 변수의 구현 샘플