Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling Eclipse CDT debugger output?

When using CDT I would like to have std::string show up in the 'variable' debug window with the string it contains. For instance if it is currently holding the word "history" I would like to see history in the debugger window labeled "variables".

I think that there is a general way to have it drill down into objects but I can't put my finger on it. Does anyone out there know how to do this?

This would also be useful for me to use when outputting just a single field from a complex object.

Thanks, Bill

like image 858
billcoke Avatar asked Nov 17 '08 15:11

billcoke


1 Answers

Displaying stl containers with eclipse/gdb was also a major pain for me for a long time.

But now I've just discovered that the latest version of gdb with python enabled can help with that.

It follows what I've done (using Ubuntu Linux 8.10):

  • Install gdb version >= 6.8.50 (for instance from debian experimental)
  • Create a file named .gdbinit in your project root with the following content:

    python import gdb.libstdcxx.v6.printers

Now the stl containers will be pretty printed.

If you want to check if you already have a python enabled gdb (or if your new installation have worked):

  • Start gdb from the console
  • On the gdb prompt execute the following

    (gdb) python print 'Python enabled GDB is working!'

  • If the above command produces what we are expecting then it is working.

For more details check this blog.

like image 188
rpseng Avatar answered Sep 26 '22 00:09

rpseng