summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Smith <aaron.smith@microsoft.com>2017-12-22 00:04:36 +0000
committerAaron Smith <aaron.smith@microsoft.com>2017-12-22 00:04:36 +0000
commit1f8552abf37da52c0ec84fb77f5604098a792d81 (patch)
treeecdc575cb8df84fd96be22625fc3fc48bc53c413
parent3cebc738b6fd533056fd469eeb56034bffd2e891 (diff)
downloadbcm5719-llvm-1f8552abf37da52c0ec84fb77f5604098a792d81.tar.gz
bcm5719-llvm-1f8552abf37da52c0ec84fb77f5604098a792d81.zip
Enable more abilities in SymbolFilePDB
Summary: 1) Finding symbols through --symfile 2) More abilities: Functions, Blocks, GlobalVariables, LocalVariables, VariableTypes Reviewers: zturner, lldb-commits Reviewed By: zturner Subscribers: clayborg Differential Revision: https://reviews.llvm.org/D41092 llvm-svn: 321327
-rw-r--r--lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp47
-rw-r--r--lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp3
2 files changed, 46 insertions, 4 deletions
diff --git a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
index 5e713224fcf..84c2555bd30 100644
--- a/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
+++ b/lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
@@ -21,12 +21,15 @@
#include "lldb/Symbol/TypeMap.h"
#include "llvm/DebugInfo/PDB/GenericError.h"
+#include "llvm/DebugInfo/PDB/IPDBDataStream.h"
#include "llvm/DebugInfo/PDB/IPDBEnumChildren.h"
#include "llvm/DebugInfo/PDB/IPDBLineNumber.h"
#include "llvm/DebugInfo/PDB/IPDBSourceFile.h"
+#include "llvm/DebugInfo/PDB/IPDBTable.h"
#include "llvm/DebugInfo/PDB/PDBSymbol.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompiland.h"
#include "llvm/DebugInfo/PDB/PDBSymbolCompilandDetails.h"
+#include "llvm/DebugInfo/PDB/PDBSymbolData.h"
#include "llvm/DebugInfo/PDB/PDBSymbolExe.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFunc.h"
#include "llvm/DebugInfo/PDB/PDBSymbolFuncDebugEnd.h"
@@ -93,6 +96,10 @@ SymbolFilePDB::SymbolFilePDB(lldb_private::ObjectFile *object_file)
SymbolFilePDB::~SymbolFilePDB() {}
uint32_t SymbolFilePDB::CalculateAbilities() {
+ uint32_t abilities = 0;
+ if (!m_obj_file)
+ return 0;
+
if (!m_session_up) {
// Lazily load and match the PDB file, but only do this once.
std::string exePath = m_obj_file->GetFileSpec().GetPath();
@@ -100,10 +107,46 @@ uint32_t SymbolFilePDB::CalculateAbilities() {
m_session_up);
if (error) {
llvm::consumeError(std::move(error));
- return 0;
+ auto module_sp = m_obj_file->GetModule();
+ if (!module_sp)
+ return 0;
+ // See if any symbol file is specified through `--symfile` option.
+ FileSpec symfile = module_sp->GetSymbolFileFileSpec();
+ if (!symfile)
+ return 0;
+ error = loadDataForPDB(PDB_ReaderType::DIA,
+ llvm::StringRef(symfile.GetPath()),
+ m_session_up);
+ if (error) {
+ llvm::consumeError(std::move(error));
+ return 0;
+ }
+ }
+ }
+ if (!m_session_up.get())
+ return 0;
+
+ auto enum_tables_up = m_session_up->getEnumTables();
+ if (!enum_tables_up)
+ return 0;
+ while (auto table_up = enum_tables_up->getNext()) {
+ if (table_up->getItemCount() == 0)
+ continue;
+ auto type = table_up->getTableType();
+ switch (type) {
+ case PDB_TableType::Symbols:
+ // This table represents a store of symbols with types listed in
+ // PDBSym_Type
+ abilities |= (CompileUnits | Functions | Blocks |
+ GlobalVariables | LocalVariables | VariableTypes);
+ break;
+ case PDB_TableType::LineNumbers:
+ abilities |= LineTables;
+ break;
+ default: break;
}
}
- return CompileUnits | LineTables;
+ return abilities;
}
void SymbolFilePDB::InitializeObject() {
diff --git a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
index 1e9cf170064..77a18aae18e 100644
--- a/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
+++ b/lldb/unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp
@@ -154,8 +154,7 @@ TEST_F(SymbolFilePDBTests, TestAbilitiesForPDB) {
EXPECT_NE(nullptr, symfile);
EXPECT_EQ(symfile->GetPluginName(), SymbolFilePDB::GetPluginNameStatic());
- uint32_t expected_abilities =
- SymbolFile::CompileUnits | SymbolFile::LineTables;
+ uint32_t expected_abilities = SymbolFile::kAllAbilities;
EXPECT_EQ(expected_abilities, symfile->CalculateAbilities());
}
OpenPOWER on IntegriCloud