0

Because it is very inconvenient to use gdb to debug c++ code, especially when you use stl. For example if you want to check the contents in vector, you need to use some code like:

print *(myVector._M_impl._M_start)@myVector.size()

and the result is not straightforward.

further more ,if you want to print std::map, it seems there is no easy way.

camino
  • 10,085
  • 20
  • 64
  • 115
  • This may help: http://stackoverflow.com/questions/12574253/c-gdb-python-pretty-printing-tutorial It has a link to a pretty printer implementation that handles `map`s and other stl containers. – us2012 Mar 10 '13 at 23:53
  • See http://stackoverflow.com/questions/432567/debugging-best-practices-for-c-stl-boost-with-gdb – Mihai8 Mar 10 '13 at 23:54
  • This has been closed as a duplicate of a very old question **which doesn't give the right answer for 2013**. I've added an [answer](http://stackoverflow.com/a/15329434/981959) to explain that the modern way is to use GDB's pretty printers – Jonathan Wakely Mar 11 '13 at 00:28
  • I have download the stl-view.gdb,and copy to ~/.gdbinit,now I can use pmap, but it seems the result still in mess, any comments? – camino Mar 11 '13 at 17:21

0 Answers0