Skip to content

Commit

Permalink
refactoring -- moved trap initialization to main
Browse files Browse the repository at this point in the history
  • Loading branch information
equivalence1 committed Nov 9, 2016
1 parent 1e091ce commit 7e69ab7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
11 changes: 11 additions & 0 deletions bin/gdb_wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ require 'ruby-debug-ide/attach/native_debugger'
require 'ruby-debug-ide/attach/process_thread'

debugger = choose_debugger(options.ruby_path, options.pid, options.gems_to_include, debugger_loader_path, argv)

trap('INT') do
unless debugger.pipe.closed?
$stderr.puts "backtraces for threads:\n\n"
debugger.process_threads.each do |thread|
$stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n"
end
end
exit!
end

debugger.attach_to_process
debugger.set_flags

Expand Down
10 changes: 0 additions & 10 deletions lib/ruby-debug-ide/attach/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,5 @@ def choose_debugger(ruby_path, pid, gems_to_include, debugger_loader_path, argv)
raise 'Neither gdb nor lldb was found. Aborting.'
end

trap('INT') do
unless debugger.pipe.closed?
$stderr.puts "backtraces for threads:\n\n"
debugger.process_threads.each do |thread|
$stderr.puts "#{thread.thread_info}\n#{thread.last_bt}\n\n"
end
end
exit!
end

debugger
end

0 comments on commit 7e69ab7

Please sign in to comment.