The test.cc is very simple:
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
vector<int32_t> vec{1,2,3};
return 0;
}
clang++ test.cc -std=c++17 -stdlib=libc++ -g
guo@dllab$ gdb ./a.out
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.3) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./a.out...done.
(gdb) l
1 #include <iostream>
2 #include <vector>
3
4 using namespace std;
5
6 int main(int argc, char *argv[])
7 {
8 vector<int32_t> vec{1,2,3};
9
10 return 0;
(gdb) b 9
Breakpoint 1 at 0x400ca5: file test.cc, line 9.
(gdb) r
Starting program: /home/guo/a.out
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, main (argc=1, argv=0x7fffffffd718) at test.cc:10
10 return 0;
(gdb) p vec
$1 = {
<std::__1::__vector_base<int, std::__1::allocator<int> >> = {
<std::__1::__vector_base_common<true>> = {<No data fields>},
members of std::__1::__vector_base<int, std::__1::allocator<int> >:
__begin_ = 0x603010,
__end_ = 0x60301c,
__end_cap_ = {
<std::__1::__compressed_pair_elem<int*, 0, false>> = {
__value_ = 0x60301c
},
<std::__1::__compressed_pair_elem<std::__1::allocator<int>, 1, true>> = {
<std::__1::allocator<int>> = {<No data fields>}, <No data fields>}, <No data fields>}
}, <No data fields>}
(gdb) pvector vec
There is no member or method named _M_impl.
I have installed stl-views-1.0.3.gdb via cat stl-views-1.0.3.gdb > ~/.gdbinit.
So pvector is supposed to be used.