[Lldb-commits] [lldb] r141480 - in /lldb/trunk: include/lldb/Core/RangeMap.h include/lldb/Symbol/Block.h source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h

Greg Clayton gclayton at apple.com
Fri Oct 7 23:59:54 PDT 2011


Author: gclayton
Date: Sat Oct  8 01:59:54 2011
New Revision: 141480

URL: http://llvm.org/viewvc/llvm-project?rev=141480&view=rev
Log:
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.


Modified:
    lldb/trunk/include/lldb/Core/RangeMap.h
    lldb/trunk/include/lldb/Symbol/Block.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h

Modified: lldb/trunk/include/lldb/Core/RangeMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RangeMap.h?rev=141480&r1=141479&r2=141480&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/RangeMap.h (original)
+++ lldb/trunk/include/lldb/Core/RangeMap.h Sat Oct  8 01:59:54 2011
@@ -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 @@
     // 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 @@
         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 @@
             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 @@
                 // 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 @@
         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 @@
             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 @@
             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 @@
 #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 @@
         }
 
     protected:
-        std::vector<Entry> m_entries;
+        Collection m_entries;
     };
 
     //----------------------------------------------------------------------
@@ -469,12 +471,15 @@
         }
     };
     
-    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 @@
         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 @@
 #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 @@
             // 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 @@
             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 @@
                 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 @@
 #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 @@
         
 
     protected:
-        std::vector<Entry> m_entries;
+        Collection m_entries;
     };
 
 } // namespace lldb_private

Modified: lldb/trunk/include/lldb/Symbol/Block.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Block.h?rev=141480&r1=141479&r2=141480&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/Block.h (original)
+++ lldb/trunk/include/lldb/Symbol/Block.h Sat Oct  8 01:59:54 2011
@@ -43,7 +43,7 @@
     public SymbolContextScope
 {
 public:
-    typedef RangeArray<uint32_t, uint32_t> RangeArray;
+    typedef RangeArray<uint32_t, uint32_t, 1> RangeArray;
     typedef RangeArray::Entry Range;
 
     //------------------------------------------------------------------

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h?rev=141480&r1=141479&r2=141480&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h Sat Oct  8 01:59:54 2011
@@ -20,7 +20,7 @@
 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;

Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h?rev=141480&r1=141479&r2=141480&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h (original)
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h Sat Oct  8 01:59:54 2011
@@ -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();





More information about the lldb-commits mailing list