5

Note: To explain this quickly I'm going to talk about this from the perspective of working in Spyder.

If the a function is called in my code, I can put a break point next to where it's called and then when my code gets to that point I can click the "Step into function.." button to see what happens inside this function.

Suppose I'm at some arbitrary breakpoint and want to see what happens inside a function that's not in my code. Is there any way to call this function through the pdb console and "step into" said function call?

Martijn Pieters
  • 963,270
  • 265
  • 3,804
  • 3,187
mathandy
  • 1,412
  • 18
  • 28

2 Answers2

5

You can use ipdb. put ipdb.set_trace() wherever you want to debug. Then press s to step into the function.

Mudits
  • 1,321
  • 2
  • 15
  • 35
-2

Have you tried function decorators? (maybe read about it)

def foo():
    print 'Hello pdb'

def add_breakpoint(func):
    def func_wrapper(*args, **kwargs):
        pdb.set_trace()
        return func(*args, **kwargs)
    return func_wrapper

foo = add_breakpoint(foo)

This will add some calls in your debug, but it will get the job done. hoping to hear if worked!

bgnalm
  • 7
  • 1
  • This doesn't work for the same reason the above solution didn't work for me. When pdb is already sitting at a breakpoint, any functions called ignore breakpoints an execute normally. – mathandy Mar 02 '15 at 01:34
  • Instead of leaving the answer stranded, like the statements 'maybe read about it', you could provide some useful links you referred that help the cause. – saichand May 25 '20 at 13:46