[Lldb-commits] [lldb] 4542841 - [lldb] Adjust libc++ string formatter for changes in D122598

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 12 06:44:35 PDT 2022


Author: Pavel Labath
Date: 2022-04-12T15:44:16+02:00
New Revision: 45428412fd7c9900d3d6ac9803aa7dcf6adfa6fe

URL: https://github.com/llvm/llvm-project/commit/45428412fd7c9900d3d6ac9803aa7dcf6adfa6fe
DIFF: https://github.com/llvm/llvm-project/commit/45428412fd7c9900d3d6ac9803aa7dcf6adfa6fe.diff

LOG: [lldb] Adjust libc++ string formatter for changes in D122598

The __size_ member is now in a slightly different location.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 9731173b7a885..2fd69452217c7 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -578,17 +578,21 @@ ExtractLibcxxStringInfo(ValueObject &valobj) {
   uint64_t size_mode_value = 0;
 
   if (layout == eLibcxxStringLayoutModeDSC) {
-    ValueObjectSP size_mode(D->GetChildAtIndexPath({1, 1, 0}));
+    llvm::SmallVector<size_t, 3> size_mode_locations[] = {
+        {1, 2}, // Post-c3d0205ee771 layout
+        {1, 1, 0},
+        {1, 1, 1},
+    };
+    ValueObjectSP size_mode;
+    for (llvm::ArrayRef<size_t> loc : size_mode_locations) {
+      size_mode = D->GetChildAtIndexPath(loc);
+      if (size_mode && size_mode->GetName() == g_size_name)
+        break;
+    }
+
     if (!size_mode)
       return {};
 
-    if (size_mode->GetName() != g_size_name) {
-      // we are hitting the padding structure, move along
-      size_mode = D->GetChildAtIndexPath({1, 1, 1});
-      if (!size_mode)
-        return {};
-    }
-
     size_mode_value = (size_mode->GetValueAsUnsigned(0));
     short_mode = ((size_mode_value & 0x80) == 0);
   } else {


        


More information about the lldb-commits mailing list