Subsequent list commands in ipdb

I noticed unusual behavior when using l (i.e. list command) in ipdb . I think I saw something like this with the Perl debugger in the past, but that still puzzles me.

The first time I inoke, it correctly displays ~ 10 lines of code around the current step (breakpoint). However, if I click it several times, it no longer shows the code around the current location, but instead it shows a code that is below this.

In the end, list displays the final lines of the script, and if I press l again, it doesn't show anything else.

Why is this and how can I make him behave sequentially, like the first time I call him?

+4
source share
2 answers

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

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

 l 42 

If you do not know the current line number, run the where command.

+4
source

The reason that several list commands in most debuggers show different lines is for the simple reason that it doesn't make much sense to show the same lines of source code over and over. Presumably, you can scroll back to see what you saw before.

However, let me say that if you want to use the trepan debugger, it has the ability to show the same lines of source code for where you are currently staying using "list." . To view the lines before the last list, use "list -".

You can also specify how many lines you want to list by default using " set listsize" .

+1
source

Source: https://habr.com/ru/post/1486518/


All Articles