Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pdb repeat next command N times

I'm trying to debug a for loop and want to see what's happening inside after it has run for a while. It iterates several thousand times and I'd want to check what's happening every hundred or so. Is there a way to tell pdb to run the next command a few hundred times so I can check quickly?

like image 979
hamdog Avatar asked Dec 18 '22 03:12

hamdog


1 Answers

There is the ignore Parameter(Docs), which lets you skip n iterations.

Say you have code like this:

import pdb; pdb.set_trace()
for i in range(1000):
    pass

you could set a breakpoint with b 3 to line 3. Then ignore the first 100 steps with ignore 1 100 (1 is the number of the breakpoint) and then c to continue. Next stop will be after 100 iterations. If you want to pass the next 100 you have to write the ignore statement again.

like image 180
Thomas Junk Avatar answered Dec 27 '22 01:12

Thomas Junk