[Tutor] Debugging in emacs
alan.gauld at freenet.co.uk
Mon Dec 27 12:23:03 CET 2004
I seemed to have missed the start of this one, but which debugger
are you trying to use? There is plain ole Python pdb, the IDLE
debugger and the Pythonwin debugger (and probably more!)
The pdb debugger is fashioned on the gdb debugger and works
very like that if you've ever sen it before? THe pdb help
system works that way too.
> > Debugging in emacs is obviously not the hottest topic around here.
You should be able to use the standard pdb features, and
the emacs shortcuts are just that - shortcuts. So try the
long hand commands first.
> > 1. Add the following to your program:
> > import pdb
> > pdb.set_trace()
> > 2. Start an interactive Python buffer (C-c !)
I'd go with the import but set_trace isn't necessary to
use pdb. My normal way of using pdb is to ipport both
it and my module, then *run* the module.
>>> import pdb, mymodule
<some output here>
> If I set a breakpoint, then 'c'/'continue' doesn't work. Instead of
> continuing, it only goes one step.
Set the breakpoint using b and a function name
(pdb) b mymodule.somefunc
notice no parems, just the name
then c for contnue (usually a few times (2 or 3) to get past the
internal pdb bits)
<some location verbiage here>
<the line of code pdb is on>
Now you can start using the print command to check state etc,
up to navigate the call stack, 'step' into functions and 'next'
over them etc...
> I am using regular ole raw emacs, on a plain terminal, no X. Are
> How are you doing with this? I could sure use a debugger.
pdb is OK, although IDLE is better and Pythonwin is better
still - they are graphical debuggers...
FWIW there is a very short intro to both pdb and IDLE in my book...
I seem to recall that Mark Lutz has a chapter onpdb in
Programming Python too.
More information about the Tutor