[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)
labath wrote: I'm not entirely comfortable with putting the (obviously c++ specific) helper function into the DataFormatters) library. There's no reason to call this from outside the c++ language plugin, right? What would you say to putting this into some header inside the plugin (or creating a new one if we have nothing suitable)? https://github.com/llvm/llvm-project/pull/147340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Annotate disassembly with register‐resident variable locations (PR #147460)
https://github.com/UltimateForce21 created https://github.com/llvm/llvm-project/pull/147460 This PR builds upon the functionality introduced in [PR #144238](https://github.com/llvm/llvm-project/pull/144238), which adds support for annotating disassembly output with DWARF variable locations. This patch includes: Additional test coverage for various DWARF location cases (e.g., stack variables, control flow edges, partial decoding). A refined implementation that uses the new DWARFExpressionEntry API. Logic to gracefully skip fragments while preserving valid annotations. ⚠️ Note: This PR depends on #144238 and should be rebased once it lands. ### Summary This patch adds a first‐pass prototype of “rich disassembly” annotations into Instruction::Dump(). For each instruction, it will: 1. Query our new `GetExpressionEntryAtAddress()` API for any in‐scope variable live‐ranges covering this PC. If a variable’s live‐range begins exactly at the current PC that is being iterated in the disassembly, call `expr->DumpLocation(...)` to render its DWARF expression (e.g. “`DW_OP_reg5 RDI`”, “`DW_OP_reg3 RBX`”, or constant) and append it as a `; var = …` comment after the instruction. Currently this only handles simple cases: Variables whose location expression is a single register (e.g. `DW_OP_reg14 R14`) Variables whose location expression is a constant (e.g. `DW_OP_consts +0`) ### Example test program ``` // test.cpp #include void testFunction(int value); int main(int argc, char** argv) { int total = 0; for (int my_special_variable = 0; my_special_variable < 5; ++my_special_variable){ puts(argv[my_special_variable]); int new_variable = my_special_variable + 1; testFunction(new_variable); total += my_special_variable; } return total; } void testFunction(int value) { std::cout << "Local variable value: " << value << std::endl; } ``` ### Disassembly output with annotations ``` (lldb) target create "/home/ultimateforce21/lldb_test/test" Current executable set to '/home/ultimateforce21/lldb_test/test' (x86_64). (lldb) b main Breakpoint 1: where = test`main + 16 at test.cpp:10:14, address = 0x1200 (lldb) r Process 26674 launched: '/home/ultimateforce21/lldb_test/test' (x86_64) Process 26674 stopped * thread #1, name = 'test', stop reason = breakpoint 1.1 frame #0: 0x5200 test`main(argc=, argv=0x7fffdc68) at test.cpp:10:14 7int main(int argc, char** argv) { 8int total = 0; 9for (int my_special_variable = 0; my_special_variable < 5; ++my_special_variable){ -> 10 puts(argv[my_special_variable]); 11 int new_variable = my_special_variable + 1; 12 testFunction(new_variable); 13 total += my_special_variable; (lldb) dis test`main: 0x51f0 <+0>: pushq %r14 ; argc = DW_OP_reg5 RDI ; argv = DW_OP_reg4 RSI ; std::__ioinit = DW_OP_addrx 0x0 0x51f2 <+2>: pushq %rbx 0x51f3 <+3>: pushq %rax 0x51f4 <+4>: movq %rsi, %r14 0x51f7 <+7>: xorl %ebx, %ebx ; total = DW_OP_consts +0, DW_OP_stack_value 0x51f9 <+9>: nopl (%rax) ; my_special_variable = DW_OP_reg3 RBX ; argc = DW_OP_entry_value(DW_OP_reg5 RDI), DW_OP_stack_value ; argv = DW_OP_reg14 R14 -> 0x5200 <+16>: movq (%r14,%rbx,8), %rdi 0x5204 <+20>: callq 0x50a0 ; symbol stub for: puts 0x5209 <+25>: addq $0x1, %rbx 0x520d <+29>: movl %ebx, %edi ; new_variable = DW_OP_reg3 RBX 0x520f <+31>: callq 0x5230 ; testFunction at test.cpp:19 0x5214 <+36>: cmpq $0x5, %rbx ; my_special_variable = DW_OP_reg3 RBX 0x5218 <+40>: jne0x5200 ; <+16> at test.cpp:10:14 0x521a <+42>: movl $0xa, %eax 0x521f <+47>: addq $0x8, %rsp 0x5223 <+51>: popq %rbx 0x5224 <+52>: popq %r14 0x5226 <+54>: retq ; argv = DW_OP_entry_value(DW_OP_reg4 RSI), DW_OP_stack_value ``` ### Next steps **Cleanup & style (DONE)** - Tidy up any styling according to LLDB’s conventions, and handle any off‐by‐one column issues. **Test coverage (DONE)** - Add a lldb-test cases exercising single-register variables at known instructions. >From 8ed8c540e7600d720a63bc2882a81a2c65c11d41 Mon Sep 17 00:00:00 2001 From: ultimateforce21 Date: Wed, 11 Jun 2025 00:11:09 -0400 Subject: [PATCH 01/19] [lldb] Add DWARFExpressionEntry and GetExpressionEntryAtAddress() to DWARFExpressionList This introduces a new API for retrieving DWARF expression metadata associated with variable location entries at a given PC address. It provides the base, end, and expression pointer for downstream consumers such as disassembler annotations. Intended for use in richer instruction annotations in Instruction::Dump(). --- .../lldb/Expression/DWARFExpressionL
[Lldb-commits] [lldb] Annotate disassembly with register‐resident variable locations (PR #147460)
github-actions[bot] wrote: Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using `@` followed by their GitHub username. If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the [LLVM GitHub User Guide](https://llvm.org/docs/GitHub.html). You can also ask questions in a comment on this PR, on the [LLVM Discord](https://discord.com/invite/xS7Z362) or on the [forums](https://discourse.llvm.org/). https://github.com/llvm/llvm-project/pull/147460 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] Annotate disassembly with register‐resident variable locations (PR #147460)
UltimateForce21 wrote: @JDevlieghere @adrian-prantl I have created the [PR #144238](https://github.com/llvm/llvm-project/pull/144238) dependent Rich Disassembler Annotations PR. https://github.com/llvm/llvm-project/pull/147460 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (PR #147031)
@@ -1,7 +1,5 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - # We need debug info tuning for lldb in order to emit the preferred name for # std::string. See https://reviews.llvm.org/D145803. CXXFLAGS_EXTRAS := -std=c++14 -glldb labath wrote: Good idea. https://github.com/llvm/llvm-project/pull/147031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (PR #147031)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147139 >From 5835f9f8adfbbafba9fb3ecea9b339bd82b0ba19 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sat, 5 Jul 2025 11:15:23 +0100 Subject: [PATCH 1/4] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had some tuple indexing tests that libc++ didn't have. Split out from https://github.com/llvm/llvm-project/pull/146740 --- .../{libcxx => generic}/tuple/Makefile| 1 - .../tuple/TestDataFormatterStdTuple.py| 73 +++ .../{libcxx => generic}/tuple/main.cpp| 3 +- .../tuple/TestDataFormatterLibcxxTuple.py | 45 .../libstdcpp/tuple/Makefile | 5 -- .../tuple/TestDataFormatterStdTuple.py| 47 .../libstdcpp/tuple/main.cpp | 9 --- 7 files changed, 75 insertions(+), 108 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/tuple/Makefile (75%) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/tuple/main.cpp (80%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile index 680e1abfbef58..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py new file mode 100644 index 0..9e019d328b6b3 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py @@ -0,0 +1,73 @@ +""" +Test lldb data formatter subsystem. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDataFormatterStdTuple(TestBase): +def setUp(self): +TestBase.setUp(self) +self.line = line_number("main.cpp", "// break here") +self.namespace = "std" + +def do_test(self): +"""Test that std::tuple is displayed correctly""" +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp", False) +) + +tuple_name = self.namespace + "::tuple" +self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"]) + +self.expect( +"frame variable one_elt", +substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"], +) + +self.expect( +"frame variable three_elts", +substrs=[ +tuple_name, +"size=3", +"{", +"[0] = 1", +"[1] = 47", +'[2] = "foo"', +"}", +], +) + +self.assertEqual( +1, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned() +) +self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid()) + +self.assertEqual( +'"foobar"', frame.GetValueForVariablePath("string_elt[0]").GetSummary() +) + self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid()) + +self.assertEqual( +1, frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned() +) +self.assertEqual( +'"baz"', frame.GetValueForVariablePath("three_elts[1]").GetSummary() +) +self.assertEqual( +2, frame.GetValueForVariablePath("three_elts[2]").GetValueAsUnsigned() +) + self.assertFalse(frame.GetValueForVa
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (PR #147175)
labath wrote: It looks like the libstdc++ test just crashes. https://github.com/llvm/llvm-project/pull/147175 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (PR #147141)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147141 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147139 >From 5835f9f8adfbbafba9fb3ecea9b339bd82b0ba19 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sat, 5 Jul 2025 11:15:23 +0100 Subject: [PATCH 1/3] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test This combines the libc++ and libstdc++ test cases. The main difference was that the libstdcpp tests had some tuple indexing tests that libc++ didn't have. Split out from https://github.com/llvm/llvm-project/pull/146740 --- .../{libcxx => generic}/tuple/Makefile| 1 - .../tuple/TestDataFormatterStdTuple.py| 73 +++ .../{libcxx => generic}/tuple/main.cpp| 3 +- .../tuple/TestDataFormatterLibcxxTuple.py | 45 .../libstdcpp/tuple/Makefile | 5 -- .../tuple/TestDataFormatterStdTuple.py| 47 .../libstdcpp/tuple/main.cpp | 9 --- 7 files changed, 75 insertions(+), 108 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/tuple/Makefile (75%) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/tuple/main.cpp (80%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/TestDataFormatterLibcxxTuple.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/TestDataFormatterStdTuple.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/tuple/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile index 680e1abfbef58..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/tuple/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/Makefile @@ -1,4 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py new file mode 100644 index 0..9e019d328b6b3 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/tuple/TestDataFormatterStdTuple.py @@ -0,0 +1,73 @@ +""" +Test lldb data formatter subsystem. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestDataFormatterStdTuple(TestBase): +def setUp(self): +TestBase.setUp(self) +self.line = line_number("main.cpp", "// break here") +self.namespace = "std" + +def do_test(self): +"""Test that std::tuple is displayed correctly""" +lldbutil.run_to_source_breakpoint( +self, "// break here", lldb.SBFileSpec("main.cpp", False) +) + +tuple_name = self.namespace + "::tuple" +self.expect("frame variable empty", substrs=[tuple_name, "size=0", "{}"]) + +self.expect( +"frame variable one_elt", +substrs=[tuple_name, "size=1", "{", "[0] = 47", "}"], +) + +self.expect( +"frame variable three_elts", +substrs=[ +tuple_name, +"size=3", +"{", +"[0] = 1", +"[1] = 47", +'[2] = "foo"', +"}", +], +) + +self.assertEqual( +1, frame.GetValueForVariablePath("one_elt[0]").GetValueAsUnsigned() +) +self.assertFalse(frame.GetValueForVariablePath("one_elt[1]").IsValid()) + +self.assertEqual( +'"foobar"', frame.GetValueForVariablePath("string_elt[0]").GetSummary() +) + self.assertFalse(frame.GetValueForVariablePath("string_elt[1]").IsValid()) + +self.assertEqual( +1, frame.GetValueForVariablePath("three_elts[0]").GetValueAsUnsigned() +) +self.assertEqual( +'"baz"', frame.GetValueForVariablePath("three_elts[1]").GetSummary() +) +self.assertEqual( +2, frame.GetValueForVariablePath("three_elts[2]").GetValueAsUnsigned() +) + self.assertFalse(frame.GetValueForVa
[Lldb-commits] [lldb] 074ccde - [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (#147031)
Author: Michael Buch Date: 2025-07-07T10:13:03+01:00 New Revision: 074ccde3b092ed231d344d4ffad50de93438196c URL: https://github.com/llvm/llvm-project/commit/074ccde3b092ed231d344d4ffad50de93438196c DIFF: https://github.com/llvm/llvm-project/commit/074ccde3b092ed231d344d4ffad50de93438196c.diff LOG: [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (#147031) The libc++ test was a subset of the tests in libstdc++. This test moves the libc++ test into `generic` and somne additional test-cases from `libstdc++` (specifically the recursive unique_ptr case). It turns out the libstdc++ formatter supports dereferencing using the "object" or "obj" names. We could either drop those from the tests or support the same for libc++. I took the latter approach but don't have strong opinions on this. Split out from https://github.com/llvm/llvm-project/pull/146740 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/main.cpp Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/TestDataFormatterLibcxxUniquePtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/unique_ptr/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/TestDataFormatterStdUniquePtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/TestDataFormatterInvalidStdUniquePtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/invalid/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/main.cpp diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 7ecb484e35474..3079de4936a85 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -411,7 +411,7 @@ lldb_private::formatters::LibcxxUniquePtrSyntheticFrontEnd:: return 0; if (name == "deleter") return 1; - if (name == "$$dereference$$") + if (name == "obj" || name == "object" || name == "$$dereference$$") return 2; return llvm::createStringError("Type has no child named '%s'", name.AsCString()); diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp index e570a4bb1a886..4daba2e364168 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppUniquePointer.cpp @@ -42,8 +42,7 @@ class LibStdcppUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { // objects are only destroyed when every shared pointer to any of them // is destroyed, so we must not store a shared pointer to any ValueObject // derived from our backend ValueObject (since we're in the same cluster). - ValueObject* m_ptr_obj = nullptr; - ValueObject* m_obj_obj = nullptr; + ValueObject *m_ptr_obj = nullptr; ValueObject* m_del_obj = nullptr; ValueObjectSP GetTuple(); @@ -107,7 +106,6 @@ lldb::ChildCacheState LibStdcppUniquePtrSyntheticFrontEnd::Update() { if (del_obj) m_del_obj = del_obj->Clone(ConstString("deleter")).get(); } - m_obj_obj = nullptr; return lldb::ChildCacheState::eRefetch; } @@ -119,15 +117,13 @@ LibStdcppUniquePtrSyntheticFrontEnd::GetChildAtIndex(uint32_t idx) { if (idx == 1 && m_del_obj) return m_del_obj->GetSP(); if (idx == 2) { -if (m_ptr_obj && !m_obj_obj) { - Status error; - ValueObjectSP obj_obj = m_ptr_obj->Dereference(error); - if (error.Success()) { -m_obj_obj = obj_obj->Clone(ConstString("object")).get(); +if (m_ptr_obj) { + Status status; + auto value_sp = m_ptr_obj->Dereference(status); + if (status.Success()) { +return value_sp; } } -if (m_obj_obj) - return m_obj_obj->GetSP(); } return lldb::ValueObjectSP(); } diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/unique_ptr/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/unique_ptr/Makefile similarity index 61% rename from lldb/test/API/func
[Lldb-commits] [lldb] [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (PR #147031)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/147253 This combines the libc++ and libstdc++ test cases. The libstdc++ test had an additional test-case for "reference to typedef". So I added those to the generic test. The rest of the tests was the same as libc++. Split out from https://github.com/llvm/llvm-project/pull/146740 >From 5ec10f9e485e8cccb0f73290d720f65911e55c86 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:58:02 +0100 Subject: [PATCH] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test --- .../{libcxx => generic}/variant/Makefile | 4 +- .../variant/TestDataFormatterStdVariant.py} | 56 -- .../{libstdcpp => generic}/variant/main.cpp | 19 ++-- .../libcxx/variant/main.cpp | 95 .../libstdcpp/variant/Makefile| 5 - .../TestDataFormatterLibStdcxxVariant.py | 101 -- 6 files changed, 32 insertions(+), 248 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/variant/Makefile (82%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/variant/TestDataFormatterLibcxxVariant.py => generic/variant/TestDataFormatterStdVariant.py} (53%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/variant/main.cpp (85%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..d5f5fec8441b5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 + include Makefile.rules 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/generic/variant/TestDataFormatterStdVariant.py similarity index 53% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index 47e07a5ce3f5b..cf2569b02a586 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/generic/variant/TestDataFormatterStdVariant.py @@ -2,53 +2,31 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVariantDataFormatterTestCase(TestBase): -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf( -oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] -) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=["<", "5.1"]) -## std::get is unavailable for std::variant before macOS 10.14 -@skipIf(macos_version=["<", "10.14"]) -def test_with_run_command(self): +class StdVariantDataFormatterTestCase(TestBase): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) -self.runCmd("frame variable has_variant") - -output = self.res.GetOutput() - -## The variable has_variant tells us if the test program -## detected we have a sufficient libc++ version to support variant -## false means we do not and therefore should skip the test -if output.find("(bool) has_variant = false") != -1: -self.skipTest("std::variant not supported") - -lldbutil.continue_to_breakpoint(self.process, bkp
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes This combines the libc++ and libstdc++ test cases. The libstdc++ test had an additional test-case for "reference to typedef". So I added those to the generic test. The rest of the tests was the same as libc++. Split out from https://github.com/llvm/llvm-project/pull/146740 --- Full diff: https://github.com/llvm/llvm-project/pull/147253.diff 6 Files Affected: - (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile (+1-3) - (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py (+22-34) - (renamed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/main.cpp (+9-10) - (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp (-95) - (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile (-5) - (removed) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py (-101) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..d5f5fec8441b5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 + include Makefile.rules 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/generic/variant/TestDataFormatterStdVariant.py similarity index 53% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index 47e07a5ce3f5b..cf2569b02a586 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/generic/variant/TestDataFormatterStdVariant.py @@ -2,53 +2,31 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVariantDataFormatterTestCase(TestBase): -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf( -oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] -) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=["<", "5.1"]) -## std::get is unavailable for std::variant before macOS 10.14 -@skipIf(macos_version=["<", "10.14"]) -def test_with_run_command(self): +class StdVariantDataFormatterTestCase(TestBase): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) -self.runCmd("frame variable has_variant") - -output = self.res.GetOutput() - -## The variable has_variant tells us if the test program -## detected we have a sufficient libc++ version to support variant -## false means we do not and therefore should skip the test -if output.find("(bool) has_variant = false") != -1: -self.skipTest("std::variant not supported") - -lldbutil.continue_to_breakpoint(self.process, bkpt) - -self.expect( -"frame variable v1", -substrs=["v1 = Active Type = int {", "Value = 12", "}"], -) +for name in ["v1", "v1_typedef"]: +self.expect( +"frame variable " + name, +substrs=[name + " = Active Type = int {", "Value = 12", "}"], +) -self.expect( -"frame variable v1_ref", -patterns=["v1_ref = 0x.* Active Type = int : {", "Value = 12", "}"], -) +for name in ["v1_ref", "v1_typedef_ref"]: +self.expect( +"frame v
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/147253 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
@@ -0,0 +1,39 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipUnlessDarwin +@skipIf(archs=no_match(["arm"])) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() Michael137 wrote: Should probably just adjust the "archs" check to "arm64", instead of checking address size https://github.com/llvm/llvm-project/pull/147252 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
Michael137 wrote: > Looking up global variables is not completely ideal (can be slow and look up > unrelated things). Would index_obj.GetValueAs**Signed**() == -1 work by any > chance? Actually after some more investigating it turns out the test was just flawed. A default-constructed variant has a valid index (being the first element of the variant). The only case where the index is `variant_npos` is when the variant is "valueless", which [according to cppreference](https://en.cppreference.com/w/cpp/utility/variant/valueless_by_exception.html) only happens when an exception is thrown during assignment to the variant. I adjusted the test to test that scenario, and the formatter seems to work. https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter tests for valueless variants (PR #147283)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (PR #147031)
labath wrote: (The test is failing due to std::make_unique not being defined. I'd be fine both with bringing back -std=c++14 and using explicit construction.) https://github.com/llvm/llvm-project/pull/147031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] b7d4735 - [lldb][test] Combine libstdc++ and libc++ vector tests into generic test (#147137)
Author: Michael Buch Date: 2025-07-07T08:39:47+01:00 New Revision: b7d4735a0e2a65c27aa74a56e19020a34de790fe URL: https://github.com/llvm/llvm-project/commit/b7d4735a0e2a65c27aa74a56e19020a34de790fe DIFF: https://github.com/llvm/llvm-project/commit/b7d4735a0e2a65c27aa74a56e19020a34de790fe.diff LOG: [lldb][test] Combine libstdc++ and libc++ vector tests into generic test (#147137) The libc++ and libstdc++ tests were pretty much an exact copy of each other. This test moves the libc++ test into generic removes it from libstdc++. I moved the `GLIBCXX_DEBUG` case over from libstdcxx. For some reason the libstdcxx test was skipped, but it passes on my Linux machine. So I unskipped it for now. Split out from https://github.com/llvm/llvm-project/pull/146740 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/main.cpp Modified: Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/TestDataFormatterLibcxxVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile similarity index 75% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile index d87cf7d402787..65e9dd2fa9e33 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/vbool/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/Makefile @@ -1,4 +1,4 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 + include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py similarity index 81% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py index f3371bc014b17..56c86d1edde25 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/vbool/TestDataFormatterStdVBool.py @@ -2,8 +2,6 @@ Test lldb data formatter subsystem. """ - -from typing import Optional import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -17,19 +15,8 @@ def setUp(self): # Find the line number to break at. self.line = line_number("main.cpp", "// Set break point at this line.") -@skip -@add_test_categories(["libstdcxx"]) -def test_with_run_command(self): -self.with_run_command() - -@add_test_categories(["libstdcxx"]) -def test_with_run_command_debug(self): -build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"} -self.with_run_command(build_args) - -def with_run_command(self, dictionary: Optional[dict] = None): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build(dictionary=dictionary) self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -52,6 +39,7 @@ def cleanup(): self.runCmd("type summary clear", check=False) self.runCmd("type filter clear", check=False) self.runCmd("type synth clear", check=False) +self.runCmd("settings set target.max-children-count 24", check=False) # Execute the cleanup function during test case tear down. self.addTearDownHook(cleanup) @@ -83,3 +71,20 @@ def cleanup(): "[48] = true", ], ) + +@add_test_categories(["libc++"]) +def test_libcxx(self): +self.build(dictionary={"USE_LIBCPP": 1}) +self.do_test() + +@add_test_categories(["libstdcxx"]) +def test_libstdcx
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ vector tests into generic test (PR #147137)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147137 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (PR #147141)
Michael137 wrote: > There are two failures: > > * the libc++ pointer child is called `__ptr_`, not `pointer`. I think we > should clone/rename the child so that the child has a consistent name. This > could be particularly useful for writing other data formatters, which may > want to dereference a shared_ptr without caring which stdlib implementation > they are using. > > * the libstdc++ child type is `std::goo<...>::type` instead of `int` in > libc++. I think the libc++ implementation is better. The case for unification > is slightly weaker here (people can always resolve the typedef manually), > though I'd still do it if its easy enough. Yup spot on! I addressed these in https://github.com/llvm/llvm-project/pull/147166 and https://github.com/llvm/llvm-project/pull/147165 https://github.com/llvm/llvm-project/pull/147141 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/147252 As a pre-requisite to combine the libcxx and libstdcxx string formatter tests (see https://github.com/llvm/llvm-project/pull/146740) this patch splits out the libcxx specific parts into a separate test. These are probably best tested with the libcxx-simulator tests. But for now I just moved them. >From 81f856c7c851d5b03ddd176977e7d0c55e7c7f6f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:47:39 +0100 Subject: [PATCH] [lldb][test] Split out libc++ std::string tests that check corrupted strings --- .../libcxx/invalid-string/Makefile| 5 + .../TestDataFormatterLibcxxString.py | 39 +++ .../libcxx/invalid-string/main.cpp| 110 ++ .../string/TestDataFormatterLibcxxString.py | 21 .../data-formatter-stl/libcxx/string/main.cpp | 103 5 files changed, 154 insertions(+), 124 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile new file mode 100644 index 0..c5df567e01a2a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py new file mode 100644 index 0..497a495106575 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py @@ -0,0 +1,39 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipUnlessDarwin +@skipIf(archs=no_match(["arm"])) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() + +# The test assumes that std::string is in its cap-size-data layout. +self.expect( +"frame variable garbage1", substrs=["garbage1 = Summary Unavailable"] +) +self.expect( +"frame variable garbage2", substrs=[r'garbage2 = "\xfa\xfa\xfa\xfa"'] +) +self.expect("frame variable garbage3", substrs=[r'garbage3 = "\xf0\xf0"']) +self.expect( +"frame variable garbage4", substrs=["garbage4 = Summary Unavailable"] +) +self.expect( +"frame variable garbage5", substrs=["garbage5 = Summary Unavailable"] +) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp new file mode 100644 index 0..eb3efe1bcb7ef --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +// For more information about libc++'s std::string ABI, see: +// +// https://joellaity.com/2020/01/31/string.html + +// A corrupt string which hits the SSO code path, but has an invalid size. +static struct { +#if _LIBCPP_ABI_VERSION == 1 + // Set the size of this short-mode string to 116. Note that in short mode, + // the size is encoded as `size << 1`. + unsigned char size = 232; + + // 23 garbage bytes for the inline string payload. + char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 +} garbage_string_short_mode; + +// A corrupt libcxx string in long mode with a payload that contains a utf8 +// sequence that's inherently too long. +static unsigned char garbage_utf8_payload
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes As a pre-requisite to combine the libcxx and libstdcxx string formatter tests (see https://github.com/llvm/llvm-project/pull/146740) this patch splits out the libcxx specific parts into a separate test. These are probably best tested with the libcxx-simulator tests. But for now I just moved them. --- Full diff: https://github.com/llvm/llvm-project/pull/147252.diff 5 Files Affected: - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile (+5) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py (+39) - (added) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp (+110) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py (-21) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp (-103) ``diff diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile new file mode 100644 index 0..c5df567e01a2a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py new file mode 100644 index 0..497a495106575 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py @@ -0,0 +1,39 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipUnlessDarwin +@skipIf(archs=no_match(["arm"])) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() + +# The test assumes that std::string is in its cap-size-data layout. +self.expect( +"frame variable garbage1", substrs=["garbage1 = Summary Unavailable"] +) +self.expect( +"frame variable garbage2", substrs=[r'garbage2 = "\xfa\xfa\xfa\xfa"'] +) +self.expect("frame variable garbage3", substrs=[r'garbage3 = "\xf0\xf0"']) +self.expect( +"frame variable garbage4", substrs=["garbage4 = Summary Unavailable"] +) +self.expect( +"frame variable garbage5", substrs=["garbage5 = Summary Unavailable"] +) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp new file mode 100644 index 0..eb3efe1bcb7ef --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +// For more information about libc++'s std::string ABI, see: +// +// https://joellaity.com/2020/01/31/string.html + +// A corrupt string which hits the SSO code path, but has an invalid size. +static struct { +#if _LIBCPP_ABI_VERSION == 1 + // Set the size of this short-mode string to 116. Note that in short mode, + // the size is encoded as `size << 1`. + unsigned char size = 232; + + // 23 garbage bytes for the inline string payload. + char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 +} garbage_string_short_mode; + +// A corrupt libcxx string in long mode with a payload that contains a utf8 +// sequence that's inherently too long. +static unsigned char garbage_utf8_payload1[] = { +250, // This means that we expect a 5-byte sequence, this is invalid. LLDB + // should fall back to ASCII printing. +250, 250, 250}; +static struct { +#if _LIBCPP_ABI_VERSION == 1 + uint64_t cap = 5; + uint64_t size = 4; + uns
[Lldb-commits] [lldb] 912ab52 - [lldb][test] Adjust import-std-module shared_ptr/weak_ptr tests
Author: Michael Buch Date: 2025-07-07T11:22:55+01:00 New Revision: 912ab5241379b4dd525080cd9a3e468d6779340c URL: https://github.com/llvm/llvm-project/commit/912ab5241379b4dd525080cd9a3e468d6779340c DIFF: https://github.com/llvm/llvm-project/commit/912ab5241379b4dd525080cd9a3e468d6779340c.diff LOG: [lldb][test] Adjust import-std-module shared_ptr/weak_ptr tests The formatters for these have been reworked in recent patches. Added: Modified: lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py Removed: diff --git a/lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py index 168c4994b39ba..85755a62018c0 100644 --- a/lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/shared_ptr-dbg-info-content/TestSharedPtrDbgInfoContentFromStdModule.py @@ -23,7 +23,7 @@ def test(self): self.expect_expr( "s", result_type="std::shared_ptr", -result_children=[ValueCheck(name="__ptr_")], +result_children=[ValueCheck(name="pointer")], ) self.expect_expr("s->a", result_type="int", result_value="3") self.expect_expr("s->a = 5", result_type="int", result_value="5") diff --git a/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py index 1704099cfd85a..35d62ae50f6a8 100644 --- a/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py @@ -10,7 +10,7 @@ class TestSharedPtr(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) -@skipIf(compiler="clang", compiler_version=['<', '17.0']) +@skipIf(compiler="clang", compiler_version=["<", "17.0"]) @skipUnlessDarwin def test(self): self.build() @@ -24,8 +24,8 @@ def test(self): self.expect_expr( "s", result_type="std::shared_ptr", -result_summary="3 strong=1 weak=1", -result_children=[ValueCheck(name="__ptr_")], +result_summary="3 strong=1 weak=0", +result_children=[ValueCheck(name="pointer")], ) self.expect_expr("*s", result_type="element_type", result_value="3") self.expect_expr("*s = 5", result_type="element_type", result_value="5") diff --git a/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py index f07b0633d32ad..e95214df3b38c 100644 --- a/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py @@ -10,7 +10,7 @@ class TestDbgInfoContentWeakPtr(TestBase): @add_test_categories(["libc++"]) @skipIf(compiler=no_match("clang")) -@skipIf(compiler="clang", compiler_version=['<', '17.0']) +@skipIf(compiler="clang", compiler_version=["<", "17.0"]) @skipUnlessDarwin def test(self): self.build() @@ -24,7 +24,7 @@ def test(self): self.expect_expr( "w", result_type="std::weak_ptr", -result_children=[ValueCheck(name="__ptr_")], +result_children=[ValueCheck(name="pointer")], ) self.expect_expr("*w.lock()", result_type="element_type") self.expect_expr("w.lock()->a", result_type="int", result_value="3") diff --git a/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py index a9c53548a93c8..0bc0fd466acd5 100644 --- a/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py @@ -10,7 +10,7 @@ class TestShare
[Lldb-commits] [lldb] c19c71b - [lldb][test] Split out libc++ std::string tests that check corrupted strings (#147252)
Author: Michael Buch Date: 2025-07-07T11:33:33+01:00 New Revision: c19c71b90593dcbb94a9592d7cf75e58c99df6da URL: https://github.com/llvm/llvm-project/commit/c19c71b90593dcbb94a9592d7cf75e58c99df6da DIFF: https://github.com/llvm/llvm-project/commit/c19c71b90593dcbb94a9592d7cf75e58c99df6da.diff LOG: [lldb][test] Split out libc++ std::string tests that check corrupted strings (#147252) As a pre-requisite to combine the libcxx and libstdcxx string formatter tests (see https://github.com/llvm/llvm-project/pull/146740) this patch splits out the libcxx specific parts into a separate test. These are probably best tested with the libcxx-simulator tests. But for now I just moved them. Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxInvalidString.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/TestDataFormatterLibcxxString.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/string/main.cpp Removed: diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile new file mode 100644 index 0..c5df567e01a2a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxInvalidString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxInvalidString.py new file mode 100644 index 0..ae8e0ac08c2b0 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxInvalidString.py @@ -0,0 +1,38 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipIf(oslist=[lldbplatformutil.getDarwinOSTriples()], archs=["arm", "aarch64"]) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() + +# The test assumes that std::string is in its cap-size-data layout. +self.expect( +"frame variable garbage1", substrs=["garbage1 = Summary Unavailable"] +) +self.expect( +"frame variable garbage2", substrs=[r'garbage2 = "\xfa\xfa\xfa\xfa"'] +) +self.expect("frame variable garbage3", substrs=[r'garbage3 = "\xf0\xf0"']) +self.expect( +"frame variable garbage4", substrs=["garbage4 = Summary Unavailable"] +) +self.expect( +"frame variable garbage5", substrs=["garbage5 = Summary Unavailable"] +) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp new file mode 100644 index 0..eb3efe1bcb7ef --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +// For more information about libc++'s std::string ABI, see: +// +// https://joellaity.com/2020/01/31/string.html + +// A corrupt string which hits the SSO code path, but has an invalid size. +static struct { +#if _LIBCPP_ABI_VERSION == 1 + // Set the size of this short-mode string to 116. Note that in short mode, + // the size is encoded as `size << 1`. + unsigned char size = 232; + + // 23 garbage bytes for the inline string payload. + char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 +} garbage_string_short_mode; + +// A corrupt libcxx string in long mode with a payload that contains a utf8 +// sequence that's inherently too long. +st
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147252 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147253 >From 1ea1e91899edc945030c02b6e84adedb48d7aa57 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:58:02 +0100 Subject: [PATCH 1/2] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test --- .../{libcxx => generic}/variant/Makefile | 4 +- .../variant/TestDataFormatterStdVariant.py} | 56 -- .../{libstdcpp => generic}/variant/main.cpp | 19 ++-- .../libcxx/variant/main.cpp | 95 .../libstdcpp/variant/Makefile| 5 - .../TestDataFormatterLibStdcxxVariant.py | 101 -- 6 files changed, 32 insertions(+), 248 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/variant/Makefile (82%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/variant/TestDataFormatterLibcxxVariant.py => generic/variant/TestDataFormatterStdVariant.py} (53%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/variant/main.cpp (85%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..d5f5fec8441b5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 + include Makefile.rules 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/generic/variant/TestDataFormatterStdVariant.py similarity index 53% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index 47e07a5ce3f5b..cf2569b02a586 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/generic/variant/TestDataFormatterStdVariant.py @@ -2,53 +2,31 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVariantDataFormatterTestCase(TestBase): -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf( -oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] -) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=["<", "5.1"]) -## std::get is unavailable for std::variant before macOS 10.14 -@skipIf(macos_version=["<", "10.14"]) -def test_with_run_command(self): +class StdVariantDataFormatterTestCase(TestBase): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) -self.runCmd("frame variable has_variant") - -output = self.res.GetOutput() - -## The variable has_variant tells us if the test program -## detected we have a sufficient libc++ version to support variant -## false means we do not and therefore should skip the test -if output.find("(bool) has_variant = false") != -1: -self.skipTest("std::variant not supported") - -lldbutil.continue_to_breakpoint(self.process, bkpt) - -self.expect( -"frame variable v1", -substrs=["v1 = Active Type = int {", "Value = 12", "}"], -) +for name in ["v1", "v1_typedef"]: +self.expect( +"frame variable " + name, +s
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Michael Buch (Michael137) Changes Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks https://github.com/llvm/llvm-project/pull/147253 --- Full diff: https://github.com/llvm/llvm-project/pull/147283.diff 3 Files Affected: - (modified) lldb/examples/synthetic/gnu_libstdcpp.py (+4-9) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py (-5) - (modified) lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp (+1) ``diff diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 20b9488af5597..96b11322db775 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -889,17 +889,12 @@ def VariantSummaryProvider(valobj, dict): if not (index_obj and index_obj.IsValid() and data_obj and data_obj.IsValid()): return "" -def get_variant_npos_value(index_byte_size): -if index_byte_size == 1: -return 0xFF -elif index_byte_size == 2: -return 0x -else: -return 0x +npos = valobj.GetTarget().FindFirstGlobalVariable("std::variant_npos") +if not npos: +return "" -npos_value = get_variant_npos_value(index_obj.GetByteSize()) index = index_obj.GetValueAsUnsigned(0) -if index == npos_value: +if index == npos.GetValueAsUnsigned(0): return " No Value" # Strip references and typedefs. 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 394e221809f7c..c3325c9e73cb9 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 @@ -2,7 +2,6 @@ Test lldb data formatter for LibStdC++ std::variant. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -62,9 +61,6 @@ def test_with_run_command(self): "frame variable v3", substrs=["v3 = Active Type = char {", "Value = 'A'", "}"], ) -""" -TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian -bots. Pending reproduce and investigation. self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"]) @@ -72,7 +68,6 @@ def test_with_run_command(self): "frame variable v_many_types_no_value", substrs=["v_many_types_no_value = No Value"], ) -""" @add_test_categories(["libstdcxx"]) def test_invalid_variant_index(self): diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index 36e0f74f831f8..acb07d5700b8a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,6 +49,7 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; + v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here `` https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
https://github.com/labath commented: Looking up global variables is not completely ideal (can be slow and look up unrelated things). Would index_obj.GetValueAs**Signed**() == -1 work by any chance? https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
https://github.com/asavonic created https://github.com/llvm/llvm-project/pull/147289 Shared modules are stored in a global `ModuleList` cache, and it is intentionally leaked to avoid doing cleanup when lldb exits. However, when lldb is used as a library, we need a way to manage opened modules to avoid problems with file locks (on some systems) for modules that we no longer need. It should be possible to record all loaded modules and use `ModuleList::RemoveSharedModule` and `RemoveOrphanSharedModules` functions to clear the cache, but these functions are not available in the API. This approach is also way too complicated when we just need to cleanup the library. The patch adds the following: - `ModuleList::ClearSharedModules` function to clear all shared modules. - `SBDebugger::SetClearSharedModules(bool)` API to enable clearing during `SBDebugger::Clear()`. - `settings set clear-shared-modules true` command line option that is equivalent to `SetClearSharedModules(true)`. This new behaviour is turned off by default: the debugger does not release these shared modules until the process exits. >From 0737ec086d765dc59c01750de924891af6de77b2 Mon Sep 17 00:00:00 2001 From: Andrew Savonichev Date: Mon, 7 Jul 2025 17:33:50 +0900 Subject: [PATCH] [lldb] Clear ModuleList shared modules in SBDebugger::Clear Shared modules are stored in a global ModuleList cache, and it is intentionally leaked to avoid doing cleanup when lldb exits. However, when lldb is used as a library, we need a way to manage opened modules to avoid problems with file locks (on some systems) for modules that we no longer need. It should be possible to record all loaded modules and use ModuleList::RemoveSharedModule and RemoveOrphanSharedModules functions to clear the cache, but these functions are not available in the API. This approach is also way too complicated when we just need to cleanup the library. The patch adds the following: - ModuleList::ClearSharedModules function to clear all shared modules. - SBDebugger::SetClearSharedModules(bool) API to enable clearing during SBDebugger::Clear(). - `settings set clear-shared-modules true` command line option that is equivalent to SetClearSharedModules(true). This new behaviour is turned off by default: the debugger does not release these shared modules until the process exits. --- lldb/include/lldb/API/SBDebugger.h| 2 + lldb/include/lldb/Core/Debugger.h | 4 + lldb/include/lldb/Core/ModuleList.h | 3 + lldb/source/API/SBDebugger.cpp| 6 + lldb/source/Core/CoreProperties.td| 4 + lldb/source/Core/Debugger.cpp | 13 ++ lldb/source/Core/ModuleList.cpp | 7 + .../python_api/debugger/TestDebuggerAPI.py| 31 +++ lldb/unittests/Target/CMakeLists.txt | 1 + .../unittests/Target/SharedModuleListTest.cpp | 209 ++ 10 files changed, 280 insertions(+) create mode 100644 lldb/unittests/Target/SharedModuleListTest.cpp diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 192fbee9c0c6d..6a2f76f2d5685 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -319,6 +319,8 @@ class LLDB_API SBDebugger { bool SetShowInlineDiagnostics(bool); + bool SetClearSharedModules(bool); + bool SetUseSourceCache(bool use_source_cache); bool GetUseSourceCache() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 504f936fe317a..4cf7fc75bafd4 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -373,6 +373,10 @@ class Debugger : public std::enable_shared_from_this, bool SetShowInlineDiagnostics(bool); + bool GetClearSharedModules() const; + + bool SetClearSharedModules(bool); + bool LoadPlugin(const FileSpec &spec, Status &error); void RunIOHandlers(); diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..587843dd05a4d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -482,6 +482,9 @@ class ModuleList { static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); + /// Empty global cache of modules to release memory, file locks, etc. + static void ClearSharedModules(); + /// Applies 'callback' to each module in this ModuleList. /// If 'callback' returns false, iteration terminates. /// The 'module_sp' passed to 'callback' is guaranteed to diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 603e306497841..221c02cfe66ed 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1466,6 +1466,12 @@ bool SBDebugger::SetShowInlineDiagnostics(bool value) { return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false); } +bool SBDebugger::SetClearSharedModules(bool va
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Andrew Savonichev (asavonic) Changes Shared modules are stored in a global `ModuleList` cache, and it is intentionally leaked to avoid doing cleanup when lldb exits. However, when lldb is used as a library, we need a way to manage opened modules to avoid problems with file locks (on some systems) for modules that we no longer need. It should be possible to record all loaded modules and use `ModuleList::RemoveSharedModule` and `RemoveOrphanSharedModules` functions to clear the cache, but these functions are not available in the API. This approach is also way too complicated when we just need to cleanup the library. The patch adds the following: - `ModuleList::ClearSharedModules` function to clear all shared modules. - `SBDebugger::SetClearSharedModules(bool)` API to enable clearing during `SBDebugger::Clear()`. - `settings set clear-shared-modules true` command line option that is equivalent to `SetClearSharedModules(true)`. This new behaviour is turned off by default: the debugger does not release these shared modules until the process exits. --- Full diff: https://github.com/llvm/llvm-project/pull/147289.diff 10 Files Affected: - (modified) lldb/include/lldb/API/SBDebugger.h (+2) - (modified) lldb/include/lldb/Core/Debugger.h (+4) - (modified) lldb/include/lldb/Core/ModuleList.h (+3) - (modified) lldb/source/API/SBDebugger.cpp (+6) - (modified) lldb/source/Core/CoreProperties.td (+4) - (modified) lldb/source/Core/Debugger.cpp (+13) - (modified) lldb/source/Core/ModuleList.cpp (+7) - (modified) lldb/test/API/python_api/debugger/TestDebuggerAPI.py (+31) - (modified) lldb/unittests/Target/CMakeLists.txt (+1) - (added) lldb/unittests/Target/SharedModuleListTest.cpp (+209) ``diff diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 192fbee9c0c6d..6a2f76f2d5685 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -319,6 +319,8 @@ class LLDB_API SBDebugger { bool SetShowInlineDiagnostics(bool); + bool SetClearSharedModules(bool); + bool SetUseSourceCache(bool use_source_cache); bool GetUseSourceCache() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 504f936fe317a..4cf7fc75bafd4 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -373,6 +373,10 @@ class Debugger : public std::enable_shared_from_this, bool SetShowInlineDiagnostics(bool); + bool GetClearSharedModules() const; + + bool SetClearSharedModules(bool); + bool LoadPlugin(const FileSpec &spec, Status &error); void RunIOHandlers(); diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..587843dd05a4d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -482,6 +482,9 @@ class ModuleList { static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); + /// Empty global cache of modules to release memory, file locks, etc. + static void ClearSharedModules(); + /// Applies 'callback' to each module in this ModuleList. /// If 'callback' returns false, iteration terminates. /// The 'module_sp' passed to 'callback' is guaranteed to diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 603e306497841..221c02cfe66ed 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1466,6 +1466,12 @@ bool SBDebugger::SetShowInlineDiagnostics(bool value) { return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false); } +bool SBDebugger::SetClearSharedModules(bool value) { + LLDB_INSTRUMENT_VA(this, value); + + return (m_opaque_sp ? m_opaque_sp->SetClearSharedModules(value) : false); +} + bool SBDebugger::SetUseSourceCache(bool value) { LLDB_INSTRUMENT_VA(this, value); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 53dd333f045c9..1a6ba1a9af84e 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -268,4 +268,8 @@ let Definition = "debugger" in { Global, DefaultFalse, Desc<"Controls whether diagnostics can refer directly to the command input, drawing arrows to it. If false, diagnostics will echo the input.">; + def ClearSharedModules: Property<"clear-shared-modules", "Boolean">, +Global, +DefaultFalse, +Desc<"Controls whether the debugger clears internal shared modules as it exits.">; } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index ed674ee1275c7..fbd2f37960e19 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -700,6 +700,17 @@ bool Debugger::SetShowInlineDiagnostics(bool b) { return SetPropertyAtIndex(idx, b); } +bool Debugger::GetClearSharedModules() const { + const uint32_t idx = ePropertyClearSha
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
asavonic wrote: > Python code formatter, darker found issues in your code. Fixed. https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
github-actions[bot] wrote: :warning: Python code formatter, darker found issues in your code. :warning: You can test this locally with the following command: ``bash darker --check --diff -r HEAD~1...HEAD lldb/test/API/python_api/debugger/TestDebuggerAPI.py `` View the diff from darker here. ``diff --- TestDebuggerAPI.py 2025-07-07 12:26:13.00 + +++ TestDebuggerAPI.py 2025-07-07 12:41:42.657880 + @@ -304,12 +304,11 @@ self.runCmd("log enable lldb module") self.dbg.Destroy(self.dbg) self.assertFalse(any("cleared shared modules cache" in msg for msg in messages)) def test_enable_SetClearSharedModules(self): -"""Check that SetClearSharedModule(true) clears shared module cache. -""" +"""Check that SetClearSharedModule(true) clears shared module cache.""" messages = list() self.dbg.SetLoggingCallback(messages.append) self.dbg.SetClearSharedModules(True) self.runCmd("log enable lldb module") self.dbg.Destroy(self.dbg) `` https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
https://github.com/asavonic updated https://github.com/llvm/llvm-project/pull/147289 >From a01eb1943afb03d1dc9439e9ae8f3a01b8c15398 Mon Sep 17 00:00:00 2001 From: Andrew Savonichev Date: Mon, 7 Jul 2025 17:33:50 +0900 Subject: [PATCH] [lldb] Clear ModuleList shared modules in SBDebugger::Clear Shared modules are stored in a global ModuleList cache, and it is intentionally leaked to avoid doing cleanup when lldb exits. However, when lldb is used as a library, we need a way to manage opened modules to avoid problems with file locks (on some systems) for modules that we no longer need. It should be possible to record all loaded modules and use ModuleList::RemoveSharedModule and RemoveOrphanSharedModules functions to clear the cache, but these functions are not available in the API. This approach is also way too complicated when we just need to cleanup the library. The patch adds the following: - ModuleList::ClearSharedModules function to clear all shared modules. - SBDebugger::SetClearSharedModules(bool) API to enable clearing during SBDebugger::Clear(). - `settings set clear-shared-modules true` command line option that is equivalent to SetClearSharedModules(true). This new behaviour is turned off by default: the debugger does not release these shared modules until the process exits. --- lldb/include/lldb/API/SBDebugger.h| 2 + lldb/include/lldb/Core/Debugger.h | 4 + lldb/include/lldb/Core/ModuleList.h | 3 + lldb/source/API/SBDebugger.cpp| 6 + lldb/source/Core/CoreProperties.td| 4 + lldb/source/Core/Debugger.cpp | 13 ++ lldb/source/Core/ModuleList.cpp | 7 + .../python_api/debugger/TestDebuggerAPI.py| 30 +++ lldb/unittests/Target/CMakeLists.txt | 1 + .../unittests/Target/SharedModuleListTest.cpp | 209 ++ 10 files changed, 279 insertions(+) create mode 100644 lldb/unittests/Target/SharedModuleListTest.cpp diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 192fbee9c0c6d..6a2f76f2d5685 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -319,6 +319,8 @@ class LLDB_API SBDebugger { bool SetShowInlineDiagnostics(bool); + bool SetClearSharedModules(bool); + bool SetUseSourceCache(bool use_source_cache); bool GetUseSourceCache() const; diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index 504f936fe317a..4cf7fc75bafd4 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -373,6 +373,10 @@ class Debugger : public std::enable_shared_from_this, bool SetShowInlineDiagnostics(bool); + bool GetClearSharedModules() const; + + bool SetClearSharedModules(bool); + bool LoadPlugin(const FileSpec &spec, Status &error); void RunIOHandlers(); diff --git a/lldb/include/lldb/Core/ModuleList.h b/lldb/include/lldb/Core/ModuleList.h index 909ee08f9ba62..587843dd05a4d 100644 --- a/lldb/include/lldb/Core/ModuleList.h +++ b/lldb/include/lldb/Core/ModuleList.h @@ -482,6 +482,9 @@ class ModuleList { static bool RemoveSharedModuleIfOrphaned(const Module *module_ptr); + /// Empty global cache of modules to release memory, file locks, etc. + static void ClearSharedModules(); + /// Applies 'callback' to each module in this ModuleList. /// If 'callback' returns false, iteration terminates. /// The 'module_sp' passed to 'callback' is guaranteed to diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 603e306497841..221c02cfe66ed 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1466,6 +1466,12 @@ bool SBDebugger::SetShowInlineDiagnostics(bool value) { return (m_opaque_sp ? m_opaque_sp->SetShowInlineDiagnostics(value) : false); } +bool SBDebugger::SetClearSharedModules(bool value) { + LLDB_INSTRUMENT_VA(this, value); + + return (m_opaque_sp ? m_opaque_sp->SetClearSharedModules(value) : false); +} + bool SBDebugger::SetUseSourceCache(bool value) { LLDB_INSTRUMENT_VA(this, value); diff --git a/lldb/source/Core/CoreProperties.td b/lldb/source/Core/CoreProperties.td index 53dd333f045c9..1a6ba1a9af84e 100644 --- a/lldb/source/Core/CoreProperties.td +++ b/lldb/source/Core/CoreProperties.td @@ -268,4 +268,8 @@ let Definition = "debugger" in { Global, DefaultFalse, Desc<"Controls whether diagnostics can refer directly to the command input, drawing arrows to it. If false, diagnostics will echo the input.">; + def ClearSharedModules: Property<"clear-shared-modules", "Boolean">, +Global, +DefaultFalse, +Desc<"Controls whether the debugger clears internal shared modules as it exits.">; } diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index ed674ee1275c7..fbd2f37960e19 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147283 >From be3eb2431b0649ce2730a4cf832dc474e262f49e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 12:40:37 +0100 Subject: [PATCH 1/3] [lldb][test] Fix libstdc++ std::variant formatter for empty variant Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks https://github.com/llvm/llvm-project/pull/147253 --- lldb/examples/synthetic/gnu_libstdcpp.py| 13 - .../variant/TestDataFormatterLibStdcxxVariant.py| 5 - .../data-formatter-stl/libstdcpp/variant/main.cpp | 1 + 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 20b9488af5597..96b11322db775 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -889,17 +889,12 @@ def VariantSummaryProvider(valobj, dict): if not (index_obj and index_obj.IsValid() and data_obj and data_obj.IsValid()): return "" -def get_variant_npos_value(index_byte_size): -if index_byte_size == 1: -return 0xFF -elif index_byte_size == 2: -return 0x -else: -return 0x +npos = valobj.GetTarget().FindFirstGlobalVariable("std::variant_npos") +if not npos: +return "" -npos_value = get_variant_npos_value(index_obj.GetByteSize()) index = index_obj.GetValueAsUnsigned(0) -if index == npos_value: +if index == npos.GetValueAsUnsigned(0): return " No Value" # Strip references and typedefs. 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 394e221809f7c..c3325c9e73cb9 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 @@ -2,7 +2,6 @@ Test lldb data formatter for LibStdC++ std::variant. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -62,9 +61,6 @@ def test_with_run_command(self): "frame variable v3", substrs=["v3 = Active Type = char {", "Value = 'A'", "}"], ) -""" -TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian -bots. Pending reproduce and investigation. self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"]) @@ -72,7 +68,6 @@ def test_with_run_command(self): "frame variable v_many_types_no_value", substrs=["v_many_types_no_value = No Value"], ) -""" @add_test_categories(["libstdcxx"]) def test_invalid_variant_index(self): diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index 36e0f74f831f8..acb07d5700b8a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,6 +49,7 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; + v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here >From 59518c7f14a6beeb29ebdc8b33eeede9176418b3 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 12:47:28 +0100 Subject: [PATCH 2/3] fixup! revert redundant test change --- .../data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index acb07d5700b8a..36e0f74f831f8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,7 +49,6 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; - v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here >From 788661c1c945b6a2b5190812a1b232f335096388 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 13:52:44 +0100 Subject: [PATCH 3/3] fixup! fix test; revert changes to formatter --- lldb/examples/synthetic/gnu_libstdcpp.py | 13 +++--- .../TestDataFormatterLibStdcxxVariant.py | 6 ++--- .../l
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -2258,6 +2258,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { unsigned NumExpansions; }; + enum class PredefinedSugarKind { +/// The "size_t" type. +SizeT, + +/// The signed integer type corresponding to "size_t". YexuanXiao wrote: @frederick-vs-ja [mentioned in the comment above](https://github.com/llvm/llvm-project/pull/143653#discussion_r2141546366) that POSIX does not require the `typedef` `ssize_t` to be the `signed` version of `size_t`. At the same time, the C and C++ standards also do not require the `typedef` `ptrdiff_t` to be the `signed` version of `size_t`. I am not sure whether there actually exist platforms with such inconsistencies, but perhaps it should not be confused? https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter tests for valueless variants (PR #147283)
https://github.com/labath approved this pull request. Cool. Thanks for looking into this. https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 9ebe6f9 - [lldb][test] Fix libstdc++ std::variant formatter tests for valueless variants (#147283)
Author: Michael Buch Date: 2025-07-07T14:28:19+01:00 New Revision: 9ebe6f9a1f9e3473166cd57282c9827df12416a3 URL: https://github.com/llvm/llvm-project/commit/9ebe6f9a1f9e3473166cd57282c9827df12416a3 DIFF: https://github.com/llvm/llvm-project/commit/9ebe6f9a1f9e3473166cd57282c9827df12416a3.diff LOG: [lldb][test] Fix libstdc++ std::variant formatter tests for valueless variants (#147283) A default-constructed variant has a valid index (being the first element of the variant). The only case where the index is variant_npos is when the variant is "valueless", which [according to cppreference](https://en.cppreference.com/w/cpp/utility/variant/valueless_by_exception.html) only happens when an exception is thrown during assignment to the variant. I adjusted the test to test that scenario, and the formatter seems to work. Unblocks https://github.com/llvm/llvm-project/pull/147253 Added: Modified: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp Removed: 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 394e221809f7c..dae9b24fbbcfe 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 @@ -2,7 +2,6 @@ Test lldb data formatter for LibStdC++ std::variant. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -62,17 +61,13 @@ def test_with_run_command(self): "frame variable v3", substrs=["v3 = Active Type = char {", "Value = 'A'", "}"], ) -""" -TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian -bots. Pending reproduce and investigation. -self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"]) +self.expect("frame variable v_valueless", substrs=["v_valueless = No Value"]) self.expect( -"frame variable v_many_types_no_value", -substrs=["v_many_types_no_value = No Value"], +"frame variable v_many_types_valueless", +substrs=["v_many_types_valueless = No Value"], ) -""" @add_test_categories(["libstdcxx"]) def test_invalid_variant_index(self): diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index 36e0f74f831f8..235928264add1 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -4,7 +4,9 @@ #include struct S { - operator int() { throw 42; } + S() = default; + S(S &&) { throw 42; } + S &operator=(S &&) = default; }; int main() { @@ -21,7 +23,7 @@ int main() { std::variant v2; std::variant v3; std::variant> v_v1; - std::variant v_no_value; + std::variant v_valueless = 5; // The next variant has many types, meaning the type index does not fit in // a byte and must be `unsigned short` instead of `unsigned char` when // using the unstable libc++ ABI. With stable libc++ ABI, the type index @@ -43,8 +45,11 @@ int main() { int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, int, - int, int, int, int, int, int, int, int, int, int, int, int> - v_many_types_no_value; + int, int, int, int, int, int, int, int, int, int, int, int, S> + v_many_types_valueless; + + v_valueless = 5; + v_many_types_valueless.emplace<0>(10); v1 = 12; // v contains int v1_typedef = v1; @@ -67,18 +72,22 @@ int main() { printf("%f\n", d); // break here try { -v_no_value.emplace<0>(S()); +// Exception in type-changing move-assignment is guaranteed to put +// std::variant into a valueless state. +v_valueless = S(); } catch (...) { } - printf("%zu\n", v_no_value.index()); + printf("%d\n", v_valueless.valueless_by_exception()); try { -v_many_types_no_value.emplace<0>(S()); +// Exception in move-assignment is guaranteed to put std::variant into a +// valueless state. +v_many_types_valueless = S(); } catch (...)
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter tests for valueless variants (PR #147283)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147283 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (PR #147141)
labath wrote: There are two failures: - the libc++ pointer child is called `__ptr_`, not `pointer`. I think we should clone/rename the child so that the child has a consistent name. This could be particularly useful for writing other data formatters, which may want to dereference a shared_ptr without caring which stdlib implementation they are using. - the libstdc++ child type is `std::goo<...>::type` instead of `int` in libc++. I think the libc++ implementation is better. The case for unification is slightly weaker here (people can always resolve the typedef manually), though I'd still do it if its easy enough. https://github.com/llvm/llvm-project/pull/147141 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147252 >From 81f856c7c851d5b03ddd176977e7d0c55e7c7f6f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:47:39 +0100 Subject: [PATCH 1/3] [lldb][test] Split out libc++ std::string tests that check corrupted strings --- .../libcxx/invalid-string/Makefile| 5 + .../TestDataFormatterLibcxxString.py | 39 +++ .../libcxx/invalid-string/main.cpp| 110 ++ .../string/TestDataFormatterLibcxxString.py | 21 .../data-formatter-stl/libcxx/string/main.cpp | 103 5 files changed, 154 insertions(+), 124 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile new file mode 100644 index 0..c5df567e01a2a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py new file mode 100644 index 0..497a495106575 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py @@ -0,0 +1,39 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipUnlessDarwin +@skipIf(archs=no_match(["arm"])) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() + +# The test assumes that std::string is in its cap-size-data layout. +self.expect( +"frame variable garbage1", substrs=["garbage1 = Summary Unavailable"] +) +self.expect( +"frame variable garbage2", substrs=[r'garbage2 = "\xfa\xfa\xfa\xfa"'] +) +self.expect("frame variable garbage3", substrs=[r'garbage3 = "\xf0\xf0"']) +self.expect( +"frame variable garbage4", substrs=["garbage4 = Summary Unavailable"] +) +self.expect( +"frame variable garbage5", substrs=["garbage5 = Summary Unavailable"] +) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp new file mode 100644 index 0..eb3efe1bcb7ef --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +// For more information about libc++'s std::string ABI, see: +// +// https://joellaity.com/2020/01/31/string.html + +// A corrupt string which hits the SSO code path, but has an invalid size. +static struct { +#if _LIBCPP_ABI_VERSION == 1 + // Set the size of this short-mode string to 116. Note that in short mode, + // the size is encoded as `size << 1`. + unsigned char size = 232; + + // 23 garbage bytes for the inline string payload. + char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 +} garbage_string_short_mode; + +// A corrupt libcxx string in long mode with a payload that contains a utf8 +// sequence that's inherently too long. +static unsigned char garbage_utf8_payload1[] = { +250, // This means that we expect a 5-byte sequence, this is invalid. LLDB + // should fall back to ASCII printing. +250, 250, 250}; +static struct { +#if _LIBCPP_ABI_VERSION == 1 + uint64_t cap = 5; + uint64_t size = 4; + unsigned char *data = &garbage_utf8_payload1[0];
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147252 >From 81f856c7c851d5b03ddd176977e7d0c55e7c7f6f Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:47:39 +0100 Subject: [PATCH 1/2] [lldb][test] Split out libc++ std::string tests that check corrupted strings --- .../libcxx/invalid-string/Makefile| 5 + .../TestDataFormatterLibcxxString.py | 39 +++ .../libcxx/invalid-string/main.cpp| 110 ++ .../string/TestDataFormatterLibcxxString.py | 21 .../data-formatter-stl/libcxx/string/main.cpp | 103 5 files changed, 154 insertions(+), 124 deletions(-) create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py create mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile new file mode 100644 index 0..c5df567e01a2a --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/Makefile @@ -0,0 +1,5 @@ +CXX_SOURCES := main.cpp + +USE_LIBCPP := 1 + +include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py new file mode 100644 index 0..497a495106575 --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/TestDataFormatterLibcxxString.py @@ -0,0 +1,39 @@ +""" +Test lldb behaves sanely when formatting corrupted `std::string`s. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class LibcxxInvalidStringDataFormatterTestCase(TestBase): +@add_test_categories(["libc++"]) +@skipUnlessDarwin +@skipIf(archs=no_match(["arm"])) +def test(self): +self.build() + +(target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( +self, "Set break point at this line.", lldb.SBFileSpec("main.cpp") +) +frame = thread.frames[0] + +if not self.process().GetAddressByteSize() == 8: +self.skip() + +# The test assumes that std::string is in its cap-size-data layout. +self.expect( +"frame variable garbage1", substrs=["garbage1 = Summary Unavailable"] +) +self.expect( +"frame variable garbage2", substrs=[r'garbage2 = "\xfa\xfa\xfa\xfa"'] +) +self.expect("frame variable garbage3", substrs=[r'garbage3 = "\xf0\xf0"']) +self.expect( +"frame variable garbage4", substrs=["garbage4 = Summary Unavailable"] +) +self.expect( +"frame variable garbage5", substrs=["garbage5 = Summary Unavailable"] +) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp new file mode 100644 index 0..eb3efe1bcb7ef --- /dev/null +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/invalid-string/main.cpp @@ -0,0 +1,110 @@ +#include +#include +#include +#include + +// For more information about libc++'s std::string ABI, see: +// +// https://joellaity.com/2020/01/31/string.html + +// A corrupt string which hits the SSO code path, but has an invalid size. +static struct { +#if _LIBCPP_ABI_VERSION == 1 + // Set the size of this short-mode string to 116. Note that in short mode, + // the size is encoded as `size << 1`. + unsigned char size = 232; + + // 23 garbage bytes for the inline string payload. + char inline_buf[23] = {0}; +#else // _LIBCPP_ABI_VERSION == 1 + // Like above, but data comes first, and use bitfields to indicate size. + char inline_buf[23] = {0}; + unsigned char size : 7 = 116; + unsigned char is_long : 1 = 0; +#endif // #if _LIBCPP_ABI_VERSION == 1 +} garbage_string_short_mode; + +// A corrupt libcxx string in long mode with a payload that contains a utf8 +// sequence that's inherently too long. +static unsigned char garbage_utf8_payload1[] = { +250, // This means that we expect a 5-byte sequence, this is invalid. LLDB + // should fall back to ASCII printing. +250, 250, 250}; +static struct { +#if _LIBCPP_ABI_VERSION == 1 + uint64_t cap = 5; + uint64_t size = 4; + unsigned char *data = &garbage_utf8_payload1[0];
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -320,6 +320,92 @@ bool clang::analyze_format_string::ParseUTF8InvalidSpecifier( // Methods on ArgType. //===--===// +static bool namedTypeToLengthModifierKind(ASTContext &Ctx, QualType QT, + LengthModifier::Kind &K) { + for (/**/; const auto *TT = QT->getAs(); + QT = TT->getDecl()->getUnderlyingType()) { erichkeane wrote: Is this not just `desguar`? ```suggestion QT = TT->desugar()) { ``` https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Add shared/weak count to libstdc++ std::shared_ptr summary (PR #147166)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147166 >From f9be1d811b66b050a79f83c16c7b404948c37505 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sat, 5 Jul 2025 12:42:39 +0100 Subject: [PATCH 1/4] [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 39 +++ .../Plugins/Language/CPlusPlus/LibCxx.h | 1 + .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 27 +++-- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 104521b8c3e71..aa13e66a1b550 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -238,7 +238,8 @@ lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator( lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr) { +: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr), + m_ptr_obj(nullptr) { if (valobj_sp) Update(); } @@ -251,7 +252,7 @@ llvm::Expected lldb_private::formatters:: lldb::ValueObjectSP lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { - if (!m_cntrl) + if (!m_cntrl || !m_ptr_obj) return lldb::ValueObjectSP(); ValueObjectSP valobj_sp = m_backend.GetSP(); @@ -259,20 +260,17 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); if (idx == 0) -return valobj_sp->GetChildMemberWithName("__ptr_"); +return m_ptr_obj->GetSP(); if (idx == 1) { -if (auto ptr_sp = valobj_sp->GetChildMemberWithName("__ptr_")) { - Status status; - auto value_type_sp = -valobj_sp->GetCompilerType() - .GetTypeTemplateArgument(0).GetPointerType(); - ValueObjectSP cast_ptr_sp = ptr_sp->Cast(value_type_sp); - ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); - if (status.Success()) { -return value_sp; - } -} +Status status; +auto value_type_sp = valobj_sp->GetCompilerType() + .GetTypeTemplateArgument(0) + .GetPointerType(); +ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp); +ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); +if (status.Success()) + return value_sp; } return lldb::ValueObjectSP(); @@ -281,6 +279,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( lldb::ChildCacheState lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { m_cntrl = nullptr; + m_ptr_obj = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -290,6 +289,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { if (!target_sp) return lldb::ChildCacheState::eRefetch; + auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("__ptr_"); + if (!ptr_obj_sp) +return lldb::ChildCacheState::eRefetch; + + m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get(); + lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_")); m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular @@ -300,10 +305,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { llvm::Expected lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { - if (name == "__ptr_") + if (name == "__ptr_" || name == "pointer") return 0; - if (name == "$$dereference$$") + + if (name == "object" || name == "$$dereference$$") return 1; + return llvm::createStringError("Type has no child named '%s'", name.AsCString()); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index 56501302d116f..6115ccde38ad2 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -108,6 +108,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { private: ValueObject *m_cntrl; + ValueObject *m_ptr_obj; }; class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 28b7c01ab1b5b..7668a87ce447e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -77,8 +77,7 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { // objects are only destroyed when every shared pointer t
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
https://github.com/erichkeane commented: I'm a little concerned about the semi-canonical nature of this type, requiring the separate 'getCanonicalSizeType' esque functions, which should just be either stored as a CanQualType or compared properly. That said, for hte most part I like this change. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
https://github.com/erichkeane edited https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -2258,6 +2258,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { unsigned NumExpansions; }; + enum class PredefinedSugarKind { +/// The "size_t" type. +SizeT, + +/// The signed integer type corresponding to "size_t". erichkeane wrote: ```suggestion /// The signed integer type corresponding to "ssize_t". ``` https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -1002,14 +1002,14 @@ RValue CodeGenFunction::EmitCoroutineIntrinsic(const CallExpr *E, } case llvm::Intrinsic::coro_size: { auto &Context = getContext(); -CanQualType SizeTy = Context.getSizeType(); +CanQualType SizeTy = Context.getCanonicalSizeType(); erichkeane wrote: A little curious why these are necessary here? Doesnt `CanQualType` typically do a `getCanonicalType` on the thing it is assigned? https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -7248,6 +7248,12 @@ QualType TreeTransform::TransformDependentBitIntType( return Result; } +template +QualType TreeTransform::TransformPredefinedSugarType( +TypeLocBuilder &TLB, PredefinedSugarTypeLoc TL) { + llvm_unreachable("This type does not need to be transformed."); erichkeane wrote: At that point, shouldn't it just return itself? We could still end up here... https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -696,11 +696,17 @@ void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) { void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { addSourceLocation(TL.getNameLoc()); } + erichkeane wrote: Another unrelated change. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -2595,8 +2595,12 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const { Align = static_cast(Width); } } + erichkeane wrote: Unrelated change? https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -721,7 +721,8 @@ static bool matchesStlAllocatorFn(const Decl *D, const ASTContext &Ctx) { (MD->getNumParams() != 1 && MD->getNumParams() != 2)) return false; - if (MD->parameters()[0]->getType().getCanonicalType() != Ctx.getSizeType()) + if (MD->parameters()[0]->getType().getCanonicalType() != erichkeane wrote: This should probably just use `Ctsx.hasSameType` isntead of the canonicalizations. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -5613,3 +5613,16 @@ HLSLAttributedResourceType::findHandleTypeOnResource(const Type *RT) { } return nullptr; } + +StringRef PredefinedSugarType::getName(Kind KD) { + switch (KD) { + case Kind::SizeT: +return "__size_t"; + case Kind::SignedSizeT: +return "__signed_size_t"; + case Kind::PtrdiffT: +return "__ptrdiff_t"; + case Kind::NumElements:; erichkeane wrote: ```suggestion case Kind::NumElements: break; ``` https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -320,6 +320,92 @@ bool clang::analyze_format_string::ParseUTF8InvalidSpecifier( // Methods on ArgType. //===--===// +static bool namedTypeToLengthModifierKind(ASTContext &Ctx, QualType QT, + LengthModifier::Kind &K) { + for (/**/; const auto *TT = QT->getAs(); + QT = TT->getDecl()->getUnderlyingType()) { +const auto *TD = TT->getDecl(); +const auto *DC = TT->getDecl()->getDeclContext(); +bool RC = false; +if (Ctx.getLangOpts().C99) { + RC = DC->isTranslationUnit(); erichkeane wrote: What about pre-C99? Does ObjC not have these? If we're not going to do these, we should do an early exit (`if )!C99 && !CPlusPlus) return false;`) at the top of the TU and remove these two branches, and just use the `RC` assignment from 333. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -2258,6 +2258,30 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase { unsigned NumExpansions; }; + enum class PredefinedSugarKind { +/// The "size_t" type. +SizeT, + +/// The signed integer type corresponding to "size_t". +SignedSizeT, + +/// The "ptrdiff_t" type. +PtrdiffT, + +// Indicates how many items the enum has. +NumElements erichkeane wrote: Shouldn't this be `NumElements = PtrdiffT`? Typically we do something like `Last = ` kinda thing in our enums, so this is a little odd/awkward. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Use container summary helper for libstdc++ formatters (PR #147140)
https://github.com/labath approved this pull request. I see we already have some C++ stuff in this file, but given that there really isn't anything specific in this function, maybe we could also drop the Cxx part from the name (maybe call it `ContainerSizeSummaryProvider `)? https://github.com/llvm/llvm-project/pull/147140 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update the String table offset based on the DWARF format (PR #147054)
HemangGadhavi wrote: > This is the relevant part of the standard, correct? Yes exactly that's what I am referring too. > I see also "7.4 32-Bit and 64-Bit DWARF Formats", is there anything else in > there we need to handle? I see there is one form `DW_FORM_strp_sup` which is not at all added in `LLDB` code but `LLVM` handles it, I am trying to generate the same, if so I can add this FORM as well. https://github.com/llvm/llvm-project/pull/147054 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ tuple tests into generic test (PR #147139)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147139 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6fec6a9 - [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other (#147165)
Author: Michael Buch Date: 2025-07-07T09:13:52+01:00 New Revision: 6fec6a98c01523a5478ce2aa9617e884dc772f6f URL: https://github.com/llvm/llvm-project/commit/6fec6a98c01523a5478ce2aa9617e884dc772f6f DIFF: https://github.com/llvm/llvm-project/commit/6fec6a98c01523a5478ce2aa9617e884dc772f6f.diff LOG: [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other (#147165) This patch adjusts the libcxx and libstdcxx std::shared_ptr formatters to look the same. Changes to libcxx: * Now creates a synthetic child called `pointer` (like we already do for `std::unique_ptr`) Changes to libstdcxx: * When asked to dereference the pointer, cast the type of the result ValueObject to the element type (which we get from the template argument to std::shared_ptr). Before: ``` (std::__shared_ptr::element_type) *foo = 123 ``` After: ``` (int) *foo = 123 ``` Tested in https://github.com/llvm/llvm-project/pull/147141 Added: Modified: lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py Removed: diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 9ee4e2ab0490e..7ecb484e35474 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -238,7 +238,8 @@ lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator( lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr) { +: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr), + m_ptr_obj(nullptr) { if (valobj_sp) Update(); } @@ -251,7 +252,7 @@ llvm::Expected lldb_private::formatters:: lldb::ValueObjectSP lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { - if (!m_cntrl) + if (!m_cntrl || !m_ptr_obj) return lldb::ValueObjectSP(); ValueObjectSP valobj_sp = m_backend.GetSP(); @@ -259,20 +260,17 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); if (idx == 0) -return valobj_sp->GetChildMemberWithName("__ptr_"); +return m_ptr_obj->GetSP(); if (idx == 1) { -if (auto ptr_sp = valobj_sp->GetChildMemberWithName("__ptr_")) { - Status status; - auto value_type_sp = -valobj_sp->GetCompilerType() - .GetTypeTemplateArgument(0).GetPointerType(); - ValueObjectSP cast_ptr_sp = ptr_sp->Cast(value_type_sp); - ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); - if (status.Success()) { -return value_sp; - } -} +Status status; +auto value_type_sp = valobj_sp->GetCompilerType() + .GetTypeTemplateArgument(0) + .GetPointerType(); +ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp); +ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); +if (status.Success()) + return value_sp; } return lldb::ValueObjectSP(); @@ -281,6 +279,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( lldb::ChildCacheState lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { m_cntrl = nullptr; + m_ptr_obj = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -290,6 +289,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { if (!target_sp) return lldb::ChildCacheState::eRefetch; + auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("__ptr_"); + if (!ptr_obj_sp) +return lldb::ChildCacheState::eRefetch; + + m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get(); + lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_")); m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular @@ -300,10 +305,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { llvm::Expected lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { - if (name == "__ptr_") + if (name == "__ptr_" || name == "pointer") return 0; - if (name == "$$dereference$$") + + if (name == "object" || name == "$$dereference$$") return 1; + return llvm::createStringError("Type has no child named '%s'", name.AsCString()); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index 0c1f120ea708a..d88a6ecb1fa89 100644 --- a/lldb/so
[Lldb-commits] [lldb] 49d7c53 - [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (#147174)
Author: Michael Buch Date: 2025-07-07T09:14:10+01:00 New Revision: 49d7c53756bc6e06bb6ae160bef5f944f18dfa2f URL: https://github.com/llvm/llvm-project/commit/49d7c53756bc6e06bb6ae160bef5f944f18dfa2f DIFF: https://github.com/llvm/llvm-project/commit/49d7c53756bc6e06bb6ae160bef5f944f18dfa2f.diff LOG: [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (#147174) This combines the libc++ and libstdc++ test cases. The libstdcpp tests were a subset of the libc++ test, so this patch moves the libcxx test into generic and removes the libstdcpp test entirely. Split out from https://github.com/llvm/llvm-project/pull/146740 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp Modified: lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 327ab3ab9edd5..06412e34eb777 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1525,8 +1525,8 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { AddCXXSynthetic( cpp_category_sp, lldb_private::formatters::LibstdcppMapIteratorSyntheticFrontEndCreator, - "std::map iterator synthetic children", "^std::_Rb_tree_iterator<.+>$", - stl_synth_flags, true); + "std::map iterator synthetic children", + "^std::_Rb_tree_(const_)?iterator<.+>$", stl_synth_flags, true); AddCXXSynthetic( cpp_category_sp, diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile similarity index 70% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile index bf8e6b8703f36..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile @@ -1,5 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBSTDCPP := 1 - include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py similarity index 94% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py index b2b83a3b46114..5851588b59b5f 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxMapDataFormatterTestCase(TestBase): +class StdMapDataFormatterTestCase(TestBase): def setUp(self): TestBase.setUp(self) ns = "ndk" if lldbplatformutil.target_is_android() else "" @@ -22,10 +21,8 @@ def check_pair(self, first_value, second_value): ] return ValueCheck(children=pair_children) -@add_test_categories(["libc++"]) -def test_with_run_command(self): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -326,3 +323,23 @@ def cleanup(): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("fram
[Lldb-commits] [lldb] [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other (PR #147165)
Michael137 wrote: > Ah, I see you've done that already. > > Not required, but I noticed that the pointer child still contains the goo: > > ``` > (lldb) v a.__ptr_ > (std::shared_ptr::element_type *) a.__ptr_ = 0xa2b8 > ``` > > If we do the casting centrally, we could have both of these appear the same > way. Good point. I'll address that separately once I merge the combined tests https://github.com/llvm/llvm-project/pull/147165 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other (PR #147165)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147165 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Add shared/weak count to libstdc++ std::shared_ptr summary (PR #147166)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147166 >From f9be1d811b66b050a79f83c16c7b404948c37505 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sat, 5 Jul 2025 12:42:39 +0100 Subject: [PATCH 1/3] [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other --- .../Plugins/Language/CPlusPlus/LibCxx.cpp | 39 +++ .../Plugins/Language/CPlusPlus/LibCxx.h | 1 + .../Plugins/Language/CPlusPlus/LibStdcpp.cpp | 27 +++-- 3 files changed, 40 insertions(+), 27 deletions(-) diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp index 104521b8c3e71..aa13e66a1b550 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp @@ -238,7 +238,8 @@ lldb_private::formatters::LibCxxVectorIteratorSyntheticFrontEndCreator( lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: LibcxxSharedPtrSyntheticFrontEnd(lldb::ValueObjectSP valobj_sp) -: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr) { +: SyntheticChildrenFrontEnd(*valobj_sp), m_cntrl(nullptr), + m_ptr_obj(nullptr) { if (valobj_sp) Update(); } @@ -251,7 +252,7 @@ llvm::Expected lldb_private::formatters:: lldb::ValueObjectSP lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( uint32_t idx) { - if (!m_cntrl) + if (!m_cntrl || !m_ptr_obj) return lldb::ValueObjectSP(); ValueObjectSP valobj_sp = m_backend.GetSP(); @@ -259,20 +260,17 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( return lldb::ValueObjectSP(); if (idx == 0) -return valobj_sp->GetChildMemberWithName("__ptr_"); +return m_ptr_obj->GetSP(); if (idx == 1) { -if (auto ptr_sp = valobj_sp->GetChildMemberWithName("__ptr_")) { - Status status; - auto value_type_sp = -valobj_sp->GetCompilerType() - .GetTypeTemplateArgument(0).GetPointerType(); - ValueObjectSP cast_ptr_sp = ptr_sp->Cast(value_type_sp); - ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); - if (status.Success()) { -return value_sp; - } -} +Status status; +auto value_type_sp = valobj_sp->GetCompilerType() + .GetTypeTemplateArgument(0) + .GetPointerType(); +ValueObjectSP cast_ptr_sp = m_ptr_obj->Cast(value_type_sp); +ValueObjectSP value_sp = cast_ptr_sp->Dereference(status); +if (status.Success()) + return value_sp; } return lldb::ValueObjectSP(); @@ -281,6 +279,7 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::GetChildAtIndex( lldb::ChildCacheState lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { m_cntrl = nullptr; + m_ptr_obj = nullptr; ValueObjectSP valobj_sp = m_backend.GetSP(); if (!valobj_sp) @@ -290,6 +289,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { if (!target_sp) return lldb::ChildCacheState::eRefetch; + auto ptr_obj_sp = valobj_sp->GetChildMemberWithName("__ptr_"); + if (!ptr_obj_sp) +return lldb::ChildCacheState::eRefetch; + + m_ptr_obj = ptr_obj_sp->Clone(ConstString("pointer")).get(); + lldb::ValueObjectSP cntrl_sp(valobj_sp->GetChildMemberWithName("__cntrl_")); m_cntrl = cntrl_sp.get(); // need to store the raw pointer to avoid a circular @@ -300,10 +305,12 @@ lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd::Update() { llvm::Expected lldb_private::formatters::LibcxxSharedPtrSyntheticFrontEnd:: GetIndexOfChildWithName(ConstString name) { - if (name == "__ptr_") + if (name == "__ptr_" || name == "pointer") return 0; - if (name == "$$dereference$$") + + if (name == "object" || name == "$$dereference$$") return 1; + return llvm::createStringError("Type has no child named '%s'", name.AsCString()); } diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h index 56501302d116f..6115ccde38ad2 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxx.h @@ -108,6 +108,7 @@ class LibcxxSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { private: ValueObject *m_cntrl; + ValueObject *m_ptr_obj; }; class LibcxxUniquePtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp index 28b7c01ab1b5b..7668a87ce447e 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcpp.cpp @@ -77,8 +77,7 @@ class LibStdcppSharedPtrSyntheticFrontEnd : public SyntheticChildrenFrontEnd { // objects are only destroyed when every shared pointer t
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (PR #147174)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147174 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (PR #147175)
Michael137 wrote: > It looks like the libstdc++ test just crashes. Ah I misnamed the test-category. https://github.com/llvm/llvm-project/pull/147175 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Update the String table offset based on the DWARF format (PR #147054)
DavidSpickett wrote: > Yes I already found it and its in my list to fix, there are few places where > DWARF32 parsing but I was planing to do in separate PR. or you want me to do > it here only ? Separate PR please. https://github.com/llvm/llvm-project/pull/147054 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Split out libc++ std::string tests that check corrupted strings (PR #147252)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147252 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ vector tests into generic test (PR #147137)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147137 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)
https://github.com/labath edited https://github.com/llvm/llvm-project/pull/144919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)
@@ -150,3 +150,84 @@ TEST(ListenerTest, StartStopListeningForEventSpec) { ASSERT_EQ(event_sp->GetBroadcaster(), &broadcaster1); ASSERT_FALSE(listener_sp->GetEvent(event_sp, std::chrono::seconds(0))); } + +TEST(ListenerTest, MoveEventsOnHijackAndRestore) { + Broadcaster broadcaster(nullptr, "test-broadcaster"); + const uint32_t event_mask = 1; + EventSP event_sp; + + // Create the original listener and start listening. + ListenerSP original_listener = Listener::MakeListener("original-listener"); + ASSERT_EQ(event_mask, original_listener->StartListeningForEvents(&broadcaster, + event_mask)); + broadcaster.SetPrimaryListener(original_listener); + + // Queue two events to original listener, but do not consume them yet. + broadcaster.BroadcastEvent(event_mask, nullptr); + broadcaster.BroadcastEvent(event_mask, nullptr); + + // Hijack. + ListenerSP hijack_listener = Listener::MakeListener("hijack-listener"); + broadcaster.HijackBroadcaster(hijack_listener, event_mask); + + // The events should have been moved to the hijack listener. + EXPECT_FALSE(original_listener->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener->GetEvent(event_sp, std::chrono::seconds(0))); + + // Queue two events while hijacked, but do not consume them yet. + broadcaster.BroadcastEvent(event_mask, nullptr); + broadcaster.BroadcastEvent(event_mask, nullptr); + + // Restore the original listener. + broadcaster.RestoreBroadcaster(); + + // The events queued while hijacked should have been moved back to the + // original listener. + EXPECT_FALSE(hijack_listener->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(original_listener->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(original_listener->GetEvent(event_sp, std::chrono::seconds(0))); +} + +TEST(ListenerTest, MoveEventsBetweenHijackers) { + Broadcaster broadcaster(nullptr, "test-broadcaster"); + const uint32_t event_mask = 1; + EventSP event_sp; + + // Create the original listener and start listening. + ListenerSP original_listener = Listener::MakeListener("original-listener"); + ASSERT_EQ(event_mask, original_listener->StartListeningForEvents(&broadcaster, + event_mask)); + broadcaster.SetPrimaryListener(original_listener); + + // First hijack. + ListenerSP hijack_listener1 = Listener::MakeListener("hijack-listener1"); + broadcaster.HijackBroadcaster(hijack_listener1, event_mask); + + // Queue two events while hijacked, but do not consume + // them yet. + broadcaster.BroadcastEvent(event_mask, nullptr); + broadcaster.BroadcastEvent(event_mask, nullptr); + + // Second hijack. + ListenerSP hijack_listener2 = Listener::MakeListener("hijack-listener2"); + broadcaster.HijackBroadcaster(hijack_listener2, event_mask); + + // The second hijacker should have the events now. + EXPECT_FALSE(hijack_listener1->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener2->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener2->GetEvent(event_sp, std::chrono::seconds(0))); + + // Queue two events while hijacked with second hijacker, but do not consume + // them yet. + broadcaster.BroadcastEvent(event_mask, nullptr); + broadcaster.BroadcastEvent(event_mask, nullptr); + + // Restore the previous hijacker. + broadcaster.RestoreBroadcaster(); + + // The first hijacker should now have the events. + EXPECT_FALSE(hijack_listener2->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener1->GetEvent(event_sp, std::chrono::seconds(0))); + EXPECT_TRUE(hijack_listener1->GetEvent(event_sp, std::chrono::seconds(0))); +} labath wrote: add a newline here https://github.com/llvm/llvm-project/pull/144919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Fix race condition in Process::WaitForProcessToStop() (PR #144919)
https://github.com/labath approved this pull request. That's pretty much what I had in mind. Thanks. https://github.com/llvm/llvm-project/pull/144919 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (PR #147174)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147174 >From afaebb5e6a16bbf91f3de26ae69050e503d55158 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 07:37:17 +0100 Subject: [PATCH 1/6] [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test This combines the libc++ and libstdc++ test cases. The libstdcpp tests were a subset of the libc++ test, so this patch moves the libcxx test into generic and removes the libstdcpp test entirely. Split out from https://github.com/llvm/llvm-project/pull/146740 --- .../{libstdcpp => generic}/map/Makefile | 2 - .../map/TestDataFormatterStdMap.py} | 22 +- .../{libcxx => generic}/map/main.cpp | 0 .../data-formatter-stl/libcxx/map/Makefile| 6 - .../libstdcpp/map/TestDataFormatterStdMap.py | 301 -- .../data-formatter-stl/libstdcpp/map/main.cpp | 55 6 files changed, 18 insertions(+), 368 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/map/Makefile (70%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/map/TestDataFormatterLibccMap.py => generic/map/TestDataFormatterStdMap.py} (95%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/map/main.cpp (100%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile similarity index 70% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile index bf8e6b8703f36..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/Makefile @@ -1,5 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBSTDCPP := 1 - include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py similarity index 95% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py index b2b83a3b46114..b039db8123bbf 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/TestDataFormatterStdMap.py @@ -9,7 +9,7 @@ from lldbsuite.test import lldbutil -class LibcxxMapDataFormatterTestCase(TestBase): +class StdMapDataFormatterTestCase(TestBase): def setUp(self): TestBase.setUp(self) ns = "ndk" if lldbplatformutil.target_is_android() else "" @@ -22,10 +22,8 @@ def check_pair(self, first_value, second_value): ] return ValueCheck(children=pair_children) -@add_test_categories(["libc++"]) -def test_with_run_command(self): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) bkpt = self.target().FindBreakpointByID( @@ -326,3 +324,19 @@ def cleanup(): lldbutil.continue_to_breakpoint(self.process(), bkpt) self.expect("frame variable ss", substrs=["%s::map" % ns, "size=0", "{}"]) + +@add_test_categories(["libc++"]) +def test_libcxx(self): +self.build(dictionary={"USE_LIBCPP" : 1}) +self.do_test() + +@add_test_categories(["libstdcxx"]) +def test_libstdcxx(self): +self.build(dictionary={"USE_LIBSTDCPP" : 1}) +self.do_test() + +@add_test_categories(["libstdcxx"]) +def test_libstdcxx_debug(self): +self.build(dictionary={"USE_LIBSTDCPP" : 1, + "CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}) +self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/map/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/map/main.cpp rename to lldb/test/API/functionalities/data-formatte
[Lldb-commits] [lldb] [lldb][Formatters] Use container summary helper for libstdc++ formatters (PR #147140)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147140 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] d06956e - [lldb][Formatters] Use container summary helper for libstdc++ formatters (#147140)
Author: Michael Buch Date: 2025-07-07T09:04:40+01:00 New Revision: d06956e24afaed103dfbcc67e81257692ae0a8b2 URL: https://github.com/llvm/llvm-project/commit/d06956e24afaed103dfbcc67e81257692ae0a8b2 DIFF: https://github.com/llvm/llvm-project/commit/d06956e24afaed103dfbcc67e81257692ae0a8b2.diff LOG: [lldb][Formatters] Use container summary helper for libstdc++ formatters (#147140) This re-uses the `LibcxxContainerSummaryProvider` for the libstdc++ formatters. There's a couple of containers that aren't making use of it for libstdc++. This patch will make it easier to review when adding those in the future. Added: Modified: lldb/include/lldb/DataFormatters/FormattersHelpers.h lldb/source/DataFormatters/FormattersHelpers.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxx.h Removed: diff --git a/lldb/include/lldb/DataFormatters/FormattersHelpers.h b/lldb/include/lldb/DataFormatters/FormattersHelpers.h index 97d367afc65d7..6a47cf37eac64 100644 --- a/lldb/include/lldb/DataFormatters/FormattersHelpers.h +++ b/lldb/include/lldb/DataFormatters/FormattersHelpers.h @@ -60,6 +60,9 @@ std::optional ExtractIndexFromString(const char *item_name); void DumpCxxSmartPtrPointerSummary(Stream &stream, ValueObject &ptr, const TypeSummaryOptions &options); +bool ContainerSizeSummaryProvider(ValueObject &valobj, Stream &stream, + const TypeSummaryOptions &options); + Address GetArrayAddressOrPointerValue(ValueObject &valobj); time_t GetOSXEpoch(); diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp b/lldb/source/DataFormatters/FormattersHelpers.cpp index 81c76b06fc47a..028fc5da73dc0 100644 --- a/lldb/source/DataFormatters/FormattersHelpers.cpp +++ b/lldb/source/DataFormatters/FormattersHelpers.cpp @@ -145,3 +145,9 @@ void lldb_private::formatters::DumpCxxSmartPtrPointerSummary( ValueObject::PrintableRepresentationSpecialCases::eDisable, false)) stream.Printf("ptr = 0x%" PRIx64, ptr.GetValueAsUnsigned(0)); } + +bool lldb_private::formatters::ContainerSizeSummaryProvider( +ValueObject &valobj, Stream &stream, const TypeSummaryOptions &options) { + return FormatEntity::FormatStringRef("size=${svar%#}", stream, nullptr, + nullptr, nullptr, &valobj, false, false); +} diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index 77047c077c678..327ab3ab9edd5 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -1016,15 +1016,15 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { stl_summary_flags.SetDontShowChildren(false); stl_summary_flags.SetSkipPointers(false); AddCXXSummary(cpp_category_sp, -lldb_private::formatters::LibcxxContainerSummaryProvider, +lldb_private::formatters::ContainerSizeSummaryProvider, "libc++ std::bitset summary provider", "^std::__[[:alnum:]]+::bitset<.+>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, -lldb_private::formatters::LibcxxContainerSummaryProvider, +lldb_private::formatters::ContainerSizeSummaryProvider, "libc++ std::vector summary provider", "^std::__[[:alnum:]]+::vector<.+>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, -lldb_private::formatters::LibcxxContainerSummaryProvider, +lldb_private::formatters::ContainerSizeSummaryProvider, "libc++ std::valarray summary provider", "^std::__[[:alnum:]]+::valarray<.+>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, @@ -1033,16 +1033,16 @@ static void LoadLibCxxFormatters(lldb::TypeCategoryImplSP cpp_category_sp) { "^std::__[[:alnum:]]+::slice_array<.+>$", stl_summary_flags, true); AddCXXSummary(cpp_category_sp, -lldb_private::formatters::LibcxxContainerSummaryProvider, +lldb_private::formatters::ContainerSizeSummaryProvider, "libc++ summary provider for the valarray proxy arrays", "^std::__[[:alnum:]]+::(gslice|mask|indirect)_array<.+>$", stl_summary_flags, true); AddCXXSummary( - cpp_category_sp, lldb_private::formatters::LibcxxContainerSummaryProvider, + cpp_category_sp, lldb_private::formatters::ContainerSizeSummaryProvider, "libc++ std::list summary provider", "^std::__[[:alnum:]]+::forward_list<.+>$", stl_summary_flags, true); AddCXXSummary( - cpp_category_sp, lldb_
[Lldb-commits] [lldb] [lldb][Formatter] Consolidate libstdc++ and libc++ unique_ptr formatter tests into generic test (PR #147031)
labath wrote: > It turns out the libstdc++ formatter supports dereferencing using the > "object" or "obj" names. I don't think there's any harm in supporting those, though I'd be surprised if many people are aware of that functionality. I kind of like this "hidden child" concept, but it feels like it ought to be just slightly more discoverable. https://github.com/llvm/llvm-project/pull/147031 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Make libc++ and libstdc++ std::shared_ptr formatters consistent with each other (PR #147165)
https://github.com/labath approved this pull request. Ah, I see you've done that already. Not required, but I noticed that the pointer child still contains the goo: ``` (lldb) v a.__ptr_ (std::shared_ptr::element_type *) a.__ptr_ = 0xa2b8 ``` If we do the casting centrally, we could have both of these appear the same way. https://github.com/llvm/llvm-project/pull/147165 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][Formatters] Add shared/weak count to libstdc++ std::shared_ptr summary (PR #147166)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147166 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::map tests into generic test (PR #147174)
https://github.com/labath approved this pull request. https://github.com/llvm/llvm-project/pull/147174 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (PR #147175)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147175 >From 24240c7efa951340d7f19e0f74d1075ab100598e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 07:49:57 +0100 Subject: [PATCH 1/3] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test --- .../{libcxx => generic}/iterator/Makefile | 3 - .../iterator/TestDataFormatterStdIterator.py} | 19 -- .../{libcxx => generic}/iterator/main.cpp | 0 .../libstdcpp/iterator/Makefile | 6 -- .../iterator/TestDataFormatterStdIterator.py | 60 --- .../libstdcpp/iterator/main.cpp | 38 6 files changed, 13 insertions(+), 113 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/iterator/Makefile (54%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/iterator/TestDataFormatterLibccIterator.py => generic/iterator/TestDataFormatterStdIterator.py} (90%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/iterator/main.cpp (100%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/TestDataFormatterStdIterator.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/iterator/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile similarity index 54% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile index 564cbada74e08..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/Makefile @@ -1,6 +1,3 @@ CXX_SOURCES := main.cpp -USE_LIBCPP := 1 - -CXXFLAGS_EXTRAS := -O0 include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py similarity index 90% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py index c43ee46fb658a..9cd1001352def 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/TestDataFormatterLibccIterator.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/TestDataFormatterStdIterator.py @@ -2,14 +2,13 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxIteratorDataFormatterTestCase(TestBase): +class StdIteratorDataFormatterTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -17,10 +16,8 @@ def setUp(self): self.line = line_number("main.cpp", "// Set break point at this line.") self.namespace = "std" -@add_test_categories(["libc++"]) -def test_with_run_command(self): -"""Test that libc++ iterators format properly.""" -self.build() +def do_test(self): +"""Test that iterators format properly.""" self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line( @@ -84,3 +81,13 @@ def cleanup(): self.expect("frame variable siumI.first", substrs=["second"], matching=False) self.expect("frame variable siumI.second", substrs=["second = 137"]) self.expect("frame variable siumI.second", substrs=["first"], matching=False) + +@add_test_categories(["libc++"]) +def test_libcxx(self): +self.build(dictionary={"USE_LIBCPP": 1}) +self.do_test() + +@add_test_categories(["libstdcpp"]) +def test_libstdcxx(self): +self.build(dictionary={"USE_LIBSTDCPP": 1}) +self.do_test() diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp similarity index 100% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/iterator/main.cpp rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/iterator/main.cpp diff
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ iterator tests into generic test (PR #147175)
https://github.com/Michael137 edited https://github.com/llvm/llvm-project/pull/147175 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147283 >From be3eb2431b0649ce2730a4cf832dc474e262f49e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 12:40:37 +0100 Subject: [PATCH 1/2] [lldb][test] Fix libstdc++ std::variant formatter for empty variant Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks https://github.com/llvm/llvm-project/pull/147253 --- lldb/examples/synthetic/gnu_libstdcpp.py| 13 - .../variant/TestDataFormatterLibStdcxxVariant.py| 5 - .../data-formatter-stl/libstdcpp/variant/main.cpp | 1 + 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 20b9488af5597..96b11322db775 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -889,17 +889,12 @@ def VariantSummaryProvider(valobj, dict): if not (index_obj and index_obj.IsValid() and data_obj and data_obj.IsValid()): return "" -def get_variant_npos_value(index_byte_size): -if index_byte_size == 1: -return 0xFF -elif index_byte_size == 2: -return 0x -else: -return 0x +npos = valobj.GetTarget().FindFirstGlobalVariable("std::variant_npos") +if not npos: +return "" -npos_value = get_variant_npos_value(index_obj.GetByteSize()) index = index_obj.GetValueAsUnsigned(0) -if index == npos_value: +if index == npos.GetValueAsUnsigned(0): return " No Value" # Strip references and typedefs. 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 394e221809f7c..c3325c9e73cb9 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 @@ -2,7 +2,6 @@ Test lldb data formatter for LibStdC++ std::variant. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -62,9 +61,6 @@ def test_with_run_command(self): "frame variable v3", substrs=["v3 = Active Type = char {", "Value = 'A'", "}"], ) -""" -TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian -bots. Pending reproduce and investigation. self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"]) @@ -72,7 +68,6 @@ def test_with_run_command(self): "frame variable v_many_types_no_value", substrs=["v_many_types_no_value = No Value"], ) -""" @add_test_categories(["libstdcxx"]) def test_invalid_variant_index(self): diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index 36e0f74f831f8..acb07d5700b8a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,6 +49,7 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; + v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here >From 59518c7f14a6beeb29ebdc8b33eeede9176418b3 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 12:47:28 +0100 Subject: [PATCH 2/2] fixup! revert redundant test change --- .../data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index acb07d5700b8a..36e0f74f831f8 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,7 +49,6 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; - v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Fix libstdc++ std::variant formatter for empty variant (PR #147283)
https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/147283 Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks https://github.com/llvm/llvm-project/pull/147253 >From be3eb2431b0649ce2730a4cf832dc474e262f49e Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Mon, 7 Jul 2025 12:40:37 +0100 Subject: [PATCH] [lldb][test] Fix libstdc++ std::variant formatter for empty variant Instead of using the byte-size to make a guess at what the `std::variant_npos` value is, just look it up in debug-info. Unblocks https://github.com/llvm/llvm-project/pull/147253 --- lldb/examples/synthetic/gnu_libstdcpp.py| 13 - .../variant/TestDataFormatterLibStdcxxVariant.py| 5 - .../data-formatter-stl/libstdcpp/variant/main.cpp | 1 + 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/lldb/examples/synthetic/gnu_libstdcpp.py b/lldb/examples/synthetic/gnu_libstdcpp.py index 20b9488af5597..96b11322db775 100644 --- a/lldb/examples/synthetic/gnu_libstdcpp.py +++ b/lldb/examples/synthetic/gnu_libstdcpp.py @@ -889,17 +889,12 @@ def VariantSummaryProvider(valobj, dict): if not (index_obj and index_obj.IsValid() and data_obj and data_obj.IsValid()): return "" -def get_variant_npos_value(index_byte_size): -if index_byte_size == 1: -return 0xFF -elif index_byte_size == 2: -return 0x -else: -return 0x +npos = valobj.GetTarget().FindFirstGlobalVariable("std::variant_npos") +if not npos: +return "" -npos_value = get_variant_npos_value(index_obj.GetByteSize()) index = index_obj.GetValueAsUnsigned(0) -if index == npos_value: +if index == npos.GetValueAsUnsigned(0): return " No Value" # Strip references and typedefs. 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 394e221809f7c..c3325c9e73cb9 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 @@ -2,7 +2,6 @@ Test lldb data formatter for LibStdC++ std::variant. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * @@ -62,9 +61,6 @@ def test_with_run_command(self): "frame variable v3", substrs=["v3 = Active Type = char {", "Value = 'A'", "}"], ) -""" -TODO: temporarily disable No Value tests as they seem to fail on ubuntu/debian -bots. Pending reproduce and investigation. self.expect("frame variable v_no_value", substrs=["v_no_value = No Value"]) @@ -72,7 +68,6 @@ def test_with_run_command(self): "frame variable v_many_types_no_value", substrs=["v_many_types_no_value = No Value"], ) -""" @add_test_categories(["libstdcxx"]) def test_invalid_variant_index(self): diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp index 36e0f74f831f8..acb07d5700b8a 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/main.cpp @@ -49,6 +49,7 @@ int main() { v1 = 12; // v contains int v1_typedef = v1; v_v1 = v1; + v1_typedef = v1; int i = std::get(v1); printf("%d\n", i); // break here ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] e14e982 - [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (#147141)
Author: Michael Buch Date: 2025-07-07T12:48:15+01:00 New Revision: e14e98290e71abe5d34b1d4724fde1b85b350547 URL: https://github.com/llvm/llvm-project/commit/e14e98290e71abe5d34b1d4724fde1b85b350547 DIFF: https://github.com/llvm/llvm-project/commit/e14e98290e71abe5d34b1d4724fde1b85b350547.diff LOG: [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (#147141) This combines the libc++ and libstdc++ test cases. The libstdcpp tests were a subset of the libc++ test, so this patch moves the libcxx test into `generic` and removes the libstdcpp test entirely. Split out from https://github.com/llvm/llvm-project/pull/146740 Added: lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/main.cpp Modified: Removed: lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/main.cpp lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/TestDataFormatterStdSmartPtr.py lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/main.cpp diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile similarity index 57% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile index 654e4b15bd568..8b20bcb05 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/smart_ptr/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/Makefile @@ -1,6 +1,3 @@ CXX_SOURCES := main.cpp -CXXFLAGS := -O0 -USE_LIBSTDCPP := 1 - include Makefile.rules diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py similarity index 86% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py index a10ab8e863002..8b641c9643958 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/shared_ptr/TestDataFormatterLibcxxSharedPtr.py +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/shared_ptr/TestDataFormatterStdSharedPtr.py @@ -1,5 +1,5 @@ """ -Test lldb data formatter for libc++ std::shared_ptr. +Test lldb data formatter for std::shared_ptr. """ import lldb @@ -9,11 +9,8 @@ class TestCase(TestBase): -@add_test_categories(["libc++"]) -def test_shared_ptr_variables(self): +def do_test(self): """Test `frame variable` output for `std::shared_ptr` types.""" -self.build() - (_, process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp") ) @@ -56,16 +53,8 @@ def test_shared_ptr_variables(self): self.assertRegex(valobj.summary, r"^10( strong=1)? weak=0$") self.assertNotEqual(valobj.child[0].unsigned, 0) -if self.expectedCompiler(["clang"]) and self.expectedCompilerVersion( -[">", "16.0"] -): -string_type = "std::string" -else: -string_type = "std::basic_string, std::allocator > " - valobj = self.expect_var_path( "sp_str", -type="std::shared_ptr<" + string_type + ">", children=[ValueCheck(name="pointer", summary='"hello"')], ) self.assertRegex(valobj.summary, r'^"hello"( strong=1)? weak=0$') @@ -73,7 +62,7 @@ def test_shared_ptr_variables(self): valobj = self.expect_var_path("sp_user", type="std::shared_ptr") self.assertRegex( valobj.summary, -"^std(::__[^:]*)?::shared_ptr::element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=0", +"element_type @ 0x0*[1-9a-f][0-9a-f]+( strong=1)? weak=0", ) self.assertNotEqual(valobj.child[0].unsigned, 0
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::shared_ptr tests into generic test (PR #147141)
https://github.com/Michael137 closed https://github.com/llvm/llvm-project/pull/147141 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -320,6 +320,92 @@ bool clang::analyze_format_string::ParseUTF8InvalidSpecifier( // Methods on ArgType. //===--===// +static bool namedTypeToLengthModifierKind(ASTContext &Ctx, QualType QT, + LengthModifier::Kind &K) { + for (/**/; const auto *TT = QT->getAs(); + QT = TT->getDecl()->getUnderlyingType()) { +const auto *TD = TT->getDecl(); +const auto *DC = TT->getDecl()->getDeclContext(); +bool RC = false; +if (Ctx.getLangOpts().C99) { + RC = DC->isTranslationUnit(); erichkeane wrote: >previous review feedback suggesting that isStdNamespace should be avoided in C >mode Curious on the reasoning here... I don't think it is problematic? https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147253 >From e592d39c751480838ed90fcaa2b247e96b5bab59 Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:58:02 +0100 Subject: [PATCH 1/4] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test --- .../{libcxx => generic}/variant/Makefile | 4 +- .../variant/TestDataFormatterStdVariant.py} | 44 +++-- .../{libstdcpp => generic}/variant/main.cpp | 21 ++-- .../variant/TestDataFormatterLibcxxVariant.py | 88 - .../libcxx/variant/main.cpp | 95 --- .../libstdcpp/variant/Makefile| 5 - 6 files changed, 23 insertions(+), 234 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/variant/Makefile (82%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py => generic/variant/TestDataFormatterStdVariant.py} (59%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/variant/main.cpp (85%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..d5f5fec8441b5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 + include Makefile.rules 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/generic/variant/TestDataFormatterStdVariant.py similarity index 59% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index dae9b24fbbcfe..24ae9bfcd1a06 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/generic/variant/TestDataFormatterStdVariant.py @@ -1,5 +1,5 @@ """ -Test lldb data formatter for LibStdC++ std::variant. +Test lldb data formatter subsystem. """ import lldb @@ -8,18 +8,14 @@ from lldbsuite.test import lldbutil -class LibStdcxxVariantDataFormatterTestCase(TestBase): -@add_test_categories(["libstdcxx"]) -def test_with_run_command(self): -"""Test LibStdC++ std::variant data formatter works correctly.""" -self.build() +class StdVariantDataFormatterTestCase(TestBase): +def do_test(self): +"""Test that that file and class static variables display correctly.""" (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) -lldbutil.continue_to_breakpoint(self.process, bkpt) - for name in ["v1", "v1_typedef"]: self.expect( "frame variable " + name, @@ -69,28 +65,12 @@ def test_with_run_command(self): substrs=["v_many_types_valueless = No Value"], ) -@add_test_categories(["libstdcxx"]) -def test_invalid_variant_index(self): -"""Test LibStdC++ data formatter for std::variant with invalid index.""" -self.build() - -(self.target, self.process, thread, bkpt) = lldbutil.run_to_source_breakpoint( -self, "// break here", lldb.SBFileSpec("main.cpp", False) -) - -lldbutil.continue_to_breakpoint(self.process, bkpt) - -self.expect( -"frame variable v1", -substrs=["v1 = Active Type = int {", "Value = 12", "}"], -) - -var_v1 = thread.frames[0].FindVariable("v1") -var_v1_raw_obj = var_v1.GetNonSyntheticValue() -index_obj = var_v1_raw_obj.GetChildMemberWithName("_M_index") -self.assertTrue(index_obj and index_obj.IsValid()) +@add_test_categories(["libc++"
[Lldb-commits] [lldb] [lldb-dap] Add external terminal support (PR #146950)
@@ -242,6 +242,8 @@ struct Configuration { std::string platformName; }; +enum Terminal : unsigned { eConsole, eIntegrated, eExternal }; ashgti wrote: I believe the format for these should be `eTerminalConsole`, `eTerminalIntegrated`, `eTerminalExternal`. https://github.com/llvm/llvm-project/pull/146950 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add external terminal support (PR #146950)
@@ -236,6 +236,7 @@ contain the following key/value pairs: | **env** | dictionary | | Environment variables to set when launching the program. The format of each environment variable string is "VAR=VALUE" for environment variables with values or just "VAR" for environment variables with no values. | **stopOnEntry** | boolean | | Whether to stop program immediately after launching. | **runInTerminal** | boolean | | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs. +| **runInTerminal** | string | | Specifies where program should be launch: `integrated` for an integrated terminal in the IDE, `external` for external terminal window or `console` (default) for IDE debug console. ashgti wrote: I think the most common way this is implemented is a key called `console` with the values of `internalConsole`, `integratedTerminal`, or `externalTerminal`. Thats used by vscode-js-debug (https://github.com/microsoft/vscode-js-debug/blob/f8f4253879aa6cd81e5c776a4f9a619771ec2fc3/src/configuration.ts#L385C3-L385C10 its defined in code instead of the package.json) and `vscode-python` (https://github.com/microsoft/vscode-python/blob/main/package.json#L941) and `vscode-cpptools` (https://github.com/microsoft/vscode-cpptools/blob/main/Extension/package.json#L5468) Maybe we should migrate to the new 'console' key for this value and deprecate the `runInTerminal` key. We could add a warning if we see the key and ask users to migrate. https://github.com/llvm/llvm-project/pull/146950 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add external terminal support (PR #146950)
@@ -236,6 +236,7 @@ contain the following key/value pairs: | **env** | dictionary | | Environment variables to set when launching the program. The format of each environment variable string is "VAR=VALUE" for environment variables with values or just "VAR" for environment variables with no values. | **stopOnEntry** | boolean | | Whether to stop program immediately after launching. | **runInTerminal** | boolean | | Launch the program inside an integrated terminal in the IDE. Useful for debugging interactive command line programs. +| **runInTerminal** | string | | Specifies where program should be launch: `integrated` for an integrated terminal in the IDE, `external` for external terminal window or `console` (default) for IDE debug console. ashgti wrote: Also, https://code.visualstudio.com/docs/debugtest/debugging-configuration#_launchjson-attributes mentions in the common variables section the `console` key as well. Its not strictly required, but it does match the behavior of other DAP implementations. https://github.com/llvm/llvm-project/pull/146950 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb-dap] Add external terminal support (PR #146950)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/146950 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
JDevlieghere wrote: > How should a proper debugger shutdown sequence look like? > > 1. Release all `SBModule` pointers. > 2. Call `SBDebugger::MemoryPressureDetected`. > 3. Call `SBDebugger::Destroy`. Ideally, `SBDebugger::Destroy` would clean up all the modules in the module cache. You say we don't do that and that we leak them intentionally, which suggests that we don't do that on purpose. It'd be interesting to understand why, but I think that's fundamentally at odds with what you're trying to achieve. If there's a "good" reason and changing that is not an option, `SBDebugger::MemoryPressureDetected` could be an escape hatch. > `SBDebugger::MemoryPressureDetected` only removes shared pointers to modules > with `use_count == 1`. Assuming that the calling program releases all its > modules in (1), we need to make sure that the debugger does not keep any > pointers elsewhere before (2). Can we rely on this? Yes, if you destroyed all the debuggers and don't hold onto modules yourself, that should release all the modules. We actually test for this after every test in our test suite. https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [clang] [clang-tools-extra] [libcxx] [lldb] [Clang] Make the SizeType, SignedSizeType and PtrdiffType be named sugar types instead of built-in types (PR #143653)
@@ -1002,14 +1002,14 @@ RValue CodeGenFunction::EmitCoroutineIntrinsic(const CallExpr *E, } case llvm::Intrinsic::coro_size: { auto &Context = getContext(); -CanQualType SizeTy = Context.getSizeType(); +CanQualType SizeTy = Context.getCanonicalSizeType(); YexuanXiao wrote: No, there is no such constructor. https://github.com/llvm/llvm-project/pull/143653 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
@@ -44,26 +163,20 @@ MainLoopWindows::~MainLoopWindows() { } llvm::Expected MainLoopWindows::Poll() { - std::vector events; + std::vector events; events.reserve(m_read_fds.size() + 1); - for (auto &[fd, info] : m_read_fds) { -int result = WSAEventSelect(fd, info.event, FD_READ | FD_ACCEPT | FD_CLOSE); -assert(result == 0); -UNUSED_IF_ASSERT_DISABLED(result); - -events.push_back(info.event); + for (auto &[_, fd_info] : m_read_fds) { +fd_info.event->WillPoll(); +events.push_back((HANDLE)fd_info.event->GetHandle()); } events.push_back(m_interrupt_event); DWORD result = WSAWaitForMultipleEvents(events.size(), events.data(), FALSE, ashgti wrote: WSAWaitForMultipleEvents is calling WaitForMultipleObjectsEx per the Remarks section of https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsawaitformultipleevents#remarks and the `lphEvents` param supports taking different HANDLE types. `WSAEVENT` is just a typedef on `HANDLE`, so they can be used in the same places in a few different APIs. https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Clear ModuleList shared modules in SBDebugger::Clear (PR #147289)
JDevlieghere wrote: > However, when lldb is used as a library, we need a way to manage opened > modules to avoid problems with file locks (on some systems) for modules that > we no longer need. Can you give a concrete example? This seems like its own issue that should be solved rather than worked around. I wouldn't expect us to need to keep files open for as long as a module exists. > It should be possible to record all loaded modules and use > `ModuleList::RemoveSharedModule` and `RemoveOrphanSharedModules` functions to > clear the cache, but these functions are not available in the API. This > approach is also way too complicated when we just need to cleanup the library. This is exposed from the SB API through `SBDebugger::MemoryPressureDetected`. Not sure what's "complicated" about calling his function, but I do agree that this shouldn't necessary be an explicit operation and would make a good default. The natural place to do this is in `SBDebugger::Destroy`. You can have many debuggers and it seems like a bad idea to clear the modules when you clear one of them. https://github.com/llvm/llvm-project/pull/147289 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Adding pipe support to lldb_private::MainLoopWindows. (PR #145621)
https://github.com/ashgti edited https://github.com/llvm/llvm-project/pull/145621 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test (PR #147253)
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/147253 >From 30e4862aceee140084e10610b0ac2e7962d195dd Mon Sep 17 00:00:00 2001 From: Michael Buch Date: Sun, 6 Jul 2025 09:58:02 +0100 Subject: [PATCH 1/3] [lldb][test] Combine libstdc++ and libc++ std::variant tests into generic test --- .../{libcxx => generic}/variant/Makefile | 4 +- .../variant/TestDataFormatterStdVariant.py} | 56 -- .../{libstdcpp => generic}/variant/main.cpp | 19 ++-- .../libcxx/variant/main.cpp | 95 .../libstdcpp/variant/Makefile| 5 - .../TestDataFormatterLibStdcxxVariant.py | 101 -- 6 files changed, 32 insertions(+), 248 deletions(-) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx => generic}/variant/Makefile (82%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libcxx/variant/TestDataFormatterLibcxxVariant.py => generic/variant/TestDataFormatterStdVariant.py} (53%) rename lldb/test/API/functionalities/data-formatter/data-formatter-stl/{libstdcpp => generic}/variant/main.cpp (85%) delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/main.cpp delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/Makefile delete mode 100644 lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/variant/TestDataFormatterLibStdcxxVariant.py diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile similarity index 82% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile index 7eeff7407804d..d5f5fec8441b5 100644 --- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/Makefile +++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/Makefile @@ -1,6 +1,4 @@ CXX_SOURCES := main.cpp - -USE_LIBCPP := 1 - CXXFLAGS_EXTRAS := -std=c++17 + include Makefile.rules 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/generic/variant/TestDataFormatterStdVariant.py similarity index 53% rename from lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/variant/TestDataFormatterLibcxxVariant.py rename to lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/variant/TestDataFormatterStdVariant.py index 47e07a5ce3f5b..cf2569b02a586 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/generic/variant/TestDataFormatterStdVariant.py @@ -2,53 +2,31 @@ Test lldb data formatter subsystem. """ - import lldb from lldbsuite.test.decorators import * from lldbsuite.test.lldbtest import * from lldbsuite.test import lldbutil -class LibcxxVariantDataFormatterTestCase(TestBase): -@add_test_categories(["libc++"]) -## Clang 7.0 is the oldest Clang that can reliably parse newer libc++ versions -## with -std=c++17. -@skipIf( -oslist=no_match(["macosx"]), compiler="clang", compiler_version=["<", "7.0"] -) -## We are skipping gcc version less that 5.1 since this test requires -std=c++17 -@skipIf(compiler="gcc", compiler_version=["<", "5.1"]) -## std::get is unavailable for std::variant before macOS 10.14 -@skipIf(macos_version=["<", "10.14"]) -def test_with_run_command(self): +class StdVariantDataFormatterTestCase(TestBase): +def do_test(self): """Test that that file and class static variables display correctly.""" -self.build() (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint( self, "// break here", lldb.SBFileSpec("main.cpp", False) ) -self.runCmd("frame variable has_variant") - -output = self.res.GetOutput() - -## The variable has_variant tells us if the test program -## detected we have a sufficient libc++ version to support variant -## false means we do not and therefore should skip the test -if output.find("(bool) has_variant = false") != -1: -self.skipTest("std::variant not supported") - -lldbutil.continue_to_breakpoint(self.process, bkpt) - -self.expect( -"frame variable v1", -substrs=["v1 = Active Type = int {", "Value = 12", "}"], -) +for name in ["v1", "v1_typedef"]: +self.expect( +"frame variable " + name, +s
[Lldb-commits] [lldb] [lldb][RPC] Upstream RPC server interface emitters (PR #138032)
https://github.com/chelcassanova updated https://github.com/llvm/llvm-project/pull/138032 >From 44b7628d7d77d3c63001890cb678ee6ab85e8034 Mon Sep 17 00:00:00 2001 From: Chelsea Cassanova Date: Wed, 30 Apr 2025 14:24:03 -0700 Subject: [PATCH] [lldb[RPC] Upstream RPC server interface emitters This commit upstreams the LLDB RPC server interface emitters. These emitters generate the server-side API interfaces for RPC, which communicate directly with liblldb itself out of process using the SB API. https://discourse.llvm.org/t/rfc-upstreaming-lldb-rpc/85804 --- .../Inputs/Server/CheckBasicIncludesEmit.h| 6 + .../Inputs/Server/CheckConstCharPointer.h | 14 + .../Tests/Server/CheckBasicIncludesEmit.test | 15 + .../Tests/Server/CheckConstCharPointer.test | 11 + .../lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp| 414 + .../server/RPCServerHeaderEmitter.cpp | 75 +++ .../server/RPCServerHeaderEmitter.h | 47 ++ .../server/RPCServerSourceEmitter.cpp | 584 ++ .../server/RPCServerSourceEmitter.h | 81 +++ 9 files changed, 1247 insertions(+) create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h create mode 100644 lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test create mode 100644 lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerHeaderEmitter.h create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.cpp create mode 100644 lldb/tools/lldb-rpc/lldb-rpc-gen/server/RPCServerSourceEmitter.h diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h new file mode 100644 index 0..77394aba12f7a --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckBasicIncludesEmit.h @@ -0,0 +1,6 @@ +// This ia a basic header file used to check that the server-side emitter +// for rpc-gen emits an expected set of includes in a generated source file. +#ifndef LLDB_API_SBRPC_CHECKBASICINCLUDE_H +#define LLDB_API_SBRPC_CHECKBASICINCLUDE_H + +#endif // LLDB_API_SBRPC_CHECKBASICINCLUDE_H diff --git a/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h new file mode 100644 index 0..37121cd445267 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Inputs/Server/CheckConstCharPointer.h @@ -0,0 +1,14 @@ +#ifndef LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H +#define LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H + +namespace lldb { +class LLDB_API SBRPC_CHECKCONSTCHARPOINTER { +public: + // const char * parameters must decoded as rpc_common::ConstCharPointer in server side + // source files. + int CheckConstCharPointer(char *string); + +}; // class SBRPC_CHECKCONSTCHARPOINTER +} // namespace lldb + +#endif // LLDB_API_SBRPC_CHECKCONSTCHARPOINTER_H diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test new file mode 100644 index 0..3d365f16ba752 --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckBasicIncludesEmit.test @@ -0,0 +1,15 @@ +# Disabling until the lldb-rpc-gen tool lands. +UNSUPPORTED: system-* +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckBasicIncludesEmit.h + +RUN: cat %t/lib/CheckBasicIncludesEmit.cpp | FileCheck %s + +# All server-side source files must have these includes at the top of their files. +CHECK: #include "RPCUserServer.h" +CHECK: #include "SBAPI.h" +CHECK: #include +CHECK: #include +CHECK: #include +CHECK: #include diff --git a/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test new file mode 100644 index 0..e384f2242162f --- /dev/null +++ b/lldb/test/Shell/RPC/Generator/Tests/Server/CheckConstCharPointer.test @@ -0,0 +1,11 @@ +# Disabling until the lldb-rpc-gen tool lands. +UNSUPPORTED: system-* +RUN: mkdir -p %t/server +RUN: mkdir -p %t/lib +RUN: %lldb-rpc-gen --output-dir=%t %S/../../Inputs/CheckConstCharPointer.h + +RUN: cat %t/lib/CheckConstCharPointer.cpp | FileCheck %s + +# const char * pointers must be decoded as rpc_common::ConstCharPointer objects +# in server side source files. +CHECK: rpc_common::ConstCharPointer string diff --git a/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp b/lldb/tools/lldb-rpc/lldb-rpc-gen/lldb-rpc-gen.cpp new file mode 100644 index 0..e6b601ea13012 --- /dev/null +++ b
[Lldb-commits] [lldb] [lldb][Formatters] Consistently unwrap pointer element_type in std::shared_ptr formatters (PR #147340)
https://github.com/Michael137 ready_for_review https://github.com/llvm/llvm-project/pull/147340 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits