You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the next command aways move based on the most recent frame, even if the user already moved to upper frames. If the next command would be locked into the deepest frame, it's usage would become very limited. So I consider this is a bug.
Example
classStudentdefinitialize(name)@name=nameenddefname@name# line 7endends=Student.new("John")s.name# line 12"foo"# line 13
When debugging with rdbg -e "b 12 ;; c ;; s ;; up ;; n" target.rb, I expect it to move like this:
From line 12, step into line 7
Move back to line 12
Next to line 13
But currently it's like:
From line 12, step into line 7
Move back to line 12
Next to line 8
Before
❯ exe/rdbg -e "b 12 ;; c ;; s ;; up ;; n" target.rb
[1, 10] in target.rb
=> 1| class Student
2| def initialize(name)
3| @name = name
4| end
5|
6| def name
7| @name
8| end
9| end
10|
=>#0 <main> at target.rb:1
(rdbg:commands) b 12
#0 BP - Line /Users/st0012/projects/debug/target.rb:12 (line)
(rdbg:commands) c
[7, 13] in target.rb
7| @name
8| end
9| end
10|
11| s = Student.new("John")
=> 12| s.name
13| "foo"
=>#0 <main> at target.rb:12
Stop by #0 BP - Line /Users/st0012/projects/debug/target.rb:12 (line)
(rdbg:commands) s
[2, 11] in target.rb
2| def initialize(name)
3| @name = name
4| end
5|
6| def name
=> 7| @name
8| end
9| end
10|
11| s = Student.new("John")
=>#0 Student#name at target.rb:7
#1 <main> at target.rb:12
(rdbg:commands) up
=> 12| s.name
=>#1 <main> at target.rb:12
(rdbg:commands) n
[3, 12] in target.rb
3| @name = name
4| end
5|
6| def name
7| @name
=> 8| end
9| end
10|
11| s = Student.new("John")
12| s.name
=>#0 Student#name at target.rb:8 #=> "John"
#1 <main> at target.rb:12
After
❯ exe/rdbg -e "b 12 ;; c ;; s ;; up ;; n" target.rb
[1, 10] in target.rb
=> 1| class Student
2| def initialize(name)
3| @name = name
4| end
5|
6| def name
7| @name
8| end
9| end
10|
=>#0 <main> at target.rb:1
(rdbg:commands) b 12
#0 BP - Line /Users/st0012/projects/debug/target.rb:12 (line)
(rdbg:commands) c
[7, 13] in target.rb
7| @name
8| end
9| end
10|
11| s = Student.new("John")
=> 12| s.name
13| "foo"
=>#0 <main> at target.rb:12
Stop by #0 BP - Line /Users/st0012/projects/debug/target.rb:12 (line)
(rdbg:commands) s
[2, 11] in target.rb
2| def initialize(name)
3| @name = name
4| end
5|
6| def name
=> 7| @name
8| end
9| end
10|
11| s = Student.new("John")
=>#0 Student#name at target.rb:7
#1 <main> at target.rb:12
(rdbg:commands) up
=> 12| s.name
=>#1 <main> at target.rb:12
(rdbg:commands) n
[8, 13] in target.rb
8| end
9| end
10|
11| s = Student.new("John")
12| s.name
=> 13| "foo"
=>#0 <main> at target.rb:13
(gdb) b foo
Breakpoint 1 at 0x555555555149: file t.c, line 2.
(gdb) run
Starting program: /mnt/c/ko1/src/rb/ruby-debug/a.out
Breakpoint 1, foo () at t.c:2
2 void foo(){
(gdb) bt
#0 foo () at t.c:2
#1 0x000055555555517e in main () at t.c:8
(gdb) f 1
#1 0x000055555555517e in main () at t.c:8
8 foo();
(gdb) n
3 printf("1\n");
(gdb) up
#1 0x000055555555517e in main () at t.c:8
8 foo();
(gdb) n
1
4 printf("2\n");
Byebug respects the current frame position, so if we want to attract more users from it we should make sure they feel familiar.
❯ byebug target.rb
[1, 10] in /Users/st0012/projects/debug/target.rb
=> 1: class Student
2: def initialize(name)
3: @name = name
4: end
5:
6: def name
7: @name # line 7
8: end
9: end
10:
(byebug) b 12
Created breakpoint 1 at /Users/st0012/projects/debug/target.rb:12
(byebug) c
Stopped by breakpoint 1 at /Users/st0012/projects/debug/target.rb:12
[4, 13] in /Users/st0012/projects/debug/target.rb
4: end
5:
6: def name
7: @name # line 7
8: end
9: end
10:
11: s = Student.new("John")
=> 12: s.name # line 12
13: "foo" # line 13
(byebug) s
[2, 11] in /Users/st0012/projects/debug/target.rb
2: def initialize(name)
3: @name = name
4: end
5:
6: def name
=> 7: @name # line 7
8: end
9: end
10:
11: s = Student.new("John")
(byebug) up
[4, 13] in /Users/st0012/projects/debug/target.rb
4: end
5:
6: def name
7: @name # line 7
8: end
9: end
10:
11: s = Student.new("John")
=> 12: s.name # line 12
13: "foo" # line 13
(byebug) n
[4, 13] in /Users/st0012/projects/debug/target.rb
4: end
5:
6: def name
7: @name # line 7
8: end
9: end
10:
11: s = Student.new("John")
12: s.name # line 12
=> 13: "foo" # line 13
(byebug)
The current behavior limits user's options: once they stepped in, they can no longer chose which frame to next from. But with the changed behavior, if users want to next from the last frame, they can still do that by simply switching to that frame.
I checked with Chrome DevTools, and Visual Studio Code and while they also have this behavior, they also offer a Step out, which is here under the name finish. It seems like we could build the behavior to use the current frame in terms of finish.
Basically next_at_frame(frame_number) is finish(frame_number) if frame_number !=0; next.
In addition to that, maybe there could be a configuration option for next to respect the current frame number? (Only when using the console obviously, for remote debugging you still want the behavior of VS Code/Chrome DevTools to apply).
I checked with Chrome DevTools, and Visual Studio Code and while they also have this behavior,
What is "this behavior"?
I checked DevTools with JS script, it behaves like current debug.gem.
I often choose upper frames and type "next" "step" and so on and I expect the current behavior (I don't care which frame is chosen. I just want to move to next line of the bottom frame). I've noticed my behavior after I considered about it. I guess other debugger writers think it?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, the
nextcommand aways move based on the most recent frame, even if the user already moved to upper frames. If thenextcommand would be locked into the deepest frame, it's usage would become very limited. So I consider this is a bug.Example
When debugging with
rdbg -e "b 12 ;; c ;; s ;; up ;; n" target.rb, I expect it to move like this:But currently it's like:
Before
After