From bff361864ff4a99296dd0177209193e3fb85a770 Mon Sep 17 00:00:00 2001 From: ViugiNick Date: Wed, 13 Jun 2018 17:53:14 +0300 Subject: [PATCH] notify debugger about gdb_wrapper pid to kill it when debugging finished (#149) --- bin/gdb_wrapper | 5 ++++- bin/rdebug-ide | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/gdb_wrapper b/bin/gdb_wrapper index a439204..2442036 100755 --- a/bin/gdb_wrapper +++ b/bin/gdb_wrapper @@ -65,7 +65,10 @@ unless options.ruby_path exit 1 end -argv = '["' + ARGV * '", "' + '"]' +main_process_argv = ARGV +main_process_argv << '--gdb-wrapper-pid' << "#{Process.pid}" +argv = '["' + main_process_argv * '", "' + '"]' + child_argv = '["' + ARGV * '", "' + "', '--ignore-port" + '"]' debugger_loader_path = File.expand_path(File.dirname(__FILE__)) + '/../lib/ruby-debug-ide/attach/debugger_loader' diff --git a/bin/rdebug-ide b/bin/rdebug-ide index 3054353..1a244bd 100755 --- a/bin/rdebug-ide +++ b/bin/rdebug-ide @@ -28,6 +28,7 @@ options = OpenStruct.new( 'value_as_nested_element' => false, 'attach_mode' => false, 'cli_debug' => false, + 'gdb_wrapper_pid' => nil, 'key_value_mode' => false ) @@ -43,6 +44,8 @@ EOB opts.on("-h", "--host HOST", "Host name used for remote debugging") {|host| options.host = host} opts.on("-p", "--port PORT", Integer, "Port used for remote debugging") {|port| options.port = port} + opts.on("-gdbp", "--gdb-wrapper-pid PID", Integer, "Pid of corresponding gdb_wrapper (for attach case)") {|pid| options.gdb_wrapper_pid = pid} + opts.on("--dispatcher-port PORT", Integer, "Port used for multi-process debugging dispatcher") do |dp| options.dispatcher_port = dp end @@ -173,6 +176,7 @@ Debugger.value_as_nested_element = options.value_as_nested_element || options.rm Debugger.key_value_mode = options.key_value_mode if options.attach_mode + at_exit {Process.kill('INT', options.gdb_wrapper_pid)} if options.gdb_wrapper_pid if Debugger::FRONT_END == "debase" Debugger.init_variables end