2

Modern C++ has a lot of templated and wrapped elements that become a hassle during debugging because gdb is a generic debugger, without specific c++ features.

There's no way to easily list the elements in an STL container. When using a boost::shared_ptr shared pointer there's often no way to de-reference the referent to see what's going on.

Is there a set of gdb macros, or even a more advanced version of gdb that can make this stuff easier to see?

Walt Howard
  • 7,676
  • 1
  • 16
  • 11

1 Answers1

3

There's no way to easily list the elements in an STL container.

Yes there is, if you're using GDB 7 and a recent GCC from the last four years or so then you should have Python pretty printers available which show the contents of containers, smart pointers and other standard library types. See my answer at https://stackoverflow.com/a/15329434/981959

You can also write your own python printers for non-standard types, such as boost::shared_ptr

Is there a set of gdb macros, or even a more advanced version of gdb that can make this stuff easier to see?

There were macros that were useful about five years ago, but there's no need for them now as it's build in to GDB and GCC. So I think the answer to your question is "yes, there's a more advanced GDB, have you tried upgrading?"

Community
  • 1
  • 1
Jonathan Wakely
  • 166,810
  • 27
  • 341
  • 521