The boost-gdb-printers project has pretty-printers for GDB. They don't seem to work out of the box, but you can grab a fixed version from here.

git clone https://github.com/lekv/boost-gdb-printers.git
cd boost-gdb-printers
sudo make install

Once you have them installed, you can add the following lines to your .gdbinit file to enable the pretty printers:

# boost pretty printers
python
import sys
import gdb
print("Setting up Boost pretty printers")
sys.path.insert(0, '/usr/local/share/boost-gdb-printers')
import boost.v1_57 as boost
boost.register_pretty_printers(gdb)
end

Once that is done you should be able to print boost::unordered_map like so:

(gdb) br backend-config.cc:81
Breakpoint 1 at 0x82c2f3: file be/src/scheduling/backend-config.cc, line 81.
(gdb) c
Continuing.
...
Thread 73 "impalad" hit Breakpoint 1, impala::BackendConfig::LookUpBackendIp (this=0xa655ac0, hostname="127.0.0.1", ip=0x7fd525052f00) at be/src/scheduling/backend-config.cc:81
81        auto it = backend_ip_map_.find(hostname);
(gdb) p backend_ip_map_
$1 = boost::unordered::unordered_map with 1 elements = {
  ["de"] = "192.168.2.4"
}
  • No labels