debug icon indicating copy to clipboard operation
debug copied to clipboard

Always show current frame's source code.

Open Linuus opened this issue 3 years ago • 4 comments

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?

Linuus avatar May 17 '22 19:05 Linuus

I'm not a pry user, so I don't know what @ shows. Do you need only list - or more information?

ko1 avatar Jun 25 '22 18:06 ko1

I'm not a pry user, so I don't know what @ shows. Do you need only list - 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.

Linuus avatar Jun 25 '22 18:06 Linuus

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?

ko1 avatar Jul 05 '22 18:07 ko1

I want to introduce alias feature in future and maybe users can set alias @ whereami

ko1 avatar Jul 05 '22 18:07 ko1

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)

ko1 avatar Oct 24 '22 19:10 ko1

gdb has frame and where command, and

  • frame shows chosen frame (10th frame) with one source
  • where shows backtrace from 0th (alias of backtrace)

The proposal refers list and list affects chosen frame (show 10th frame's code).

ko1 avatar Oct 24 '22 19:10 ko1