class RbBCC::USDT

Attributes

context[R]
path[R]
pid[R]

Public Class Methods

new(pid: nil, path: nil) click to toggle source
# File lib/rbbcc/usdt.rb, line 7
def initialize(pid: nil, path: nil)
  @pid = pid
  @path = path
  if pid
    @context = Clib.bcc_usdt_new_frompid(pid, path)
  elsif path
    @context = Clib.bcc_usdt_new_frompath(path)
  else
    raise "Either a pid or a binary path must be specified"
  end
  if !@context || @context.null?
    raise SystemCallError.new(Fiddle.last_error)
  end
end

Public Instance Methods

enable_probe(probe:, fn_name:) click to toggle source
# File lib/rbbcc/usdt.rb, line 23
def enable_probe(probe:, fn_name:)
  ret = Clib.bcc_usdt_enable_probe(@context, probe, fn_name)
  if(ret < 0)
    raise SystemCallError.new(Fiddle.last_error)
  end
  ret
end
enumerate_active_probes() click to toggle source
# File lib/rbbcc/usdt.rb, line 31
def enumerate_active_probes
  probes = []
  callback = Clib.bind('void _usdt_cb(char *, char *, unsigned long long, int)') do |binpath, fn_name, addr, pid|
    probe = USDTProbe.new(Clib.__extract_char(binpath), Clib.__extract_char(fn_name), addr, pid)
    probes << probe
  end

  Clib.bcc_usdt_foreach_uprobe(@context, callback)

  return probes
end

Private Instance Methods

__del__() click to toggle source
# File lib/rbbcc/usdt.rb, line 44
def __del__
  lambda { Clib.bcc_usdt_close(@context); Util.debug("USDT GC'ed.") }
end