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

Add --keep-process-alive #232

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions bin/rdebug-ide
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ options = OpenStruct.new(
'stop' => false,
'tracing' => false,
'skip_wait_for_start' => false,
'keep_process_alive' => false,
'int_handler' => true,
'dispatcher_port' => -1,
'evaluation_timeout' => 10,
Expand Down Expand Up @@ -70,6 +71,7 @@ EOB
opts.on('--stop', 'stop when the script is loaded') {options.stop = true}
opts.on("-x", "--trace", "turn on line tracing") {options.tracing = true}
opts.on("--skip_wait_for_start", "skip wait for 'start' command") {options.skip_wait_for_start = true}
opts.on("--keep-process-alive", "don't exit the process when debugger is exited") {options.keep_process_alive = true}
opts.on("-l", "--load-mode", "load mode (experimental)") {options.load_mode = true}
opts.on("-d", "--debug", "Debug self - prints information for debugging ruby-debug itself") do
Debugger.cli_debug = true
Expand Down Expand Up @@ -167,6 +169,10 @@ if options.int_handler
trap('INT') { Debugger.interrupt_last }
end

if options.keep_process_alive
ENV['DEBUGGER_KEEP_PROCESS_ALIVE'] = "true"
end

# set options
Debugger.keep_frame_binding = options.frame_bind
Debugger.tracing = options.tracing
Expand Down
12 changes: 9 additions & 3 deletions lib/ruby-debug-ide/commands/control.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ def regexp

def execute
begin
@printer.print_msg("finished")
@printer.print_debug("Exiting debugger.")
if ENV['DEBUGGER_KEEP_PROCESS_ALIVE'] == "true"
@delegate_sd_obj.interface.closing = true
Debugger.breakpoints.clear
@delegate_sd_obj.interface.command_queue << 'c'
else
@printer.print_msg("finished")
@printer.print_debug("Exiting debugger.")
end
ensure
exit! # exit -> exit!: No graceful way to stop threads...
exit! unless ENV['DEBUGGER_KEEP_PROCESS_ALIVE'] == "true" # exit -> exit!: No graceful way to stop threads...
end
end

Expand Down
4 changes: 3 additions & 1 deletion lib/ruby-debug-ide/interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ class LocalInterface < Interface

class RemoteInterface < Interface # :nodoc:
attr_accessor :command_queue
attr_accessor :closing

def initialize(socket)
@socket = socket
@command_queue = Queue.new
@closing = false
end

def read_command
Expand All @@ -23,7 +25,7 @@ def read_command
end

def print(*args)
@socket.printf(*args)
@socket.printf(*args) unless (@closing && ENV['DEBUGGER_KEEP_PROCESS_ALIVE'])
end

def close
Expand Down
2 changes: 1 addition & 1 deletion test-base/test_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def start_ruby_process(script, additional_opts = '')
status = wait_thr.value
end
@process_finished = true
fail "ERROR: \"#{process}\" failed with exitstatus=#{status.exitstatus}" unless status.success?
fail "ERROR: \"#{cmd}\" failed with exitstatus=#{status.exitstatus}" unless status.success?
end

end
Expand Down