[PATCH] D29094: Add verbose printing of line info in LLVM Symbolizer

Simon Que via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 24 12:54:55 PST 2017


sque created this revision.
Herald added a subscriber: mehdi_amini.

The verbose mode prints out all the fields of DILineInfo in human-readable form.


https://reviews.llvm.org/D29094

Files:
  include/llvm/DebugInfo/Symbolize/DIPrinter.h
  lib/DebugInfo/Symbolize/DIPrinter.cpp
  tools/llvm-symbolizer/llvm-symbolizer.cpp


Index: tools/llvm-symbolizer/llvm-symbolizer.cpp
===================================================================
--- tools/llvm-symbolizer/llvm-symbolizer.cpp
+++ tools/llvm-symbolizer/llvm-symbolizer.cpp
@@ -85,6 +85,9 @@
     "print-source-context-lines", cl::init(0),
     cl::desc("Print N number of source file context"));
 
+static cl::opt<bool> ClVerbose("verbose", cl::init(false),
+                               cl::desc("Print verbose line info"));
+
 template<typename T>
 static bool error(Expected<T> &ResOrErr) {
   if (ResOrErr)
@@ -160,7 +163,7 @@
   LLVMSymbolizer Symbolizer(Opts);
 
   DIPrinter Printer(outs(), ClPrintFunctions != FunctionNameKind::None,
-                    ClPrettyPrint, ClPrintSourceContextLines);
+                    ClPrettyPrint, ClPrintSourceContextLines, ClVerbose);
 
   const int kMaxInputStringLength = 1024;
   char InputString[kMaxInputStringLength];
Index: lib/DebugInfo/Symbolize/DIPrinter.cpp
===================================================================
--- lib/DebugInfo/Symbolize/DIPrinter.cpp
+++ lib/DebugInfo/Symbolize/DIPrinter.cpp
@@ -78,8 +78,15 @@
   std::string Filename = Info.FileName;
   if (Filename == kDILineInfoBadString)
     Filename = kBadString;
-  OS << Filename << ":" << Info.Line << ":" << Info.Column << "\n";
-  printContext(Filename, Info.Line);
+  if (Verbose) {
+    OS << "  Filename: " << Filename << "\n";
+    OS << "  Line: " << Info.Line << "\n";
+    OS << "  Column: " << Info.Column << "\n";
+    OS << "  Discriminator: " << Info.Discriminator << "\n";
+  } else {
+    OS << Filename << ":" << Info.Line << ":" << Info.Column << "\n";
+    printContext(Filename, Info.Line);
+  }
 }
 
 DIPrinter &DIPrinter::operator<<(const DILineInfo &Info) {
Index: include/llvm/DebugInfo/Symbolize/DIPrinter.h
===================================================================
--- include/llvm/DebugInfo/Symbolize/DIPrinter.h
+++ include/llvm/DebugInfo/Symbolize/DIPrinter.h
@@ -29,15 +29,18 @@
   bool PrintFunctionNames;
   bool PrintPretty;
   int PrintSourceContext;
+  bool Verbose;
 
   void print(const DILineInfo &Info, bool Inlined);
   void printContext(const std::string &FileName, int64_t Line);
 
 public:
   DIPrinter(raw_ostream &OS, bool PrintFunctionNames = true,
-            bool PrintPretty = false, int PrintSourceContext = 0)
+            bool PrintPretty = false, int PrintSourceContext = 0,
+            bool Verbose = false)
       : OS(OS), PrintFunctionNames(PrintFunctionNames),
-        PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext) {}
+        PrintPretty(PrintPretty), PrintSourceContext(PrintSourceContext),
+        Verbose(Verbose) {}
 
   DIPrinter &operator<<(const DILineInfo &Info);
   DIPrinter &operator<<(const DIInliningInfo &Info);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29094.85623.patch
Type: text/x-patch
Size: 2790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170124/cb40f1dd/attachment.bin>


More information about the llvm-commits mailing list