mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
[DebugInfo] Remove unused functions from DWARFDebugAranges and fix code style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191778 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e22c56d6d8
commit
d1fc0f8d4e
@ -63,36 +63,35 @@ namespace {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFDebugAranges::extract(DataExtractor debug_aranges_data) {
|
void DWARFDebugAranges::extract(DataExtractor DebugArangesData) {
|
||||||
if (debug_aranges_data.isValidOffset(0)) {
|
if (!DebugArangesData.isValidOffset(0))
|
||||||
uint32_t offset = 0;
|
return;
|
||||||
|
uint32_t offset = 0;
|
||||||
|
|
||||||
typedef std::vector<DWARFDebugArangeSet> SetCollection;
|
typedef std::vector<DWARFDebugArangeSet> SetCollection;
|
||||||
SetCollection sets;
|
SetCollection sets;
|
||||||
|
|
||||||
DWARFDebugArangeSet set;
|
DWARFDebugArangeSet set;
|
||||||
Range range;
|
Range range;
|
||||||
while (set.extract(debug_aranges_data, &offset))
|
while (set.extract(DebugArangesData, &offset))
|
||||||
sets.push_back(set);
|
sets.push_back(set);
|
||||||
|
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
|
|
||||||
std::for_each(sets.begin(), sets.end(), CountArangeDescriptors(count));
|
std::for_each(sets.begin(), sets.end(), CountArangeDescriptors(count));
|
||||||
|
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
Aranges.reserve(count);
|
Aranges.reserve(count);
|
||||||
AddArangeDescriptors range_adder(Aranges, ParsedCUOffsets);
|
AddArangeDescriptors range_adder(Aranges, ParsedCUOffsets);
|
||||||
std::for_each(sets.begin(), sets.end(), range_adder);
|
std::for_each(sets.begin(), sets.end(), range_adder);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DWARFDebugAranges::generate(DWARFContext *ctx) {
|
void DWARFDebugAranges::generate(DWARFContext *CTX) {
|
||||||
if (ctx) {
|
if (CTX) {
|
||||||
const uint32_t num_compile_units = ctx->getNumCompileUnits();
|
const uint32_t num_compile_units = CTX->getNumCompileUnits();
|
||||||
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
|
for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
|
||||||
if (DWARFCompileUnit *cu = ctx->getCompileUnitAtIndex(cu_idx)) {
|
if (DWARFCompileUnit *cu = CTX->getCompileUnitAtIndex(cu_idx)) {
|
||||||
uint32_t CUOffset = cu->getOffset();
|
uint32_t CUOffset = cu->getOffset();
|
||||||
if (ParsedCUOffsets.insert(CUOffset).second)
|
if (ParsedCUOffsets.insert(CUOffset).second)
|
||||||
cu->buildAddressRangeTable(this, true, CUOffset);
|
cu->buildAddressRangeTable(this, true, CUOffset);
|
||||||
@ -100,15 +99,11 @@ bool DWARFDebugAranges::generate(DWARFContext *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
sort(true, /* overlap size */ 0);
|
sort(true, /* overlap size */ 0);
|
||||||
return !isEmpty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugAranges::dump(raw_ostream &OS) const {
|
void DWARFDebugAranges::dump(raw_ostream &OS) const {
|
||||||
const uint32_t num_ranges = getNumRanges();
|
for (RangeCollIterator I = Aranges.begin(), E = Aranges.end(); I != E; ++I) {
|
||||||
for (uint32_t i = 0; i < num_ranges; ++i) {
|
I->dump(OS);
|
||||||
const Range &range = Aranges[i];
|
|
||||||
OS << format("0x%8.8x: [0x%8.8" PRIx64 " - 0x%8.8" PRIx64 ")\n",
|
|
||||||
range.Offset, (uint64_t)range.LoPC, (uint64_t)range.HiPC());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,18 +112,18 @@ void DWARFDebugAranges::Range::dump(raw_ostream &OS) const {
|
|||||||
Offset, LoPC, HiPC());
|
Offset, LoPC, HiPC());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugAranges::appendRange(uint32_t offset, uint64_t low_pc,
|
void DWARFDebugAranges::appendRange(uint32_t CUOffset, uint64_t LowPC,
|
||||||
uint64_t high_pc) {
|
uint64_t HighPC) {
|
||||||
if (!Aranges.empty()) {
|
if (!Aranges.empty()) {
|
||||||
if (Aranges.back().Offset == offset && Aranges.back().HiPC() == low_pc) {
|
if (Aranges.back().Offset == CUOffset && Aranges.back().HiPC() == LowPC) {
|
||||||
Aranges.back().setHiPC(high_pc);
|
Aranges.back().setHiPC(HighPC);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Aranges.push_back(Range(low_pc, high_pc, offset));
|
Aranges.push_back(Range(LowPC, HighPC, CUOffset));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWARFDebugAranges::sort(bool minimize, uint32_t n) {
|
void DWARFDebugAranges::sort(bool Minimize, uint32_t OverlapSize) {
|
||||||
const size_t orig_arange_size = Aranges.size();
|
const size_t orig_arange_size = Aranges.size();
|
||||||
// Size of one? If so, no sorting is needed
|
// Size of one? If so, no sorting is needed
|
||||||
if (orig_arange_size <= 1)
|
if (orig_arange_size <= 1)
|
||||||
@ -136,7 +131,7 @@ void DWARFDebugAranges::sort(bool minimize, uint32_t n) {
|
|||||||
// Sort our address range entries
|
// Sort our address range entries
|
||||||
std::stable_sort(Aranges.begin(), Aranges.end(), RangeLessThan);
|
std::stable_sort(Aranges.begin(), Aranges.end(), RangeLessThan);
|
||||||
|
|
||||||
if (!minimize)
|
if (!Minimize)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Most address ranges are contiguous from function to function
|
// Most address ranges are contiguous from function to function
|
||||||
@ -151,7 +146,7 @@ void DWARFDebugAranges::sort(bool minimize, uint32_t n) {
|
|||||||
// copy the new minimal stuff over to the new collection.
|
// copy the new minimal stuff over to the new collection.
|
||||||
size_t minimal_size = 1;
|
size_t minimal_size = 1;
|
||||||
for (size_t i = 1; i < orig_arange_size; ++i) {
|
for (size_t i = 1; i < orig_arange_size; ++i) {
|
||||||
if (!Range::SortedOverlapCheck(Aranges[i-1], Aranges[i], n))
|
if (!Range::SortedOverlapCheck(Aranges[i-1], Aranges[i], OverlapSize))
|
||||||
++minimal_size;
|
++minimal_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +161,8 @@ void DWARFDebugAranges::sort(bool minimize, uint32_t n) {
|
|||||||
uint32_t j = 0;
|
uint32_t j = 0;
|
||||||
minimal_aranges[j] = Aranges[0];
|
minimal_aranges[j] = Aranges[0];
|
||||||
for (size_t i = 1; i < orig_arange_size; ++i) {
|
for (size_t i = 1; i < orig_arange_size; ++i) {
|
||||||
if(Range::SortedOverlapCheck (minimal_aranges[j], Aranges[i], n)) {
|
if (Range::SortedOverlapCheck(minimal_aranges[j], Aranges[i],
|
||||||
|
OverlapSize)) {
|
||||||
minimal_aranges[j].setHiPC (Aranges[i].HiPC());
|
minimal_aranges[j].setHiPC (Aranges[i].HiPC());
|
||||||
} else {
|
} else {
|
||||||
// Only increment j if we aren't merging
|
// Only increment j if we aren't merging
|
||||||
@ -181,50 +177,20 @@ void DWARFDebugAranges::sort(bool minimize, uint32_t n) {
|
|||||||
minimal_aranges.swap(Aranges);
|
minimal_aranges.swap(Aranges);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DWARFDebugAranges::findAddress(uint64_t address) const {
|
uint32_t DWARFDebugAranges::findAddress(uint64_t Address) const {
|
||||||
if (!Aranges.empty()) {
|
if (!Aranges.empty()) {
|
||||||
Range range(address);
|
Range range(Address);
|
||||||
RangeCollIterator begin = Aranges.begin();
|
RangeCollIterator begin = Aranges.begin();
|
||||||
RangeCollIterator end = Aranges.end();
|
RangeCollIterator end = Aranges.end();
|
||||||
RangeCollIterator pos = std::lower_bound(begin, end, range, RangeLessThan);
|
RangeCollIterator pos = std::lower_bound(begin, end, range, RangeLessThan);
|
||||||
|
|
||||||
if (pos != end && pos->LoPC <= address && address < pos->HiPC()) {
|
if (pos != end && pos->LoPC <= Address && Address < pos->HiPC()) {
|
||||||
return pos->Offset;
|
return pos->Offset;
|
||||||
} else if (pos != begin) {
|
} else if (pos != begin) {
|
||||||
--pos;
|
--pos;
|
||||||
if (pos->LoPC <= address && address < pos->HiPC())
|
if (pos->LoPC <= Address && Address < pos->HiPC())
|
||||||
return (*pos).Offset;
|
return (*pos).Offset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return -1U;
|
return -1U;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
DWARFDebugAranges::allRangesAreContiguous(uint64_t &LoPC, uint64_t &HiPC) const{
|
|
||||||
if (Aranges.empty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
uint64_t next_addr = 0;
|
|
||||||
RangeCollIterator begin = Aranges.begin();
|
|
||||||
for (RangeCollIterator pos = begin, end = Aranges.end(); pos != end;
|
|
||||||
++pos) {
|
|
||||||
if (pos != begin && pos->LoPC != next_addr)
|
|
||||||
return false;
|
|
||||||
next_addr = pos->HiPC();
|
|
||||||
}
|
|
||||||
// We checked for empty at the start of function so front() will be valid.
|
|
||||||
LoPC = Aranges.front().LoPC;
|
|
||||||
// We checked for empty at the start of function so back() will be valid.
|
|
||||||
HiPC = Aranges.back().HiPC();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DWARFDebugAranges::getMaxRange(uint64_t &LoPC, uint64_t &HiPC) const {
|
|
||||||
if (Aranges.empty())
|
|
||||||
return false;
|
|
||||||
// We checked for empty at the start of function so front() will be valid.
|
|
||||||
LoPC = Aranges.front().LoPC;
|
|
||||||
// We checked for empty at the start of function so back() will be valid.
|
|
||||||
HiPC = Aranges.back().HiPC();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -65,30 +65,15 @@ public:
|
|||||||
Aranges.clear();
|
Aranges.clear();
|
||||||
ParsedCUOffsets.clear();
|
ParsedCUOffsets.clear();
|
||||||
}
|
}
|
||||||
bool allRangesAreContiguous(uint64_t& LoPC, uint64_t& HiPC) const;
|
void extract(DataExtractor DebugArangesData);
|
||||||
bool getMaxRange(uint64_t& LoPC, uint64_t& HiPC) const;
|
void generate(DWARFContext *CTX);
|
||||||
bool extract(DataExtractor debug_aranges_data);
|
|
||||||
bool generate(DWARFContext *ctx);
|
|
||||||
|
|
||||||
// Use append range multiple times and then call sort
|
// Use appendRange multiple times and then call sort.
|
||||||
void appendRange(uint32_t cu_offset, uint64_t low_pc, uint64_t high_pc);
|
void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
|
||||||
void sort(bool minimize, uint32_t n);
|
void sort(bool Minimize, uint32_t OverlapSize);
|
||||||
|
|
||||||
const Range *rangeAtIndex(uint32_t idx) const {
|
|
||||||
if (idx < Aranges.size())
|
|
||||||
return &Aranges[idx];
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
void dump(raw_ostream &OS) const;
|
void dump(raw_ostream &OS) const;
|
||||||
uint32_t findAddress(uint64_t address) const;
|
uint32_t findAddress(uint64_t Address) const;
|
||||||
bool isEmpty() const { return Aranges.empty(); }
|
|
||||||
uint32_t getNumRanges() const { return Aranges.size(); }
|
|
||||||
|
|
||||||
uint32_t offsetAtIndex(uint32_t idx) const {
|
|
||||||
if (idx < Aranges.size())
|
|
||||||
return Aranges[idx].Offset;
|
|
||||||
return -1U;
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef std::vector<Range> RangeColl;
|
typedef std::vector<Range> RangeColl;
|
||||||
typedef RangeColl::const_iterator RangeCollIterator;
|
typedef RangeColl::const_iterator RangeCollIterator;
|
||||||
|
Loading…
Reference in New Issue
Block a user