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

support reset no_sigint_hook config #858

Merged
merged 1 commit into from
Dec 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
support reset no_sigint_hook config
```ruby
require 'debug'       # no_sigint_hook: true
require 'debug/start' # no_sigint_hook: false
```

In this case SIGINT should be a breakpoint but it was not enabled.
ko1 committed Dec 2, 2022
commit 0b8b5c08c42ec9bb8abb101eb08ba28c90be99fb
6 changes: 6 additions & 0 deletions lib/debug/config.rb
Original file line number Diff line number Diff line change
@@ -149,6 +149,12 @@ def update conf
if_updated old_conf, conf, :sigdump_sig do |old_sig, new_sig|
setup_sigdump old_sig, new_sig
end

if_updated old_conf, conf, :no_sigint_hook do |old, new|
if defined?(SESSION)
SESSION.set_no_sigint_hook old, new
end
end
end

private def if_updated old_conf, new_conf, key
25 changes: 15 additions & 10 deletions lib/debug/local.rb
Original file line number Diff line number Diff line change
@@ -13,23 +13,28 @@ def remote?
false
end

def activate session, on_fork: false
unless CONFIG[:no_sigint_hook]
prev_handler = trap(:SIGINT){
if session.active?
ThreadClient.current.on_trap :SIGINT
end
}
session.intercept_trap_sigint_start prev_handler
end
def activate_sigint
prev_handler = trap(:SIGINT){
if SESSION.active?
ThreadClient.current.on_trap :SIGINT
end
}
SESSION.intercept_trap_sigint_start prev_handler
end

def deactivate
def deactivate_sigint
if SESSION.intercept_trap_sigint?
prev = SESSION.intercept_trap_sigint_end
trap(:SIGINT, prev)
end
end

def activate session, on_fork: false
activate_sigint unless CONFIG[:no_sigint_hook]
end

def deactivate
deactivate_sigint
@console.deactivate
end

11 changes: 11 additions & 0 deletions lib/debug/session.rb
Original file line number Diff line number Diff line change
@@ -1926,6 +1926,17 @@ def postmortem=(is_enable)
end
end

def set_no_sigint_hook old, new
return unless old != new
return unless @ui.respond_to? :activate_sigint

if old # no -> yes
@ui.activate_sigint
else
@ui.deactivate_sigint
end
end

def save_int_trap cmd
prev, @intercepted_sigint_cmd = @intercepted_sigint_cmd, cmd
prev
2 changes: 1 addition & 1 deletion lib/debug/start.rb
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@

require_relative 'session'
return unless defined?(DEBUGGER__)
DEBUGGER__.start
DEBUGGER__.start no_sigint_hook: false