ruby-dtrace-consumer 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENCE +20 -0
- data/README.md +51 -0
- data/ext/Makefile +187 -0
- data/ext/dtrace_aggdata.c +132 -0
- data/ext/dtrace_aggdata.c~ +141 -0
- data/ext/dtrace_aggdata.o +0 -0
- data/ext/dtrace_api.bundle +0 -0
- data/ext/dtrace_api.c +102 -0
- data/ext/dtrace_api.c~ +113 -0
- data/ext/dtrace_api.h +138 -0
- data/ext/dtrace_api.h~ +155 -0
- data/ext/dtrace_api.o +0 -0
- data/ext/dtrace_bufdata.c +130 -0
- data/ext/dtrace_bufdata.c~ +139 -0
- data/ext/dtrace_bufdata.o +0 -0
- data/ext/dtrace_dropdata.c +121 -0
- data/ext/dtrace_dropdata.c~ +131 -0
- data/ext/dtrace_dropdata.o +0 -0
- data/ext/dtrace_errdata.c +100 -0
- data/ext/dtrace_errdata.c~ +110 -0
- data/ext/dtrace_errdata.o +0 -0
- data/ext/dtrace_hdl.c +677 -0
- data/ext/dtrace_hdl.c~ +689 -0
- data/ext/dtrace_hdl.o +0 -0
- data/ext/dtrace_probedata.c +273 -0
- data/ext/dtrace_probedata.c~ +283 -0
- data/ext/dtrace_probedata.o +0 -0
- data/ext/dtrace_probedesc.c +93 -0
- data/ext/dtrace_probedesc.c~ +78 -0
- data/ext/dtrace_probedesc.o +0 -0
- data/ext/dtrace_process.c +44 -0
- data/ext/dtrace_process.c~ +56 -0
- data/ext/dtrace_process.o +0 -0
- data/ext/dtrace_program.c +52 -0
- data/ext/dtrace_program.c~ +62 -0
- data/ext/dtrace_program.o +0 -0
- data/ext/dtrace_programinfo.c +70 -0
- data/ext/dtrace_programinfo.c~ +60 -0
- data/ext/dtrace_programinfo.o +0 -0
- data/ext/dtrace_recdesc.c +37 -0
- data/ext/dtrace_recdesc.c~ +46 -0
- data/ext/dtrace_recdesc.o +0 -0
- data/ext/dtrace_util.c +92 -0
- data/ext/dtrace_util.o +0 -0
- data/ext/extconf.rb +7 -0
- data/lib/dtrace.rb +95 -0
- data/lib/dtrace/aggregate.rb +40 -0
- data/lib/dtrace/aggregateset.rb +19 -0
- data/lib/dtrace/consumer.rb +174 -0
- data/lib/dtrace/data.rb +85 -0
- data/lib/dtrace/dof.rb +8 -0
- data/lib/dtrace/printfrecord.rb +10 -0
- data/lib/dtrace/probedata.rb +23 -0
- data/lib/dtrace/probedesc.rb +15 -0
- data/lib/dtrace/record.rb +11 -0
- data/lib/dtrace/stackrecord.rb +31 -0
- data/lib/dtrace/tracer.rb +35 -0
- data/lib/dtrace/version.rb +8 -0
- data/lib/dtrace/version.rb~ +8 -0
- data/lib/dtraceconsumer.rb +9 -0
- data/test/test_aggregates.rb +45 -0
- data/test/test_drops_errors.rb +166 -0
- data/test/test_dtrace.rb +155 -0
- data/test/test_gc.rb +11 -0
- data/test/test_helper.rb +20 -0
- data/test/test_helper.rb~ +16 -0
- data/test/test_legacy_consumer.rb +47 -0
- data/test/test_probedata.rb +30 -0
- data/test/test_processes.rb +66 -0
- data/test/test_profile.rb +198 -0
- data/test/test_repeat.rb +50 -0
- data/test/test_rubyprobe.rb +52 -0
- data/test/test_rubyprobe.rb~ +52 -0
- data/test/test_typefilter.rb +94 -0
- metadata +121 -0
data/test/test_repeat.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# Test repeatedly using DTrace in the same process. Show that we can
|
4
|
+
# reopen the DTrace handle multiple times, without explictly closing
|
5
|
+
# it (that happens in GC, so in this script that's probably right at
|
6
|
+
# the end).
|
7
|
+
|
8
|
+
class TestRepeat < DTraceTest
|
9
|
+
|
10
|
+
def test_repeats
|
11
|
+
@dtp.close
|
12
|
+
@dtp = nil
|
13
|
+
|
14
|
+
(0..9).each do |i|
|
15
|
+
t = DTrace.new
|
16
|
+
t.setopt("bufsize", "4m")
|
17
|
+
t.setopt("aggsize", "4m")
|
18
|
+
|
19
|
+
progtext = 'syscall:::entry { trace("foo"); }'
|
20
|
+
|
21
|
+
prog = t.compile progtext
|
22
|
+
prog.execute
|
23
|
+
t.go
|
24
|
+
|
25
|
+
# Let some activity happen.
|
26
|
+
sleep 1
|
27
|
+
|
28
|
+
c = DTrace::Consumer.new(t)
|
29
|
+
assert c
|
30
|
+
|
31
|
+
i = 0
|
32
|
+
c.consume do |d|
|
33
|
+
assert d
|
34
|
+
assert_not_nil d.cpu
|
35
|
+
assert_equal 'syscall', d.probe.provider
|
36
|
+
assert_not_nil d.probe.func
|
37
|
+
assert_equal 'entry', d.probe.name
|
38
|
+
|
39
|
+
d.data.each do |r|
|
40
|
+
assert_equal 'foo', r.value
|
41
|
+
end
|
42
|
+
c.finish
|
43
|
+
i = i + 1
|
44
|
+
end
|
45
|
+
assert i > 0
|
46
|
+
|
47
|
+
t.close
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestRubyprobe < DTraceTest
|
4
|
+
|
5
|
+
def test_rubyprobe
|
6
|
+
progtext = <<EOD
|
7
|
+
ruby*:::ruby-probe
|
8
|
+
{
|
9
|
+
trace(copyinstr(arg0));
|
10
|
+
trace(copyinstr(arg1));
|
11
|
+
}
|
12
|
+
EOD
|
13
|
+
|
14
|
+
begin
|
15
|
+
prog = @dtp.compile progtext
|
16
|
+
prog.execute
|
17
|
+
@dtp.go
|
18
|
+
rescue DTrace::Exception
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
if prog
|
23
|
+
|
24
|
+
c = DTrace::Consumer.new(@dtp)
|
25
|
+
|
26
|
+
# Leopard's ruby-probe is DTracer, Solaris's is Tracer.
|
27
|
+
begin
|
28
|
+
trace_module = DTracer
|
29
|
+
rescue NameError
|
30
|
+
begin
|
31
|
+
trace_module = Tracer
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
(0..9).each do |i|
|
36
|
+
trace_module.fire("foo", i.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
data = []
|
40
|
+
c.consume_once do |d|
|
41
|
+
data << d
|
42
|
+
end
|
43
|
+
|
44
|
+
(0..9).each do |i|
|
45
|
+
d = data.shift
|
46
|
+
assert_equal("foo", d.data[0].value)
|
47
|
+
assert_equal(i.to_s, d.data[1].value)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestRubyprobe < DTraceTest
|
4
|
+
|
5
|
+
def test_rubyprobe
|
6
|
+
progtext = <<EOD
|
7
|
+
ruby*:::ruby-probe
|
8
|
+
{
|
9
|
+
trace(copyinstr(arg0));
|
10
|
+
trace(copyinstr(arg1));
|
11
|
+
}
|
12
|
+
EOD
|
13
|
+
|
14
|
+
begin
|
15
|
+
prog = @dtp.compile progtext
|
16
|
+
rescue DTrace::Exception
|
17
|
+
flunk "no ruby probe"
|
18
|
+
end
|
19
|
+
prog.execute
|
20
|
+
@dtp.go
|
21
|
+
|
22
|
+
c = DTrace::Consumer.new(@dtp)
|
23
|
+
|
24
|
+
# Leopard's ruby-probe is DTracer, Solaris's is Tracer.
|
25
|
+
begin
|
26
|
+
trace_module = DTracer
|
27
|
+
rescue NameError
|
28
|
+
begin
|
29
|
+
trace_module = Tracer
|
30
|
+
rescue NameError
|
31
|
+
flunk "no DTracer or Tracer module"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
(0..9).each do |i|
|
36
|
+
trace_module.fire("foo", i.to_s)
|
37
|
+
end
|
38
|
+
|
39
|
+
data = []
|
40
|
+
c.consume_once do |d|
|
41
|
+
data << d
|
42
|
+
end
|
43
|
+
|
44
|
+
(0..9).each do |i|
|
45
|
+
d = data.shift
|
46
|
+
assert_equal("foo", d.data[0].value)
|
47
|
+
assert_equal(i.to_s, d.data[1].value)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# Tests for the feature allowing you to filter DTraceData types
|
4
|
+
|
5
|
+
class TestTypefilter < DTraceTest
|
6
|
+
def test_filter
|
7
|
+
progtext =<<EOD
|
8
|
+
profile-1000
|
9
|
+
{
|
10
|
+
@a[execname] = count();
|
11
|
+
@b[execname] = count();
|
12
|
+
}
|
13
|
+
|
14
|
+
profile-10
|
15
|
+
{
|
16
|
+
trace("foo");
|
17
|
+
printa(@a);
|
18
|
+
printf("bar");
|
19
|
+
printa(@b);
|
20
|
+
}
|
21
|
+
EOD
|
22
|
+
|
23
|
+
prog = @dtp.compile progtext
|
24
|
+
prog.execute
|
25
|
+
@dtp.go
|
26
|
+
|
27
|
+
sleep 1
|
28
|
+
|
29
|
+
c = DTrace::Consumer.new(@dtp)
|
30
|
+
assert c
|
31
|
+
|
32
|
+
data = []
|
33
|
+
c.consume_once(DTrace::AggregateSet) do |d|
|
34
|
+
data << d
|
35
|
+
end
|
36
|
+
|
37
|
+
assert data.length > 0
|
38
|
+
data.each do |d|
|
39
|
+
assert d
|
40
|
+
assert_equal DTrace::Data, d.class
|
41
|
+
d.data.each do |agg|
|
42
|
+
assert_equal DTrace::AggregateSet, agg.class
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_filter_two_classes
|
49
|
+
progtext =<<EOD
|
50
|
+
profile-1000
|
51
|
+
{
|
52
|
+
@a[execname] = count();
|
53
|
+
@b[execname] = count();
|
54
|
+
}
|
55
|
+
|
56
|
+
profile-10
|
57
|
+
{
|
58
|
+
trace("foo");
|
59
|
+
printa(@a);
|
60
|
+
printf("bar");
|
61
|
+
printa(@b);
|
62
|
+
}
|
63
|
+
EOD
|
64
|
+
|
65
|
+
prog = @dtp.compile progtext
|
66
|
+
prog.execute
|
67
|
+
@dtp.go
|
68
|
+
|
69
|
+
sleep 1
|
70
|
+
|
71
|
+
c = DTrace::Consumer.new(@dtp)
|
72
|
+
assert c
|
73
|
+
|
74
|
+
data = []
|
75
|
+
c.consume_once(DTrace::AggregateSet, DTrace::PrintfRecord) do |d|
|
76
|
+
data << d
|
77
|
+
end
|
78
|
+
|
79
|
+
assert data.length > 0
|
80
|
+
data.each do |d|
|
81
|
+
assert d
|
82
|
+
assert_equal DTrace::Data, d.class
|
83
|
+
d.data.each do |r|
|
84
|
+
if r.respond_to?(:add_aggregate)
|
85
|
+
assert_equal DTrace::AggregateSet, r.class
|
86
|
+
else
|
87
|
+
assert_equal DTrace::PrintfRecord, r.class
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
metadata
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-dtrace-consumer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Andrews
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-24 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- chris@nodnol.org
|
17
|
+
executables: []
|
18
|
+
extensions:
|
19
|
+
- ext/extconf.rb
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- lib/dtrace/aggregate.rb
|
23
|
+
- lib/dtrace/aggregateset.rb
|
24
|
+
- lib/dtrace/consumer.rb
|
25
|
+
- lib/dtrace/data.rb
|
26
|
+
- lib/dtrace/dof.rb
|
27
|
+
- lib/dtrace/printfrecord.rb
|
28
|
+
- lib/dtrace/probedata.rb
|
29
|
+
- lib/dtrace/probedesc.rb
|
30
|
+
- lib/dtrace/record.rb
|
31
|
+
- lib/dtrace/stackrecord.rb
|
32
|
+
- lib/dtrace/tracer.rb
|
33
|
+
- lib/dtrace/version.rb
|
34
|
+
- lib/dtrace/version.rb~
|
35
|
+
- lib/dtrace.rb
|
36
|
+
- lib/dtraceconsumer.rb
|
37
|
+
- ext/dtrace_aggdata.c
|
38
|
+
- ext/dtrace_aggdata.c~
|
39
|
+
- ext/dtrace_aggdata.o
|
40
|
+
- ext/dtrace_api.bundle
|
41
|
+
- ext/dtrace_api.c
|
42
|
+
- ext/dtrace_api.c~
|
43
|
+
- ext/dtrace_api.h
|
44
|
+
- ext/dtrace_api.h~
|
45
|
+
- ext/dtrace_api.o
|
46
|
+
- ext/dtrace_bufdata.c
|
47
|
+
- ext/dtrace_bufdata.c~
|
48
|
+
- ext/dtrace_bufdata.o
|
49
|
+
- ext/dtrace_dropdata.c
|
50
|
+
- ext/dtrace_dropdata.c~
|
51
|
+
- ext/dtrace_dropdata.o
|
52
|
+
- ext/dtrace_errdata.c
|
53
|
+
- ext/dtrace_errdata.c~
|
54
|
+
- ext/dtrace_errdata.o
|
55
|
+
- ext/dtrace_hdl.c
|
56
|
+
- ext/dtrace_hdl.c~
|
57
|
+
- ext/dtrace_hdl.o
|
58
|
+
- ext/dtrace_probedata.c
|
59
|
+
- ext/dtrace_probedata.c~
|
60
|
+
- ext/dtrace_probedata.o
|
61
|
+
- ext/dtrace_probedesc.c
|
62
|
+
- ext/dtrace_probedesc.c~
|
63
|
+
- ext/dtrace_probedesc.o
|
64
|
+
- ext/dtrace_process.c
|
65
|
+
- ext/dtrace_process.c~
|
66
|
+
- ext/dtrace_process.o
|
67
|
+
- ext/dtrace_program.c
|
68
|
+
- ext/dtrace_program.c~
|
69
|
+
- ext/dtrace_program.o
|
70
|
+
- ext/dtrace_programinfo.c
|
71
|
+
- ext/dtrace_programinfo.c~
|
72
|
+
- ext/dtrace_programinfo.o
|
73
|
+
- ext/dtrace_recdesc.c
|
74
|
+
- ext/dtrace_recdesc.c~
|
75
|
+
- ext/dtrace_recdesc.o
|
76
|
+
- ext/dtrace_util.c
|
77
|
+
- ext/dtrace_util.o
|
78
|
+
- ext/extconf.rb
|
79
|
+
- ext/Makefile
|
80
|
+
- test/test_aggregates.rb
|
81
|
+
- test/test_drops_errors.rb
|
82
|
+
- test/test_dtrace.rb
|
83
|
+
- test/test_gc.rb
|
84
|
+
- test/test_helper.rb
|
85
|
+
- test/test_helper.rb~
|
86
|
+
- test/test_legacy_consumer.rb
|
87
|
+
- test/test_probedata.rb
|
88
|
+
- test/test_processes.rb
|
89
|
+
- test/test_profile.rb
|
90
|
+
- test/test_repeat.rb
|
91
|
+
- test/test_rubyprobe.rb
|
92
|
+
- test/test_rubyprobe.rb~
|
93
|
+
- test/test_typefilter.rb
|
94
|
+
- README.md
|
95
|
+
- LICENCE
|
96
|
+
homepage: http://github.com/chrisa/ruby-dtrace
|
97
|
+
licenses: []
|
98
|
+
post_install_message:
|
99
|
+
rdoc_options: []
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
- ext
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
none: false
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.8.24
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: DTrace Consumer library for Ruby
|
121
|
+
test_files: []
|