class EnvUtil::Debugger

Constants

PRECOMMAND

sudo -n: –non-interactive

Attributes

name[RW]

Public Class Methods

command_file(file) click to toggle source
# File lib/envutil.rb, line 128
def command_file(file) "--command=#{file}"; end
new(name, &block) click to toggle source
# File lib/envutil.rb, line 90
def initialize(name, &block)
  @name = name
  instance_eval(&block)
end
register(name, &block) click to toggle source
# File lib/envutil.rb, line 86
def self.register(name, &block)
  @list << new(name, &block)
end
start(pid, *args, **opts) click to toggle source
# File lib/envutil.rb, line 125
def start(pid, *args, **opts)
  spawn(*%W[gdb --batch --quiet --pid #{pid}], *args, **opts)
end
usable?() click to toggle source
# File lib/envutil.rb, line 124
def usable?; system(*%w[gdb --batch --quiet --nx -ex exit]); end

Public Instance Methods

dump(pid, timeout: 60, reprieve: timeout&.div(4)) click to toggle source
# File lib/envutil.rb, line 99
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
spawn(*args, **opts) click to toggle source
Calls superclass method
# File lib/envutil.rb, line 118
def spawn(*args, **opts)
  super(*PRECOMMAND, *args, **opts)
end
start(pid, *args) click to toggle source
# File lib/envutil.rb, line 97
def start(pid, *args) end
usable?() click to toggle source
# File lib/envutil.rb, line 95
def usable?; false; end