[Lldb-commits] [lldb] 208a11a - Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
David Blaikie via lldb-commits
lldb-commits at lists.llvm.org
Tue Apr 14 14:44:44 PDT 2020
Author: David Blaikie
Date: 2020-04-14T14:44:32-07:00
New Revision: 208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f
URL: https://github.com/llvm/llvm-project/commit/208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f
DIFF: https://github.com/llvm/llvm-project/commit/208a11ab3a7be7c3e5d3fae9dd4affdb01a0ed1f.diff
LOG: Reapply "llvm-dwarfdump: Report errors when failing to parse loclist/debug_loc entries""
Originally committed as 416fa7720e30750939c53935051c6c750dfad2c2
Reverted (due to buildbot failure - breaking lldb) in 7a45aeacf3a23449039ef2efcf476995ae1c7007.
I still can't seem to build lldb locally, but Pavel Labath has kindly
provided a potential fix to preserve the old behavior in lldb by
registering a simple recoverable error handler there that prints to the
desired stream in lldb, rather than stderr.
Added:
Modified:
lldb/source/Expression/DWARFExpression.cpp
lldb/test/Shell/SymbolFile/DWARF/debug_loc.s
llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases2.s
llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s
llvm/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s
llvm/test/DebugInfo/X86/dwarfdump-str-offsets-invalid-6.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_address_size_not_multiple.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_segment_selector.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_extended_length_field.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_length_field.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists.s
llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Removed:
################################################################################
diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp
index 04fbfccd0c2e..e85b5f341fe5 100644
--- a/lldb/source/Expression/DWARFExpression.cpp
+++ b/lldb/source/Expression/DWARFExpression.cpp
@@ -137,12 +137,15 @@ void DWARFExpression::GetDescription(Stream *s, lldb::DescriptionLevel level,
m_dwarf_cu->GetLocationTable(m_data);
llvm::MCRegisterInfo *MRI = abi ? &abi->GetMCRegisterInfo() : nullptr;
-
+ llvm::DIDumpOptions DumpOpts;
+ DumpOpts.RecoverableErrorHandler = [&](llvm::Error E) {
+ s->AsRawOstream() << "error: " << toString(std::move(E));
+ };
loctable_up->dumpLocationList(
&offset, s->AsRawOstream(),
llvm::object::SectionedAddress{m_loclist_addresses->cu_file_addr}, MRI,
DummyDWARFObject(m_data.GetByteOrder() == eByteOrderLittle), nullptr,
- llvm::DIDumpOptions(), s->GetIndentLevel() + 2);
+ DumpOpts, s->GetIndentLevel() + 2);
} else {
// We have a normal location that contains DW_OP location opcodes
DumpLocation(s, m_data, level, abi);
diff --git a/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s b/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s
index 1410ff2674ff..0068b63744e9 100644
--- a/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s
+++ b/lldb/test/Shell/SymbolFile/DWARF/debug_loc.s
@@ -29,8 +29,7 @@
# CHECK-NEXT: [0x0000000000000000, 0x0000000000000001): DW_OP_reg5 RDI
# CHECK-NEXT: [0x0000000000000001, 0x0000000000000006): DW_OP_reg0 RAX
# CHECK: Variable{{.*}}, name = "x1", {{.*}}, scope = parameter
-# CHECK: Variable{{.*}}, name = "x2", {{.*}}, scope = parameter, location =
-# CHECK-NEXT: error: unexpected end of data
+# CHECK: Variable{{.*}}, name = "x2", {{.*}}, scope = parameter, location = 0x00000000: error: unexpected end of data
# CHECK: Variable{{.*}}, name = "x3", {{.*}}, scope = parameter, location =
# CHECK-NEXT: [0x0000000000000002, 0x0000000000000003): DW_OP_reg1 RDX
# LOCLISTS: Variable{{.*}}, name = "x4", {{.*}}, scope = parameter, location =
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
index 8f047bb872e5..17f0b7f5c32a 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLoc.cpp
@@ -156,9 +156,7 @@ bool DWARFLocationTable::dumpLocationList(uint64_t *Offset, raw_ostream &OS,
return true;
});
if (E) {
- OS << "\n";
- OS.indent(Indent);
- OS << "error: " << toString(std::move(E));
+ DumpOpts.RecoverableErrorHandler(std::move(E));
return false;
}
return true;
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
index 5ee701b03fba..b623894d5e2d 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases.s
@@ -1,20 +1,20 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE1=0 -o %t1.o
-# RUN: llvm-dwarfdump -debug-loc %t1.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t1.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE2=0 -o %t2.o
-# RUN: llvm-dwarfdump -debug-loc %t2.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t2.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE3=0 -o %t3.o
-# RUN: llvm-dwarfdump -debug-loc %t3.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t3.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE4=0 -o %t4.o
-# RUN: llvm-dwarfdump -debug-loc %t4.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t4.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE5=0 -o %t5.o
-# RUN: llvm-dwarfdump -debug-loc %t5.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t5.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE6=0 -o %t6.o
-# RUN: llvm-dwarfdump -debug-loc %t6.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loc %t6.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE7=0 -o %t7.o
# RUN: llvm-dwarfdump -debug-loc %t7.o 2>&1 | FileCheck %s --check-prefix=UNKNOWN-REG
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases2.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases2.s
index 7e951e58d2c7..8a1abd6684d1 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases2.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loc-error-cases2.s
@@ -1,5 +1,6 @@
# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
-# RUN: llvm-dwarfdump %t | FileCheck %s
+# RUN: not llvm-dwarfdump %t 2>%t.err | FileCheck %s
+# RUN: FileCheck %s < %t.err -check-prefix=ERR
# CHECK: DW_AT_name ("x0")
# CHECK-NEXT: DW_AT_location (0x00000000
@@ -7,12 +8,12 @@
# CHECK-NEXT: [0x0000000000000002, 0x0000000000000003): DW_OP_reg0 RAX)
# CHECK: DW_AT_name ("x1")
-# CHECK-NEXT: DW_AT_location (0xdeadbeef
-# CHECK-NEXT: error: unexpected end of data at offset 0xdeadbeef)
+# CHECK-NEXT: DW_AT_location (0xdeadbeef: )
+# ERR: error: unexpected end of data at offset 0xdeadbeef
# CHECK: DW_AT_name ("x2")
-# CHECK-NEXT: DW_AT_location (0x00000036
-# CHECK-NEXT: error: unexpected end of data at offset 0x48)
+# CHECK-NEXT: DW_AT_location (0x00000036: )
+# ERR: error: unexpected end of data at offset 0x48
.type f, at function
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
index bb83684d6028..048104986fa4 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases.s
@@ -1,23 +1,23 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE1=0 -o %t1.o
-# RUN: llvm-dwarfdump -debug-loclists %t1.o 2>&1 | FileCheck %s --check-prefix=ULEB
+# RUN: not llvm-dwarfdump -debug-loclists %t1.o 2>&1 | FileCheck %s --check-prefix=ULEB
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE2=0 -o %t2.o
-# RUN: llvm-dwarfdump -debug-loclists %t2.o 2>&1 | FileCheck %s --check-prefix=ULEB
+# RUN: not llvm-dwarfdump -debug-loclists %t2.o 2>&1 | FileCheck %s --check-prefix=ULEB
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE3=0 -o %t3.o
-# RUN: llvm-dwarfdump -debug-loclists %t3.o 2>&1 | FileCheck %s --check-prefix=ULEB
+# RUN: not llvm-dwarfdump -debug-loclists %t3.o 2>&1 | FileCheck %s --check-prefix=ULEB
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE4=0 -o %t4.o
-# RUN: llvm-dwarfdump -debug-loclists %t4.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loclists %t4.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE5=0 -o %t5.o
-# RUN: llvm-dwarfdump -debug-loclists %t5.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loclists %t5.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE6=0 -o %t6.o
-# RUN: llvm-dwarfdump -debug-loclists %t6.o 2>&1 | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-loclists %t6.o 2>&1 | FileCheck %s
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux --defsym CASE7=0 -o %t7.o
-# RUN: llvm-dwarfdump -debug-loclists %t7.o 2>&1 | FileCheck %s --check-prefix=UNIMPL
+# RUN: not llvm-dwarfdump -debug-loclists %t7.o 2>&1 | FileCheck %s --check-prefix=UNIMPL
# CHECK: error: unexpected end of data
# ULEB: error: malformed uleb128, extends past end
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s
index f15d071cce3d..14dc7f49d681 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-debug-loclists-error-cases2.s
@@ -1,5 +1,6 @@
# RUN: llvm-mc -triple=x86_64-pc-linux -filetype=obj %s > %t
-# RUN: not llvm-dwarfdump %t | FileCheck %s
+# RUN: not llvm-dwarfdump %t 2> %t.err | FileCheck %s
+# RUN: FileCheck %s < %t.err -check-prefix=ERR
# CHECK: DW_AT_name ("x0")
# CHECK-NEXT: DW_AT_location (0x0000000c
@@ -7,12 +8,12 @@
# CHECK-NEXT: [0x0000000000000002, 0x0000000000000003): DW_OP_reg0 RAX)
# CHECK: DW_AT_name ("x1")
-# CHECK-NEXT: DW_AT_location (0xdeadbeef
-# CHECK-NEXT: error: unexpected end of data at offset 0xdeadbeef)
+# CHECK-NEXT: DW_AT_location (0xdeadbeef: )
+# ERR: error: unexpected end of data at offset 0xdeadbeef
# CHECK: DW_AT_name ("x2")
# CHECK-NEXT: DW_AT_location (0x00000025
-# CHECK-NEXT: error: unexpected end of data at offset 0x34)
+# ERR: error: unexpected end of data at offset 0x34
.type f, at function
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s b/llvm/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s
index 7d5a6f938bd4..22254b92e559 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-ranges-baseaddr.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc -triple x86_64-pc-linux -filetype=obj %s -o %t
-# RUN: llvm-dwarfdump -v %t 2>%t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -v %t 2>%t.err | FileCheck %s
# RUN: FileCheck %s <%t.err -check-prefix=ERR
# CHECK: .debug_info contents:
diff --git a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-invalid-6.s b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-invalid-6.s
index 01bc39c68610..6b8c669e143d 100644
--- a/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-invalid-6.s
+++ b/llvm/test/DebugInfo/X86/dwarfdump-str-offsets-invalid-6.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc -triple x86_64-unknown-linux %s -filetype=obj -o %t.o
-# RUN: llvm-dwarfdump -v %t.o 2>&1 | FileCheck --check-prefix=OVERLAP %s
+# RUN: not llvm-dwarfdump -v %t.o 2>&1 | FileCheck --check-prefix=OVERLAP %s
#
# Test object to verify that llvm-dwarfdump handles an invalid string offsets
# table with overlapping contributions.
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_address_size_not_multiple.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_address_size_not_multiple.s
index d758709c6703..dd0c46f3ebf0 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_address_size_not_multiple.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_address_size_not_multiple.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
index 0ad055b2753d..2638471f4426 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_invalid_addr_size.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
index 125be8307507..aaedf7f53810 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o - | \
-# RUN: llvm-dwarfdump --debug-addr - 2>&1 | \
+# RUN: not llvm-dwarfdump --debug-addr - 2>&1 | \
# RUN: FileCheck %s --implicit-check-not=error
# CHECK: error: parsing address table at offset 0x0: unsupported reserved unit length of value 0xfffffff0
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_segment_selector.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_segment_selector.s
index 3200b4f2da3b..5207951c4091 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_segment_selector.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_segment_selector.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
index 3b12737ddf59..b4875335adf0 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_small_length_field.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_extended_length_field.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_extended_length_field.s
index 8ac3cc55324d..1034c97f7647 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_extended_length_field.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_extended_length_field.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_length_field.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_length_field.s
index 1a5154117011..bc840ebf7fab 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_length_field.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_length_field.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
index 5bd90617e259..4de8df404367 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_too_small_for_section.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# CHECK: .debug_addr contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
index 4eeeaa7e6980..dec91fe073fc 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_addr_unsupported_version.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple i386-pc-linux -o - | \
-# RUN: llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
+# RUN: not llvm-dwarfdump -debug-addr - 2> %t.err | FileCheck %s
# RUN: FileCheck %s -input-file %t.err -check-prefix=ERR
# ERR: address table at offset 0x0 has unsupported version 6
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists.s
index 60533ca27217..650fc1aafbd6 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists.s
@@ -1,7 +1,8 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o %t.o
-# RUN: llvm-dwarfdump --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=TERSE,BOTH
+# RUN: not llvm-dwarfdump --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=TERSE,BOTH
+# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
+# RUN: not llvm-dwarfdump -v --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=VERBOSE,BOTH
# RUN: FileCheck %s --input-file %t.err --check-prefix=ERR
-# RUN: llvm-dwarfdump -v --debug-rnglists %t.o 2> %t.err | FileCheck %s --check-prefixes=VERBOSE,BOTH
# BOTH: .debug_rnglists contents:
# TERSE-NEXT: range list header: length = 0x00000037, version = 0x0005, addr_size = 0x08, seg_size = 0x00, offset_entry_count = 0x00000000
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
index b11a2cc8bfde..64060471f055 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_invalid.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %S/Inputs/debug_rnglists_short_section.s -filetype obj -triple x86_64-pc-linux -o - | \
-# RUN: llvm-dwarfdump --debug-rnglists - 2>&1 | FileCheck %s --check-prefix=SHORT
+# RUN: not llvm-dwarfdump --debug-rnglists - 2>&1 | FileCheck %s --check-prefix=SHORT
# SHORT-NOT: error:
# SHORT-NOT: range list header
# SHORT: error: parsing .debug_rnglists table at offset 0x0: unexpected end of data at offset 0x0
@@ -7,7 +7,7 @@
# SHORT-NOT: error:
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o - | \
-# RUN: llvm-dwarfdump --debug-rnglists - 2> %t.err | FileCheck %s --check-prefix=GOOD
+# RUN: not llvm-dwarfdump --debug-rnglists - 2> %t.err | FileCheck %s --check-prefix=GOOD
# RUN: FileCheck %s --input-file %t.err
# GOOD: .debug_rnglists contents:
diff --git a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
index 7db4aefde761..27c30d93cb7b 100644
--- a/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
+++ b/llvm/test/tools/llvm-dwarfdump/X86/debug_rnglists_reserved_length.s
@@ -1,5 +1,5 @@
# RUN: llvm-mc %s -filetype obj -triple x86_64-pc-linux -o - | \
-# RUN: llvm-dwarfdump --debug-rnglists - 2>&1 | \
+# RUN: not llvm-dwarfdump --debug-rnglists - 2>&1 | \
# RUN: FileCheck %s --implicit-check-not=error
# CHECK: error: parsing .debug_rnglists table at offset 0x0: unsupported reserved unit length of value 0xfffffff0
diff --git a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
index 14115c8eb998..31de753e7a19 100644
--- a/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
+++ b/llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
@@ -243,7 +243,7 @@ static void error(StringRef Prefix, std::error_code EC) {
exit(1);
}
-static DIDumpOptions getDumpOpts() {
+static DIDumpOptions getDumpOpts(DWARFContext& C) {
DIDumpOptions DumpOpts;
DumpOpts.DumpType = DumpType;
DumpOpts.ChildRecurseDepth = ChildRecurseDepth;
@@ -254,6 +254,7 @@ static DIDumpOptions getDumpOpts() {
DumpOpts.ShowForm = ShowForm;
DumpOpts.SummarizeTypes = SummarizeTypes;
DumpOpts.Verbose = Verbose;
+ DumpOpts.RecoverableErrorHandler = C.getRecoverableErrorHandler();
// In -verify mode, print DIEs without children in error messages.
if (Verify)
return DumpOpts.noImplicitRecursion();
@@ -294,6 +295,7 @@ using HandlerFn = std::function<bool(ObjectFile &, DWARFContext &DICtx,
/// Print only DIEs that have a certain name.
static bool filterByName(const StringSet<> &Names, DWARFDie Die,
StringRef NameRef, raw_ostream &OS) {
+ DIDumpOptions DumpOpts = getDumpOpts(Die.getDwarfUnit()->getContext());
std::string Name =
(IgnoreCase && !UseRegex) ? NameRef.lower() : NameRef.str();
if (UseRegex) {
@@ -306,13 +308,13 @@ static bool filterByName(const StringSet<> &Names, DWARFDie Die,
exit(1);
}
if (RE.match(Name)) {
- Die.dump(OS, 0, getDumpOpts());
+ Die.dump(OS, 0, DumpOpts);
return true;
}
}
} else if (Names.count(Name)) {
// Match full text.
- Die.dump(OS, 0, getDumpOpts());
+ Die.dump(OS, 0, DumpOpts);
return true;
}
return false;
@@ -385,8 +387,9 @@ static void filterByAccelName(ArrayRef<std::string> Names, DWARFContext &DICtx,
llvm::sort(Dies);
Dies.erase(std::unique(Dies.begin(), Dies.end()), Dies.end());
+ DIDumpOptions DumpOpts = getDumpOpts(DICtx);
for (DWARFDie Die : Dies)
- Die.dump(OS, 0, getDumpOpts());
+ Die.dump(OS, 0, DumpOpts);
}
/// Handle the --lookup option and dump the DIEs and line info for the given
@@ -402,7 +405,7 @@ static bool lookup(ObjectFile &Obj, DWARFContext &DICtx, uint64_t Address,
if (!DIEsForAddr)
return false;
- DIDumpOptions DumpOpts = getDumpOpts();
+ DIDumpOptions DumpOpts = getDumpOpts(DICtx);
DumpOpts.ChildRecurseDepth = 0;
DIEsForAddr.CompileUnit->dump(OS, DumpOpts);
if (DIEsForAddr.FunctionDIE) {
@@ -450,7 +453,7 @@ static bool dumpObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
}
// Dump the complete DWARF structure.
- DICtx.dump(OS, getDumpOpts(), DumpOffsets);
+ DICtx.dump(OS, getDumpOpts(DICtx), DumpOffsets);
return true;
}
@@ -461,7 +464,7 @@ static bool verifyObjectFile(ObjectFile &Obj, DWARFContext &DICtx,
raw_ostream &stream = Quiet ? nulls() : OS;
stream << "Verifying " << Filename.str() << ":\tfile format "
<< Obj.getFileFormatName() << "\n";
- bool Result = DICtx.verify(stream, getDumpOpts());
+ bool Result = DICtx.verify(stream, getDumpOpts(DICtx));
if (Result)
stream << "No errors.\n";
else
More information about the lldb-commits
mailing list