IDiaLineNumber
Note
This article applies to Visual Studio 2015. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here
Accesses information that describes the process of mapping from a block of bytes of image text to a source file line number.
Syntax
IDiaLineNumber : IUnknown
Methods in Vtable Order
The following table shows the methods of IDiaLineNumber
.
Method | Description |
---|---|
IDiaLineNumber::get_compiland | Retrieves a reference to the symbol for the compiland that contributed the bytes of image text. |
IDiaLineNumber::get_sourceFile | Retrieves a reference to the source file object. |
IDiaLineNumber::get_lineNumber | Retrieves the line number in the source file. |
IDiaLineNumber::get_lineNumberEnd | Retrieves the one-based source line number where the statement or expression ends. |
IDiaLineNumber::get_columnNumber | Retrieves the column number where the expression or statement begins. |
IDiaLineNumber::get_columnNumberEnd | Retrieves the column number where the expression or statement ends. |
IDiaLineNumber::get_addressSection | Retrieves the section part of the memory address where a block begins. |
IDiaLineNumber::get_addressOffset | Retrieves the offset part of the memory address where a block begins. |
IDiaLineNumber::get_relativeVirtualAddress | Retrieves the image relative virtual address (RVA) of a block. |
IDiaLineNumber::get_virtualAddress | Retrieves the virtual address (VA) of a block. |
IDiaLineNumber::get_length | Retrieves the number of bytes in a block. |
IDiaLineNumber::get_sourceFileId | Retrieves a unique source file identifier for the source file that contributed this line. |
IDiaLineNumber::get_statement | Retrieves a flag indicating that this line information describes the beginning of a statement in the program source. |
IDiaLineNumber::get_compilandId | Retrieves the unique identifier for the compiland that contributed this line. |
Remarks
Notes for Callers
Obtain this interface by calling the IDiaEnumLineNumbers::Item or IDiaEnumLineNumbers::Next methods.
Example
The following function displays line numbers used in a function (represented by pSymbol
).
void dumpFunctionLines( IDiaSymbol* pSymbol, IDiaSession* pSession )
{
ULONGLONG length = 0;
DWORD isect = 0;
DWORD offset = 0;
pSymbol->get_addressSection( &isect );
pSymbol->get_addressOffset( &offset );
pSymbol->get_length( &length );
if ( isect != 0 && length > 0 )
{
CComPtr< IDiaEnumLineNumbers > pLines;
if ( SUCCEEDED( pSession->findLinesByAddr(
isect,
offset,
static_cast<DWORD>( length ),
&pLines)
)
)
{
CComPtr< IDiaLineNumber > pLine;
DWORD celt = 0;
bool firstLine = true;
while ( SUCCEEDED( pLines->Next( 1, &pLine, &celt ) ) &&
celt == 1 )
{
DWORD offset;
DWORD seg;
DWORD linenum;
CComPtr< IDiaSymbol > pComp;
CComPtr< IDiaSourceFile > pSrc;
pLine->get_compiland( &pComp );
pLine->get_sourceFile( &pSrc );
pLine->get_addressSection( &seg );
pLine->get_addressOffset( &offset );
pLine->get_lineNumber( &linenum );
printf( "\tline %d at 0x%x:0x%x\n", linenum, seg, offset );
pLine = NULL;
if ( firstLine )
{
// sanity check
CComPtr< IDiaEnumLineNumbers > pLinesByLineNum;
if ( SUCCEEDED( pSession->findLinesByLinenum(
pComp,
pSrc,
linenum,
0,
&pLinesByLineNum)
)
)
{
CComPtr< IDiaLineNumber > pLine;
DWORD celt;
while ( SUCCEEDED( pLinesByLineNum->Next( 1, &pLine, &celt ) ) &&
celt == 1 )
{
DWORD offset;
DWORD seg;
DWORD linenum;
pLine->get_addressSection( &seg );
pLine->get_addressOffset( &offset );
pLine->get_lineNumber( &linenum );
printf( "\t\tfound line %d at 0x%x:0x%x\n", linenum, seg, offset );
pLine = NULL;
}
}
firstLine = false;
}
}
}
}
}
Requirements
Header: Dia2.h
Library: diaguids.lib
DLL: msdia80.dll
See Also
Interfaces (Debug Interface Access SDK)
IDiaEnumLineNumbers
IDiaEnumLineNumbers::Item
IDiaEnumLineNumbers::Next