[Lldb-commits] [lldb] r341506 - Print column info in backtraces et al. if available

Adrian Prantl via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 5 16:52:08 PDT 2018


Author: adrian
Date: Wed Sep  5 16:52:08 2018
New Revision: 341506

URL: http://llvm.org/viewvc/llvm-project?rev=341506&view=rev
Log:
Print column info in backtraces et al. if available

This patch allows LLDB to print column info in backtraces et al. if
available, which is useful when the backtrace contains a frame like
the following:

  f(can_crash(0), can_crash(1));

Differential Revision: https://reviews.llvm.org/D51661

Modified:
    lldb/trunk/include/lldb/Core/FormatEntity.h
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
    lldb/trunk/source/Core/Debugger.cpp
    lldb/trunk/source/Core/FormatEntity.cpp

Modified: lldb/trunk/include/lldb/Core/FormatEntity.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/FormatEntity.h?rev=341506&r1=341505&r2=341506&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/FormatEntity.h (original)
+++ lldb/trunk/include/lldb/Core/FormatEntity.h Wed Sep  5 16:52:08 2018
@@ -104,6 +104,7 @@ public:
       FunctionIsOptimized,
       LineEntryFile,
       LineEntryLineNumber,
+      LineEntryColumn,
       LineEntryStartAddress,
       LineEntryEndAddress,
       CurrentPCArrow

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile?rev=341506&r1=341505&r2=341506&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/Makefile Wed Sep  5 16:52:08 2018
@@ -1,6 +1,6 @@
 LEVEL = ../../make
 
 C_SOURCES := main.c
-CFLAGS_EXTRAS := -fsanitize=address -g
+CFLAGS_EXTRAS := -fsanitize=address -g -gcolumn-info
 
 include $(LEVEL)/Makefile.rules

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py?rev=341506&r1=341505&r2=341506&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/asan/TestReportData.py Wed Sep  5 16:52:08 2018
@@ -37,6 +37,7 @@ class AsanTestReportDataCase(TestBase):
         self.line_free = line_number('main.c', '// free line')
         self.line_breakpoint = line_number('main.c', '// break line')
         self.line_crash = line_number('main.c', '// BOOM line')
+        self.col_crash = 16
 
     def asan_tests(self):
         exe = self.getBuildArtifact("a.out")
@@ -63,7 +64,7 @@ class AsanTestReportDataCase(TestBase):
             lldb.eStopReasonInstrumentation)
 
         self.expect("bt", "The backtrace should show the crashing line",
-                    substrs=['main.c:%d' % self.line_crash])
+                    substrs=['main.c:%d:%d' % (self.line_crash, self.col_crash)])
 
         self.expect(
             "thread info -s",

Modified: lldb/trunk/source/Core/Debugger.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=341506&r1=341505&r2=341506&view=diff
==============================================================================
--- lldb/trunk/source/Core/Debugger.cpp (original)
+++ lldb/trunk/source/Core/Debugger.cpp Wed Sep  5 16:52:08 2018
@@ -121,7 +121,8 @@ OptionEnumValueElement g_language_enumer
   "${module.file.basename}{`${function.name-without-args}"                     \
   "{${frame.no-debug}${function.pc-offset}}}}"
 
-#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
+#define FILE_AND_LINE                                                          \
+  "{ at ${line.file.basename}:${line.number}{:${line.column}}}"
 #define IS_OPTIMIZED "{${function.is-optimized} [opt]}"
 
 #define DEFAULT_THREAD_FORMAT                                                  \

Modified: lldb/trunk/source/Core/FormatEntity.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/FormatEntity.cpp?rev=341506&r1=341505&r2=341506&view=diff
==============================================================================
--- lldb/trunk/source/Core/FormatEntity.cpp (original)
+++ lldb/trunk/source/Core/FormatEntity.cpp Wed Sep  5 16:52:08 2018
@@ -146,6 +146,7 @@ static FormatEntity::Entry::Definition g
 static FormatEntity::Entry::Definition g_line_child_entries[] = {
     ENTRY_CHILDREN("file", LineEntryFile, None, g_file_child_entries),
     ENTRY("number", LineEntryLineNumber, UInt32),
+    ENTRY("column", LineEntryColumn, UInt32),
     ENTRY("start-addr", LineEntryStartAddress, UInt64),
     ENTRY("end-addr", LineEntryEndAddress, UInt64),
 };
@@ -372,6 +373,7 @@ const char *FormatEntity::Entry::TypeToC
     ENUM_TO_CSTR(FunctionIsOptimized);
     ENUM_TO_CSTR(LineEntryFile);
     ENUM_TO_CSTR(LineEntryLineNumber);
+    ENUM_TO_CSTR(LineEntryColumn);
     ENUM_TO_CSTR(LineEntryStartAddress);
     ENUM_TO_CSTR(LineEntryEndAddress);
     ENUM_TO_CSTR(CurrentPCArrow);
@@ -1813,6 +1815,16 @@ bool FormatEntity::Format(const Entry &e
       return true;
     }
     return false;
+
+  case Entry::Type::LineEntryColumn:
+    if (sc && sc->line_entry.IsValid() && sc->line_entry.column) {
+      const char *format = "%" PRIu32;
+      if (!entry.printf_format.empty())
+        format = entry.printf_format.c_str();
+      s.Printf(format, sc->line_entry.column);
+      return true;
+    }
+    return false;
 
   case Entry::Type::LineEntryStartAddress:
   case Entry::Type::LineEntryEndAddress:




More information about the lldb-commits mailing list