diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2019-01-20 11:41:25 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2019-01-20 11:41:25 +0000 | 
| commit | d9484dd61cc151c4f34c31e07f693fefa66316b5 (patch) | |
| tree | ab0560b3da293f1fafd3269c59692e929418f5c2 /contrib/llvm/lib/Support/Signals.cpp | |
| parent | 79e0962d4c3cf1f0acf359a9d69cb3ac68c414c4 (diff) | |
| parent | d8e91e46262bc44006913e6796843909f1ac7bcd (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/lib/Support/Signals.cpp')
| -rw-r--r-- | contrib/llvm/lib/Support/Signals.cpp | 14 | 
1 files changed, 11 insertions, 3 deletions
diff --git a/contrib/llvm/lib/Support/Signals.cpp b/contrib/llvm/lib/Support/Signals.cpp index 6534ff69b84c..333f492d4589 100644 --- a/contrib/llvm/lib/Support/Signals.cpp +++ b/contrib/llvm/lib/Support/Signals.cpp @@ -20,6 +20,8 @@  #include "llvm/Support/FileSystem.h"  #include "llvm/Support/FileUtilities.h"  #include "llvm/Support/Format.h" +#include "llvm/Support/FormatVariadic.h" +#include "llvm/Support/FormatAdapters.h"  #include "llvm/Support/ManagedStatic.h"  #include "llvm/Support/MemoryBuffer.h"  #include "llvm/Support/Mutex.h" @@ -155,7 +157,7 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,    }    Optional<StringRef> Redirects[] = {StringRef(InputFile), -                                     StringRef(OutputFile), llvm::None}; +                                     StringRef(OutputFile), StringRef("")};    StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",  #ifdef _WIN32                        // Pass --relative-address on Windows so that we don't @@ -180,8 +182,14 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,    auto CurLine = Lines.begin();    int frame_no = 0;    for (int i = 0; i < Depth; i++) { +    auto PrintLineHeader = [&]() { +      OS << right_justify(formatv("#{0}", frame_no++).str(), +                          std::log10(Depth) + 2) +         << ' ' << format_ptr(StackTrace[i]) << ' '; +    };      if (!Modules[i]) { -      OS << '#' << frame_no++ << ' ' << format_ptr(StackTrace[i]) << '\n'; +      PrintLineHeader(); +      OS << '\n';        continue;      }      // Read pairs of lines (function name and file/line info) until we @@ -192,7 +200,7 @@ static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace,        StringRef FunctionName = *CurLine++;        if (FunctionName.empty())          break; -      OS << '#' << frame_no++ << ' ' << format_ptr(StackTrace[i]) << ' '; +      PrintLineHeader();        if (!FunctionName.startswith("??"))          OS << FunctionName << ' ';        if (CurLine == Lines.end())  | 
