[Lldb-commits] [PATCH] D39602: Update tuple/list/deque data formatters to work with newest libc++

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 7 14:18:19 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317624: Update tuple/list/deque data formatters to work with newest libc++ (authored by labath).

Repository:
  rL LLVM

https://reviews.llvm.org/D39602

Files:
  lldb/trunk/examples/synthetic/libcxx.py
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
  lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp


Index: lldb/trunk/examples/synthetic/libcxx.py
===================================================================
--- lldb/trunk/examples/synthetic/libcxx.py
+++ lldb/trunk/examples/synthetic/libcxx.py
@@ -693,6 +693,13 @@
         except:
             return None
 
+    def _get_value_of_compressed_pair(self, pair):
+        value = pair.GetChildMemberWithName("__value_")
+        if not value.IsValid():
+            # pre-r300140 member name
+            value = pair.GetChildMemberWithName("__first_")
+        return value.GetValueAsUnsigned(0)
+
     def update(self):
         logger = lldb.formatters.Logger.Logger()
         try:
@@ -709,8 +716,8 @@
             # variable tells which element in this NxM array is the 0th
             # one, and the 'size' element gives the number of elements
             # in the deque.
-            count = self.valobj.GetChildMemberWithName(
-                '__size_').GetChildMemberWithName('__first_').GetValueAsUnsigned(0)
+            count = self._get_value_of_compressed_pair(
+                    self.valobj.GetChildMemberWithName('__size_'))
             # give up now if we cant access memory reliably
             if self.block_size < 0:
                 logger.write("block_size < 0")
@@ -724,8 +731,8 @@
                 '__begin_').GetValueAsUnsigned(0)
             map_end = map_.GetChildMemberWithName(
                 '__end_').GetValueAsUnsigned(0)
-            map_endcap = map_.GetChildMemberWithName(
-                '__end_cap_').GetChildMemberWithName('__first_').GetValueAsUnsigned(0)
+            map_endcap = self._get_value_of_compressed_pair(
+                    map_.GetChildMemberWithName( '__end_cap_'))
             # check consistency
             if not map_first <= map_begin <= map_end <= map_endcap:
                 logger.write("map pointers are not monotonic")
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
===================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxTuple.cpp
@@ -38,7 +38,11 @@
 
 bool TupleFrontEnd::Update() {
   m_elements.clear();
-  m_base_sp = m_backend.GetChildMemberWithName(ConstString("base_"), true);
+  m_base_sp = m_backend.GetChildMemberWithName(ConstString("__base_"), true);
+  if (! m_base_sp) {
+    // Pre r304382 name of the base element.
+    m_base_sp = m_backend.GetChildMemberWithName(ConstString("base_"), true);
+  }
   if (! m_base_sp)
     return false;
   m_elements.assign(m_base_sp->GetCompilerType().GetNumDirectBaseClasses(),
Index: lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
===================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/LibCxxList.cpp
@@ -298,6 +298,15 @@
                                    m_element_type);
 }
 
+static ValueObjectSP GetValueOfCompressedPair(ValueObject &pair) {
+  ValueObjectSP value = pair.GetChildMemberWithName(ConstString("__value_"), true);
+  if (! value) {
+    // pre-r300140 member name
+    value = pair.GetChildMemberWithName(ConstString("__first_"), true);
+  }
+  return value;
+}
+
 bool ForwardListFrontEnd::Update() {
   AbstractListFrontEnd::Update();
 
@@ -310,7 +319,7 @@
       m_backend.GetChildMemberWithName(ConstString("__before_begin_"), true));
   if (!impl_sp)
     return false;
-  impl_sp = impl_sp->GetChildMemberWithName(ConstString("__first_"), true);
+  impl_sp = GetValueOfCompressedPair(*impl_sp);
   if (!impl_sp)
     return false;
   m_head = impl_sp->GetChildMemberWithName(ConstString("__next_"), true).get();
@@ -331,10 +340,9 @@
   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);
+    ValueObjectSP value = GetValueOfCompressedPair(*size_alloc);
+    if (value) {
+      m_count = value->GetValueAsUnsigned(UINT32_MAX);
     }
   }
   if (m_count != UINT32_MAX) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39602.121986.patch
Type: text/x-patch
Size: 4233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20171107/91339e33/attachment-0001.bin>


More information about the lldb-commits mailing list