pythondebuggingipythonipdb

Subsequent "list" commands in ipdb


I just noticed an odd behavior when using l (i.e. the list command) in ipdb. I think I have seen something similar with the Perl debugger in the past, but it still puzzles me.

The first time I inoke it shows corerectly ~10 lines of code around the current step (breakpoint). However, if I press it repeatedly, it does not show code around the current location anymore, but instead it shows code that comes below it.

Eventually list shows the final lines of the script, and if I press l again it doesn't show anything anymore.

Why is this, and how can I have it behave consistently as the first time I invoke it?


Solution

  • Many command line debuggers behave that way. (pdb, gdb, ipdb ...).

    If you want display current line again, specify the line number.

    l 42
    

    If you don't know the current line number, issue where command.