Class: RbBCC::USDT
- Inherits:
-
Object
- Object
- RbBCC::USDT
- Defined in:
- lib/rbbcc/usdt.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
Instance Method Summary collapse
- #enable_probe(probe:, fn_name:) ⇒ Object
- #enumerate_active_probes ⇒ Object
-
#initialize(pid: nil, path: nil) ⇒ USDT
constructor
A new instance of USDT.
Constructor Details
#initialize(pid: nil, path: nil) ⇒ USDT
Returns a new instance of USDT.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# 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 |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
21 22 23 |
# File 'lib/rbbcc/usdt.rb', line 21 def context @context end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
21 22 23 |
# File 'lib/rbbcc/usdt.rb', line 21 def path @path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
21 22 23 |
# File 'lib/rbbcc/usdt.rb', line 21 def pid @pid end |
Instance Method Details
#enable_probe(probe:, fn_name:) ⇒ Object
23 24 25 26 27 28 29 |
# 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 ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# 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 |