[PATCH] Make llvm-symbolizer work on Windows.

Alexey Samsonov vonosmas at gmail.com
Thu Apr 23 18:12:40 PDT 2015


================
Comment at: include/llvm/DebugInfo/PDB/PDBContext.h:10
@@ +9,3 @@
+
+#ifndef LLVM_LIB_DEBUGINFO_PDBCONTEXT_H
+#define LLVM_LIB_DEBUGINFO_PDBCONTEXT_H
----------------
Header guard looks wrong.

================
Comment at: include/llvm/DebugInfo/PDB/PDBContext.h:30
@@ +29,3 @@
+
+  PDBContext(PDBContext &) = delete;
+  PDBContext &operator=(PDBContext &) = delete;
----------------
Will these be implicitly deleted anyway?

================
Comment at: lib/DebugInfo/PDB/PDBContext.cpp:37
@@ +36,3 @@
+  }
+  Session->setLoadAddress(ImageBase);
+}
----------------
Note that ImageBase may be uninitialized at this point.

================
Comment at: lib/DebugInfo/PDB/PDBContext.cpp:60
@@ +59,3 @@
+    auto LineInfo = LineNumbers->getNext();
+    auto SourceFile = Session->getSourceFileById(LineInfo->getSourceFileId());
+
----------------
Can LineInfo be nullptr at this point?

================
Comment at: tools/llvm-symbolizer/LLVMSymbolize.cpp:169
@@ -166,1 +168,3 @@
   DIInliningInfo InlinedContext;
+  // PDB doesn't yet support inline information.
+  if (isa<PDBContext>(DebugInfoContext.get()))
----------------
The code has assumption that ModuleInfo::symbolizeInlinedCode() always returns *some* frames (at least one empty) - see the special case for InlinedContext.getNumberOfFrames() == 0. Hence, the assert in LLVMSymbolizer::symbolizeCode().

I think, that's a wrong place to add a fallback - instead you can make PDBContext::getInliningInfoForAddress() return a DIInliningInfo with a single frame, obtained from PDBContext::getLineInfoForAddress().

================
Comment at: tools/llvm-symbolizer/llvm-symbolizer.cpp:131
@@ -125,1 +130,3 @@
 
+#if defined(_WIN32) && defined(HAVE_DIA_SDK)
+  ::CoInitializeEx(nullptr, COINIT_MULTITHREADED);
----------------
Can you create RAII object that would call CoInitializeEx in ctor and CoUninitialize in dtor (and use it in applicable tools - for now llvm-symbolizer / llvm-dwarfdump)? It can have empty implementation on non-Windows platforms.

http://reviews.llvm.org/D9234

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list