Skip to content

Commit f26a70a

Browse files
committedAug 6, 2019
Switch LLVM to use 64-bit offsets (2/5)
This updates all libraries and tools in LLVM Core to use 64-bit offsets which directly or indirectly come to DataExtractor. Differential Revision: https://reviews.llvm.org/D65638 llvm-svn: 368014
1 parent f5f35c5 commit f26a70a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+652
-614
lines changed
 

‎llvm/include/llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,11 @@ class DWARFAbbreviationDeclaration {
130130
/// \param Attr DWARF attribute to search for.
131131
/// \param U the DWARFUnit the contains the DIE.
132132
/// \returns Optional DWARF form value if the attribute was extracted.
133-
Optional<DWARFFormValue> getAttributeValue(const uint32_t DIEOffset,
133+
Optional<DWARFFormValue> getAttributeValue(const uint64_t DIEOffset,
134134
const dwarf::Attribute Attr,
135135
const DWARFUnit &U) const;
136136

137-
bool extract(DataExtractor Data, uint32_t* OffsetPtr);
137+
bool extract(DataExtractor Data, uint64_t* OffsetPtr);
138138
void dump(raw_ostream &OS) const;
139139

140140
// Return an optional byte size of all attribute data in this abbreviation

‎llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h

+37-33
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
9696
using AtomType = uint16_t;
9797
using Form = dwarf::Form;
9898

99-
uint32_t DIEOffsetBase;
99+
uint64_t DIEOffsetBase;
100100
SmallVector<std::pair<AtomType, Form>, 3> Atoms;
101101

102102
Optional<uint64_t> extractOffset(Optional<DWARFFormValue> Value) const;
@@ -109,7 +109,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
109109
/// Returns true if we should continue scanning for entries or false if we've
110110
/// reached the last (sentinel) entry of encountered a parsing error.
111111
bool dumpName(ScopedPrinter &W, SmallVectorImpl<DWARFFormValue> &AtomForms,
112-
uint32_t *DataOffset) const;
112+
uint64_t *DataOffset) const;
113113

114114
public:
115115
/// Apple-specific implementation of an Accelerator Entry.
@@ -119,7 +119,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
119119
Entry(const HeaderData &Data);
120120
Entry() = default;
121121

122-
void extract(const AppleAcceleratorTable &AccelTable, uint32_t *Offset);
122+
void extract(const AppleAcceleratorTable &AccelTable, uint64_t *Offset);
123123

124124
public:
125125
Optional<uint64_t> getCUOffset() const override;
@@ -143,15 +143,15 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
143143
class ValueIterator : public std::iterator<std::input_iterator_tag, Entry> {
144144
const AppleAcceleratorTable *AccelTable = nullptr;
145145
Entry Current; ///< The current entry.
146-
unsigned DataOffset = 0; ///< Offset into the section.
146+
uint64_t DataOffset = 0; ///< Offset into the section.
147147
unsigned Data = 0; ///< Current data entry.
148148
unsigned NumData = 0; ///< Number of data entries.
149149

150150
/// Advance the iterator.
151151
void Next();
152152
public:
153153
/// Construct a new iterator for the entries at \p DataOffset.
154-
ValueIterator(const AppleAcceleratorTable &AccelTable, unsigned DataOffset);
154+
ValueIterator(const AppleAcceleratorTable &AccelTable, uint64_t DataOffset);
155155
/// End marker.
156156
ValueIterator() = default;
157157

@@ -193,7 +193,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
193193
/// DieOffset is the offset into the .debug_info section for the DIE
194194
/// related to the input hash data offset.
195195
/// DieTag is the tag of the DIE
196-
std::pair<uint32_t, dwarf::Tag> readAtoms(uint32_t &HashDataOffset);
196+
std::pair<uint64_t, dwarf::Tag> readAtoms(uint64_t *HashDataOffset);
197197
void dump(raw_ostream &OS) const override;
198198

199199
/// Look up all entries in the accelerator table matching \c Key.
@@ -245,7 +245,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
245245
struct Header : public HeaderPOD {
246246
SmallString<8> AugmentationString;
247247

248-
Error extract(const DWARFDataExtractor &AS, uint32_t *Offset);
248+
Error extract(const DWARFDataExtractor &AS, uint64_t *Offset);
249249
void dump(ScopedPrinter &W) const;
250250
};
251251

@@ -354,30 +354,30 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
354354
DataExtractor StrData;
355355

356356
uint32_t Index;
357-
uint32_t StringOffset;
358-
uint32_t EntryOffset;
357+
uint64_t StringOffset;
358+
uint64_t EntryOffset;
359359

360360
public:
361361
NameTableEntry(const DataExtractor &StrData, uint32_t Index,
362-
uint32_t StringOffset, uint32_t EntryOffset)
362+
uint64_t StringOffset, uint64_t EntryOffset)
363363
: StrData(StrData), Index(Index), StringOffset(StringOffset),
364364
EntryOffset(EntryOffset) {}
365365

366366
/// Return the index of this name in the parent Name Index.
367367
uint32_t getIndex() const { return Index; }
368368

369369
/// Returns the offset of the name of the described entities.
370-
uint32_t getStringOffset() const { return StringOffset; }
370+
uint64_t getStringOffset() const { return StringOffset; }
371371

372372
/// Return the string referenced by this name table entry or nullptr if the
373373
/// string offset is not valid.
374374
const char *getString() const {
375-
uint32_t Off = StringOffset;
375+
uint64_t Off = StringOffset;
376376
return StrData.getCStr(&Off);
377377
}
378378

379379
/// Returns the offset of the first Entry in the list.
380-
uint32_t getEntryOffset() const { return EntryOffset; }
380+
uint64_t getEntryOffset() const { return EntryOffset; }
381381
};
382382

