This revision was automatically updated to reflect the committed changes. Closed by commit rG8b80e8ee1fca: [lldb] Disable looking at pointee types to find synthetic value for non-ObjC (authored by aeubanks).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D137983/new/ https://reviews.llvm.org/D137983 Files: lldb/source/Core/ValueObject.cpp lldb/test/API/lang/cpp/incomplete-stl-types/Makefile lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp @@ -0,0 +1,8 @@ +#include <set> + +void f(std::set<int> &v); + +int main() { + std::set<int> v; + f(v); +} Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp @@ -0,0 +1,5 @@ +#include <set> + +void f(std::set<int> &v) { + // break here +} Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py @@ -0,0 +1,18 @@ +""" +Test situations where the debug info only has a declaration, no definition, for +an STL container with a formatter. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestStlIncompleteTypes(TestBase): + def test(self): + self.build() + lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("f.cpp")) + + var = self.frame().GetValueForVariablePath("v") + self.assertIn("set", var.GetDisplayTypeName()) Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile @@ -0,0 +1,9 @@ +CXX_SOURCES := main.cpp f.cpp + +include Makefile.rules + +# Force main.cpp to be built with no debug information +main.o: CFLAGS = $(CFLAGS_NO_DEBUG) + +# And force -flimit-debug-info on the rest. +f.o: CFLAGS_EXTRAS += $(LIMIT_DEBUG_INFO_FLAGS) Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ lldb/source/Core/ValueObject.cpp @@ -2673,7 +2673,10 @@ // In case of incomplete child compiler type, use the pointee type and try // to recreate a new ValueObjectChild using it. if (!m_deref_valobj) { - if (HasSyntheticValue()) { + // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g. + // `std::vector<int> &`). Remove ObjC restriction once that's resolved. + if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) && + HasSyntheticValue()) { child_compiler_type = compiler_type.GetPointeeType(); if (child_compiler_type) {
Index: lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp @@ -0,0 +1,8 @@ +#include <set> + +void f(std::set<int> &v); + +int main() { + std::set<int> v; + f(v); +} Index: lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp @@ -0,0 +1,5 @@ +#include <set> + +void f(std::set<int> &v) { + // break here +} Index: lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py @@ -0,0 +1,18 @@ +""" +Test situations where the debug info only has a declaration, no definition, for +an STL container with a formatter. +""" + +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestStlIncompleteTypes(TestBase): + def test(self): + self.build() + lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("f.cpp")) + + var = self.frame().GetValueForVariablePath("v") + self.assertIn("set", var.GetDisplayTypeName()) Index: lldb/test/API/lang/cpp/incomplete-stl-types/Makefile =================================================================== --- /dev/null +++ lldb/test/API/lang/cpp/incomplete-stl-types/Makefile @@ -0,0 +1,9 @@ +CXX_SOURCES := main.cpp f.cpp + +include Makefile.rules + +# Force main.cpp to be built with no debug information +main.o: CFLAGS = $(CFLAGS_NO_DEBUG) + +# And force -flimit-debug-info on the rest. +f.o: CFLAGS_EXTRAS += $(LIMIT_DEBUG_INFO_FLAGS) Index: lldb/source/Core/ValueObject.cpp =================================================================== --- lldb/source/Core/ValueObject.cpp +++ lldb/source/Core/ValueObject.cpp @@ -2673,7 +2673,10 @@ // In case of incomplete child compiler type, use the pointee type and try // to recreate a new ValueObjectChild using it. if (!m_deref_valobj) { - if (HasSyntheticValue()) { + // FIXME(#59012): C++ stdlib formatters break with incomplete types (e.g. + // `std::vector<int> &`). Remove ObjC restriction once that's resolved. + if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) && + HasSyntheticValue()) { child_compiler_type = compiler_type.GetPointeeType(); if (child_compiler_type) {
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits