[lib/Fuzzer] add a trace-based mutatation logic. Same idea as with DFSan-based mutato...
[oota-llvm.git] / tools / llvm-symbolizer / LLVMSymbolize.cpp
index 326cab5a186041d827caf24eeddb7c5f7a0b93e9..afb7cc81c824cfd0abe51a9ed18dae16b75a8392 100644 (file)
 #include <sstream>
 #include <stdlib.h>
 
+#if defined(_MSC_VER)
+#include <Windows.h>
+#include <DbgHelp.h>
+#endif
+
 namespace llvm {
 namespace symbolize {
 
@@ -471,8 +476,10 @@ LLVMSymbolizer::getOrCreateModuleInfo(const std::string &ModuleName) {
     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 (Error == PDB_ErrorCode::Success) {
+      Context = new PDBContext(*CoffObject, std::move(Session),
+                               Opts.RelativeAddresses);
+    }
   }
   if (!Context)
     Context = new DWARFContextInMemory(*Objects.second);
@@ -522,7 +529,17 @@ std::string LLVMSymbolizer::DemangleName(const std::string &Name) {
   free(DemangledName);
   return Result;
 #else
-  return Name;
+  char DemangledName[1024] = {0};
+  DWORD result = ::UnDecorateSymbolName(
+      Name.c_str(), DemangledName, 1023,
+      UNDNAME_NO_ACCESS_SPECIFIERS |       // Strip public, private, protected
+          UNDNAME_NO_ALLOCATION_LANGUAGE | // Strip __thiscall, __stdcall, etc
+          UNDNAME_NO_THROW_SIGNATURES |    // Strip throw() specifications
+          UNDNAME_NO_MEMBER_TYPE |      // Strip virtual, static, etc specifiers
+          UNDNAME_NO_MS_KEYWORDS |      // Strip all MS extension keywords
+          UNDNAME_NO_FUNCTION_RETURNS); // Strip function return types
+
+  return (result == 0) ? Name : std::string(DemangledName);
 #endif
 }