1
votes

I'm trying to accomplish pretty printers (for viewing variables of type vectors,lists etc, STL containers) for debugging C++ using Eclipse (Version: Kepler Service Release 1) and CDT in Mac OSX Mountain Lion. I know I can use XCODE to debug, but want to debug using Eclipse. I appreciated any help. Thanks.

I tried the following, but failed debugging:

  1. Downloaded GNU gdb from ftp://ftp.gnu.org/gnu/gdb/gdb-7.6.tar.gz

  2. Installed GNU GDB with python the following way

    ./configure --prefix=/usr/local/gdb7.6 --with-python=/usr/bin/python
    make 
    make install
    
  3. Checked-out the latest Python libstdc++ printers to a folder ~/gdb_printers

    svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
    
  4. Created ~/gdb_printers/.gdbinit and added the following in the .gdbinit file

    python
    import sys
    sys.path.insert(0, '/Users/ravi/gdb_printers/python')
    from libstdcxx.v6.printers import register_libstdcxx_printers
    register_libstdcxx_printers (None)
    end
    
  5. Eclipse Setup

In Windows > Preferences > C/C++ > Debug > GDB

Where it Says GDB Debugger /usr/local/gdb7.6/bin/gdb

Where it says GDB Command File: /Users/ravi/gdb_printers/.gdbinit

  1. Now, when I try to debug, I get the following error.

    Error in final launch sequence
        Failed to execute MI command:
        source /Users/ravi/gdb_printers/.gdbinit
    Error message from debugger back end:
    /Users/ravi/gdb_printers/.gdbinit:6: Error in sourced command file:\nError while executing Python code.
    /Users/ravi/gdb_printers/.gdbinit:6: Error in sourced command file:\nError while executing Python code.
    
1

1 Answers

0
votes

I had the same issue with Eclipse 4.3 on Ubuntu 13.10.

I'm using the petty printer provided in the package libstdc++6-4.8-gdb in order to have installed the files at /usr/share/gcc-4.8/python

To fix the same message you had I had a look a the code in the printers.py. It happens that the issue was because of the code

raise ValueError, "..."

that should be writen

raise ValueError("...")

I don't anything in Python programming but googling around makes me trying this. And it seems to work. Pretty printer is up and running in my Eclipse session.

Hope this helps. Regards