summaryrefslogtreecommitdiff
path: root/tools/llvm-symbolizer
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2015-04-27 17:19:51 +0000
committerZachary Turner <zturner@google.com>2015-04-27 17:19:51 +0000
commit7b8e8e5dc065a4324b395e7c6aff7ae56f8795cd (patch)
tree0897a840b0844469b32c4a1a62554627f4a66116 /tools/llvm-symbolizer
parentd8caa1c4ca0d32dde9c0e34f0179625a652b279b (diff)
Make llvm-symbolizer work on Windows.
Differential Revision: http://reviews.llvm.org/D9234 Reviewed By: Alexey Samsonov git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235900 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llvm-symbolizer')
-rw-r--r--tools/llvm-symbolizer/CMakeLists.txt1
-rw-r--r--tools/llvm-symbolizer/LLVMSymbolize.cpp16
-rw-r--r--tools/llvm-symbolizer/llvm-symbolizer.cpp4
3 files changed, 20 insertions, 1 deletions
diff --git a/tools/llvm-symbolizer/CMakeLists.txt b/tools/llvm-symbolizer/CMakeLists.txt
index 6968f1c6216..5df3b17a065 100644
--- a/tools/llvm-symbolizer/CMakeLists.txt
+++ b/tools/llvm-symbolizer/CMakeLists.txt
@@ -5,6 +5,7 @@
set(LLVM_LINK_COMPONENTS
DebugInfoDWARF
+ DebugInfoPDB
Object
Support
)
diff --git a/tools/llvm-symbolizer/LLVMSymbolize.cpp b/tools/llvm-symbolizer/LLVMSymbolize.cpp
index c3988e13617..326cab5a186 100644
--- a/tools/llvm-symbolizer/LLVMSymbolize.cpp
+++ b/tools/llvm-symbolizer/LLVMSymbolize.cpp
@@ -15,6 +15,8 @@
#include "llvm/ADT/STLExtras.h"
#include "llvm/Config/config.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
+#include "llvm/DebugInfo/PDB/PDB.h"
+#include "llvm/DebugInfo/PDB/PDBContext.h"
#include "llvm/Object/ELFObjectFile.h"
#include "llvm/Object/MachO.h"
#include "llvm/Support/Casting.h"
@@ -164,6 +166,7 @@ DILineInfo ModuleInfo::symbolizeCode(
DIInliningInfo ModuleInfo::symbolizeInlinedCode(
uint64_t ModuleOffset, const LLVMSymbolizer::Options &Opts) const {
DIInliningInfo InlinedContext;
+
if (DebugInfoContext) {
InlinedContext = DebugInfoContext->getInliningInfoForAddress(
ModuleOffset, getDILineInfoSpecifier(Opts));
@@ -461,7 +464,18 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
Modules.insert(make_pair(ModuleName, (ModuleInfo *)nullptr));
return nullptr;
}
- DIContext *Context = new DWARFContextInMemory(*Objects.second);
+ DIContext *Context = nullptr;
+ if (auto CoffObject = dyn_cast<COFFObjectFile>(Objects.first)) {
+ // If this is a COFF object, assume it contains PDB debug information. If
+ // we don't find any we will fall back to the DWARF case.
+ std::unique_ptr<IPDBSession> Session;
+ PDB_ErrorCode Error = loadDataForEXE(PDB_ReaderType::DIA,
+ Objects.first->getFileName(), Session);
+ if (Error == PDB_ErrorCode::Success)
+ Context = new PDBContext(*CoffObject, std::move(Session));
+ }
+ if (!Context)
+ Context = new DWARFContextInMemory(*Objects.second);
assert(Context);
ModuleInfo *Info = new ModuleInfo(Objects.first, Context);
Modules.insert(make_pair(ModuleName, Info));
diff --git a/tools/llvm-symbolizer/llvm-symbolizer.cpp b/tools/llvm-symbolizer/llvm-symbolizer.cpp
index cb40472f9d2..7a77a4476e3 100644
--- a/tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ b/tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -17,6 +17,7 @@
#include "LLVMSymbolize.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/COM.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileSystem.h"
@@ -123,6 +124,8 @@ int main(int argc, char **argv) {
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
+ llvm::sys::InitializeCOMRAII COM(llvm::sys::COMThreadingMode::MultiThreaded);
+
cl::ParseCommandLineOptions(argc, argv, "llvm-symbolizer\n");
LLVMSymbolizer::Options Opts(ClUseSymbolTable, ClPrintFunctions,
ClPrintInlining, ClDemangle, ClDefaultArch);
@@ -146,5 +149,6 @@ int main(int argc, char **argv) {
outs() << Result << "\n";
outs().flush();
}
+
return 0;
}