Skip to content

Commit 69dfa07

Browse files
committed
[DebugInfo] Dump fields in .debug_aranges according to the DWARF format (1/8).
The patch changes dumping of unit_length and debug_info_offset fields in an address range header so that they are printed as 16-digit hex values if the contribution is in the DWARF64 format. Differential Revision: https://reviews.llvm.org/D79997
1 parent 04e0050 commit 69dfa07

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugArangeSet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class DWARFDebugArangeSet {
2525
/// The total length of the entries for that set, not including the length
2626
/// field itself.
2727
uint64_t Length;
28+
/// The DWARF format of the set.
29+
dwarf::DwarfFormat Format;
2830
/// The offset from the beginning of the .debug_info section of the
2931
/// compilation unit entry referenced by the table.
3032
uint64_t CuOffset;

llvm/lib/DebugInfo/DWARF/DWARFDebugArangeSet.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
6060
// the segment selectors are omitted from all tuples, including
6161
// the terminating tuple.
6262

63-
dwarf::DwarfFormat format;
6463
Error Err = Error::success();
65-
std::tie(HeaderData.Length, format) = data.getInitialLength(offset_ptr, &Err);
64+
std::tie(HeaderData.Length, HeaderData.Format) =
65+
data.getInitialLength(offset_ptr, &Err);
6666
HeaderData.Version = data.getU16(offset_ptr, &Err);
67-
HeaderData.CuOffset =
68-
data.getUnsigned(offset_ptr, dwarf::getDwarfOffsetByteSize(format), &Err);
67+
HeaderData.CuOffset = data.getUnsigned(
68+
offset_ptr, dwarf::getDwarfOffsetByteSize(HeaderData.Format), &Err);
6969
HeaderData.AddrSize = data.getU8(offset_ptr, &Err);
7070
HeaderData.SegSize = data.getU8(offset_ptr, &Err);
7171
if (Err) {
@@ -77,7 +77,7 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
7777

7878
// Perform basic validation of the header fields.
7979
uint64_t full_length =
80-
dwarf::getUnitLengthFieldByteSize(format) + HeaderData.Length;
80+
dwarf::getUnitLengthFieldByteSize(HeaderData.Format) + HeaderData.Length;
8181
if (!data.isValidOffsetForDataOfSize(Offset, full_length))
8282
return createStringError(errc::invalid_argument,
8383
"the length of address range table at offset "
@@ -157,10 +157,12 @@ Error DWARFDebugArangeSet::extract(DWARFDataExtractor data,
157157
}
158158

159159
void DWARFDebugArangeSet::dump(raw_ostream &OS) const {
160+
int OffsetDumpWidth = 2 * dwarf::getDwarfOffsetByteSize(HeaderData.Format);
160161
OS << "Address Range Header: "
161-
<< format("length = 0x%8.8" PRIx64 ", ", HeaderData.Length)
162+
<< format("length = 0x%0*" PRIx64 ", ", OffsetDumpWidth, HeaderData.Length)
162163
<< format("version = 0x%4.4x, ", HeaderData.Version)
163-
<< format("cu_offset = 0x%8.8" PRIx64 ", ", HeaderData.CuOffset)
164+
<< format("cu_offset = 0x%0*" PRIx64 ", ", OffsetDumpWidth,
165+
HeaderData.CuOffset)
164166
<< format("addr_size = 0x%2.2x, ", HeaderData.AddrSize)
165167
<< format("seg_size = 0x%2.2x\n", HeaderData.SegSize);
166168

llvm/test/DebugInfo/X86/dwarfdump-debug-aranges.s

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
# CHECK: Address Range Header: length = 0x0000001c,
2929
.L2version:
3030
.short 2 # Version
31-
.long 0x11223344 # Debug Info Offset
31+
.long 0x112233 # Debug Info Offset
3232
.byte 4 # Address Size
3333
.byte 0 # Segment Selector Size
3434
# CHECK-SAME: version = 0x0002,
35-
# CHECK-SAME: cu_offset = 0x11223344,
35+
# CHECK-SAME: cu_offset = 0x00112233,
3636
# CHECK-SAME: addr_size = 0x04,
3737
# CHECK-SAME: seg_size = 0x00
3838
.space 4 # Padding
@@ -48,11 +48,11 @@
4848
# CHECK: Address Range Header: length = 0x0000002c,
4949
.L3version:
5050
.short 2 # Version
51-
.long 0x22334455 # Debug Info Offset
51+
.long 0x112233 # Debug Info Offset
5252
.byte 8 # Address Size
5353
.byte 0 # Segment Selector Size
5454
# CHECK-SAME: version = 0x0002,
55-
# CHECK-SAME: cu_offset = 0x22334455,
55+
# CHECK-SAME: cu_offset = 0x00112233,
5656
# CHECK-SAME: addr_size = 0x08,
5757
# CHECK-SAME: seg_size = 0x00
5858
.space 4 # Padding
@@ -67,14 +67,14 @@
6767
## Case 4: Check that 64-bit DWARF format is supported.
6868
.long 0xffffffff # DWARF64 mark
6969
.quad .L4end - .L4version # Length
70-
# CHECK: Address Range Header: length = 0x0000001c,
70+
# CHECK: Address Range Header: length = 0x000000000000001c,
7171
.L4version:
7272
.short 2 # Version
73-
.quad 0x1234567899aabbcc # Debug Info Offset
73+
.quad 0x123456789abc # Debug Info Offset
7474
.byte 4 # Address Size
7575
.byte 0 # Segment Selector Size
7676
# CHECK-SAME: version = 0x0002,
77-
# CHECK-SAME: cu_offset = 0x1234567899aabbcc,
77+
# CHECK-SAME: cu_offset = 0x0000123456789abc,
7878
# CHECK-SAME: addr_size = 0x04,
7979
# CHECK-SAME: seg_size = 0x00
8080
# No padding

0 commit comments

Comments
 (0)