-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb] Show value for libcxx and libstdcxx summary and remove pointer value in libcxx container summary #125294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… value in libcxx container summary
@llvm/pr-subscribers-lldb Author: Zequan Wu (ZequanWu) ChangesThis has two changes:
Full diff: https://github.com/llvm/llvm-project/pull/125294.diff 7 Files Affected:
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(
|
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"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SBValue::GetValue
essentially uses the summary string provided by summary provider. So it returns "size=5" after I removed the pointer value in libcxx container summary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but you can still use expect_expr
to match this. You just need to say result_summary=re.compile("your_pattern")
✅ With the latest revision this PR passed the Python code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, better to be consistent, and the pointer value is useful.
...tionalities/data-formatter/data-formatter-stl/libcxx/vector/TestDataFormatterLibcxxVector.py
Outdated
Show resolved
Hide resolved
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"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense, but you can still use expect_expr
to match this. You just need to say result_summary=re.compile("your_pattern")
… value in libcxx container summary (llvm#125294) This has two changes: 1. Set show value for libcxx and libstdcxx summary provider. This will print the pointer value for both pointer type and reference type. 2. Remove pointer value printing in libcxx container summary. Discussion: https://discourse.llvm.org/t/lldb-hides-raw-pointer-value-for-libcxx-and-libstdcxx-pointer-types-in-summary-string/84226
…125294) This includes support for module translation, module import and add tests for both. Fix llvm#115390 ClangIR cannot currently lower global aliases to LLVM because of missing support for this.
This has two changes:
Discussion:
https://discourse.llvm.org/t/lldb-hides-raw-pointer-value-for-libcxx-and-libstdcxx-pointer-types-in-summary-string/84226