[Lldb-commits] [lldb] r180071 - Much better way to get at the size of an std::list

Enrico Granata egranata at apple.com
Mon Apr 22 16:36:35 PDT 2013


Author: enrico
Date: Mon Apr 22 18:36:35 2013
New Revision: 180071

URL: http://llvm.org/viewvc/llvm-project?rev=180071&view=rev
Log:
Much better way to get at the size of an std::list

Modified:
    lldb/trunk/source/DataFormatters/LibCxxList.cpp

Modified: lldb/trunk/source/DataFormatters/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/LibCxxList.cpp?rev=180071&r1=180070&r2=180071&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/LibCxxList.cpp (original)
+++ lldb/trunk/source/DataFormatters/LibCxxList.cpp Mon Apr 22 18:36:35 2013
@@ -181,26 +181,44 @@ lldb_private::formatters::LibcxxStdListS
         return m_count;
     if (!m_head || !m_tail || m_node_address == 0)
         return 0;
-    uint64_t next_val = m_head->GetValueAsUnsigned(0);
-    uint64_t prev_val = m_tail->GetValueAsUnsigned(0);
-    if (next_val == 0 || prev_val == 0)
-        return 0;
-    if (next_val == m_node_address)
-        return 0;
-    if (next_val == prev_val)
-        return 1;
-    if (HasLoop())
-        return 0;
-    uint64_t size = 2;
-    ListEntry current(m_head);
-    while (current.next() && current.next()->GetValueAsUnsigned(0) != m_node_address)
+    ValueObjectSP size_alloc(m_backend.GetChildMemberWithName(ConstString("__size_alloc_"), true));
+    if (size_alloc)
+    {
+        ValueObjectSP first(size_alloc->GetChildMemberWithName(ConstString("__first_"), true));
+        if (first)
+        {
+            m_count = first->GetValueAsUnsigned(UINT32_MAX);
+        }
+    }
+    if (m_count != UINT32_MAX)
+    {
+        if (!HasLoop())
+            return m_count;
+        return m_count = 0;
+    }
+    else
     {
-        size++;
-        current.SetEntry(current.next());
-        if (size > m_list_capping_size)
-            break;
+        uint64_t next_val = m_head->GetValueAsUnsigned(0);
+        uint64_t prev_val = m_tail->GetValueAsUnsigned(0);
+        if (next_val == 0 || prev_val == 0)
+            return 0;
+        if (next_val == m_node_address)
+            return 0;
+        if (next_val == prev_val)
+            return 1;
+        if (HasLoop())
+            return 0;
+        uint64_t size = 2;
+        ListEntry current(m_head);
+        while (current.next() && current.next()->GetValueAsUnsigned(0) != m_node_address)
+        {
+            size++;
+            current.SetEntry(current.next());
+            if (size > m_list_capping_size)
+                break;
+        }
+        return m_count = (size-1);
     }
-    return m_count = (size-1);
 }
 
 lldb::ValueObjectSP





More information about the lldb-commits mailing list