2009-06-16 10 views
0

Windows VS2005でデバッグでコンパイルされたC++アプリケーションの.pdbプログラムデータベースがあります。私は関数名を見つけるためにDIA SDKを使用しますが、シンボルのファイル名を取得することはできません。pdbプログラムデータベースにファイル名がありません

スイッチをオンにする必要はありますか?これは動作しますか?

答えて

0

この回答は、最初に行番号を見つけてからソースファイルを見つけたようです。

など。

virtual IProgramSymbol^ getSymbolFromAddress(UInt32 address) 
{ 
    // Find the symbol with the virtual address we were given 
    IDiaSymbol^sym = nullptr; 
    m_session->findSymbolByVA(address, SymTagEnum::SymTagFunction, sym); 

    if (sym != nullptr) 
    { 
     // Get source code information via lines numbers. Odd, but this seems to be the way 
     // to do it. 
     String^srcFile = "unknown"; 
     int line = 0; 

     UInt64 startAdr = sym->virtualAddress; 

     // Find line numbers from start_address to start_address+1, which should be 1 symbol! 
     IDiaEnumLineNumbers^lines; 
     m_session->findLinesByVA(startAdr, 1, lines); 

     if (lines != nullptr) 
     { 
      // get the line number 
      IDiaLineNumber^lnb = lines->Item(0); 
      line = lnb->lineNumber; 

      // get the source file from the line number (weird!) 
      IDiaSourceFile^sf = lnb->sourceFile; 
      if (sf != nullptr) 
      { 
       srcFile = sf->fileName; 
      } 
     } 

     return gcnew DiaSymbol(sym, srcFile, line); // found a function 
    } 
関連する問題