gdb and the SGI STL

For performance reasons, SGI's STL implmentation is all inline; a naming convention is generally followed (i.e. double underscore as a prefix for local variables), but tends to create long, cryptic variable names. Unfortunately, raw gdb is not a graceful way to debug STL-heavy code, the reasons being -

gdb_stl_utils is a small utility that may help solving these problems.
To use it, download and compile (a simple g++ -o StlStdContainers.o will do); then, load gdb_stl_utils into gdb by using the command "source gdb_stl_utils" (in gdb). You will then have access to the following gdb function:

p_stl_vector, p_stl_vector_size
p_stl_list, p_stl_list_size
p_stl_tree, p_stl_tree_size (for maps and sets)
p_stl_hash, p_stl_hash_size (for hash_maps and sets)

The names are self-explanatory: the functions print the contents and the sizes of STL containers given to them.

Good luck and happy debugging!

June 2005: Tony Novak updated the tools to the latest gcc version and packaged them. Thanks!