[PATCH] D55723: [llvm-symbolizer] Omit stderr output when symbolizing a stacktrace

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 14 14:40:31 PST 2018


aganea created this revision.
aganea added reviewers: rnk, zturner.
Herald added a reviewer: jfb.
Herald added a subscriber: kristina.

As discussed previously, don't print errors when symbolizing a stack trace:

  LLVMSymbolizer: error reading file: 'ucrtbased.pdb': no such file or directory
  LLVMSymbolizer: error reading file: 'kernel32.pdb': no such file or directory
  LLVMSymbolizer: error reading file: 'ntdll.pdb': no such file or directory
  #0 0x00007ff71c62501c HandleAbort f:\svn\llvm\lib\support\windows\signals.inc:409:0
  #1 0x00007ffe6510bba1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6bba1)
  #2 0x00007ffe6510d7f9 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6d7f9)

...now shows:

  #0 0x00007ff71c62501c HandleAbort f:\svn\llvm\lib\support\windows\signals.inc:409:0
  #1 0x00007ffe6510bba1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6bba1)
  #2 0x00007ffe6510d7f9 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6d7f9)

I've also aligned the count at the begining of the line (I can commit two separate patches if you wish):

   #0 0x00007ff7e7004fbc HandleAbort f:\svn\llvm\lib\support\windows\signals.inc:409:0
   #1 0x00007ffe674fbba1 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0x6bba1)
                          (...)
   #9 0x00007ff7e720b3c1 <lambda_0a1b45eabab73a8e6866a119e7429fe9>::operator() f:\svn\lld\coff\pdb.cpp:1227:0
  #10 0x00007ff7e71f1b4e llvm::codeview::forEachCodeViewRecord f:\svn\llvm\include\llvm\debuginfo\codeview\cvrecord.h:77:0
  #11 0x00007ff7e71d7ea3 `anonymous namespace'::PDBLinker::mergeSymbolRecords f:\svn\lld\coff\pdb.cpp:1197:0


Repository:
  rL LLVM

https://reviews.llvm.org/D55723

Files:
  lib/Support/Signals.cpp


Index: lib/Support/Signals.cpp
===================================================================
--- lib/Support/Signals.cpp
+++ 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 @@
   }
 
   Optional<StringRef> Redirects[] = {StringRef(InputFile),
-                                     StringRef(OutputFile), llvm::None};
+                                     StringRef(OutputFile), ""};
   StringRef Args[] = {"llvm-symbolizer", "--functions=linkage", "--inlining",
 #ifdef _WIN32
                       // Pass --relative-address on Windows so that we don't
@@ -180,8 +182,14 @@
   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 @@
       StringRef FunctionName = *CurLine++;
       if (FunctionName.empty())
         break;
-      OS << '#' << frame_no++ << ' ' << format_ptr(StackTrace[i]) << ' ';
+      PrintLineHeader();
       if (!FunctionName.startswith("??"))
         OS << FunctionName << ' ';
       if (CurLine == Lines.end())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55723.178293.patch
Type: text/x-patch
Size: 1774 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181214/f7a55ada/attachment.bin>


More information about the llvm-commits mailing list