IDiaLineNumber
Accesses information that describes the process of mapping from a block of bytes of image text to a source file line number.
IDiaLineNumber : IUnknown
Methods in Vtable Order
The following table shows the methods of IDiaLineNumber.
Method |
Description |
---|---|
Retrieves a reference to the symbol for the compiland that contributed the bytes of image text. |
|
Retrieves a reference to the source file object. |
|
Retrieves the line number in the source file. |
|
Retrieves the one-based source line number where the statement or expression ends. |
|
Retrieves the column number where the expression or statement begins. |
|
Retrieves the column number where the expression or statement ends. |
|
Retrieves the section part of the memory address where a block begins. |
|
Retrieves the offset part of the memory address where a block begins. |
|
Retrieves the image relative virtual address (RVA) of a block. |
|
Retrieves the virtual address (VA) of a block. |
|
Retrieves the number of bytes in a block. |
|
Retrieves a unique source file identifier for the source file that contributed this line. |
|
Retrieves a flag indicating that this line information describes the beginning of a statement in the program source. |
|
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