[Lldb-commits] [lldb] r276061 - Fix an issue where the libc++ std::list formatter wasn't recognizing the new memory layout correctly

Enrico Granata via lldb-commits lldb-commits at lists.llvm.org
Tue Jul 19 16:50:31 PDT 2016


Author: enrico
Date: Tue Jul 19 18:50:31 2016
New Revision: 276061

URL: http://llvm.org/viewvc/llvm-project?rev=276061&view=rev
Log:
Fix an issue where the libc++ std::list formatter wasn't recognizing the new memory layout correctly

rdar://problem/26999542


Modified:
    lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp

Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp?rev=276061&r1=276060&r2=276061&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp Tue Jul 19 18:50:31 2016
@@ -40,17 +40,21 @@ namespace {
         ListEntry
         next ()
         {
+            static ConstString g_next("__next_");
+            
             if (!m_entry_sp)
                 return ListEntry();
-            return ListEntry(m_entry_sp->GetChildAtIndexPath({0,1}));
+            return ListEntry(m_entry_sp->GetChildMemberWithName(g_next, true));
         }
 
         ListEntry
         prev ()
         {
+            static ConstString g_prev("__prev_");
+
             if (!m_entry_sp)
                 return ListEntry();
-            return ListEntry(m_entry_sp->GetChildAtIndexPath({0,0}));
+            return ListEntry(m_entry_sp->GetChildMemberWithName(g_prev, true));
         }
 
         uint64_t
@@ -304,6 +308,9 @@ lldb_private::formatters::LibcxxStdListS
 lldb::ValueObjectSP
 lldb_private::formatters::LibcxxStdListSyntheticFrontEnd::GetChildAtIndex (size_t idx)
 {
+    static ConstString g_value("__value_");
+    static ConstString g_next("__next_");
+
     if (idx >= CalculateNumChildren())
         return lldb::ValueObjectSP();
     
@@ -335,6 +342,23 @@ lldb_private::formatters::LibcxxStdListS
     current_sp = current_sp->GetChildAtIndex(1, true); // get the __value_ child
     if (!current_sp)
         return lldb::ValueObjectSP();
+    
+    if (current_sp->GetName() == g_next)
+    {
+        ProcessSP process_sp(current_sp->GetProcessSP());
+        if (!process_sp)
+            return nullptr;
+
+        // if we grabbed the __next_ pointer, then the child is one pointer deep-er
+        lldb::addr_t addr = current_sp->GetParent()->GetPointerValue();
+        addr = addr + 2*process_sp->GetAddressByteSize();
+        ExecutionContext exe_ctx(process_sp);
+        current_sp = CreateValueObjectFromAddress("__value_",
+                                                  addr,
+                                                  exe_ctx,
+                                                  m_element_type);
+    }
+    
     // we need to copy current_sp into a new object otherwise we will end up with all items named __value_
     DataExtractor data;
     Error error;




More information about the lldb-commits mailing list