[DebugInfoPDB] Add DIA implementations of findSymbolByRVA and findSymbolByAddr
llvm-svn: 329724
diff --git a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
index afbfdeab..d81f594 100644
--- a/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
+++ b/llvm/lib/DebugInfo/PDB/DIA/DIASession.cpp
@@ -106,7 +106,7 @@
if (!llvm::convertUTF8ToUTF16String(Path, Path16))
return make_error<GenericError>(generic_error_code::invalid_path);
- const wchar_t *Path16Str = reinterpret_cast<const wchar_t*>(Path16.data());
+ const wchar_t *Path16Str = reinterpret_cast<const wchar_t *>(Path16.data());
HRESULT HR;
if (FAILED(HR = DiaDataSource->loadDataFromPdb(Path16Str))) {
return ErrorFromHResult(HR, "Calling loadDataFromPdb {0}", Path);
@@ -214,6 +214,31 @@
return PDBSymbol::create(*this, std::move(RawSymbol));
}
+std::unique_ptr<PDBSymbol> DIASession::findSymbolByRVA(uint32_t RVA,
+ PDB_SymType Type) const {
+ enum SymTagEnum EnumVal = static_cast<enum SymTagEnum>(Type);
+
+ CComPtr<IDiaSymbol> Symbol;
+ if (S_OK != Session->findSymbolByRVA(RVA, EnumVal, &Symbol))
+ return nullptr;
+
+ auto RawSymbol = llvm::make_unique<DIARawSymbol>(*this, Symbol);
+ return PDBSymbol::create(*this, std::move(RawSymbol));
+}
+
+std::unique_ptr<PDBSymbol>
+DIASession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset,
+ PDB_SymType Type) const {
+ enum SymTagEnum EnumVal = static_cast<enum SymTagEnum>(Type);
+
+ CComPtr<IDiaSymbol> Symbol;
+ if (S_OK != Session->findSymbolByAddr(Sect, Offset, EnumVal, &Symbol))
+ return nullptr;
+
+ auto RawSymbol = llvm::make_unique<DIARawSymbol>(*this, Symbol);
+ return PDBSymbol::create(*this, std::move(RawSymbol));
+}
+
std::unique_ptr<IPDBEnumLineNumbers>
DIASession::findLineNumbers(const PDBSymbolCompiland &Compiland,
const IPDBSourceFile &File) const {
@@ -222,9 +247,8 @@
const DIASourceFile &RawFile = static_cast<const DIASourceFile &>(File);
CComPtr<IDiaEnumLineNumbers> LineNumbers;
- if (S_OK !=
- Session->findLines(RawCompiland.getDiaSymbol(), RawFile.getDiaFile(),
- &LineNumbers))
+ if (S_OK != Session->findLines(RawCompiland.getDiaSymbol(),
+ RawFile.getDiaFile(), &LineNumbers))
return nullptr;
return llvm::make_unique<DIAEnumLineNumbers>(LineNumbers);
@@ -359,9 +383,7 @@
return llvm::make_unique<DIAEnumTables>(DiaEnumerator);
}
-template <class T>
-static CComPtr<T>
-getTableEnumerator(IDiaSession &Session) {
+template <class T> static CComPtr<T> getTableEnumerator(IDiaSession &Session) {
CComPtr<T> Enumerator;
CComPtr<IDiaEnumTables> ET;
CComPtr<IDiaTable> Table;
@@ -372,8 +394,7 @@
while (ET->Next(1, &Table, &Count) == S_OK && Count == 1) {
// There is only one table that matches the given iid
- if (S_OK ==
- Table->QueryInterface(__uuidof(T), (void **)&Enumerator))
+ if (S_OK == Table->QueryInterface(__uuidof(T), (void **)&Enumerator))
break;
Table.Release();
}
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
index 37b1a91..086da13 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
@@ -200,6 +200,17 @@
return nullptr;
}
+std::unique_ptr<PDBSymbol>
+NativeSession::findSymbolByRVA(uint32_t RVA, PDB_SymType Type) const {
+ return nullptr;
+}
+
+std::unique_ptr<PDBSymbol>
+NativeSession::findSymbolBySectOffset(uint32_t Sect, uint32_t Offset,
+ PDB_SymType Type) const {
+ return nullptr;
+}
+
std::unique_ptr<IPDBEnumLineNumbers>
NativeSession::findLineNumbers(const PDBSymbolCompiland &Compiland,
const IPDBSourceFile &File) const {