From 8bdcdd9e37fee3b71d696a5892a95eb3c74ed54d Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 10 Oct 2014 22:58:26 +0000 Subject: [PATCH] Follow-up to r219534 to make symbolization more robust. 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. llvm-svn: 219541 --- lib/Support/Unix/Signals.inc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Support/Unix/Signals.inc b/lib/Support/Unix/Signals.inc index a9e484003e1..a19cc61c3c1 100644 --- a/lib/Support/Unix/Signals.inc +++ b/lib/Support/Unix/Signals.inc @@ -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());