Always show current frame's source code.
Your proposal
When I used pry, I often used the @ command to show the context around the debugger. Let's say you break somewhere and it prints the debugger call and surrounding code. Then I do ls @article to print a lot of info about some variable/object. Now the context around the debugger is far away, so I type @ to see it again. I tried with debug to use list and it works once, but the next time I use list it shows the successor lines instead. Then I have to type list - to go back up again which is a bit annoying...
So, it would be nice to have a command that always works as the first invocation of list.
Additional context
Maybe there already is a command that does this that I'm missing?
I'm not a pry user, so I don't know what @ shows. Do you need only list - or more information?
I'm not a pry user, so I don't know what
@shows. Do you need onlylist -or more information?
It shows what list does the first time. The code and context around the breakpoint. list does it but if you run list again it shows the chunk of code after instead and I have to run list - to page back up again.
list does it but if you run list again it shows the chunk of code after instead and I have to run list - to page back up again
I see.
$ ruby ~/src/rb/t.rb
From: /home/ko1/src/rb/t.rb:9 Object#bar:
8: def bar
=> 9: binding.pry
10: end
[1] pry(main)> @
From: /home/ko1/src/rb/t.rb:9 Object#bar:
8: def bar
=> 9: binding.pry
10: end
It seems print same information when it stops.
[4, 13] in ~/src/rb/t.rb
4| def foo
5| bar
6| end
7|
8| def bar
=> 9| binding.b
10| end
11|
12| foo
13|
=>#0 Object#bar at ~/src/rb/t.rb:9
#1 Object#foo at ~/src/rb/t.rb:5
# and 1 frames (use `bt' command for all frames)
maybe same on debug.gem, you asked.
I understand the request. pry's feature @ is alias of whereami.
The name whereami is acceptable?
I want to introduce alias feature in future and maybe users can set alias @ whereami
I have another question.
When we choose another frame with frame 10, which frame should be shown?
- 0th frame (stopping frame)
- 10th frame (manipulating frame)
gdb has frame and where command, and
frameshows chosen frame (10th frame) with one sourcewhereshows backtrace from 0th (alias ofbacktrace)
The proposal refers list and list affects chosen frame (show 10th frame's code).