开发者

How do I list the current line in python PDB?

开发者 https://www.devze.com 2023-02-14 04:23 出处:网络
In the perl debugger, if you repeatedly list segments of code taking you away from the current line, you can return to the current line by entering the command . (dot).

In the perl debugger, if you repeatedly list segments of code taking you away from the current line, you can return to the current line by entering the command . (dot).

I have not been able 开发者_StackOverflowto find anything comparable using the python PDB module. If I list myself away from the current line and want to view it again, it seems I have to either remember the line number that was currently executing (unlikely for me) or execute a statement (often undesirable).

Am I missing something?


Late but hopefully still helpful. Make the following alias:

alias ll u;;d;;l

Then whenever you type ll, pdb will list from the current position. It works by going up the stack and then down the stack, which resets 'l' to show from the current position. (This won't work if you are at the top of the stack trace.)

Tip: Permanent alias

To make the alias permanent, add the line into your .pdbrc-file in the user home directory (~/.pdbrc). This works with both pdb and ipdb.


In Python 3.2 and higher, you can use list . to reset the list location.

Source: Python Bug tracker #4179


This question is 7 years old now..

If there’s anyone who are curious about this problem, just use the dot

(pdb) l .

This now works.


Well, I don't think there's a command similar to . in perl debugger, but you can always find the current line using the where / w command. That will show you both the current (contextual) frame as well as the most recent frame, which I believe is where the debugger was triggered.

0

精彩评论

暂无评论...
验证码 换一张
取 消