[llvm] 3838563 - Use DWARFDataExtractor::getInitialLength in DWARFDebugAddr
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 4 04:12:09 PST 2020
Author: Pavel Labath
Date: 2020-03-04T13:00:15+01:00
New Revision: 38385630adb072c65882f1a18a4e634dcba9ff46
URL: https://github.com/llvm/llvm-project/commit/38385630adb072c65882f1a18a4e634dcba9ff46
DIFF: https://github.com/llvm/llvm-project/commit/38385630adb072c65882f1a18a4e634dcba9ff46.diff
LOG: Use DWARFDataExtractor::getInitialLength in DWARFDebugAddr
Reviewers: ikudrin, jhenderson, probinson
Subscribers: hiraditya, dblaikie, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D75532
Added:
Modified:
llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.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
Removed:
################################################################################
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
index 273d316e0912..e0f4a3bcd9d5 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
@@ -44,34 +44,14 @@ Error DWARFDebugAddrTable::extractV5(const DWARFDataExtractor &Data,
uint64_t *OffsetPtr, uint8_t CUAddrSize,
std::function<void(Error)> WarnCallback) {
Offset = *OffsetPtr;
- // Check that we can read the unit length field.
- if (!Data.isValidOffsetForDataOfSize(Offset, 4))
- return createStringError(errc::invalid_argument,
- "section is not large enough to contain an "
- "address table length at offset 0x%" PRIx64,
- Offset);
- Format = dwarf::DwarfFormat::DWARF32;
- Length = Data.getU32(OffsetPtr);
- if (Length == dwarf::DW_LENGTH_DWARF64) {
- // Check that we can read the extended unit length field.
- if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, 8)) {
- invalidateLength();
- return createStringError(
- errc::invalid_argument,
- "section is not large enough to contain an extended length field "
- "of the address table at offset 0x%" PRIx64,
- Offset);
- }
- Format = dwarf::DwarfFormat::DWARF64;
- Length = Data.getU64(OffsetPtr);
- } else if (Length >= dwarf::DW_LENGTH_lo_reserved) {
- uint64_t DiagnosticLength = Length;
+ llvm::Error Err = Error::success();
+ std::tie(Length, Format) = Data.getInitialLength(OffsetPtr, &Err);
+ if (Err) {
invalidateLength();
- return createStringError(
- errc::not_supported,
- "address table at offset 0x%" PRIx64
- " has unsupported reserved unit length of value 0x%" PRIx64,
- Offset, DiagnosticLength);
+ return createStringError(errc::invalid_argument,
+ "parsing address table at offset 0x%" PRIx64
+ ": %s",
+ Offset, toString(std::move(Err)).c_str());
}
if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, Length)) {
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 58857808422f..125be8307507 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
@@ -2,7 +2,7 @@
# RUN: llvm-dwarfdump --debug-addr - 2>&1 | \
# RUN: FileCheck %s --implicit-check-not=error
-# CHECK: error: address table at offset 0x0 has unsupported reserved unit length of value 0xfffffff0
+# CHECK: error: parsing address table at offset 0x0: unsupported reserved unit length of value 0xfffffff0
.section .debug_addr,"", at progbits
.long 0xfffffff0
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 8c2cc11de854..8ac3cc55324d 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
@@ -4,7 +4,7 @@
# CHECK: .debug_addr contents:
# CHECK-NOT: {{.}}
-# ERR: section is not large enough to contain an extended length field of the address table at offset 0x0
+# ERR: parsing address table at offset 0x0: unexpected end of data at offset 0x4
# ERR-NOT: {{.}}
# too small section to contain an extended length field of a DWARF64 address table.
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 dcec7dad5f9e..1a5154117011 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
@@ -4,7 +4,7 @@
# CHECK: .debug_addr contents:
# CHECK-NOT: {{.}}
-# ERR: section is not large enough to contain an address table length at offset 0x0
+# ERR: parsing address table at offset 0x0: unexpected end of data at offset 0x0
# ERR-NOT: {{.}}
# too small section to contain length field
More information about the llvm-commits
mailing list