Skip to content

Commit 7e69ab7

Browse files
committed
refactoring -- moved trap initialization to main
1 parent 1e091ce commit 7e69ab7

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

bin/gdb_wrapper

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ require 'ruby-debug-ide/attach/native_debugger'
7979
require 'ruby-debug-ide/attach/process_thread'
8080

8181
debugger = choose_debugger(options.ruby_path, options.pid, options.gems_to_include, debugger_loader_path, argv)
82+
83+
trap('INT') do
84+
unless debugger.pipe.closed?
85+
$stderr.puts "backtraces for threads:\n\n"
86+
debugger.process_threads.each do |thread|
87+
$stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n"
88+
end
89+
end
90+
exit!
91+
end
92+
8293
debugger.attach_to_process
8394
debugger.set_flags
8495

lib/ruby-debug-ide/attach/util.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,5 @@ def choose_debugger(ruby_path, pid, gems_to_include, debugger_loader_path, argv)
2121
raise 'Neither gdb nor lldb was found. Aborting.'
2222
end
2323

24-
trap('INT') do
25-
unless debugger.pipe.closed?
26-
$stderr.puts "backtraces for threads:\n\n"
27-
debugger.process_threads.each do |thread|
28-
$stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n"
29-
end
30-
end
31-
exit!
32-
end
33-
3424
debugger
3525
end

0 commit comments

Comments
 (0)