I want to debug a c++ program using gdb. I use the pi and the py commands to evaluate python commands from within gdb, which works fine when I invoke gdb from the command line. However, when I invoke gdb from within emacs using M-x gdb and then gdb -i=mi file_name, the following errors occur:
- the
picommand correctly opens an interactive python shell, but any input to this shell yields the errors like this:
File "stdin", line 1
-interpreter-exec console "2"
SyntaxError: invalid syntax
- the
pycommand works correctly for a single command (likepy print 2+2), but not for multiple commands
I can get around those problems by starting gdb with gud-gdb, but then I dont have the support for gdb-many-windows. Maybe the problem is caused by the prompt after typing pi, which is no longer (gdb) but >>> instead?
I am going to go out on a limb and say this is a bug in gud mode. The clue is the
-interpreter-execline in the error.What happens here is that gud runs gdb in a special "MI" ("Machine Interface") mode. In this mode, commands and their responses are designed to be machine-, rather than human-, readable.
To let GUIs provide a console interface to users, MI provides the
-interpreter-execcommand, which evaluates a command using some other gdb "interpreter" (which doesn't mean what you may think and in particular has nothing to do with Python).So, gud sends user input to gdb, I believe, with
-interpreter-exec console .... But, in the case of a continuation line for apythoncommand, this is the wrong thing to do.I tried this out in Emacs and I was able to make it work for the
pythoncommand when I spelled it out -- butpy,pi, andpython-interactiveall failed.