[llvm] r191813 - [DebugInfo] Further simplify DWARFDebugAranges public interface
Alexey Samsonov
samsonov at google.com
Wed Oct 2 00:12:48 PDT 2013
Author: samsonov
Date: Wed Oct 2 02:12:47 2013
New Revision: 191813
URL: http://llvm.org/viewvc/llvm-project?rev=191813&view=rev
Log:
[DebugInfo] Further simplify DWARFDebugAranges public interface
Modified:
llvm/trunk/lib/DebugInfo/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp
llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h
Modified: llvm/trunk/lib/DebugInfo/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFContext.cpp?rev=191813&r1=191812&r2=191813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFContext.cpp Wed Oct 2 02:12:47 2013
@@ -231,13 +231,7 @@ const DWARFDebugAranges *DWARFContext::g
if (Aranges)
return Aranges.get();
- DataExtractor arangesData(getARangeSection(), isLittleEndian(), 0);
-
Aranges.reset(new DWARFDebugAranges());
- Aranges->extract(arangesData);
- // Generate aranges from DIEs: even if .debug_aranges section is present,
- // it may describe only a small subset of compilation units, so we need to
- // manually build aranges for the rest of them.
Aranges->generate(this);
return Aranges.get();
}
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp?rev=191813&r1=191812&r2=191813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugAranges.cpp Wed Oct 2 02:12:47 2013
@@ -45,32 +45,29 @@ void DWARFDebugAranges::extract(DataExtr
appendRange(CUOffset, LowPC, HighPC);
}
}
- sortAndMinimize();
}
void DWARFDebugAranges::generate(DWARFContext *CTX) {
- if (CTX) {
- const uint32_t num_compile_units = CTX->getNumCompileUnits();
- for (uint32_t cu_idx = 0; cu_idx < num_compile_units; ++cu_idx) {
- if (DWARFCompileUnit *cu = CTX->getCompileUnitAtIndex(cu_idx)) {
- uint32_t CUOffset = cu->getOffset();
- if (ParsedCUOffsets.insert(CUOffset).second)
- cu->buildAddressRangeTable(this, true, CUOffset);
- }
- }
- }
- sortAndMinimize();
-}
+ clear();
+ if (!CTX)
+ return;
-void DWARFDebugAranges::dump(raw_ostream &OS) const {
- for (RangeCollIterator I = Aranges.begin(), E = Aranges.end(); I != E; ++I) {
- I->dump(OS);
+ // Extract aranges from .debug_aranges section.
+ DataExtractor ArangesData(CTX->getARangeSection(), CTX->isLittleEndian(), 0);
+ extract(ArangesData);
+
+ // Generate aranges from DIEs: even if .debug_aranges section is present,
+ // it may describe only a small subset of compilation units, so we need to
+ // manually build aranges for the rest of them.
+ for (uint32_t i = 0, n = CTX->getNumCompileUnits(); i < n; ++i) {
+ if (DWARFCompileUnit *CU = CTX->getCompileUnitAtIndex(i)) {
+ uint32_t CUOffset = CU->getOffset();
+ if (ParsedCUOffsets.insert(CUOffset).second)
+ CU->buildAddressRangeTable(this, true, CUOffset);
+ }
}
-}
-void DWARFDebugAranges::Range::dump(raw_ostream &OS) const {
- OS << format("{0x%8.8x}: [0x%8.8" PRIx64 " - 0x%8.8" PRIx64 ")\n",
- CUOffset, LowPC, HighPC());
+ sortAndMinimize();
}
void DWARFDebugAranges::appendRange(uint32_t CUOffset, uint64_t LowPC,
Modified: llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h?rev=191813&r1=191812&r2=191813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h (original)
+++ llvm/trunk/lib/DebugInfo/DWARFDebugAranges.h Wed Oct 2 02:12:47 2013
@@ -20,6 +20,22 @@ class DWARFContext;
class DWARFDebugAranges {
public:
+ void clear() {
+ Aranges.clear();
+ ParsedCUOffsets.clear();
+ }
+
+ void generate(DWARFContext *CTX);
+
+ // Use appendRange multiple times and then call sortAndMinimize.
+ void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
+
+ uint32_t findAddress(uint64_t Address) const;
+
+private:
+ void extract(DataExtractor DebugArangesData);
+ void sortAndMinimize();
+
struct Range {
explicit Range(uint64_t LowPC = -1ULL, uint64_t HighPC = -1ULL,
uint32_t CUOffset = -1U)
@@ -50,31 +66,15 @@ public:
return Left.HighPC() >= Right.LowPC;
}
- void dump(raw_ostream &OS) const;
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.
};
- void clear() {
- Aranges.clear();
- ParsedCUOffsets.clear();
- }
- void extract(DataExtractor DebugArangesData);
- void generate(DWARFContext *CTX);
-
- // Use appendRange multiple times and then call sortAndMinimize.
- void appendRange(uint32_t CUOffset, uint64_t LowPC, uint64_t HighPC);
- void sortAndMinimize();
-
- void dump(raw_ostream &OS) const;
- uint32_t findAddress(uint64_t Address) const;
-
typedef std::vector<Range> RangeColl;
typedef RangeColl::const_iterator RangeCollIterator;
typedef DenseSet<uint32_t> ParsedCUOffsetColl;
-private:
RangeColl Aranges;
ParsedCUOffsetColl ParsedCUOffsets;
};
More information about the llvm-commits
mailing list