In order to make eclipse debug with pretty printing I followed the answer that was given to this question:
Ubuntu 14.04, gcc 4.8.4: gdb pretty printing doesn't work because of Python issue
However I inserted the command inside the ~/.gdbinit file and it didn't work. By running the .gdbinit with sh -x I got that Syntax error: "(" unexpected .
It seems to be a bash error in correlation with the python command. Every solution I search and tried did not fix the problem(e.x use single quotes or without the ; or use #!/usr/bin/python or #!/usr/bin/env python at the beginning of the file). Does anyone have an idea on how to deal with this?
Asked
Active
Viewed 734 times
1
-
Why you decided to run .gdbinit with sh -x ? Don't do this. – ks1322 Feb 03 '17 at 17:15
-
@ks1322 I just run it this way in order to see if something was wrong with the command. The same result I got when I run the command in the terminal. – dk13 Feb 03 '17 at 17:22
-
.gdbinit can not be run by shell. It contains gdb commands. Can you add your .gdbinit to your question? Do you have Python installed? And btw, for Ubuntu 16.04 relevant path would be /usr/share/gcc-5/python. – dbrank0 Feb 06 '17 at 08:20
-
@dbrank0 The file contains only the command **python sys.path.append("/usr/share/gcc-6/python");** as the link recommended. I have installed the latest gcc and yes python is installed. – dk13 Feb 06 '17 at 13:37
1 Answers
1
To enable pretty printing on ubuntu 16.04 (default gcc, gdb) this script was required:
python
sys.path.insert(0, '/usr/share/gcc-5/python')
from libstdcxx.v6.printers import register_libstdcxx_printers
register_libstdcxx_printers (None)
end
You will probably need gcc-6 in there.
After this, you need to enter full path to above script in eclipse debug configuration's debugger tab "gdb command file" field and apply the change.
Once this is set up launch via this debug configuration and examine containers in variables view.
For reference, here is CDT FAQ explaining this.

dbrank0
- 9,026
- 2
- 37
- 55