Open tbaederr opened 1 year ago
@llvm/issue-subscribers-lldb
That's most likely because the _GLIBCXX_DEBUG
changes the layout of the vector, which the data formatter doesn't account for.
On my Ubuntu machine With the flag the raw layout is:
(lldb) frame var --raw v
(std::__debug::vector<int, std::allocator<int> >) v = {
__gnu_debug::_Safe_container<std::__debug::vector<int, std::allocator<int> >, std::allocator<int>, __gnu_debug::_Safe_sequence, true> = {
__gnu_debug::_Safe_sequence<std::__debug::vector<int, std::allocator<int> > > = {
__gnu_debug::_Safe_sequence_base = {
_M_iterators = nullptr
_M_const_iterators = nullptr
_M_version = 2
}
}
}
std::__cxx1998::vector<int, std::allocator<int> > = {
std::__cxx1998::_Vector_base<int, std::allocator<int> > = {
_M_impl = {
std::__cxx1998::_Vector_base<int, std::allocator<int> >::_Vector_impl_data = {
_M_start = 0x000055555556ceb0
_M_finish = 0x000055555556ceb4
_M_end_of_storage = 0x000055555556ceb4
}
}
}
}
__gnu_debug::_Safe_vector<std::__debug::vector<int, std::allocator<int> >, std::__cxx1998::vector<int, std::allocator<int> > > = {
_M_guaranteed_capacity = 1
}
}
(lldb) type summary info v
summary applied to (std::vector<int, std::allocator<int> >) v is: (show children) (hide value) libc++ std::vector summary provider
(lldb) type synthetic info v
synthetic applied to (std::vector<int, std::allocator<int> >) v is: libc++ std::vector synthetic children
Looks like the summary provider that gets used for std::__debug::vector
is the one for libc++.
Whereas the regular vector looks like:
(lldb) frame var --raw v
(std::vector<int, std::allocator<int> >) v = {
std::_Vector_base<int, std::allocator<int> > = {
_M_impl = {
std::_Vector_base<int, std::allocator<int> >::_Vector_impl_data = {
_M_start = 0x000055555556aeb0
_M_finish = 0x000055555556aeb4
_M_end_of_storage = 0x000055555556aeb4
}
}
}
}
(lldb) type summary info v
summary applied to (std::vector<int, std::allocator<int> >) v is: `size=${svar%#}` (show children) (hide value)
(lldb) type synthetic info v
synthetic applied to (std::vector<int, std::allocator<int> >) v is: Python class lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider
I think to fix this we'd have to adjust the std::vector
formatter regex to account for the __debug
namespace and then implement support for this layout in StdVectorSynthProvider
(which lives in gnu_libstdcpp.py).
Using this code:
shows the correct vector size in lldb when compiled with
clang++ ./vec.cpp -g -std=c++20
:But when compiled with
clang++ ./vec.cpp -g -std=c++20 -D_GLIBCXX_DEBUG
:... the size is reported as 0, which is clearly wrong.
Using lldb 15.0.7.