2011-09-14 09:09:52 +08: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.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
|
|
|
|
#define LLVM_DEBUGINFO_DWARFDEBUGARANGES_H
|
|
|
|
|
2012-11-16 16:36:25 +08:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2014-04-26 05:30:03 +08:00
|
|
|
#include "llvm/Support/DataExtractor.h"
|
2014-04-26 05:42:35 +08:00
|
|
|
#include <vector>
|
2011-09-14 09:09:52 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class DWARFContext;
|
|
|
|
|
|
|
|
class DWARFDebugAranges {
|
|
|
|
public:
|
2013-10-02 15:12:47 +08:00
|
|
|
void generate(DWARFContext *CTX);
|
|
|
|
uint32_t findAddress(uint64_t Address) const;
|
|
|
|
|
|
|
|
private:
|
2014-04-26 05:30:03 +08:00
|
|
|
void clear();
|
2013-10-02 15:12:47 +08:00
|
|
|
void extract(DataExtractor DebugArangesData);
|
2014-04-26 05:30:03 +08:00
|
|
|
|
2014-06-13 07:58:49 +08:00
|
|
|
// Call appendRange multiple times and then call construct.
|
2014-04-26 05:30:03 +08:00
|
|
|
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
2014-06-13 07:58:49 +08:00
|
|
|
void construct();
|
2013-10-02 15:12:47 +08:00
|
|
|
|
2011-09-14 09:09:52 +08:00
|
|
|
struct Range {
|
2013-10-02 00:25:14 +08: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 09:09:52 +08:00
|
|
|
|
2013-10-02 00:25:14 +08:00
|
|
|
void setHighPC(uint64_t HighPC) {
|
|
|
|
if (HighPC == -1ULL || HighPC <= LowPC)
|
2011-09-14 09:09:52 +08:00
|
|
|
Length = 0;
|
|
|
|
else
|
2013-10-02 00:25:14 +08:00
|
|
|
Length = HighPC - LowPC;
|
2011-09-14 09:09:52 +08:00
|
|
|
}
|
2013-10-02 00:25:14 +08:00
|
|
|
uint64_t HighPC() const {
|
2011-09-14 09:09:52 +08:00
|
|
|
if (Length)
|
2013-10-02 00:25:14 +08:00
|
|
|
return LowPC + Length;
|
2011-09-14 09:09:52 +08:00
|
|
|
return -1ULL;
|
|
|
|
}
|
2014-06-13 07:58:49 +08:00
|
|
|
|
2013-10-02 00:25:14 +08:00
|
|
|
bool containsAddress(uint64_t Address) const {
|
|
|
|
return LowPC <= Address && Address < HighPC();
|
|
|
|
}
|
2014-06-13 07:58:49 +08:00
|
|
|
bool operator<(const Range &other) const {
|
2013-10-02 00:25:14 +08:00
|
|
|
return LowPC < other.LowPC;
|
2011-09-14 09:09:52 +08:00
|
|
|
}
|
|
|
|
|
2013-10-02 00:25:14 +08: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 09:09:52 +08:00
|
|
|
};
|
|
|
|
|
2014-06-13 07:58:49 +08: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 09:09:52 +08:00
|
|
|
typedef std::vector<Range> RangeColl;
|
|
|
|
typedef RangeColl::const_iterator RangeCollIterator;
|
|
|
|
|
2014-06-13 07:58:49 +08:00
|
|
|
std::vector<RangeEndpoint> Endpoints;
|
2011-09-14 09:09:52 +08:00
|
|
|
RangeColl Aranges;
|
2014-06-13 07:58:49 +08:00
|
|
|
DenseSet<uint32_t> ParsedCUOffsets;
|
2011-09-14 09:09:52 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|