Search code examples
pythondebuggingipdb

ipdb how to bring the python debugger up to the frame which called the third-party code


In my python code, I have several levels of call stacks like this:

f1:user_func1 
  f2:**user_func2**
    f3:third_party_func1
      f4:third_party_func2
          f5:exception happens here. 

An exception happens somewhere in the third-party code (frame f5). I use ipdb to go the frame where the exception happened, and use the up command "u" to bring the debugger back to the frame where my code calls the third party code (frame f2).

Sometimes there are many level in the third-party code so I need to press u many times. Is there way to quickly bring the debugger to the frame of your code that calls the third-party code?


Solution

  • From ipdb command line:

    ipdb> help up
    u(p) [count]
        Move the current frame count (default one) levels up in the
        stack trace (to an older frame).