Skip to content

Commit

Permalink
[DWARF] Refactoring range list dumping to fold DWARF v4 functionality…
Browse files Browse the repository at this point in the history
… into v5 handling

Eliminating some duplication of rangelist dumping code at the expense of
some version-dependent code in dump and extract routines.

Reviewer: dblaikie, JDevlieghere, vleschuk

Differential revision: https://reviews.llvm.org/D51081

llvm-svn: 342048
  • Loading branch information
wolfy1961 committed Sep 12, 2018
1 parent 88e18a6 commit 3a8781c
Show file tree
Hide file tree
Showing 21 changed files with 438 additions and 417 deletions.
4 changes: 3 additions & 1 deletion llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
Expand Up @@ -231,7 +231,9 @@ class DWARFContext : public DIContext {
/// Get a DIE given an exact offset.
DWARFDie getDIEForOffset(uint32_t Offset);

unsigned getMaxVersion() const { return MaxVersion; }
unsigned getMaxVersion(uint16_t DefaultVersion = 0) const {
return MaxVersion ? MaxVersion : DefaultVersion;
}

void setMaxVersionIfGreater(unsigned Version) {
if (Version > MaxVersion)
Expand Down
86 changes: 0 additions & 86 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRangeList.h

This file was deleted.

39 changes: 31 additions & 8 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
Expand Up @@ -12,15 +12,17 @@

#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DIContext.h"
#include "llvm/DebugInfo/DWARF/DWARFAddressRange.h"
#include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
#include "llvm/DebugInfo/DWARF/DWARFListTable.h"
#include <cstdint>
#include <map>
#include <vector>

namespace llvm {

struct BaseAddress;
class DWARFContext;
class Error;
class raw_ostream;

Expand All @@ -33,10 +35,29 @@ struct RangeListEntry : public DWARFListEntryBase {
uint64_t Value0;
uint64_t Value1;

Error extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr);
void dump(raw_ostream &OS, uint8_t AddrSize, uint8_t MaxEncodingStringLength,
uint64_t &CurrentBase, DIDumpOptions DumpOpts) const;
bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
Error extract(DWARFDataExtractor Data, uint32_t End, uint16_t Version,
StringRef SectionName, uint32_t *OffsetPtr, bool isDWO = false);
bool isEndOfList() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
bool isBaseAddressSelectionEntry() const {
return EntryKind == dwarf::DW_RLE_base_address;
}
uint64_t getStartAddress() const {
assert((EntryKind == dwarf::DW_RLE_start_end ||
EntryKind == dwarf::DW_RLE_offset_pair ||
EntryKind == dwarf::DW_RLE_startx_length) &&
"Unexpected range list entry kind");
return Value0;
}
uint64_t getEndAddress() const {
assert((EntryKind == dwarf::DW_RLE_start_end ||
EntryKind == dwarf::DW_RLE_offset_pair) &&
"Unexpected range list entry kind");
return Value1;
}
void dump(raw_ostream &OS, DWARFContext *C, uint8_t AddrSize,
uint64_t &CurrentBase, unsigned Indent, uint16_t Version,
uint8_t MaxEncodingStringLength = 0,
DIDumpOptions DumpOpts = {}) const;
};

/// A class representing a single rangelist.
Expand All @@ -49,10 +70,12 @@ class DWARFDebugRnglist : public DWARFListType<RangeListEntry> {

class DWARFDebugRnglistTable : public DWARFListTableBase<DWARFDebugRnglist> {
public:
DWARFDebugRnglistTable()
: DWARFListTableBase(/* SectionName = */ ".debug_rnglists",
DWARFDebugRnglistTable(DWARFContext *C, StringRef SectionName,
bool isDWO = false)
: DWARFListTableBase(C, SectionName, isDWO,
/* HeaderString = */ "ranges:",
/* ListTypeString = */ "range") {}
/* ListTypeString = */ "range",
dwarf::RangeListEncodingString) {}
};

} // end namespace llvm
Expand Down

0 comments on commit 3a8781c

Please sign in to comment.