Skip to content

Commit f39a9bb

Browse files
committed
[DWARF] Revert r345546: Refactor range list extraction and dumping
This patch caused some internal tests to break which are being investigated. llvm-svn: 345687
1 parent 8fddd98 commit f39a9bb

15 files changed

+398
-394
lines changed

llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,16 +231,16 @@ class DWARFContext : public DIContext {
231231
/// Get a DIE given an exact offset.
232232
DWARFDie getDIEForOffset(uint32_t Offset);
233233

234-
unsigned getMaxVersion(uint16_t DefaultVersion = 0) {
234+
unsigned getMaxVersion() {
235235
// Ensure info units have been parsed to discover MaxVersion
236236
info_section_units();
237-
return MaxVersion ? MaxVersion : DefaultVersion;
237+
return MaxVersion;
238238
}
239239

240-
unsigned getMaxDWOVersion(uint16_t DefaultVersion = 0) {
240+
unsigned getMaxDWOVersion() {
241241
// Ensure DWO info units have been parsed to discover MaxVersion
242242
dwo_info_section_units();
243-
return MaxVersion ? MaxVersion : DefaultVersion;
243+
return MaxVersion;
244244
}
245245

246246
void setMaxVersionIfGreater(unsigned Version) {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//===- DWARFDebugRangeList.h ------------------------------------*- C++ -*-===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
11+
#define LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H
12+
13+
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
14+
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
15+
#include <cassert>
16+
#include <cstdint>
17+
#include <vector>
18+
19+
namespace llvm {
20+
21+
class raw_ostream;
22+
23+
class DWARFDebugRangeList {
24+
public:
25+
struct RangeListEntry {
26+
/// A beginning address offset. This address offset has the size of an
27+
/// address and is relative to the applicable base address of the
28+
/// compilation unit referencing this range list. It marks the beginning
29+
/// of an address range.
30+
uint64_t StartAddress;
31+
/// An ending address offset. This address offset again has the size of
32+
/// an address and is relative to the applicable base address of the
33+
/// compilation unit referencing this range list. It marks the first
34+
/// address past the end of the address range. The ending address must
35+
/// be greater than or equal to the beginning address.
36+
uint64_t EndAddress;
37+
/// A section index this range belongs to.
38+
uint64_t SectionIndex;
39+
40+
/// The end of any given range list is marked by an end of list entry,
41+
/// which consists of a 0 for the beginning address offset
42+
/// and a 0 for the ending address offset.
43+
bool isEndOfListEntry() const {
44+
return (StartAddress == 0) && (EndAddress == 0);
45+
}
46+
47+
/// A base address selection entry consists of:
48+
/// 1. The value of the largest representable address offset
49+
/// (for example, 0xffffffff when the size of an address is 32 bits).
50+
/// 2. An address, which defines the appropriate base address for
51+
/// use in interpreting the beginning and ending address offsets of
52+
/// subsequent entries of the location list.
53+
bool isBaseAddressSelectionEntry(uint8_t AddressSize) const {
54+
assert(AddressSize == 4 || AddressSize == 8);
55+
if (AddressSize == 4)
56+
return StartAddress == -1U;
57+
else
58+
return StartAddress == -1ULL;
59+
}
60+
};
61+
62+
private:
63+
/// Offset in .debug_ranges section.
64+
uint32_t Offset;
65+
uint8_t AddressSize;
66+
std::vector<RangeListEntry> Entries;
67+
68+
public:
69+
DWARFDebugRangeList() { clear(); }
70+
71+
void clear();
72+
void dump(raw_ostream &OS) const;
73+
Error extract(const DWARFDataExtractor &data, uint32_t *offset_ptr);
74+
const std::vector<RangeListEntry> &getEntries() { return Entries; }
75+
76+
/// getAbsoluteRanges - Returns absolute address ranges defined by this range
77+
/// list. Has to be passed base address of the compile unit referencing this
78+
/// range list.
79+
DWARFAddressRangesVector
80+
getAbsoluteRanges(llvm::Optional<SectionedAddress> BaseAddr) const;
81+
};
82+
83+
} // end namespace llvm
84+
85+
#endif // LLVM_DEBUGINFO_DWARF_DWARFDEBUGRANGELIST_H

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h

Lines changed: 8 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,15 @@
1313
#include "llvm/ADT/Optional.h"
1414
#include "llvm/BinaryFormat/Dwarf.h"
1515
#include "llvm/DebugInfo/DIContext.h"
16-
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
1716
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
17+
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
1818
#include "llvm/DebugInfo/DWARF/DWARFListTable.h"
1919
#include <cstdint>
2020
#include <map>
2121
#include <vector>
2222

2323
namespace llvm {
2424

25-
struct BaseAddress;
26-
class DWARFContext;
2725
class Error;
2826
class raw_ostream;
2927
class DWARFUnit;
@@ -37,30 +35,12 @@ struct RangeListEntry : public DWARFListEntryBase {
3735
uint64_t Value0;
3836
uint64_t Value1;
3937

40-
Error extract(DWARFDataExtractor Data, uint32_t End, uint16_t Version,
41-
StringRef SectionName, uint32_t *OffsetPtr, bool isDWO = false);
42-
bool isEndOfList() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
43-
bool isBaseAddressSelectionEntry() const {
44-
return EntryKind == dwarf::DW_RLE_base_address;
45-
}
46-
uint64_t getStartAddress() const {
47-
assert((EntryKind == dwarf::DW_RLE_start_end ||
48-
EntryKind == dwarf::DW_RLE_offset_pair ||
49-
EntryKind == dwarf::DW_RLE_startx_length) &&
50-
"Unexpected range list entry kind");
51-
return Value0;
52-
}
53-
uint64_t getEndAddress() const {
54-
assert((EntryKind == dwarf::DW_RLE_start_end ||
55-
EntryKind == dwarf::DW_RLE_offset_pair) &&
56-
"Unexpected range list entry kind");
57-
return Value1;
58-
}
59-
void dump(raw_ostream &OS, DWARFContext *C, uint8_t AddrSize,
60-
uint64_t &CurrentBase, unsigned Indent, uint16_t Version,
61-
uint8_t MaxEncodingStringLength, DIDumpOptions DumpOpts,
38+
Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr);
39+
void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
40+
uint64_t &CurrentBase, DIDumpOptions DumpOpts,
6241
llvm::function_ref<Optional<SectionedAddress>(uint32_t)>
6342
LookupPooledAddress) const;
43+
bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
6444
};
6545

6646
/// A class representing a single rangelist.
@@ -74,12 +54,10 @@ class DWARFDebugRnglist : public DWARFListType<RangeListEntry> {
7454

7555
class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> {
7656
public:
77-
DWARFDebugRnglistTable(DWARFContext *C, StringRef SectionName,
78-
bool isDWO = false)
79-
: DWARFListTableBase(C, SectionName, isDWO,
57+
DWARFDebugRnglistTable()
58+
: DWARFListTableBase(/* SectionName = */ ".debug_rnglists",
8059
/* HeaderString = */ "ranges:",
81-
/* ListTypeString = */ "range",
82-
dwarf::RangeListEncodingString) {}
60+
/* ListTypeString = */ "range") {}
8361
};
8462

8563
} // end namespace llvm

0 commit comments

Comments
 (0)