Debugging

F

Fulvio

***********************
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. Mostly I'd like to understand the use of "condition" command in
terms to use breakpoints (BP) with functions.
Simple the first doubt was a counted BP. What variable using that BP and which
function can be taken from the command line?

10x

F
 
R

R. Bernstein

Fulvio said:
***********************
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.)
 
F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


(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.)

Thank you for your details. The pdb that I'm talking about, can be found
in /usr/lib/python2.4/pdb.py (an C:\python2.4\lib\pdb.py for the win32
version).
I'll give a look to pydb site...

The previous post I might have missed some explaination on my proceeding. I'd
say that I'm testing a small program under pdb control
(python /usr/lib/python2.4/pdb.py ./myprog.py). So pdb will load myprog and
stop the first line code.
Once I'm at the pdb command line I can issue the commands available inside the
pdb itself. Concerning the mentioned BP function I meant to set a
counter/function which let the BP run until reach the true condition.
Then "condition" is one of the pdb commands which let add a conditon to a BP.
The reference Manual gives information for all the pdb functions, but aren't
detailed, specially on how to set up BP conditions, like countdown, timed and
camparison conditions.

Hope I've been clear this time :)

F
 
B

Bruno Desthuilliers

Fulvio said:
***********************
Your mail has been scanned by InterScan MSS.
***********************




Thank you for your details. The pdb that I'm talking about, can be found
in /usr/lib/python2.4/pdb.py (an C:\python2.4\lib\pdb.py for the win32
version).
I'll give a look to pydb site...

The previous post I might have missed some explaination on my proceeding. I'd
say that I'm testing a small program under pdb control
(python /usr/lib/python2.4/pdb.py ./myprog.py). So pdb will load myprog and
stop the first line code.
Once I'm at the pdb command line I can issue the commands available inside the
pdb itself. Concerning the mentioned BP function I meant to set a
counter/function which let the BP run until reach the true condition.
Then "condition" is one of the pdb commands which let add a conditon to a BP.
The reference Manual gives information for all the pdb functions, but aren't
detailed, specially on how to set up BP conditions, like countdown,

"""
ignore bpnumber [count]

Sets the ignore count for the given breakpoint number. If count is
omitted, the ignore count is set to 0. A breakpoint becomes active when
the ignore count is zero. When non-zero, the count is decremented each
time the breakpoint is reached and the breakpoint is not disabled and
any associated condition evaluates to true.
"""

saw nothing about this one... but perhaps with
and
camparison conditions.

"""
condition bpnumber [condition]

Condition is an expression which must evaluate to true before the
breakpoint is honored. If condition is absent, any existing condition is
removed; i.e., the breakpoint is made unconditional.
"""

HTH
 
R

R. Bernstein

Fulvio said:
The previous post I might have missed some explaination on my proceeding. I'd
say that I'm testing a small program under pdb control
(python /usr/lib/python2.4/pdb.py ./myprog.py). So pdb will load myprog and
stop the first line code.
Once I'm at the pdb command line I can issue the commands available inside the
pdb itself.

Okay.

There's one other pydb command might be of interest. I mentioned the
ability to issue debugger commands by giving the commands as a string
in a command-line option, or putting the debugger commands in a file
and giving the name of a file in a command-line option. However
*inside* pydb, one can also run a canned set of debugger commands read
in from a file. This is "source" command. Again, this is exactly
analogous the command of the same name in gdb.

Should you want to somehow build such a debugger script from an
interactive debugging session, "set history" and "set logging" might
be helpful.
 
F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


ignore bpnumber [count]

Sorry, I ignored this command :)
saw nothing about this one... but perhaps with

There's tbreak FYI, but what condition will trigger I haven't tried yet.
condition bpnumber [condition]

    Condition is an expression which must evaluate to true before the
breakpoint is honored. If condition is absent, any existing condition is
removed; i.e., the breakpoint is made unconditional.

