Search code examples
c++eclipseubuntugdbpretty-print

Pretty Printers Error while executing Python code in Eclipse Ubuntu 14


I am trying to enable Pretty Printing in Eclipse in Ubuntu 14.0.4. I have followed the steps to setup pretty printing: http://wiki.eclipse.org/CDT/User/FAQ I have SVNed a directory, created a .gdbinit file with the suggested code and correct path, and pointed my Eclipse debug to that file. I have fixed the bug in the printers.py file. When I run the debug with this selected, I get

Error in final launch sequence
Failed to execute MI command:
source /home/dreitz/python/init.gdbinit
Error message from debugger back end:
/home/dreitz/python/init.gdbinit:6: Error in sourced command file:\nError while executing Python code.
/home/dreitz/python/init.gdbinit:6: Error in sourced command file:\nError while executing Python code.

init.gdbinit contains the python launch code. Can anyone see what the problem is here?

Some solutions I have found that I am confused by:

  • a ~/.gdbinit file is referenced as being updated, instead of creating your own .gdbinit file. I do not know where this pre-existing file can be found.

  • Mismatch with versions. I have checked that GDB is installed, and python 2.7.8 is installed.


Solution

  • After some tests, what worked for me was changing the .gdbinit content to this:

    python
    import sys
    sys.path.insert(0, '/your/path/here/python')
    sys.path.insert(0, '/your/path/here/python/libstdcxx/v6')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    end
    

    Basically, I added one of the subfolders to the path, as well as removed the line that was calling the method register_libstdcxx_printers (None), since my gdb was complaining that it was already loaded.

    I don't know why the original command did not work, but at least, now it is.