[PATCH] D75532: Use DWARFDataExtractor::getInitialLength in DWARFDebugAddr
Pavel Labath via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 08:34:59 PST 2020
labath created this revision.
labath added reviewers: ikudrin, jhenderson, probinson.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75532
Files:
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
Index: 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_length_field.s
+++ 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
Index: 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_extended_length_field.s
+++ 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.
Index: llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
===================================================================
--- llvm/test/tools/llvm-dwarfdump/X86/debug_addr_reserved_length.s
+++ 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
Index: llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFDebugAddr.cpp
@@ -44,34 +44,14 @@
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)) {
+ llvm::Error Err = Error::success();
+ std::tie(Length, Format) = Data.getInitialLength(OffsetPtr, &Err);
+ if (Err) {
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;
- 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)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75532.247915.patch
Type: text/x-patch
Size: 4089 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200303/5657579f/attachment.bin>
More information about the llvm-commits
mailing list