I did some test, but whatever comes out doesn't disable the breakpoint until
condition becomes true.
Supposing to have a function on program's variables the statement like " if
myvar == True: break" doesn't gives power to the BP.
If I do a check on the list of BPs the condition evidently appears, but no
luck :-O
Also clear statement does clear only all BPs, it won't let me clear the
choosen BP number.

OK. I still on the learning curve, so things come slowly.

F
 
F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


analogous the command of the same name in gdb.

That's available as pdb in the same directory. I didn't try it yet.
About pydb, I may say that triggered my curiosity and I'll give it a try.
Should you want to somehow build such a debugger script from an
interactive debugging session, "set history" and "set logging" might
be helpful.

Well, in my normal use (as I was used to do with "trace" in Arexx :) ), I'm
putting the program on hold and run it from inside pdb. I don't know
procedures by use of command file set.
In such mode I might seed some breakpoint at keypoint of the program and when
there it stops I investigate some of the critical variable used in that
point, to see if all goes as expected.

F
 
B

Bruno Desthuilliers

Fulvio a écrit :
condition bpnumber [condition]

Condition is an expression which must evaluate to true before the
breakpoint is honored. If condition is absent, any existing condition is
removed; i.e., the breakpoint is made unconditional.


I did some test, but whatever comes out doesn't disable the breakpoint until
condition becomes true.

I'm not sure to get what you mean here... The condition is a Python
*expression*. If this expressions evals to True, the bp will trigger,
else it will be ignored.

given the code:

00: for x in range(10):
01: y = x * 2
02: print y

and the pdb commands:

(pdb) break 2
(pdb) condition 1 y >= 6

The bp #1 should only trigger if y >= 6
Supposing to have a function on program's variables the statement like " if
myvar == True: break" doesn't gives power to the BP.

I definitively don't understand you. How does statements in your program
relates to setting conditions on a bp in the debugger ?
If I do a check on the list of BPs the condition evidently appears, but no
luck :-O
Also clear statement
s/statement/command/

does clear only all BPs, it won't let me clear the
choosen BP number.

Did you really bother reading the doc ? If you want to clear a given pb,
you need to pass it's number as argument to clear.
 
F

Fulvio

***********************
Your mail has been scanned by InterScan MSS.
***********************


The bp #1 should only trigger if y >= 6

This give me the right point.
I definitively don't understand you. How does statements in your program
relates to setting conditions on a bp in the debugger ?

The online help states :
|(Pdb) h b
|b(reak) ([file:]lineno | function) [, condition]
|With a line number argument, set a break there in the current
|file. With a function name, set a break at first executable line
|of that function. Without argument, list all breaks. If a second
|argument is present, it is a string specifying an expression
|which must evaluate to true before the breakpoint is honored.

"(Pdb)" is the prompt, as you can see.

I was thinking the "condition" is anything python can digest .Therefore an 'if
condition: code' should be accepted. Editing a BP with a condition like that
is taken as good (perhaps there's no check on its validity)
Did you really bother reading the doc
http://www.python.it/doc/Python-Docs/html/lib/debugger-commands.html
I downloaded all directory tree :)
Doesn't make difference in what is wrote on those and what is given at command
line help. If my ignorance disturbing too much, feel free to ignore it any
time. (No flame intention, however) I appreciate your help and these replies
will make easier for somebody else when a search engine will hit this post.

|(Pdb) b 17
|Breakpoint 3 at /home/user/tmp/mbxreader.py:17
|(Pdb) cl 3
|No breakpoint numbered 3
|(Pdb) h cl
|cl(ear) filename:lineno
|cl(ear) [bpnumber [bpnumber...]]
|With a space separated list of breakpoint numbers, clear
|those breakpoints. Without argument, clear all breaks

Do I input wrongly?
Finally I've done some test on pydb, I felt no much differences. But also the
author tried to keep compatibility with Pdb/Bdb, except some more functions.

F
 
B

Ben Finney

Fulvio said:
***********************
Your mail has been scanned by InterScan MSS.
***********************

Please stop sending messages with obnoxious headers like this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,279
Latest member
LaRoseDermaBottle

Latest Threads

Top