Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use binding's location on irb command #804

Merged
merged 1 commit into from
Nov 17, 2022
Merged

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Nov 17, 2022

Description

This makes the debugger's irb command work in the same location as the current frame's location, instead of "(rdbg)/#{f}". With the current implementation, commands like whereami don't work. The debugger shouldn't modify the source location for irb command.

Before

$ ruby ~/tmp/a.rb
[1, 3] in ~/tmp/a.rb
     1| require 'debug'
=>   2| debugger
     3| puts 'hello'
=>#0    <main> at ~/tmp/a.rb:2
(rdbg) irb    # command
irb(main)[01:0]> whereami
The current context doesn't have code.
=> nil

It doesn't show the current location, and whereami doesn't work.

After

$ ruby ~/tmp/a.rb
[1, 3] in ~/tmp/a.rb
     1| require 'debug'
=>   2| debugger
     3| puts 'hello'
=>#0    <main> at ~/tmp/a.rb:2
(rdbg) irb    # command

From: /home/k0kubun/tmp/a.rb @ line 2 :

    1: require 'debug'
 => 2: debugger
    3: puts 'hello'

irb(main)[01:0]> whereami

From: /home/k0kubun/tmp/a.rb @ line 2 :

    1: require 'debug'
 => 2: debugger
    3: puts 'hello'

=> nil

It shows the current location, and whereami works as well.

@ko1
Copy link
Collaborator

ko1 commented Nov 17, 2022

From: /home/k0kubun/tmp/a.rb @ line 2 :

    1: require 'debug'
 => 2: debugger
    3: puts 'hello

the location lines are needed? (it seems verbose)
if you know how to remove them, please tell me how.

@k0kubun
Copy link
Member Author

k0kubun commented Nov 17, 2022

We could add an option like binding.irb(show_code: false) and use that from debug's irb command if you wish.

@k0kubun
Copy link
Member Author

k0kubun commented Nov 17, 2022

If you want that behavior and agree with ruby/irb#444, I think we can merge that on IRB's side.

@ko1
Copy link
Collaborator

ko1 commented Nov 17, 2022

Thank you, after releasing with #444 let's update with it.
Now I merge current patch.

@ko1 ko1 merged commit e422abe into ruby:master Nov 17, 2022
@k0kubun k0kubun deleted the irb-location branch November 17, 2022 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants