diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp --- a/lldb/source/Core/ValueObject.cpp +++ b/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 &`). Remove ObjC restriction once that's resolved. + if (Language::LanguageIsObjC(GetPreferredDisplayLanguage()) && + HasSyntheticValue()) { child_compiler_type = compiler_type.GetPointeeType(); if (child_compiler_type) { diff --git a/lldb/test/API/lang/cpp/incomplete-stl-types/Makefile b/lldb/test/API/lang/cpp/incomplete-stl-types/Makefile new file mode 100644 --- /dev/null +++ b/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) diff --git a/lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py b/lldb/test/API/lang/cpp/incomplete-stl-types/TestStlIncompleteTypes.py new file mode 100644 --- /dev/null +++ b/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()) diff --git a/lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp b/lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/lang/cpp/incomplete-stl-types/f.cpp @@ -0,0 +1,5 @@ +#include + +void f(std::set &v) { + // break here +} diff --git a/lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp b/lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp new file mode 100644 --- /dev/null +++ b/lldb/test/API/lang/cpp/incomplete-stl-types/main.cpp @@ -0,0 +1,8 @@ +#include + +void f(std::set &v); + +int main() { + std::set v; + f(v); +}