I want to be able to get the address and print a single pair from an STL container using GDB.
E.g., given the following toy program:
#include
This is because amap.begin()
does not exist in resulting binary. This is how C++ templates work: if you don't use or explicitly instantiate some template method it is not generated in resulting binary.
If you do want to call amap.begin()
from gdb you have to instantiate it. One way to do it is to instantiate all methods of std::map
:
#include
gdb session:
(gdb) p amap.begin()
$1 = {first = 1, second = 2}