I did some exploration myself, here is my new understanding of pdb
.
When you input import ipdb;ipdb.set_trace()
you actually add an entry point of ipdb
to the line, not really a breakpoint.
After you enter ipdb
, you can then set up breakpoints.
So, to realize what I want for conditional debugging, I should do this:
import ipdb;ipdb.set_trace()
for i in range(100):
print i
then after I enter ipdb
, I can input b xx, i == 10
, and then c
or r
to run the code. The code will stop when the condition is met.
When I input l
, the bpnumber
is shown for the line as :
xx-1 for i in range(100):
bpnumber> xx print i
xx+1 ...
I have to say, the documentation and all other explanations are very confusing, I hope my answer here clarifies the difference between the "debug entry point" and "debug breakpoint"