0
我有一個來自C++應用程序的.pdb程序數據庫,它在Windows VS2005的調試版中編譯。我使用DIA SDK來查找函數名稱,但似乎無法檢索這些符號的文件名。在pdb程序數據庫中沒有文件名
是否需要打開一些開關?這是否工作?
我有一個來自C++應用程序的.pdb程序數據庫,它在Windows VS2005的調試版中編譯。我使用DIA SDK來查找函數名稱,但似乎無法檢索這些符號的文件名。在pdb程序數據庫中沒有文件名
是否需要打開一些開關?這是否工作?
所以這個答案似乎是你先找到行號然後是源文件?
E.g.
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
}