Follow-up to r219534 to make symbolization more robust.
authorAlexey Samsonov <vonosmas@gmail.com>
Fri, 10 Oct 2014 22:58:26 +0000 (22:58 +0000)
committerAlexey Samsonov <vonosmas@gmail.com>
Fri, 10 Oct 2014 22:58:26 +0000 (22:58 +0000)
1) Explicitly provide important arguments to llvm-symbolizer,
not relying on defaults.
2) Be more defensive about symbolizer output.

This might fix weird failures on ninja-x64-msvc-RA-centos6 buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219541 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Unix/Signals.inc

index a9e484003e1cf2c006674c5cb6aedbcb2262455e..a19cc61c3c120a9a5865dde23127d2746f129c61 100644 (file)
@@ -363,9 +363,10 @@ static bool printSymbolizedStackTrace(void **StackTrace, int Depth, FILE *FD) {
     }
   }
 
-  const char *args[] = {"llvm-symbolizer", nullptr};
+  const char *Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
+                        "--demangle", nullptr};
   int RunResult =
-      sys::ExecuteAndWait(LLVMSymbolizerPath, args, nullptr, Redirects.data());
+      sys::ExecuteAndWait(LLVMSymbolizerPath, Args, nullptr, Redirects.data());
   if (RunResult != 0)
     return false;
 
@@ -385,12 +386,16 @@ static bool printSymbolizedStackTrace(void **StackTrace, int Depth, FILE *FD) {
     // Read pairs of lines (function name and file/line info) until we
     // encounter empty line.
     for (;;) {
+      if (CurLine == Lines.end())
+        return false;
       StringRef FunctionName = *CurLine++;
       if (FunctionName.empty())
         break;
       fprintf(FD, "#%d %p ", frame_no++, StackTrace[i]);
       if (!FunctionName.startswith("??"))
         fprintf(FD, "%s ", FunctionName.str().c_str());
+      if (CurLine == Lines.end())
+        return false;
       StringRef FileLineInfo = *CurLine++;
       if (!FileLineInfo.startswith("??"))
         fprintf(FD, "%s", FileLineInfo.str().c_str());