class EnvUtil::Debugger
Constants
- PRECOMMAND
-
sudo -n: βnon-interactive
Attributes
Public Class Methods
Source
# File lib/envutil.rb, line 136 def command_file(file) "--command=#{file}"; end
Source
# File lib/envutil.rb, line 98 def initialize(name, &block) @name = name instance_eval(&block) end
Source
# File lib/envutil.rb, line 94 def self.register(name, &block) @list << new(name, &block) end
Source
# File lib/envutil.rb, line 150 def self.search # Cache the result even when no debugger is available, not to probe # unusable debuggers repeatedly. return @debugger if defined?(@debugger) @debugger = @list.find(&:usable?) end
Source
# File lib/envutil.rb, line 133 def start(pid, *args, **opts) spawn(*%W[gdb --batch --quiet --pid #{pid}], *args, **opts) end
Source
# File lib/envutil.rb, line 132 def usable?; system(*%w[gdb --batch --quiet --nx -ex exit], out: IO::NULL, err: IO::NULL); end
Public Instance Methods
Source
# File lib/envutil.rb, line 107 def dump(pid, timeout: 60, reprieve: timeout&.div(4)) dpid = start(pid, *command_file(File.join(__dir__, "dump.#{name}")), out: :err) rescue Errno::ENOENT return else return unless dpid [[timeout, :TERM], [reprieve, :KILL]].find do |t, sig| begin return EnvUtil.timeout(t) {Process.wait(dpid)} rescue Timeout::Error Process.kill(sig, dpid) end end true end
Source
# File lib/envutil.rb, line 126 def spawn(*args, **opts) super(*PRECOMMAND, *args, **opts) end
Calls superclass method