[llvm] 9be3567 - [llvm-dwarfdump] Add a table header for -debug-line -verbose output
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 4 08:58:10 PDT 2020
Author: Fangrui Song
Date: 2020-06-04T08:56:17-07:00
New Revision: 9be3567df20a9f2819d29d8e32f4eee73a4408fd
URL: https://github.com/llvm/llvm-project/commit/9be3567df20a9f2819d29d8e32f4eee73a4408fd
DIFF: https://github.com/llvm/llvm-project/commit/9be3567df20a9f2819d29d8e32f4eee73a4408fd.diff
LOG: [llvm-dwarfdump] Add a table header for -debug-line -verbose output
Like non-verbose output, so that it is easy to recognize the `Line,Column,File,ISA,Discriminator` column values.
Reviewed By: JDevlieghere, jhenderson
Differential Revision: https://reviews.llvm.org/D80874
Added:
Modified:
llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
llvm/test/tools/llvm-dwarfdump/X86/verbose.test
Removed:
################################################################################
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
index 1de94aed470b..4cf64edb82db 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
@@ -143,7 +143,7 @@ class DWARFDebugLine {
void reset(bool DefaultIsStmt);
void dump(raw_ostream &OS) const;
- static void dumpTableHeader(raw_ostream &OS);
+ static void dumpTableHeader(raw_ostream &OS, unsigned Indent);
static bool orderByAddress(const Row &LHS, const Row &RHS) {
return std::tie(LHS.Address.SectionIndex, LHS.Address.Address) <
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 2c1c28407ac5..7fb950a95d29 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -460,10 +460,12 @@ void DWARFDebugLine::Row::reset(bool DefaultIsStmt) {
EpilogueBegin = false;
}
-void DWARFDebugLine::Row::dumpTableHeader(raw_ostream &OS) {
- OS << "Address Line Column File ISA Discriminator Flags\n"
- << "------------------ ------ ------ ------ --- ------------- "
- "-------------\n";
+void DWARFDebugLine::Row::dumpTableHeader(raw_ostream &OS, unsigned Indent) {
+ OS.indent(Indent)
+ << "Address Line Column File ISA Discriminator Flags\n";
+ OS.indent(Indent)
+ << "------------------ ------ ------ ------ --- ------------- "
+ "-------------\n";
}
void DWARFDebugLine::Row::dump(raw_ostream &OS) const {
@@ -494,7 +496,7 @@ void DWARFDebugLine::LineTable::dump(raw_ostream &OS,
if (!Rows.empty()) {
OS << '\n';
- Row::dumpTableHeader(OS);
+ Row::dumpTableHeader(OS, 0);
for (const Row &R : Rows) {
R.dump(OS);
}
@@ -737,6 +739,10 @@ Error DWARFDebugLine::LineTable::parse(
ParsingState State(this, DebugLineOffset, RecoverableErrorHandler);
*OffsetPtr = DebugLineOffset + Prologue.getLength();
+ if (OS && *OffsetPtr < EndOffset) {
+ *OS << '\n';
+ Row::dumpTableHeader(*OS, 12);
+ }
while (*OffsetPtr < EndOffset) {
if (OS)
*OS << format("0x%08.08" PRIx64 ": ", *OffsetPtr);
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
index 4f128788b102..5b1ebde8b77c 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
@@ -763,7 +763,7 @@ void DWARFVerifier::verifyDebugLineRows() {
<< "] row[" << RowIndex
<< "] decreases in address from previous row:\n";
- DWARFDebugLine::Row::dumpTableHeader(OS);
+ DWARFDebugLine::Row::dumpTableHeader(OS, 0);
if (RowIndex > 0)
LineTable->Rows[RowIndex - 1].dump(OS);
Row.dump(OS);
@@ -781,7 +781,7 @@ void DWARFVerifier::verifyDebugLineRows() {
<< " (valid values are [" << (isDWARF5 ? "0," : "1,")
<< LineTable->Prologue.FileNames.size()
<< (isDWARF5 ? ")" : "]") << "):\n";
- DWARFDebugLine::Row::dumpTableHeader(OS);
+ DWARFDebugLine::Row::dumpTableHeader(OS, 0);
Row.dump(OS);
OS << '\n';
}
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
index 23ebdf1ad6f1..8017b9327188 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_line_invalid.test
@@ -38,7 +38,9 @@
# RUN: FileCheck %s --input-file=%t-malformed-off-last.err --check-prefix=ALL
# FIRST: debug_line[0x00000000]
-# VERBOSE: DW_LNE_set_address (0x000000000badbeef)
+# VERBOSE: Address Line Column File ISA Discriminator Flags
+# VERBOSE-NEXT: ------------------ ------ ------ ------ --- ------------- -------------
+# VERBOSE-NEXT: DW_LNE_set_address (0x000000000badbeef)
# VERBOSE-NEXT: DW_LNE_end_sequence
# FIRST: 0x000000000badbeef {{.*}} end_sequence
# NOFIRST-NOT: debug_line[0x00000000]
@@ -51,6 +53,7 @@
# RESERVED-NOT: prologue
# RESERVED: warning: parsing line table prologue at offset 0x00000048: unsupported reserved unit length of value 0xfffffffe
# RESERVED-NOT: prologue
+# RESERVED-NOT: Address
# FATAL-NOT: debug_line
## For non-fatal issues, the table data should be dumped:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/verbose.test b/llvm/test/tools/llvm-dwarfdump/X86/verbose.test
index a05edb9a2ae1..64b596af8383 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/verbose.test
+++ b/llvm/test/tools/llvm-dwarfdump/X86/verbose.test
@@ -1,25 +1,35 @@
-# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o - \
-# RUN: | llvm-dwarfdump -v --debug-info --debug-line - \
-# RUN: | FileCheck %s
+# RUN: llvm-mc %S/brief.s -filetype obj -triple x86_64-apple-darwin -o %t.o
+# RUN: llvm-dwarfdump -v --debug-info --debug-line %t.o | \
+# RUN: FileCheck %s --match-full-lines --strict-whitespace
-# CHECK-NOT: .debug_abbrev contents:
+# CHECK-NOT:{{.*}} contents:
-# CHECK: .debug_info contents:
-# CHECK: DW_TAG_compile_unit [1]
-# CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "brief.c")
-# CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "main")
-# CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "int")
+# CHECK:.debug_info contents:
+# CHECK:0x0000000b: DW_TAG_compile_unit [1] *
+# CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "brief.c")
+# CHECK:0x0000002a: DW_TAG_subprogram [2]
+# CHECK: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "main")
+# CHECK:0x00000043: DW_TAG_base_type [3]
+# CHECK-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x{{.*}}] = "int")
-# CHECK: .debug_line contents:
-# CHECK: 00 DW_LNE_set_address (0x0000000000000000)
-# CHECK: 01 DW_LNS_copy
-# CHECK: 0x0000000000000000 1 0 1 0 0 is_stmt
-# CHECK: 05 DW_LNS_set_column (12)
-# CHECK: 0a DW_LNS_set_prologue_end
-# CHECK: 66 address += 6, line += 0
-# CHECK: 0x0000000000000006 1 12 1 0 0 is_stmt prologue_end
-# CHECK: 02 DW_LNS_advance_pc (2)
-# CHECK: 00 DW_LNE_end_sequence
-# CHECK: 0x0000000000000008 1 12 1 0 0 is_stmt end_sequence
-#
-# CHECK-NOT: {{.*}} contents:
+# CHECK:.debug_line contents:
+# CHECK: length: 0x00000000
+# CHECK-EMPTY:
+# CHECK-NEXT: Address Line Column File ISA Discriminator Flags
+# CHECK-NEXT: ------------------ ------ ------ ------ --- ------------- -------------
+# CHECK-NEXT:0x00000029: 00 DW_LNE_set_address (0x0000000000000000)
+# CHECK-NEXT:0x00000034: 01 DW_LNS_copy
+# CHECK-NEXT: 0x0000000000000000 1 0 1 0 0 is_stmt
+# CHECK-EMPTY:
+# CHECK-EMPTY:
+# CHECK:0x00000035: 05 DW_LNS_set_column (12)
+# CHECK-NEXT:0x00000037: 0a DW_LNS_set_prologue_end
+# CHECK-NEXT:0x00000038: 66 address += 6, line += 0
+# CHECK-NEXT: 0x0000000000000006 1 12 1 0 0 is_stmt prologue_end
+# CHECK-EMPTY:
+# CHECK-NEXT:0x00000039: 02 DW_LNS_advance_pc (2)
+# CHECK-NEXT:0x0000003b: 00 DW_LNE_end_sequence
+# CHECK-NEXT: 0x0000000000000008 1 12 1 0 0 is_stmt end_sequence
+# CHECK-EMPTY:
+
+# CHECK-NOT:{{.*}} contents:
More information about the llvm-commits
mailing list