383383
/// Represents a single accelerator table within the DWARF v5 .debug_names
@@ -389,40 +389,40 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
389389

390390
// Base of the whole unit and of various important tables, as offsets from
391391
// the start of the section.
392-
uint32_t Base;
393-
uint32_t CUsBase;
394-
uint32_t BucketsBase;
395-
uint32_t HashesBase;
396-
uint32_t StringOffsetsBase;
397-
uint32_t EntryOffsetsBase;
398-
uint32_t EntriesBase;
392+
uint64_t Base;
393+
uint64_t CUsBase;
394+
uint64_t BucketsBase;
395+
uint64_t HashesBase;
396+
uint64_t StringOffsetsBase;
397+
uint64_t EntryOffsetsBase;
398+
uint64_t EntriesBase;
399399

400400
void dumpCUs(ScopedPrinter &W) const;
401401
void dumpLocalTUs(ScopedPrinter &W) const;
402402
void dumpForeignTUs(ScopedPrinter &W) const;
403403
void dumpAbbreviations(ScopedPrinter &W) const;
404-
bool dumpEntry(ScopedPrinter &W, uint32_t *Offset) const;
404+
bool dumpEntry(ScopedPrinter &W, uint64_t *Offset) const;
405405
void dumpName(ScopedPrinter &W, const NameTableEntry &NTE,
406406
Optional<uint32_t> Hash) const;
407407
void dumpBucket(ScopedPrinter &W, uint32_t Bucket) const;
408408

409-
Expected<AttributeEncoding> extractAttributeEncoding(uint32_t *Offset);
409+
Expected<AttributeEncoding> extractAttributeEncoding(uint64_t *Offset);
410410

411411
Expected<std::vector<AttributeEncoding>>
412-
extractAttributeEncodings(uint32_t *Offset);
412+
extractAttributeEncodings(uint64_t *Offset);
413413

414-
Expected<Abbrev> extractAbbrev(uint32_t *Offset);
414+
Expected<Abbrev> extractAbbrev(uint64_t *Offset);
415415

416416
public:
417-
NameIndex(const DWARFDebugNames &Section, uint32_t Base)
417+
NameIndex(const DWARFDebugNames &Section, uint64_t Base)
418418
: Section(Section), Base(Base) {}
419419

420420
/// Reads offset of compilation unit CU. CU is 0-based.
421-
uint32_t getCUOffset(uint32_t CU) const;
421+
uint64_t getCUOffset(uint32_t CU) const;
422422
uint32_t getCUCount() const { return Hdr.CompUnitCount; }
423423

424424
/// Reads offset of local type unit TU, TU is 0-based.
425-
uint32_t getLocalTUOffset(uint32_t TU) const;
425+
uint64_t getLocalTUOffset(uint32_t TU) const;
426426
uint32_t getLocalTUCount() const { return Hdr.LocalTypeUnitCount; }
427427

428428
/// Reads signature of foreign type unit TU. TU is 0-based.
@@ -451,6 +451,10 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
451451
return Abbrevs;
452452
}
453453

454+
Expected<Entry> getEntry(uint64_t *Offset) const;
455+
456+
// A temporarily method to preserve compatibility with existing code.
457+
// Will be removed when the migration to 64-bit offsets is finished.
454458
Expected<Entry> getEntry(uint32_t *Offset) const;
455459

456460
/// Look up all entries in this Name Index matching \c Key.
@@ -460,8 +464,8 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
460464
NameIterator end() const { return NameIterator(this, getNameCount() + 1); }
461465

462466
Error extract();
463-
uint32_t getUnitOffset() const { return Base; }
464-
uint32_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; }
467+
uint64_t getUnitOffset() const { return Base; }
468+
uint64_t getNextUnitOffset() const { return Base + 4 + Hdr.UnitLength; }
465469
void dump(ScopedPrinter &W) const;
466470

467471
friend class DWARFDebugNames;
@@ -479,12 +483,12 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
479483
bool IsLocal;
480484

481485
Optional<Entry> CurrentEntry;
482-
unsigned DataOffset = 0; ///< Offset into the section.
486+
uint64_t DataOffset = 0; ///< Offset into the section.
483487
std::string Key; ///< The Key we are searching for.
484488
Optional<uint32_t> Hash; ///< Hash of Key, if it has been computed.
485489

486490
bool getEntryAtCurrentOffset();
487-
Optional<uint32_t> findEntryOffsetInCurrentIndex();
491+
Optional<uint64_t> findEntryOffsetInCurrentIndex();
488492
bool findInCurrentIndex();
489493
void searchFromStartOfCurrentIndex();
490494
void next();
@@ -572,7 +576,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
572576

573577
private:
574578
SmallVector<NameIndex, 0> NameIndices;
575-
DenseMap<uint32_t, const NameIndex *> CUToNameIndex;
579+
DenseMap<uint64_t, const NameIndex *> CUToNameIndex;
576580

577581
public:
578582
DWARFDebugNames(const DWARFDataExtractor &AccelSection,
@@ -591,7 +595,7 @@ class DWARFDebugNames : public DWARFAcceleratorTable {
591595

592596
/// Return the Name Index covering the compile unit at CUOffset, or nullptr if
593597
/// there is no Name Index covering that unit.
594-
const NameIndex *getCUNameIndex(uint32_t CUOffset);
598+
const NameIndex *getCUNameIndex(uint64_t CUOffset);
595599
};
596600

597601
} // end namespace llvm

0 commit comments

Comments
 (0)
Please sign in to comment.