Skip to content

Commit

Permalink
[DWARF][NFC] Refactor range list extraction and dumping
Browse files Browse the repository at this point in the history
The purpose of this patch is twofold: 
- Fold pre-DWARF v5 functionality into v5 to eliminate the need for 2 different 
  versions of range list handling. We get rid of DWARFDebugRangelist{.cpp,.h}.
- Templatize the handling of range list tables so that location list handling
  can take advantage of it as well. Location list and range list tables have the 
  same basic layout.

A non-NFC version of this patch was previously submitted with r342218, but it caused
errors with some TSan tests. This patch has no functional changes. The difference to
the non-NFC patch is that there are no changes to rangelist dumping in this patch.

Differential Revision: https://reviews.llvm.org/D53545

llvm-svn: 345546
  • Loading branch information
wolfy1961 committed Oct 29, 2018
1 parent 89c1ac7 commit fb6cffc
Show file tree
Hide file tree
Showing 15 changed files with 394 additions and 398 deletions.
8 changes: 4 additions & 4 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h
Expand Up @@ -231,16 +231,16 @@ class DWARFContext : public DIContext {
/// Get a DIE given an exact offset.
DWARFDie getDIEForOffset(uint32_t Offset);

unsigned getMaxVersion() {
unsigned getMaxVersion(uint16_t DefaultVersion = 0) {
// Ensure info units have been parsed to discover MaxVersion
info_section_units();
return MaxVersion;
return MaxVersion ? MaxVersion : DefaultVersion;
}

unsigned getMaxDWOVersion() {
unsigned getMaxDWOVersion(uint16_t DefaultVersion = 0) {
// Ensure DWO info units have been parsed to discover MaxVersion
dwo_info_section_units();
return MaxVersion;
return MaxVersion ? MaxVersion : DefaultVersion;
}

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

This file was deleted.

38 changes: 30 additions & 8 deletions llvm/include/llvm/DebugInfo/DWARF/DWARFDebugRnglists.h
Expand Up @@ -13,15 +13,17 @@
#include "llvm/ADT/Optional.h"
#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;
class DWARFUnit;
Expand All @@ -35,12 +37,30 @@ 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,
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, DIDumpOptions DumpOpts,
llvm::function_ref<Optional<SectionedAddress>(uint32_t)>
LookupPooledAddress) const;
bool isSentinel() const { return EntryKind == dwarf::DW_RLE_end_of_list; }
};

/// A class representing a single rangelist.
Expand All @@ -54,10 +74,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 fb6cffc

Please sign in to comment.