[Lldb-commits] [PATCH] D128694: [lldb/Dataformatters] Adapt C++ std::string dataformatter for D128285

Med Ismail Bennani via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Mon Jun 27 17:40:53 PDT 2022


mib created this revision.
mib added reviewers: aprantl, JDevlieghere.
mib added a project: LLDB.
Herald added a project: All.
mib requested review of this revision.
Herald added a subscriber: lldb-commits.

This patch changes the C++ `std::string` dataformatter to reflect
internal layout changes following D128285 <https://reviews.llvm.org/D128285>.

Now, on short strings, in order to access the `__size` attributes, we
need to access a packed anonymous struct, which introduces another
indirection.

This should fix the various test failures that are happening on
GreenDragon:

https://green.lab.llvm.org/green/job/lldb-cmake/44918/

rdar://96010248

Signed-off-by: Med Ismail Bennani <medismail.bennani at gmail.com>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128694

Files:
  lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp


Index: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
===================================================================
--- lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -624,11 +624,17 @@
     ValueObjectSP short_sp(dataval_sp->GetChildAtIndex(1, true));
     if (!short_sp)
       return {};
-    ValueObjectSP location_sp = short_sp->GetChildAtIndex(
+
+    // After D128285, we need to access the size from a packed anonymous struct
+    ValueObjectSP packed_fields_sp = short_sp->GetChildAtIndex(0, true);
+    if (!packed_fields_sp)
+      return {};
+
+    ValueObjectSP location_sp = packed_fields_sp->GetChildAtIndex(
         (layout == eLibcxxStringLayoutModeDSC) ? 0 : 1, true);
     // After D125496, there is a flat layout.
     if (location_sp->GetName() == g_size_name)
-      location_sp = short_sp->GetChildAtIndex(3, true);
+      location_sp = short_sp->GetChildAtIndex(2, true);
     if (using_bitmasks)
       size = (layout == eLibcxxStringLayoutModeDSC)
                  ? size_mode_value


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128694.440445.patch
Type: text/x-patch
Size: 1080 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220628/a90cd9b3/attachment.bin>


More information about the lldb-commits mailing list