Debugging

R. Bernstein rocky at panix.com
Sat Oct 21 17:43:27 CEST 2006


Fulvio <fulvio at tm.net.my> writes:

> ***********************
> Your mail has been scanned by InterScan MSS.
> ***********************
> 
> 
> Hello,
> 
> I'm trying out a small utility and my method uses PDB for debugging. I tried 
> to read some information regarding the commands of PDB but are rather 
> synthetic. 

I'm not sure what this means. If you are doing something like an IDE,
that is calling debugger routines from inside a program, then appears
that most of them use bdb, which is not documented but based on the
number times other programs have used it, it doesn't seem to be all
that insurmountable either.

(I have in mind one day to merge in all of the extensions that
everyone has seemed to add in all of those IDEs, along with the
extensions I've added for pydb, and make that a separate package and
add documentation for all of this.)

pdb does not support options, but pydb (http://bashdb.sf.net/pydb)
does. In pdb, if what you wanted to do was run a debugger script, the
way you could do it is to put the commands in .pdbrc. For pydb the
default file read is .pydbrc, but you can turn that *off* with -nx and
you can specify another file of your own using --command=*filename*.

In pydb, instead of listing commands in a file, it's also possible to
give them on a command line like this

pydb --exec='step 2;;where;;quit' python-script python-script-opt1

(Inside both pdb or pydb, ';;' separates commands)

> Mostly I'd like to understand the use of  "condition" command in 
> terms to use breakpoints (BP) with functions.

pydb (and to some extent pdb) follow the gdb command concepts. pydb
has more extensive documentation
(http://bashdb.sourceforge.net/pydb/pydb/lib/index.html) but if this
isn't enough I think the corresponding sections from gdb might be of help.

> Simple the first doubt was a counted BP. What variable using that BP and which 
> function can be taken from the command line?

In pydb as with gdb, the first breakpoint has number 1, the next
breakpoint 2. When breakpoints are deleted, the numbers don't get
reused. 

(I think all of this is the case also with pdb, but someone might
check on this; it's possible breakpoints in pdb start from 0 instead
of 1 as is the  case in gdb/pydb.)



More information about the Python-list mailing list