[Lldb-commits] [lldb] [lldb] optionally match the `__debug` namespace for libstdc++ containers. (PR #140727)
Ebuka Ezike via lldb-commits
lldb-commits at lists.llvm.org
Tue May 27 06:27:37 PDT 2025
https://github.com/da-viper updated https://github.com/llvm/llvm-project/pull/140727
>From cb2db78130e372b67d760cd89d2418252fa37459 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Sun, 18 May 2025 09:55:25 +0100
Subject: [PATCH 1/7] [lldb] optionally match the `__debug` namespace for
libstdc++ containers.
If libstdc++ is compiled with `_GLIBCXX_DEBUG` flag it puts the containers in the namespace `std::__debug`. this causes the summary and synthetic formatters not to match the types. The formatters is updated to optionally match the `__debug::`.
The formatters now clashed with the libc++ containers namespace regex which uses `std::__1` namespace
The libc++ formatter is loaded first, then the libstdc++ since the priority of the formatters in lldb is the last one added.
Fixes #60841
---
.../Language/CPlusPlus/CPlusPlusLanguage.cpp | 67 +++++++++++--------
.../TestDataFormatterCategories.py | 4 +-
2 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 542f13bef23e7..e98eef49f501a 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -592,7 +592,7 @@ class NodeAllocator {
public:
void reset() { Alloc.Reset(); }
- template <typename T, typename... Args> T *makeNode(Args &&... args) {
+ template <typename T, typename... Args> T *makeNode(Args &&...args) {
return new (Alloc.Allocate(sizeof(T), alignof(T)))
T(std::forward<Args>(args)...);
}
@@ -614,7 +614,7 @@ class ManglingSubstitutor
ManglingSubstitutor() : Base(nullptr, nullptr) {}
template <typename... Ts>
- ConstString substitute(llvm::StringRef Mangled, Ts &&... Vals) {
+ ConstString substitute(llvm::StringRef Mangled, Ts &&...Vals) {
this->getDerived().reset(Mangled, std::forward<Ts>(Vals)...);
return substituteImpl(Mangled);
}
@@ -1449,47 +1449,50 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
stl_deref_flags.SetFrontEndWantsDereference();
cpp_category_sp->AddTypeSynthetic(
- "^std::vector<.+>(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?vector<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::map<.+> >(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?map<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::deque<.+>(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug)?deque<.+>(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdDequeSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::set<.+> >(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?set<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?multimap<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?multiset<.+> >(( )?&)?$", eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdMapLikeSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::unordered_(multi)?(map|set)<.+> >$", eFormatterMatchRegex,
+ "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$",
+ eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdUnorderedMapSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::(__cxx11::)?list<.+>(( )?&)?$", eFormatterMatchRegex,
+ "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
+ eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_deref_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
cpp_category_sp->AddTypeSynthetic(
- "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex,
+ "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
+ eFormatterMatchRegex,
SyntheticChildrenSP(new ScriptedSyntheticChildren(
stl_synth_flags,
"lldb.formatters.cpp.gnu_libstdcpp.StdForwardListSynthProvider")));
@@ -1501,44 +1504,47 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
stl_summary_flags.SetDontShowChildren(false);
stl_summary_flags.SetSkipPointers(false);
- cpp_category_sp->AddTypeSummary("^std::bitset<.+>(( )?&)?$",
- eFormatterMatchRegex,
- TypeSummaryImplSP(new StringSummaryFormat(
- stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::vector<.+>(( )?&)?$",
- eFormatterMatchRegex,
- TypeSummaryImplSP(new StringSummaryFormat(
- stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::map<.+> >(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?bitset<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::set<.+> >(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?vector<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::deque<.+>(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?map<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::multimap<.+> >(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?set<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::multiset<.+> >(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?deque<.+>(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::unordered_(multi)?(map|set)<.+> >$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?multimap<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
- cpp_category_sp->AddTypeSummary("^std::(__cxx11::)?list<.+>(( )?&)?$",
+ cpp_category_sp->AddTypeSummary("^std::(__debug::)?multiset<.+> >(( )?&)?$",
eFormatterMatchRegex,
TypeSummaryImplSP(new StringSummaryFormat(
stl_summary_flags, "size=${svar%#}")));
cpp_category_sp->AddTypeSummary(
- "^std::(__cxx11::)?forward_list<.+>(( )?&)?$", eFormatterMatchRegex,
+ "^std::(__debug::)?unordered_(multi)?(map|set)<.+> >$",
+ eFormatterMatchRegex,
+ TypeSummaryImplSP(
+ new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+ cpp_category_sp->AddTypeSummary(
+ "^std::((__debug::)?|(__cxx11::)?)list<.+>(( )?&)?$",
+ eFormatterMatchRegex,
+ TypeSummaryImplSP(
+ new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
+ cpp_category_sp->AddTypeSummary(
+ "^std::((__debug::)?|(__cxx11::)?)forward_list<.+>(( )?&)?$",
+ eFormatterMatchRegex,
TypeSummaryImplSP(new ScriptSummaryFormat(
stl_summary_flags,
"lldb.formatters.cpp.gnu_libstdcpp.ForwardListSummaryProvider")));
@@ -1592,7 +1598,7 @@ static void LoadLibStdcppFormatters(lldb::TypeCategoryImplSP cpp_category_sp) {
AddCXXSynthetic(
cpp_category_sp,
lldb_private::formatters::LibStdcppBitsetSyntheticFrontEndCreator,
- "std::bitset synthetic child", "^std::bitset<.+>(( )?&)?$",
+ "std::bitset synthetic child", "^std::(__debug::)?bitset<.+>(( )?&)?$",
stl_deref_flags, true);
AddCXXSynthetic(
@@ -1731,8 +1737,11 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
DataVisualization::Categories::GetCategory(ConstString(GetPluginName()),
g_category);
if (g_category) {
- LoadLibStdcppFormatters(g_category);
+ // NOTE: the libstdcpp formatters are loaded after libcxx formatters
+ // because of a conflict matching the `__debug`namespace in libstdcpp.
+ // since lldb priorities the last loaded matching formatter.
LoadLibCxxFormatters(g_category);
+ LoadLibStdcppFormatters(g_category);
LoadSystemFormatters(g_category);
}
});
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py b/lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
index f602d017f28b7..f659f1edd1fc9 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-categories/TestDataFormatterCategories.py
@@ -335,5 +335,7 @@ def cleanup():
# and also validate that one can print formatters for a language
self.expect(
- "type summary list -l c++", substrs=["vector", "map", "list", "string"]
+ "type summary list -l c++",
+ substrs=["vector", "map", "list", "string"],
+ ordered=False,
)
>From 4dd4146502d79c3fc9d416463ec958127d779b04 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Wed, 21 May 2025 21:23:36 +0100
Subject: [PATCH 2/7] [lldb] review changes.
---
.../Language/CPlusPlus/CPlusPlusLanguage.cpp | 5 +++--
.../libstdcpp/map/TestDataFormatterStdMap.py | 17 +++++++++++++++++
.../vbool/TestDataFormatterStdVBool.py | 16 ++++++++++++++--
.../vector/TestDataFormatterStdVector.py | 14 ++++++++++++--
4 files changed, 46 insertions(+), 6 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index e98eef49f501a..e5595d7c94fbb 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1738,8 +1738,9 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
g_category);
if (g_category) {
// NOTE: the libstdcpp formatters are loaded after libcxx formatters
- // because of a conflict matching the `__debug`namespace in libstdcpp.
- // since lldb priorities the last loaded matching formatter.
+ // because we don't want to the libcxx formatters to match the potential
+ // `__debug` inline namespace that libstdcpp may use. since LLDB
+ // priorities the last loaded matching formatter.
LoadLibCxxFormatters(g_category);
LoadLibStdcppFormatters(g_category);
LoadSystemFormatters(g_category);
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
index 1f3fa911256f6..0e32f07b21f5c 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -19,9 +19,24 @@ def setUp(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command(self):
+ build_args = {"EXE": "a.out"}
+ self.with_run_command("", build_args)
+
+ @add_test_categories(["libstdcxx"])
+ @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
+ def test_with_run_command_debug(self):
+ build_args = {"CXXFLAGS": "-D_GLIBCXX_DEBUG", "EXE": "debug_a.out"}
+ self.with_run_command("__debug::", build_args)
+
+ def with_run_command(self, namespace: str, dictionary: dict):
"""Test that that file and class static variables display correctly."""
self.build()
self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+ self.build(dictionary=dictionary)
+ artifact_name = dictionary.get("EXE", "a.out")
+ self.runCmd(
+ "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
+ )
lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
@@ -47,8 +62,10 @@ def cleanup():
self.runCmd("frame variable ii --show-types")
+ match = f"std::{namespace}map<"
self.runCmd(
'type summary add -x "std::map<" --summary-string "map has ${svar%#} items" -e'
+ f'type summary add -x "{match}" --summary-string "map has ${{svar%#}} items" -e'
)
self.expect("frame variable ii", substrs=["map has 0 items", "{}"])
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/libstdcpp/vbool/TestDataFormatterStdVBool.py
index df98fd5e2899c..084bce9525c62 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/libstdcpp/vbool/TestDataFormatterStdVBool.py
@@ -18,9 +18,21 @@ def setUp(self):
@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": "-D_GLIBCXX_DEBUG"}
+ self.with_run_command(build_args)
+
+ def with_run_command(self, dictionary: dict):
"""Test that that file and class static variables display correctly."""
- self.build()
- self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+ self.build(dictionary=dictionary)
+ artifact_name = dictionary.get("EXE", "a.out")
+ self.runCmd("file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET)
+ self.runCmd(
+ "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
+ )
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
index bb9ffcfc9a77e..cac44f25a426f 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
@@ -19,9 +19,19 @@ def setUp(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command(self):
+ self.with_run_command({})
+
+ @add_test_categories(["libstdcxx"])
+ @expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
+ def test_with_run_command_debug(self):
+ build_args = {"CXXFLAGS": "-D_GLIBCXX_DEBUG"}
+ self.with_run_command(build_args)
+
+ def with_run_command(self, dictionary: dict):
"""Test that that file and class static variables display correctly."""
- self.build()
- self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+ self.build(dictionary=dictionary)
+ artifact_name = "a.out"
+ self.runCmd("file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
>From 987c324a833f4b97c7f45e4dc3b44eba00e4e011 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Sun, 25 May 2025 17:46:57 +0100
Subject: [PATCH 3/7] [lldb] use CXXFLAGS_EXTRAS
---
.../source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 2 +-
.../libstdcpp/map/TestDataFormatterStdMap.py | 6 ++----
.../libstdcpp/vbool/TestDataFormatterStdVBool.py | 4 ++--
.../libstdcpp/vector/TestDataFormatterStdVector.py | 6 ++++--
4 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index e5595d7c94fbb..115a49af8f14c 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1740,7 +1740,7 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
// NOTE: the libstdcpp formatters are loaded after libcxx formatters
// because we don't want to the libcxx formatters to match the potential
// `__debug` inline namespace that libstdcpp may use. since LLDB
- // priorities the last loaded matching formatter.
+ // prioritizes the last loaded matching formatter.
LoadLibCxxFormatters(g_category);
LoadLibStdcppFormatters(g_category);
LoadSystemFormatters(g_category);
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
index 0e32f07b21f5c..d4ea0cf5f3b31 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -19,13 +19,12 @@ def setUp(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command(self):
- build_args = {"EXE": "a.out"}
- self.with_run_command("", build_args)
+ self.with_run_command("", {})
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command_debug(self):
- build_args = {"CXXFLAGS": "-D_GLIBCXX_DEBUG", "EXE": "debug_a.out"}
+ build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
self.with_run_command("__debug::", build_args)
def with_run_command(self, namespace: str, dictionary: dict):
@@ -64,7 +63,6 @@ def cleanup():
match = f"std::{namespace}map<"
self.runCmd(
- 'type summary add -x "std::map<" --summary-string "map has ${svar%#} items" -e'
f'type summary add -x "{match}" --summary-string "map has ${{svar%#}} items" -e'
)
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/libstdcpp/vbool/TestDataFormatterStdVBool.py
index 084bce9525c62..ba787320a4a23 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/libstdcpp/vbool/TestDataFormatterStdVBool.py
@@ -16,20 +16,20 @@ 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": "-D_GLIBCXX_DEBUG"}
+ build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
self.with_run_command(build_args)
def with_run_command(self, dictionary: dict):
"""Test that that file and class static variables display correctly."""
self.build(dictionary=dictionary)
artifact_name = dictionary.get("EXE", "a.out")
- self.runCmd("file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET)
self.runCmd(
"file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
index cac44f25a426f..07994225c910e 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
@@ -24,14 +24,16 @@ def test_with_run_command(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command_debug(self):
- build_args = {"CXXFLAGS": "-D_GLIBCXX_DEBUG"}
+ build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
self.with_run_command(build_args)
def with_run_command(self, dictionary: dict):
"""Test that that file and class static variables display correctly."""
self.build(dictionary=dictionary)
artifact_name = "a.out"
- self.runCmd("file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET)
+ self.runCmd(
+ "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
+ )
lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
>From 9581927077fca0435515eeb4489f1c95bf2d4c83 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 27 May 2025 13:54:01 +0100
Subject: [PATCH 4/7] [lldb] add review changes.
---
.../Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp | 4 ++--
.../libstdcpp/map/TestDataFormatterStdMap.py | 12 +++---------
.../libstdcpp/vbool/TestDataFormatterStdVBool.py | 8 +++-----
.../libstdcpp/vector/TestDataFormatterStdVector.py | 10 ++++------
4 files changed, 12 insertions(+), 22 deletions(-)
diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
index 115a49af8f14c..b178e06a975cd 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
@@ -1739,8 +1739,8 @@ lldb::TypeCategoryImplSP CPlusPlusLanguage::GetFormatters() {
if (g_category) {
// NOTE: the libstdcpp formatters are loaded after libcxx formatters
// because we don't want to the libcxx formatters to match the potential
- // `__debug` inline namespace that libstdcpp may use. since LLDB
- // prioritizes the last loaded matching formatter.
+ // `__debug` inline namespace that libstdcpp may use.
+ // LLDB prioritizes the last loaded matching formatter.
LoadLibCxxFormatters(g_category);
LoadLibStdcppFormatters(g_category);
LoadSystemFormatters(g_category);
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
index d4ea0cf5f3b31..40405d951ff9c 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -27,15 +27,10 @@ def test_with_run_command_debug(self):
build_args = {"CXXFLAGS_EXTRAS": "-D_GLIBCXX_DEBUG"}
self.with_run_command("__debug::", build_args)
- def with_run_command(self, namespace: str, dictionary: dict):
+ def with_run_command(self, namespace: str, dictionary: Optional[dict] = None):
"""Test that that file and class static variables display correctly."""
- self.build()
- self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
self.build(dictionary=dictionary)
- artifact_name = dictionary.get("EXE", "a.out")
- self.runCmd(
- "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
- )
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
@@ -61,9 +56,8 @@ def cleanup():
self.runCmd("frame variable ii --show-types")
- match = f"std::{namespace}map<"
self.runCmd(
- f'type summary add -x "{match}" --summary-string "map has ${{svar%#}} items" -e'
+ f'type summary add -x "std::{namespace}map<" --summary-string "map has ${{svar%#}} items" -e'
)
self.expect("frame variable ii", substrs=["map has 0 items", "{}"])
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/libstdcpp/vbool/TestDataFormatterStdVBool.py
index ba787320a4a23..53ad1c5c9336c 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/libstdcpp/vbool/TestDataFormatterStdVBool.py
@@ -3,6 +3,7 @@
"""
+from typing import Optional
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -26,13 +27,10 @@ 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: dict):
+ def with_run_command(self, dictionary: Optional[dict] = None):
"""Test that that file and class static variables display correctly."""
self.build(dictionary=dictionary)
- artifact_name = dictionary.get("EXE", "a.out")
- self.runCmd(
- "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
- )
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_file_and_line(
self, "main.cpp", self.line, num_expected_locations=-1
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
index 07994225c910e..6cfd17a39304e 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vector/TestDataFormatterStdVector.py
@@ -3,6 +3,7 @@
"""
+from typing import Optional
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@@ -19,7 +20,7 @@ def setUp(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command(self):
- self.with_run_command({})
+ self.with_run_command()
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
@@ -27,13 +28,10 @@ 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: dict):
+ def with_run_command(self, dictionary: Optional[dict] = None):
"""Test that that file and class static variables display correctly."""
self.build(dictionary=dictionary)
- artifact_name = "a.out"
- self.runCmd(
- "file " + self.getBuildArtifact(artifact_name), CURRENT_EXECUTABLE_SET
- )
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
lldbutil.run_break_set_by_source_regexp(self, "Set break point at this line.")
>From 932179499d9c83540f92252376b16cac831c3301 Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 27 May 2025 14:21:33 +0100
Subject: [PATCH 5/7] [lldb] missing include.
---
.../data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
index 40405d951ff9c..720dd653034b6 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -2,7 +2,7 @@
Test lldb data formatter subsystem.
"""
-
+from typing import Optional
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
>From bb3c01c55a423e56d4818559a799fb5dd47865aa Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 27 May 2025 14:27:18 +0100
Subject: [PATCH 6/7] Update
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
Co-authored-by: Michael Buch <michaelbuch12 at gmail.com>
---
.../data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
index 720dd653034b6..30d490e1fc3ea 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/map/TestDataFormatterStdMap.py
@@ -19,7 +19,7 @@ def setUp(self):
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
def test_with_run_command(self):
- self.with_run_command("", {})
+ self.with_run_command()
@add_test_categories(["libstdcxx"])
@expectedFailureAll(bugnumber="llvm.org/pr50861", compiler="gcc")
>From d3f861ac0b6b57e72d51f5343693a521709e320d Mon Sep 17 00:00:00 2001
From: Ebuka Ezike <yerimyah1 at gmail.com>
Date: Tue, 27 May 2025 14:27:26 +0100
Subject: [PATCH 7/7] Update
lldb/test/API/functionalities/data-formatter/data-formatter-stl/libstdcpp/vbool/TestDataFormatterStdVBool.py
Co-authored-by: Michael Buch <michaelbuch12 at gmail.com>
---
.../libstdcpp/vbool/TestDataFormatterStdVBool.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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/libstdcpp/vbool/TestDataFormatterStdVBool.py
index 53ad1c5c9336c..f3371bc014b17 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/libstdcpp/vbool/TestDataFormatterStdVBool.py
@@ -20,7 +20,7 @@ def setUp(self):
@skip
@add_test_categories(["libstdcxx"])
def test_with_run_command(self):
- self.with_run_command({})
+ self.with_run_command()
@add_test_categories(["libstdcxx"])
def test_with_run_command_debug(self):
More information about the lldb-commits
mailing list