We recommend using Visual Studio 2017

IDiaSession

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at IDiaSession.

Provides a query context for debug symbols.

IDiaSession : IUnknown  

The following table shows the methods of IDiaSession.

MethodDescription
IDiaSession::get_loadAddressRetrieves the load address for the executable file that corresponds to the symbols in this symbol store. This is the same value that was passed to the put_loadAddress method.
IDiaSession::put_loadAddressSets the load address for the executable file that corresponds to the symbols in this symbol store. Note: It is important to call this method when you get an IDiaSession object and before you start using the object.
IDiaSession::get_globalScopeRetrieves a reference to the global scope.
IDiaSession::getEnumTablesRetrieves an enumerator for all tables contained in the symbol store.
IDiaSession::getSymbolsByAddrRetrieves an enumerator for all named symbols at static locations.
IDiaSession::findChildrenRetrieves all children of a specified parent identifier that match the name and symbol type.
IDiaSession::findSymbolByAddrRetrieves a specified symbol type that contains, or is closest to, a specified address.
IDiaSession::findSymbolByRVARetrieves a specified symbol type that contains, or is closest to, a specified relative virtual address (RVA).
IDiaSession::findSymbolByVARetrieves a specified symbol type that contains, or is closest to, a specified virtual address (VA).
IDiaSession::findSymbolByTokenRetrieves the symbol that contains a specified metadata token.
IDiaSession::symsAreEquivChecks to see if two symbols are equivalent.
IDiaSession::symbolByIdRetrieves a symbol by its unique identifier.
IDiaSession::findSymbolByRVAExRetrieves a specified symbol type that contains, or is closest to, a specified relative virtual address and offset.
IDiaSession::findSymbolByVAExRetrieves a specified symbol type that contains, or is closest to, a specified virtual address and offset.
IDiaSession::findFileRetrieves a source file by compiland and name.
IDiaSession::findFileByIdRetrieves a source file by source file identifier.
IDiaSession::findLinesRetrieves line numbers within a specified compiland and source file identifier.
IDiaSession::findLinesByAddrRetrieves the lines in a specified compiland that contain a specified address.
IDiaSession::findLinesByRVARetrieves the lines in a specified compiland that contain a specified relative virtual address.
IDiaSession::findLinesByVAFinds the line number information for lines contained in a specified address range.
IDiaSession::findLinesByLinenumRetrieves the lines in a specified compiland by source file and line number.
IDiaSession::findInjectedSourceRetrieves a source that has been placed into the symbol store by attribute providers or other components of the compilation process.
IDiaSession::getEnumDebugStreamsRetrieves an enumerated sequence of debug data streams.
IDiaSession::findInlineFramesByAddrRetrieves an enumeration that allows a client to iterate through all of the inline frames on a given address.
IDiaSession::findInlineFramesByRVARetrieves an enumeration that allows a client to iterate through all of the inline frames on a specified relative virtual address (RVA).
IDiaSession::findInlineFramesByVARetrieves an enumeration that allows a client to iterate through all of the inline frames on a specified virtual address (VA).
IDiaSession::findInlineeLinesRetrieves an enumeration that allows a client to iterate through the line number information of all functions that are inlined, directly or indirectly, by the specified parent symbol.
IDiaSession::findInlineeLinesByAddrRetrieves an enumeration that allows a client to iterate through the line number information of all functions that are inlined, directly or indirectly, by the specified parent symbol and are contained within the specified address range.
IDiaSession::findInlineeLinesByRVARetrieves an enumeration that allows a client to iterate through the line number information of all functions that are inlined, directly or indirectly, by the specified parent symbol and are contained within the specified relative virtual address (RVA).
IDiaSession::findInlineeLinesByVARetrieves an enumeration that allows a client to iterate through the line number information of all functions that are inlined, directly or indirectly, by the specified parent symbol and are contained within the specified virtual address (VA).
IDiaSession::findInlineeLinesByLinenumRetrieves an enumeration that allows a client to iterate through the line number information of all functions that are inlined, directly or indirectly, in the specified source file and line number.
IDiaSession::findInlineesByNameRetrieves an enumeration that allows a client to iterate through the line number information of all inlined functions that match a specified name.
IDiaSession::findSymbolsForAcceleratorPointerTagReturns an enumeration of symbols for the variable that the specified tag value corresponds to in the parent Accelerator stub function.
IDiaSession::findSymbolsByRVAForAcceleratorPointerTagGiven a corresponding tag value, this method returns an enumeration of symbols that are contained in a specified parent Accelerator stub function at a specified relative virtual address.
IDiaSession::findAcceleratorInlineesByNameReturns an enumeration of symbols for inline frames corresponding to the specified inline function name.
IDiaSession::findAcceleratorInlineesByLinenumReturns an enumeration of symbols for inline frames that correspond to the specified source location.

It is important to call the IDiaSession::put_loadAddress method after creating the IDiaSession object — and the value passed to the put_loadAddress method must be non-zero — for any virtual address (VA) properties of symbols to be accessible. The load address comes from whatever program loaded the executable being debugged. For example, you can call the Win32 function GetModuleInformation to retrieve the load address for the executable, given a handle to the executable.

This example shows how to obtain the IDiaSession interface as part of a general initialization of the DIA SDK.

CComPtr<IDiaDataSource> pSource;  
ComPtr<IDiaSession> psession;  
  
void InitializeDIA(const char *szFilename)  
{  
    HRESULT hr = CoCreateInstance( CLSID_DiaSource,  
                                   NULL,  
                                   CLSCTX_INPROC_SERVER,  
                                   __uuidof( IDiaDataSource ),  
                                  (void **) &pSource);  
    if (FAILED(hr))  
    {  
        Fatal("Could not CoCreate CLSID_DiaSource. Register msdia80.dll." );  
    }  
    wchar_t wszFilename[ _MAX_PATH ];  
    mbstowcs( wszFilename,  
              szFilename,  
              sizeof( wszFilename )/sizeof( wszFilename[0] ) );  
    if ( FAILED( pSource->loadDataFromPdb( wszFilename ) ) )  
    {  
        if ( FAILED( pSource->loadDataForExe( wszFilename, NULL, NULL ) ) )  
        {  
            Fatal( "loadDataFromPdb/Exe" );  
        }  
    }  
    if ( FAILED( pSource->openSession( &psession ) ) )  
    {  
        Fatal( "openSession" );  
    }  
}  

Header: Dia2.h

Library: diaguids.lib

DLL: msdia80.dll

Interfaces (Debug Interface Access SDK)
Overview
Exe
IDiaAddressMap
IDiaDataSource
IDiaDataSource::openSession
IDiaSymbol::findChildren
Querying the .Pdb File

Show: