[Lldb-commits] [lldb] [lldb] Show value for libcxx and libstdcxx summary and remove pointer value in libcxx container summary (PR #125294)

Zequan Wu via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 31 14:22:54 PST 2025


https://github.com/ZequanWu updated https://github.com/llvm/llvm-project/pull/125294

>From bbecf2f990c1fdf8ed993c3bba4c68212ebb299c Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Fri, 31 Jan 2025 13:05:14 -0800
Subject: [PATCH 1/3] [lldb] Show value for libcxx and libstdcxx summary and
 remove pointer value in libcxx container summary

---
 .../Language/CPlusPlus/CPlusPlusLanguage.cpp  |  4 +-
 .../Plugins/Language/CPlusPlus/LibCxx.cpp     |  6 ---
 .../deque/TestDataFormatterLibcxxDeque.py     | 49 ++++++++++++-------
 .../span/TestDataFormatterLibcxxSpan.py       |  5 +-
 .../variant/TestDataFormatterLibcxxVariant.py |  2 +-
 .../vector/TestDataFormatterLibcxxVector.py   | 49 ++++++++++++-------
 .../TestDataFormatterLibStdcxxVariant.py      |  2 +-
 7 files changed, 69 insertions(+), 48 deletions(-)

diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 2bf574e97768ec..4b045d12ad4947 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -641,7 +641,7 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
       .SetSkipPointers(false)
       .SetSkipReferences(false)
       .SetDontShowChildren(true)
-      .SetDontShowValue(true)
+      .SetDontShowValue(false)
       .SetShowMembersOneLiner(false)
       .SetHideItemNames(false);
 
@@ -1204,7 +1204,7 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
       .SetSkipPointers(false)
       .SetSkipReferences(false)
       .SetDontShowChildren(true)
-      .SetDontShowValue(true)
+      .SetDontShowValue(false)
       .SetShowMembersOneLiner(false)
       .SetHideItemNames(false);
 
diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
index 6d0ccdbbe4a71d..2aa8fdba706348 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp
@@ -430,12 +430,6 @@ size_t lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd::
 
 bool lldb_private::formatters::LibcxxContainerSummaryProvider(
     ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) {
-  if (valobj.IsPointerType()) {
-    uint64_t value = valobj.GetValueAsUnsigned(0);
-    if (!value)
-      return false;
-    stream.Printf("0x%016" PRIx64 " ", value);
-  }
   return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr,
                                        nullptr, nullptr, &valobj, false, false);
 }
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
index 3596b546be306a..8f8af60d4e9728 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
@@ -9,22 +9,37 @@
 
 
 class LibcxxDequeDataFormatterTestCase(TestBase):
-    def check_numbers(self, var_name):
-        self.expect(
-            "frame variable " + var_name,
-            substrs=[
-                var_name + " = size=7",
-                "[0] = 1",
-                "[1] = 12",
-                "[2] = 123",
-                "[3] = 1234",
-                "[4] = 12345",
-                "[5] = 123456",
-                "[6] = 1234567",
-                "}",
-            ],
-        )
-
+    def check_numbers(self, var_name, show_ptr = False):
+        if show_ptr:
+            self.expect(
+                "frame variable " + var_name,
+                patterns=[var_name + " = 0x.* size=7"],
+                substrs=[
+                    "[0] = 1",
+                    "[1] = 12",
+                    "[2] = 123",
+                    "[3] = 1234",
+                    "[4] = 12345",
+                    "[5] = 123456",
+                    "[6] = 1234567",
+                    "}",
+                ],
+            )
+        else:
+            self.expect(
+                "frame variable " + var_name,
+                substrs=[
+                    var_name + " = size=7",
+                    "[0] = 1",
+                    "[1] = 12",
+                    "[2] = 123",
+                    "[3] = 1234",
+                    "[4] = 12345",
+                    "[5] = 123456",
+                    "[6] = 1234567",
+                    "}",
+                ],
+            )
         self.expect_expr(
             var_name,
             result_summary="size=7",
@@ -75,7 +90,7 @@ def test_ref_and_ptr(self):
         )
 
         # The reference should display the same was as the value did
-        self.check_numbers("ref")
+        self.check_numbers("ref", True)
 
         # The pointer should just show the right number of elements:
         self.expect("frame variable ptr", substrs=["ptr =", " size=7"])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
index d5de73ac14ca14..4df4fa1acc8e77 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/TestDataFormatterLibcxxSpan.py
@@ -172,7 +172,4 @@ def test_ref_and_ptr(self):
 
         # The pointer should just show the right number of elements:
 
