2011-09-14 01:09:52 +00:00
|
|
|
//===-- DWARFDebugAranges.h -------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H
|
|
|
|
#define LLVM_LIB_DEBUGINFO_DWARFDEBUGARANGES_H
|
2011-09-14 01:09:52 +00:00
|
|
|
|
2012-11-16 08:36:25 +00:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2014-04-25 21:30:03 +00:00
|
|
|
#include "llvm/Support/DataExtractor.h"
|
2014-04-25 21:42:35 +00:00
|
|
|
#include <vector>
|
2011-09-14 01:09:52 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class DWARFContext;
|
|
|
|
|
|
|
|
class DWARFDebugAranges {
|
|
|
|
public:
|
2013-10-02 07:12:47 +00:00
|
|
|
void generate(DWARFContext *CTX);
|
|
|
|
uint32_t findAddress(uint64_t Address) const;
|
|
|
|
|
|
|
|
private:
|
2014-04-25 21:30:03 +00:00
|
|
|
void clear();
|
2013-10-02 07:12:47 +00:00
|
|
|
void extract(DataExtractor DebugArangesData);
|
2014-04-25 21:30:03 +00:00
|
|
|
|
2014-06-12 23:58:49 +00:00
|
|
|
// Call appendRange multiple times and then call construct.
|
2014-04-25 21:30:03 +00:00
|
|
|
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
2014-06-12 23:58:49 +00:00
|
|
|
void construct();
|
2013-10-02 07:12:47 +00:00
|
|
|
|
2011-09-14 01:09:52 +00:00
|
|
|
struct Range {
|
2013-10-01 16:25:14 +00:00
|
|
|
explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
|
|
|
|
uint32_t CUOffset = -1U)
|
|
|
|
: LowPC(LowPC), Length(HighPC - LowPC), CUOffset(CUOffset) {}
|
2011-09-14 01:09:52 +00:00
|
|
|
|
2013-10-01 16:25:14 +00:00
|
|
|
void setHighPC(uint64_t HighPC) {
|
|
|
|
if (HighPC == -1ULL || HighPC <= LowPC)
|
2011-09-14 01:09:52 +00:00
|
|
|
Length = 0;
|
|
|
|
else
|
2013-10-01 16:25:14 +00:00
|
|
|
Length = HighPC - LowPC;
|
2011-09-14 01:09:52 +00:00
|
|
|
}
|
2013-10-01 16:25:14 +00:00
|
|
|
uint64_t HighPC() const {
|
2011-09-14 01:09:52 +00:00
|
|
|
if (Length)
|
2013-10-01 16:25:14 +00:00
|
|
|
return LowPC + Length;
|
2011-09-14 01:09:52 +00:00
|
|
|
return -1ULL;
|
|
|
|
}
|
2014-06-12 23:58:49 +00:00
|
|
|
|
2013-10-01 16:25:14 +00:00
|
|
|
bool containsAddress(uint64_t Address) const {
|
|
|
|
return LowPC <= Address && Address < HighPC();
|
|
|
|
}
|
2014-06-12 23:58:49 +00:00
|
|
|
bool operator<(const Range &other) const {
|
2013-10-01 16:25:14 +00:00
|
|
|
return LowPC < other.LowPC;
|
2011-09-14 01:09:52 +00:00
|
|
|
}
|
|
|
|
|
2013-10-01 16:25:14 +00:00
|
|
|
uint64_t LowPC; // Start of address range.
|
|
|
|
uint32_t Length; // End of address range (not including this address).
|
|
|
|
uint32_t CUOffset; // Offset of the compile unit or die.
|
2011-09-14 01:09:52 +00:00
|
|
|
};
|
|
|
|
|
2014-06-12 23:58:49 +00:00
|
|
|
struct RangeEndpoint {
|
|
|
|
uint64_t Address;
|
|
|
|
uint32_t CUOffset;
|
|
|
|
bool IsRangeStart;
|
|
|
|
|
|
|
|
RangeEndpoint(uint64_t Address, uint32_t CUOffset, bool IsRangeStart)
|
|
|
|
: Address(Address), CUOffset(CUOffset), IsRangeStart(IsRangeStart) {}
|
|
|
|
|
|
|
|
bool operator<(const RangeEndpoint &Other) const {
|
|
|
|
return Address < Other.Address;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-09-14 01:09:52 +00:00
|
|
|
typedef std::vector<Range> RangeColl;
|
|
|
|
typedef RangeColl::const_iterator RangeCollIterator;
|
|
|
|
|
2014-06-12 23:58:49 +00:00
|
|
|
std::vector<RangeEndpoint> Endpoints;
|
2011-09-14 01:09:52 +00:00
|
|
|
RangeColl Aranges;
|
2014-06-12 23:58:49 +00:00
|
|
|
DenseSet<uint32_t> ParsedCUOffsets;
|
2011-09-14 01:09:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|