% cat test.cc
#include <map>
int main ()
{
std::map<int, int> m;
m.insert(m.end(), std::pair<int, int>(1, 1));
m.insert(m.end(), std::pair<int, int>(2, 1));
m.insert(m.end(), std::pair<int, int>(3, 1));
return 0;
}
% g++ -Wall -g test.cc
% gdb ./a.out
GNU gdb (Debian 8.2.1-2+b3) 8.2.1
Copyright (C) 2018 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) break main
Breakpoint 1 at 0x11d1: file test.cc, line 5.
(gdb) run
Starting program: /home/mikhirev/tmp/a.out
Breakpoint 1, main () at test.cc:5
5 std::map<int, int> m;
(gdb) watch m
Watchpoint 2: m
(gdb) c
Continuing.
Watchpoint 2: m
Old value = std::map with 0 elements
New value = std::map with 0 elements
std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:209
209 _M_header._M_left = &_M_header;
(gdb) bt
#0 std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:209
#1 0x0000555555555382 in std::_Rb_tree_header::_Rb_tree_header (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:176
#2 0x00005555555554b4 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree_impl<std::less<int>, true>::_Rb_tree_impl (
this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_tree.h:703
#3 0x00005555555553f6 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree (this=0x7fffffffe580)
at /usr/include/c++/8/bits/stl_tree.h:929
#4 0x0000555555555412 in std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >::map (this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_map.h:183
#5 0x00005555555551e0 in main () at test.cc:5
(gdb) c
Continuing.
Watchpoint 2: m
Old value = std::map with 0 elements
New value = std::map with 0 elements
std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:210
210 _M_header._M_right = &_M_header;
(gdb) bt
#0 std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:210
#1 0x0000555555555382 in std::_Rb_tree_header::_Rb_tree_header (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:176
#2 0x00005555555554b4 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree_impl<std::less<int>, true>::_Rb_tree_impl (
this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_tree.h:703
#3 0x00005555555553f6 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree (this=0x7fffffffe580)
at /usr/include/c++/8/bits/stl_tree.h:929
#4 0x0000555555555412 in std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >::map (this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_map.h:183
#5 0x00005555555551e0 in main () at test.cc:5
(gdb) c
Continuing.
Watchpoint 2: m
Old value = std::map with 0 elements
New value = std::map with 0 elements
std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:211
211 _M_node_count = 0;
(gdb) bt
#0 std::_Rb_tree_header::_M_reset (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:211
#1 0x0000555555555382 in std::_Rb_tree_header::_Rb_tree_header (this=0x7fffffffe588) at /usr/include/c++/8/bits/stl_tree.h:176
#2 0x00005555555554b4 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree_impl<std::less<int>, true>::_Rb_tree_impl (
this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_tree.h:703
#3 0x00005555555553f6 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_Rb_tree (this=0x7fffffffe580)
at /usr/include/c++/8/bits/stl_tree.h:929
#4 0x0000555555555412 in std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >::map (this=0x7fffffffe580) at /usr/include/c++/8/bits/stl_map.h:183
#5 0x00005555555551e0 in main () at test.cc:5
(gdb) c
Continuing.
Watchpoint 2: m
Old value = std::map with 0 elements
New value = std::map with 0 elements
0x00007ffff7ebb603 in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(gdb) bt
#0 0x00007ffff7ebb603 in std::_Rb_tree_insert_and_rebalance(bool, std::_Rb_tree_node_base*, std::_Rb_tree_node_base*, std::_Rb_tree_node_base&) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#1 0x0000555555555df7 in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_M_insert_node (this=0x7fffffffe580, __x=0x0,
__p=0x7fffffffe588, __z=0x55555556be70) at /usr/include/c++/8/bits/stl_tree.h:2320
#2 0x00005555555556ea in std::_Rb_tree<int, std::pair<int const, int>, std::_Select1st<std::pair<int const, int> >, std::less<int>, std::allocator<std::pair<int const, int> > >::_M_emplace_hint_unique<std::pair<int, int> > (
this=0x7fffffffe580, __pos={first = 0, second = 0}, __args#0=...) at /usr/include/c++/8/bits/stl_tree.h:2421
#3 0x000055555555558b in std::map<int, int, std::less<int>, std::allocator<std::pair<int const, int> > >::insert<std::pair<int, int> > (this=0x7fffffffe580, __position={first = 0, second = 0}, __x=...)
at /usr/include/c++/8/bits/stl_map.h:876
#4 0x0000555555555245 in main () at test.cc:7