Skip to content

Always show current frame's source code. #639

Closed

Description

@Linuus

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?

Activity

  1. ko1 commented on Jun 25, 2022

    @ko1
    Collaborator

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

  2. added
    enhancement
    on Jun 25, 2022
  3. Linuus commented on Jun 25, 2022

    @Linuus
    Author

    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.

  4. ko1 commented on Jul 5, 2022

    @ko1
    Collaborator

    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?

  5. ko1 commented on Jul 5, 2022

    @ko1
    Collaborator

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

  6. added this to the milestone on Jul 6, 2022
  7. ko1 commented on Oct 24, 2022

    @ko1
    Collaborator

    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)
  8. ko1 commented on Oct 24, 2022

    @ko1
    Collaborator

    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).

  9. added a commit that references this issue on Oct 26, 2022
  10. added a commit that references this issue on Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions