IDebugComPlusSymbolProvider:: GetFunctionLineOffset

检索在表示特定行偏移量的函数中的地址。

HRESULT GetFunctionLineOffset(
   IDebugAddress*  pAddress, 
   DWORD           dwLine, 
   IDebugAddress** ppNewAddress 
);
int GetFunctionLineOffset(
   IDebugAddress     pAddress, 
   uint              dwLine, 
   out IDebugAddress ppNewAddress
);

参数

  • pAddress
    [in] 解析表示功能。

  • dwLine
    [in] 从函数开头的行偏移量。

  • ppNewAddress
    [out] 表示从函数开头的行偏移量的新地址。

返回值

如果成功,则返回; S_OK否则,返回错误代码。

示例

下面的示例演示如何执行显示 IDebugComPlusSymbolProvider 接口的 CDebugSymbolProvider 对象的方法。

HRESULT CDebugSymbolProvider::GetFunctionLineOffset(
    IDebugAddress *pAddress,
    DWORD dwLine,
    IDebugAddress **ppNewAddress
)
{
    HRESULT hr = S_OK;
    CDEBUG_ADDRESS address;
    CComPtr<CModule> pModule;
    DWORD dwOffset;
    CDebugAddress* paddr = NULL;

    METHOD_ENTRY(CDebugSymbolProvider::GetFunctionLineOffset);

    IfFalseGo( pAddress, S_FALSE );
    IfFailGo( pAddress->GetAddress( &address ) );

    ASSERT(address.addr.dwKind == ADDRESS_KIND_METADATA_METHOD);
    IfFalseGo( address.addr.dwKind == ADDRESS_KIND_METADATA_METHOD, S_FALSE );

    IfFailGo( GetModule( address.GetModule(), &pModule) );

    // Find the first offset for dwLine in the function

    IfFailGo( pModule->GetFunctionLineOffset( address.addr.addr.addrMethod.tokMethod,
              address.addr.addr.addrMethod.dwVersion,
              dwLine,
              &dwOffset ) );

    // Create the new Address

    address.addr.addr.addrMethod.dwOffset = dwOffset;
    IfNullGo( paddr = new CDebugAddress(address), E_OUTOFMEMORY );
    IfFailGo( paddr->QueryInterface( __uuidof(IDebugAddress),
                                     (void**) ppNewAddress ) );

Error:

    METHOD_EXIT(CDebugSymbolProvider::GetFunctionLineOffset, hr);
    RELEASE( paddr );
    return hr;
}

请参见

参考

IDebugComPlusSymbolProvider