applewil
applewil

Reputation: 428

How does gdb print stl containers

How does GDB pretty print this container?

const unordered_map<string, int> map{{"hello", 1}, {"world", 2}};
(gdb) p map
$1 = std::unordered_map with 2 elements = {["world"] = 2, ["hello"] = 1}

How can I get this functionality for my custom container?

Upvotes: 1

Views: 1139

Answers (1)

Employed Russian
Employed Russian

Reputation: 213754

How does GDB pretty print this container?

By using pretty-printers.

The pretty-printers for libstdc++ std::vector, std::unordred_map etc. are part of and shipped with libstdc++.

I see the pretty printers are located in the stl objfile

No, they are not. A filename pointing to them is in the object file, but not the pretty-printers themselves.

Upvotes: 1

Related Questions