-
Notifications
You must be signed in to change notification settings - Fork 124
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
Allow using binding.bp to start a debug session #65
Comments
Yes, it is planned idea. The drawback is, explicit debug start will track the program execution:
In many cases it is not a problem. Terminology:
Maybe this proposal is, if |
Another possibility is, Maybe explicit |
In a future, like |
That's what I have in mind too. Should I open a PR for it? |
I showed some points, and we need to choose one. |
Ah sorry I didn't express that clearly: I took that line as
# move this out from Session.initialize_session
Binding.module_eval do
def bp command: nil
session_initialized = ::DEBUGGER__.const_get(:SESSION)
::DEBUGGER__.console unless session_initialized
if command
cmds = command.split(";;")
SESSION.add_initial_commands cmds
end
::DEBUGGER__.add_line_breakpoint __FILE__, __LINE__ + 1, oneshot: true if session_initialized
true
end
end |
Yes. I know. And I showed some drawback #65 (comment) |
let me summarize our options here:
and the difference between then is the timing of debugging session starts:
I think the 1st option makes more sense and I'd do it like I mentioned in #65 (comment) |
Could you explain why? |
activating the debug session with I know asking them to add gem "debug", require: false
# wherever I want to debug
require "debug" # start the session
binding.bp # and add a breakpoint still has more code than gem "debug" # require files & define binding.bp, but don't start anything
# wherever I want to debug
binding.bp # start the session and add a breakpoint |
You are right. How about disadvantages? |
I don't see a clear downside in this approach. shouldn't gem "debug"
binding.bp essentially the same as this? require "debug"
DEBUGGER__.console
# and later
binding.bp the only difference seems to be that we'll patch can you point out anything I miss here? |
|
I don't understand. since these start in |
In #65 (comment) I showed 3 points.
So after
In other words, there is a problem in a few cases. |
because require "debug" # code loaded (1)
# nothing tracked here
DEBUGGER__.console # start tracking (2) + stop the program (3)
# things are tracked
binding.bp # stop the program (3) to users, it means that "before the program is first stopped, nothing is being tracked". so if we can make require "debug" # code loaded (1)
# nothing tracked here
binding.bp # start tracking (2) + stop the program (3)
# things are tracked
binding.bp # stop the program (3)
or are you worrying about the tracking won't be explicit to users after the change? if that's the case, I think the problem would be the APIs being confusing when users use it like (speaking as someone who doesn't know this project very well)
Potential SolutionI think we can reduce the confusion by making the API more flexible:
so eventually the flow would look like: Without Prior Trackingfor using like require "debug" # code loaded (1)
# nothing tracked here
binding.bp # start tracking (2) + stop the program (3)
# also reminds users about tracking
# things are tracked
binding.bp # stop the program (3) With Prior Trackingrequire "debug" # code loaded (1)
# nothing tracked here
DEBUGGER__.track # start tracking (2)
# things are tracked
binding.bp # stop the program (3) |
or just
This is why there is |
but it's not accessible from application commands like |
not important but they are also
I'm thinking to start debug session (tracking) only with |
|
yeah I think this will make starting the debugger a lot easier 👍 |
@ko1 I'm going to give it a shot 🙂 |
@ko1 can you help me verify if these scenarios are correct? Scenarios
|
|
does that mean in the future those 2 methods won't stop the program anymore? (which I'd prefer) |
I also find that entering debug console with |
I found that the application should terminate with SIGINT if user doesn't enable debugger explicitly.
Allowed operations:
|
Now I'm thinking to enable (1) and (2) even if it is implicit enabling. |
To control them, I'm thinking # debug/session.rb
# start debugger functionality.
#
# trace_loading: start tracing loading files.
# trace_threading: start tracing thread creation/termination
# load_init: allow to load init
# suspend_on_sigint: enter debug session with C-c
# nonstop: Do not stop at the beggining of main script
def self.start trace_loading: true,
trace_threading: true,
load_init: true,
suspend_on_sigint: false,
nonstop: true
end
def self.run
start suspend_on_sigint: true, nonstop: true
end # debug.rb
require 'debug/session'
DEBUGGER__::start
# debug/run.rb
require 'debug/session'
DEBUGGER__::run
# debug/open.rb
require 'debug/session'
DEBUGGER__::open |
I'm not sure anybody wants to use |
@ko1 thank you! |
Please try it and tell me how it's good or not. |
@ko1 just tested in my Rails project and it worked great 👍 |
As stated in the readme, the correct way to start a debug session in the middle of a program is:
And then the user can freely use
binding.bp
to insert new breakpoints.This is a fine workflow, but I think we can make it more simpler. Since we already have the
binding.bp
method, which just looks likebyebug
andbinding.pry
, why don't we make it work like them?Then the users will have one less thing to learn 🙂
(I have to admit that it took me a while to remember to call
DEBUGGER__.console
, which I still forget from time to time 😂)The text was updated successfully, but these errors were encountered: