pdb repeat next command N times

Viewed 3907

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?

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.

Related