-        ptrAddr = self.findVariable("ptr").GetValue()
-        self.expect_expr(
-            "ptr", result_type="std::span<int, 5> *", result_summary=f"{ptrAddr} size=5"
-        )
+        self.expect("frame variable ptr", patterns=["ptr = 0x.*", " size=5"])
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
index 4154ad3c297fab..47e07a5ce3f5b1 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py
@@ -47,7 +47,7 @@ def test_with_run_command(self):
 
         self.expect(
             "frame variable v1_ref",
-            substrs=["v1_ref =  Active Type = int : {", "Value = 12", "}"],
+            patterns=["v1_ref = 0x.* Active Type = int : {", "Value = 12", "}"],
         )
 
         self.expect(
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
index a475c15d3da347..cabb7fbaed39a9 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -10,22 +10,37 @@
 
 
 class LibcxxVectorDataFormatterTestCase(TestBase):
-    def check_numbers(self, var_name):
-        self.expect(
-            "frame variable " + var_name,
-            substrs=[
-                var_name + " = size=7",
-                "[0] = 1",
-                "[1] = 12",
-                "[2] = 123",
-                "[3] = 1234",
-                "[4] = 12345",
-                "[5] = 123456",
-                "[6] = 1234567",
-                "}",
-            ],
-        )
-
+    def check_numbers(self, var_name, show_ptr = False):
+        if show_ptr:           
+            self.expect(
+                "frame variable " + var_name,
+                patterns=[var_name + " = 0x.* size=7"],
+                substrs=[
+                    "[0] = 1",
+                    "[1] = 12",
+                    "[2] = 123",
+                    "[3] = 1234",
+                    "[4] = 12345",
+                    "[5] = 123456",
+                    "[6] = 1234567",
+                    "}",
+                ],
+            )
+        else:
+            self.expect(
+                "frame variable " + var_name,
+                substrs=[
+                    var_name + " = size=7",
+                    "[0] = 1",
+                    "[1] = 12",
+                    "[2] = 123",
+                    "[3] = 1234",
+                    "[4] = 12345",
+                    "[5] = 123456",
+                    "[6] = 1234567",
+                    "}",
+                ],
+            )
         self.expect_expr(
             var_name,
             result_summary="size=7",
@@ -174,7 +189,7 @@ def test_ref_and_ptr(self):
         )
 
         # The reference should display the same was as the value did
-        self.check_numbers("ref")
+        self.check_numbers("ref", True)
 
         # The pointer should just show the right number of elements:
 
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
index ea4a53fcb4097a..394e221809f7c4 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py
@@ -30,7 +30,7 @@ def test_with_run_command(self):
         for name in ["v1_ref", "v1_typedef_ref"]:
             self.expect(
                 "frame variable " + name,
-                substrs=[name + " =  Active Type = int : {", "Value = 12", "}"],
+                patterns=[name + " = 0x.*  Active Type = int : {", "Value = 12", "}"],
             )
 
         self.expect(

>From 0743f7bae1e6ba1d1eb99e52f48b9c7ab9311e78 Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Fri, 31 Jan 2025 14:09:28 -0800
Subject: [PATCH 2/3] format

---
 .../libcxx/deque/TestDataFormatterLibcxxDeque.py                | 2 +-
 .../libcxx/vector/TestDataFormatterLibcxxVector.py              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
index 8f8af60d4e9728..ecfbb5893febe4 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/deque/TestDataFormatterLibcxxDeque.py
@@ -9,7 +9,7 @@
 
 
 class LibcxxDequeDataFormatterTestCase(TestBase):
-    def check_numbers(self, var_name, show_ptr = False):
+    def check_numbers(self, var_name, show_ptr=False):
         if show_ptr:
             self.expect(
                 "frame variable " + var_name,
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
index cabb7fbaed39a9..3bacbf6da49cc6 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -10,7 +10,7 @@
 
 
 class LibcxxVectorDataFormatterTestCase(TestBase):
-    def check_numbers(self, var_name, show_ptr = False):
+    def check_numbers(self, var_name, show_ptr=False):
         if show_ptr:           
             self.expect(
                 "frame variable " + var_name,

>From 6ad17184f4f10f21333bb3877322489d634b70ce Mon Sep 17 00:00:00 2001
From: Zequan Wu <zequanwu at google.com>
Date: Fri, 31 Jan 2025 14:21:26 -0800
Subject: [PATCH 3/3] format

---
 .../libcxx/vector/TestDataFormatterLibcxxVector.py              | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
index 3bacbf6da49cc6..c99c4474a36e38 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
@@ -11,7 +11,7 @@
 
 class LibcxxVectorDataFormatterTestCase(TestBase):
     def check_numbers(self, var_name, show_ptr=False):
-        if show_ptr:           
+        if show_ptr:
             self.expect(
                 "frame variable " + var_name,
                 patterns=[var_name + " = 0x.* size=7"],



More information about the lldb-commits mailing list