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