diff options
author | Greg Clayton <gclayton@apple.com> | 2011-10-08 06:59:54 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2011-10-08 06:59:54 +0000 |
commit | be42123fa214b039b86ad152bd21d910db7a7af2 (patch) | |
tree | f1868cd0c2df524b4c1704ef8464c5ee4c59ead4 | |
parent | c03a99ae9cced3e3086f10db444ddc90d115a3f3 (diff) | |
download | lldb-be42123fa214b039b86ad152bd21d910db7a7af2.tar.gz |
Changed RangeMap over to use llvm::SmallVector and updated the RangeArray and the RangeDataArray to have an extra "unsigned N" template parameter. Updated the lldb_private::Block to use a RangeArray with a uint32_t for both the function base offset and block range size, and then a 1 for the small vector size since most lexical blocks in DWARF only have 1 range. Updates the DWARFDebugRanges RangeArray to use an unsigned of 2 since most blocks that have more than one range usually have 2. Also updated a DWARFDebugAranges to default their RangeArray to use a SmallVector with unsigned size of 1 since this will take care of the .o files when doing DWARF in .o files and since there really isn't any good size we can guess with.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@141480 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/lldb/Core/RangeMap.h | 75 | ||||
-rw-r--r-- | include/lldb/Symbol/Block.h | 2 | ||||
-rw-r--r-- | source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h | 2 | ||||
-rw-r--r-- | source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h | 2 |
4 files changed, 43 insertions, 38 deletions
diff --git a/include/lldb/Core/RangeMap.h b/include/lldb/Core/RangeMap.h index a1d118a25..1c858c54b 100644 --- a/include/lldb/Core/RangeMap.h +++ b/include/lldb/Core/RangeMap.h @@ -11,7 +11,7 @@ #define liblldb_RangeMap_h_ #include "lldb/lldb-private.h" -#include <vector> +#include "llvm/ADT/SmallVector.h" // Uncomment to make sure all Range objects are sorted when needed //#define ASSERT_RANGEMAP_ARE_SORTED @@ -163,13 +163,15 @@ namespace lldb_private { // that the collection contains. //---------------------------------------------------------------------- - template <typename B, typename S> + template <typename B, typename S, unsigned N> class RangeArray { public: typedef B BaseType; typedef S SizeType; typedef Range<B,S> Entry; + //typedef std::vector<Entry> Collection; + typedef llvm::SmallVector<Entry, N> Collection; RangeArray () : m_entries () @@ -197,7 +199,7 @@ namespace lldb_private { bool IsSorted () const { - typename std::vector<Entry>::const_iterator pos, end, prev; + typename Collection::const_iterator pos, end, prev; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) @@ -218,9 +220,9 @@ namespace lldb_private { if (m_entries.size() > 1) { // The list should be sorted prior to calling this function - typename std::vector<Entry>::iterator pos; - typename std::vector<Entry>::iterator end; - typename std::vector<Entry>::iterator prev; + typename Collection::iterator pos; + typename Collection::iterator end; + typename Collection::iterator prev; bool can_combine = false; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason @@ -237,7 +239,7 @@ namespace lldb_private { // and populate it accordingly, and then swap it into place. if (can_combine) { - std::vector<Entry> minimal_ranges; + Collection minimal_ranges; for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && prev->Overlap(*pos)) @@ -283,7 +285,7 @@ namespace lldb_private { void Slide (BaseType slide) { - typename std::vector<Entry>::iterator pos, end; + typename Collection::iterator pos, end; for (pos = m_entries.begin(), end = m_entries.end(); pos != end; ++pos) pos->Slide (slide); } @@ -336,9 +338,9 @@ namespace lldb_private { if (!m_entries.empty()) { Entry entry (addr, 1); - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -363,9 +365,9 @@ namespace lldb_private { if (!m_entries.empty()) { Entry entry (addr, 1); - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -391,9 +393,9 @@ namespace lldb_private { #endif if (!m_entries.empty()) { - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); if (pos != end && pos->Contains(range)) { @@ -412,7 +414,7 @@ namespace lldb_private { } protected: - std::vector<Entry> m_entries; + Collection m_entries; }; //---------------------------------------------------------------------- @@ -469,12 +471,15 @@ namespace lldb_private { } }; - template <typename B, typename S, typename T> + template <typename B, typename S, typename T, unsigned N> class RangeDataArray { public: typedef RangeData<B,S,T> Entry; - + //typedef std::vector<Entry> Collection; + typedef llvm::SmallVector<Entry, N> Collection; + + RangeDataArray () { } @@ -500,7 +505,7 @@ namespace lldb_private { bool IsSorted () const { - typename std::vector<Entry>::const_iterator pos, end, prev; + typename Collection::const_iterator pos, end, prev; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) @@ -518,9 +523,9 @@ namespace lldb_private { #ifdef ASSERT_RANGEMAP_ARE_SORTED assert (IsSorted()); #endif - typename std::vector<Entry>::iterator pos; - typename std::vector<Entry>::iterator end; - typename std::vector<Entry>::iterator prev; + typename Collection::iterator pos; + typename Collection::iterator end; + typename Collection::iterator prev; bool can_combine = false; // First we determine if we can combine any of the Entry objects so we // don't end up allocating and making a new collection for no reason @@ -537,7 +542,7 @@ namespace lldb_private { // and populate it accordingly, and then swap it into place. if (can_combine) { - std::vector<Entry> minimal_ranges; + Collection minimal_ranges; for (pos = m_entries.begin(), end = m_entries.end(), prev = end; pos != end; prev = pos++) { if (prev != end && prev->data == pos->data) @@ -600,9 +605,9 @@ namespace lldb_private { if ( !m_entries.empty() ) { Entry entry (addr, 1); - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -629,9 +634,9 @@ namespace lldb_private { Entry entry; entry.SetRangeBase(addr); entry.SetByteSize(1); - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, entry, BaseLessThan); if (pos != end && pos->Contains(addr)) { @@ -657,9 +662,9 @@ namespace lldb_private { #endif if ( !m_entries.empty() ) { - typename std::vector<Entry>::const_iterator begin = m_entries.begin(); - typename std::vector<Entry>::const_iterator end = m_entries.end(); - typename std::vector<Entry>::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); + typename Collection::const_iterator begin = m_entries.begin(); + typename Collection::const_iterator end = m_entries.end(); + typename Collection::const_iterator pos = std::lower_bound (begin, end, range, BaseLessThan); if (pos != end && pos->Contains(range)) { @@ -679,7 +684,7 @@ namespace lldb_private { protected: - std::vector<Entry> m_entries; + Collection m_entries; }; } // namespace lldb_private diff --git a/include/lldb/Symbol/Block.h b/include/lldb/Symbol/Block.h index f2c243f94..6ca309778 100644 --- a/include/lldb/Symbol/Block.h +++ b/include/lldb/Symbol/Block.h @@ -43,7 +43,7 @@ class Block : public SymbolContextScope { public: - typedef RangeArray<uint32_t, uint32_t> RangeArray; + typedef RangeArray<uint32_t, uint32_t, 1> RangeArray; typedef RangeArray::Entry Range; //------------------------------------------------------------------ diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h index 78e1dfddc..e17a37da5 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h @@ -20,7 +20,7 @@ class SymbolFileDWARF; class DWARFDebugAranges { protected: - typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t> RangeToDIE; + typedef lldb_private::RangeDataArray<dw_addr_t, uint32_t, dw_offset_t, 1> RangeToDIE; public: typedef RangeToDIE::Entry Range; diff --git a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h index 9145cc126..82a82edfa 100644 --- a/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h +++ b/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h @@ -20,7 +20,7 @@ class DWARFDebugRanges { public: - typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t> RangeList; + typedef lldb_private::RangeArray<dw_addr_t, dw_addr_t, 2> RangeList; typedef RangeList::Entry Range; DWARFDebugRanges(); |