Why I cannot see content of std::vector in the gdb?

unlvsur unlvsur unlvsur@live.com
Wed Oct 6 02:17:52 GMT 2021


c++ - Inspecting standard container (std::map) contents with gdb - Stack Overflow<https://stackoverflow.com/questions/427589/inspecting-standard-container-stdmap-contents-with-gdb>

I just saw your (jwakely) answer that libstdc++ supports pretty printer for gdb. But it does not work? Any configs I missed here?

g++ -o a a.cc -g -std=c++20 -I../fast_io/include

gdb ./a
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a...
(gdb) dir
Reinitialize source path to empty? (y or n) n
(gdb) l
1       #include<vector>
2       #include<fast_io.h>
3
4       int main()
5       {
6               std::vector<int> vec{2,4,6,1,204,6,5};
7               for(auto const& e : vec)
8                       println(e);
9       }
(gdb) break 7
Breakpoint 1 at 0x40129e: file a.cc, line 7.
(gdb) r
Starting program: /home/cqwrteur/fast_io_cleanup/temp/a

Breakpoint 1, main () at a.cc:7
7               for(auto const& e : vec)
(gdb) print vec
$1 = {<std::_Vector_base<int, std::allocator<int> >> = {
    _M_impl = {<std::allocator<int>> = {<__gnu_cxx::new_allocator<int>> = {<No data fields>}, <No data fields>}, <std::_Vector_base<int, std::allocator<int> >::_Vector_impl_data> = {_M_start = 0x4072a0, _M_finish = 0x4072bc,
        _M_end_of_storage = 0x4072bc}, <No data fields>}}, <No data fields>}
(gdb)

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows



More information about the Libstdc++ mailing list