描述用于处理从字节块图像文本对源文件行号的访问信息。
IDiaLineNumber : IUnknown
方法按 Vtable 顺序
下表显示 IDiaLineNumber方法。
方法 |
说明 |
---|---|
检索对提供字节图像文本的编译符号。 |
|
检索对源文件对象。 |
|
检索源文件中的行号。 |
|
检索语句或表达式的从一开始的源行号。 |
|
检索该表达式或语句开始的列数。 |
|
检索表达式或语句结束的列数。 |
|
检索块启动内存地址的部分部件。 |
|
检索块启动内存地址的偏移量部件。 |
|
检索块图像的相对 (RVA)虚拟地址。 |
|
检索块的虚拟地址 (VA)。 |
|
检索字节数在块中。 |
|
检索提供此行的源文件的一个源文件标识符。 |
|
检索指示的标志此行信息在程序源描述语句的开头。 |
|
检索提供此行的编译的唯一标识符。 |
备注
调用方的说明
通过调用 IDiaEnumLineNumbers::Item 或 IDiaEnumLineNumbers::Next 方法获取此接口。
示例
以下功能显示在函数的行号 (表示 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;
}
}
}
}
}
要求
标题:Dia2.h
库:diaguids.lib
DLL:msdia80.dll