summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
authorAdrian McCarthy <amccarth@google.com>2017-03-15 20:17:58 +0000
committerAdrian McCarthy <amccarth@google.com>2017-03-15 20:17:58 +0000
commit65d26888422a919a3d822b4b0c194022b4a6fccc (patch)
tree1b7dd020f0740fad7c2dc8344792be1a423ab50a /llvm/lib/DebugInfo
parent9fd6ee6a7842628f72b39fa2bdacdb201a6681d8 (diff)
downloadbcm5719-llvm-65d26888422a919a3d822b4b0c194022b4a6fccc.tar.gz
bcm5719-llvm-65d26888422a919a3d822b4b0c194022b4a6fccc.zip
Introduce NativeEnumModules and NativeCompilandSymbol
Together, these allow lldb-pdbdump to list all the modules from a PDB using a native reader (rather than DIA). Note that I'll probably be specializing NativeRawSymbol in a subsequent patch. Differential Revision: https://reviews.llvm.org/D30956 llvm-svn: 297883
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/PDB/CMakeLists.txt2
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp42
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp52
-rw-r--r--llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp21
4 files changed, 115 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/PDB/CMakeLists.txt b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
index 4d4eb6ceaf1..1b9dd2b651d 100644
--- a/llvm/lib/DebugInfo/PDB/CMakeLists.txt
+++ b/llvm/lib/DebugInfo/PDB/CMakeLists.txt
@@ -39,6 +39,8 @@ add_pdb_impl_folder(Native
Native/InfoStreamBuilder.cpp
Native/ModInfo.cpp
Native/ModStream.cpp
+ Native/NativeCompilandSymbol.cpp
+ Native/NativeEnumModules.cpp
Native/NativeRawSymbol.cpp
Native/NamedStreamMap.cpp
Native/NativeSession.cpp
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
new file mode 100644
index 00000000000..24b62823eb2
--- /dev/null
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeCompilandSymbol.cpp
@@ -0,0 +1,42 @@
+//===- NativeCompilandSymbol.h - Native impl of PDBCompilandSymbol -C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
+
+namespace llvm {
+namespace pdb {
+
+NativeCompilandSymbol::NativeCompilandSymbol(NativeSession &Session,
+ const ModuleInfoEx &MI)
+ : NativeRawSymbol(Session), Module(MI) {}
+
+PDB_SymType NativeCompilandSymbol::getSymTag() const {
+ return PDB_SymType::Compiland;
+}
+
+bool NativeCompilandSymbol::isEditAndContinueEnabled() const {
+ return Module.Info.hasECInfo();
+}
+
+uint32_t NativeCompilandSymbol::getLexicalParentId() const { return 0; }
+
+// DIA, which this API was modeled after, uses counter-intuitive meanings for
+// IDiaSymbol::get_name and IDiaSymbol::get_libraryName, which is why these
+// methods may appear to be cross-mapped.
+
+std::string NativeCompilandSymbol::getLibraryName() const {
+ return Module.Info.getObjFileName();
+}
+
+std::string NativeCompilandSymbol::getName() const {
+ return Module.Info.getModuleName();
+}
+
+} // namespace pdb
+} // namespace llvm
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
new file mode 100644
index 00000000000..7532110d005
--- /dev/null
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeEnumModules.cpp
@@ -0,0 +1,52 @@
+//==- NativeEnumModules.cpp - Native Symbol Enumerator impl ------*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
+
+#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/Native/NativeCompilandSymbol.h"
+#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
+#include "llvm/DebugInfo/PDB/PDBSymbol.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
+
+namespace llvm {
+namespace pdb {
+
+NativeEnumModules::NativeEnumModules(NativeSession &PDBSession,
+ ArrayRef<ModuleInfoEx> Modules,
+ uint32_t Index)
+ : Session(PDBSession), Modules(Modules), Index(Index) {}
+
+uint32_t NativeEnumModules::getChildCount() const {
+ return static_cast<uint32_t>(Modules.size());
+}
+
+std::unique_ptr<PDBSymbol>
+NativeEnumModules::getChildAtIndex(uint32_t Index) const {
+ if (Index >= Modules.size())
+ return nullptr;
+ return std::unique_ptr<PDBSymbol>(new PDBSymbolCompiland(Session,
+ std::unique_ptr<IPDBRawSymbol>(
+ new NativeCompilandSymbol(Session, Modules[Index]))));
+}
+
+std::unique_ptr<PDBSymbol> NativeEnumModules::getNext() {
+ if (Index >= Modules.size())
+ return nullptr;
+ return getChildAtIndex(Index++);
+}
+
+void NativeEnumModules::reset() { Index = 0; }
+
+NativeEnumModules *NativeEnumModules::clone() const {
+ return new NativeEnumModules(Session, Modules, Index);
+}
+
+}
+}
diff --git a/llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp b/llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
index 527ca8d717f..3974ddc08a4 100644
--- a/llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
+++ b/llvm/lib/DebugInfo/PDB/Native/NativeRawSymbol.cpp
@@ -10,11 +10,13 @@
#include "llvm/DebugInfo/PDB/Native/NativeRawSymbol.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
-#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
+#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
+#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
+#include "llvm/DebugInfo/PDB/Native/NativeEnumModules.h"
+#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
#include "llvm/DebugInfo/PDB/PDBExtras.h"
-#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/raw_ostream.h"
@@ -28,6 +30,21 @@ void NativeRawSymbol::dump(raw_ostream &OS, int Indent) const {}
std::unique_ptr<IPDBEnumSymbols>
NativeRawSymbol::findChildren(PDB_SymType Type) const {
+ switch (Type) {
+ case PDB_SymType::Compiland: {
+ auto &File = Session.getPDBFile();
+ auto Dbi = File.getPDBDbiStream();
+ if (Dbi) {
+ const auto Modules = Dbi->modules();
+ return std::unique_ptr<IPDBEnumSymbols>(
+ new NativeEnumModules(Session, Modules));
+ }
+ consumeError(Dbi.takeError());
+ break;
+ }
+ default:
+ break;
+ }
return nullptr;
}
OpenPOWER on IntegriCloud