IDiaLineNumber

访问描述从图像文本的字节块映射到源文件行号的过程的信息。

语法

IDiaLineNumber : IUnknown

Vtable 顺序中的方法

下表显示了 IDiaLineNumber 方法。

方法 说明
IDiaLineNumber::get_compiland 检索对提供图像文本字节的编译单位的符号的引用。
IDiaLineNumber::get_sourceFile 检索对源文件对象的引用。
IDiaLineNumber::get_lineNumber 检索源文件中的行号。
IDiaLineNumber::get_lineNumberEnd 检索语句或表达式结束位置从 1 开始的源代码行号。
IDiaLineNumber::get_columnNumber 检索表达式或语句开始的列号。
IDiaLineNumber::get_columnNumberEnd 检索表达式或语句结束的列号。
IDiaLineNumber::get_addressSection 检索块开始的内存地址中的节部分。
IDiaLineNumber::get_addressOffset 检索块开始的内存地址中的偏移部分。
IDiaLineNumber::get_relativeVirtualAddress 检索块的图像相对虚拟地址 (RVA)。
IDiaLineNumber::get_virtualAddress 检索块的虚拟地址 (VA)。
IDiaLineNumber::get_length 检索块中的字节数。
IDiaLineNumber::get_sourceFileId 检索提供此行的源文件的唯一源文件标识符。
IDiaLineNumber::get_statement 检索一个标志,该标志指示此行信息描述程序源中的语句的开头。
IDiaLineNumber::get_compilandId 检索提供此行的编译单位的唯一标识符。

备注

对调用者的说明

通过调用 IDiaEnumLineNumbers::ItemIDiaEnumLineNumbers::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

另请参阅