ruby-dtrace 0.0.6 → 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/Manifest.txt +86 -19
- data/README.txt +48 -6
- data/Rakefile +61 -20
- data/examples/scsi.rb +1 -1
- data/ext/dof/Makefile +154 -0
- data/ext/dof/constants.c +57 -0
- data/ext/dof/dof.h +56 -0
- data/ext/dof/dof_api.c +58 -0
- data/ext/dof/dof_helper.c +82 -0
- data/ext/dof/extconf.rb +4 -0
- data/ext/dof/file.c +90 -0
- data/ext/dof/generator.c +9 -0
- data/ext/dof/header.c +79 -0
- data/ext/dof/mkmf.log +10 -0
- data/ext/dof/parser.c +415 -0
- data/ext/dof/parser.h +10 -0
- data/ext/dof/section.c +312 -0
- data/ext/dtrace_aggdata.c +2 -2
- data/ext/dtrace_api.c +46 -34
- data/ext/dtrace_api.h +31 -7
- data/ext/dtrace_bufdata.c +3 -3
- data/ext/dtrace_hdl.c +66 -3
- data/ext/dtrace_probedata.c +4 -4
- data/ext/{dtrace_probe.c → dtrace_probedesc.c} +7 -7
- data/ext/extconf.rb +25 -0
- data/ext/i386-darwin/dtrace_probe.c +278 -0
- data/ext/i386-solaris/dtrace_probe.c +225 -0
- data/ext/stubs.txt +78 -0
- data/lib/dtrace.rb +34 -13
- 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 +82 -0
- data/lib/dtrace/dof.rb +8 -0
- data/lib/dtrace/dof/file.rb +64 -0
- data/lib/dtrace/dof/section.rb +75 -0
- data/lib/dtrace/dof/section/strtab.rb +28 -0
- data/lib/{dtraceprintfrecord.rb → dtrace/printfrecord.rb} +4 -2
- data/lib/dtrace/probe.rb +3 -6
- data/lib/dtrace/probedata.rb +23 -0
- data/lib/dtrace/probedesc.rb +15 -0
- data/lib/dtrace/provider.rb +190 -169
- data/lib/dtrace/provider/klass.rb +33 -0
- data/lib/dtrace/provider/probedef.rb +24 -0
- data/lib/{dtracerecord.rb → dtrace/record.rb} +4 -2
- data/lib/{dtracestackrecord.rb → dtrace/stackrecord.rb} +10 -8
- data/lib/dtrace/version.rb +9 -0
- data/lib/dtraceconsumer.rb +3 -167
- data/plugin/dtrace/lib/dtracer.rb +4 -4
- data/test/apple-dof +0 -0
- data/test/disabled_probe_effect.txt +19 -0
- data/test/dof +0 -0
- data/test/dof2 +0 -0
- data/test/test_disabled_probe_effect.rb +56 -0
- data/test/test_dof_generator.rb +142 -0
- data/test/test_dof_helper.rb +106 -0
- data/test/test_dof_parser.rb +27 -0
- data/test/test_dof_providers.rb +278 -0
- data/test/test_dof_strtabs.rb +98 -0
- data/test/test_dtrace.rb +67 -1
- data/test/test_dtrace_aggregates.rb +5 -5
- data/test/test_dtrace_drops_errors.rb +5 -5
- data/test/test_dtrace_probe.rb +385 -0
- data/test/test_dtrace_probes.rb +414 -0
- data/test/test_dtrace_processes.rb +2 -2
- data/test/test_dtrace_profile.rb +12 -12
- data/test/test_dtrace_provider.rb +138 -0
- data/test/test_dtrace_repeat.rb +1 -1
- data/test/test_dtrace_rubyprobe.rb +3 -1
- data/test/test_dtrace_typefilter.rb +9 -9
- data/test/test_legacy_consumer.rb +56 -0
- metadata +112 -71
- data/lib/dtrace/provider/osx.rb +0 -25
- data/lib/dtrace/provider/solaris.rb +0 -29
- data/lib/dtraceaggregate.rb +0 -37
- data/lib/dtraceaggregateset.rb +0 -17
- data/lib/dtracedata.rb +0 -80
- data/lib/dtraceprobe.rb +0 -13
- data/lib/dtraceprobedata.rb +0 -21
- data/test/test_dynusdt.rb +0 -135
data/lib/dtrace/provider/osx.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
class Dtrace
|
7
|
-
class Provider
|
8
|
-
class OSX < Provider
|
9
|
-
|
10
|
-
# build the .bundle
|
11
|
-
def ruby_object
|
12
|
-
run "#{Config::CONFIG['LDSHARED']} -I #{hdrdir} -o #{@tempdir}/#{@name}.bundle #{@tempdir}/probes.c"
|
13
|
-
end
|
14
|
-
|
15
|
-
def dtrace_object
|
16
|
-
# no-op on OSX
|
17
|
-
end
|
18
|
-
|
19
|
-
def link
|
20
|
-
# no-op on OSX
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'rbconfig'
|
7
|
-
|
8
|
-
class Dtrace
|
9
|
-
class Provider
|
10
|
-
class Solaris < Provider
|
11
|
-
|
12
|
-
# build the .o
|
13
|
-
def ruby_object
|
14
|
-
run "#{Config::CONFIG['CC']} -I#{hdrdir} -o #{@tempdir}/#{@name}.o -c #{@tempdir}/probes.c"
|
15
|
-
end
|
16
|
-
|
17
|
-
# build the dtrace.o (dtrace -G)
|
18
|
-
def dtrace_object
|
19
|
-
run "/usr/sbin/dtrace -G -s #{@tempdir}/probes.d -o #{@tempdir}/probes.o #{@tempdir}/#{@name}.o"
|
20
|
-
end
|
21
|
-
|
22
|
-
# build the .so
|
23
|
-
def link
|
24
|
-
run "#{Config::CONFIG['CC']} -shared -o #{@tempdir}/#{@name}.so #{@tempdir}/#{@name}.o #{@tempdir}/probes.o"
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/dtraceaggregate.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
# Represents an aggregation record built from a series of
|
7
|
-
# DtraceAggData records.
|
8
|
-
#
|
9
|
-
# Intended to to built up by calling +add_record+ repeatedly with
|
10
|
-
# DtraceAggData objects until a completed DtraceAggregate is returned.
|
11
|
-
# (until a complete record is available, +add_record+ returns nil).
|
12
|
-
#
|
13
|
-
# See dtraceconsumer.rb for an example of this.
|
14
|
-
class DtraceAggregate
|
15
|
-
attr_reader :value, :tuple
|
16
|
-
|
17
|
-
# Create an empty DtraceAggregate: use +add_record+ to add data.
|
18
|
-
def initialize
|
19
|
-
@tuple = Array.new
|
20
|
-
end
|
21
|
-
|
22
|
-
# Add a DtraceAggData record to this aggregate. Returns nil until it
|
23
|
-
# receives a record of aggtype "last", when it returns the complete
|
24
|
-
# DtraceAggregate.
|
25
|
-
def add_record(r)
|
26
|
-
case r.aggtype
|
27
|
-
when "tuple"
|
28
|
-
@tuple << r.value
|
29
|
-
when "value"
|
30
|
-
@value = r.value
|
31
|
-
when "last"
|
32
|
-
return self
|
33
|
-
end
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
data/lib/dtraceaggregateset.rb
DELETED
data/lib/dtracedata.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
# The object returned from a consumer when a probe fires. Accumulates
|
6
|
-
# records from the callbacks, and is yielded when the data is complete.
|
7
|
-
class DtraceData
|
8
|
-
attr_reader :data
|
9
|
-
attr_reader :probe
|
10
|
-
attr_reader :cpu, :indent, :prefix, :flow
|
11
|
-
|
12
|
-
def initialize(types)
|
13
|
-
@types = types
|
14
|
-
@data = []
|
15
|
-
@curraggset = nil
|
16
|
-
@curragg = nil
|
17
|
-
end
|
18
|
-
|
19
|
-
def add_data(d)
|
20
|
-
if @types.length == 0 || @types.include?(d.class)
|
21
|
-
@data << d
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def finish
|
26
|
-
if @curraggset
|
27
|
-
add_data(@curraggset)
|
28
|
-
@curraggset = nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def add_recdata(rec)
|
33
|
-
if @curraggset
|
34
|
-
add_data(@curraggset)
|
35
|
-
@curraggset = nil
|
36
|
-
end
|
37
|
-
if rec.action == "printa"
|
38
|
-
@curraggset = DtraceAggregateSet.new
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def add_probedata(probedata)
|
43
|
-
probedata.each_record do |p|
|
44
|
-
add_data(p)
|
45
|
-
end
|
46
|
-
|
47
|
-
# Record the probe that fired, and CPU/indent/prefix/flow
|
48
|
-
@probe = probedata.probe
|
49
|
-
@cpu = probedata.cpu
|
50
|
-
@indent = probedata.indent
|
51
|
-
@prefix = probedata.prefix
|
52
|
-
@flow = probedata.flow
|
53
|
-
end
|
54
|
-
|
55
|
-
def add_bufdata(buf)
|
56
|
-
r = buf.record
|
57
|
-
# buf records can be empty (trace();)
|
58
|
-
if r
|
59
|
-
case r.class.to_s
|
60
|
-
when DtraceStackRecord.to_s
|
61
|
-
add_data(r)
|
62
|
-
when DtraceRecord.to_s
|
63
|
-
add_data(r)
|
64
|
-
when DtracePrintfRecord.to_s
|
65
|
-
add_data(r)
|
66
|
-
when DtraceAggData.to_s
|
67
|
-
if @curragg == nil
|
68
|
-
@curragg = DtraceAggregate.new
|
69
|
-
end
|
70
|
-
if agg = @curragg.add_record(r)
|
71
|
-
if @curraggset
|
72
|
-
@curraggset.add_aggregate(@curragg)
|
73
|
-
end
|
74
|
-
@curragg = nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
data/lib/dtraceprobe.rb
DELETED
data/lib/dtraceprobedata.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
class DtraceProbeData
|
7
|
-
|
8
|
-
def records
|
9
|
-
records = Array.new
|
10
|
-
self.each_record do |rec|
|
11
|
-
records << rec
|
12
|
-
end
|
13
|
-
records
|
14
|
-
end
|
15
|
-
|
16
|
-
def to_s
|
17
|
-
rs = self.records
|
18
|
-
rs.map {|r| r.value }.join ', '
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
data/test/test_dynusdt.rb
DELETED
@@ -1,135 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Ruby-Dtrace
|
3
|
-
# (c) 2007 Chris Andrews <chris@nodnol.org>
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'dtrace'
|
7
|
-
require 'dtrace/provider'
|
8
|
-
require 'test/unit'
|
9
|
-
require 'rbconfig'
|
10
|
-
|
11
|
-
# Tests for the Dtrace "dynamic USDT" library
|
12
|
-
|
13
|
-
class TestDynUsdt < Test::Unit::TestCase
|
14
|
-
|
15
|
-
def test_create_usdt
|
16
|
-
Dtrace::Provider.create :test_provider_create_usdt do |p|
|
17
|
-
p.probe :test_probe, :string
|
18
|
-
end
|
19
|
-
|
20
|
-
t = Dtrace.new
|
21
|
-
t.setopt("bufsize", "4m")
|
22
|
-
|
23
|
-
progtext = 'test_provider_create_usdt*:::test-probe { trace(copyinstr(arg0)); }'
|
24
|
-
|
25
|
-
prog = t.compile progtext
|
26
|
-
prog.execute
|
27
|
-
t.go
|
28
|
-
|
29
|
-
c = DtraceConsumer.new(t)
|
30
|
-
|
31
|
-
Dtrace::Probe::TestProviderCreateUsdt.test_probe do |p|
|
32
|
-
p.fire "test_argument"
|
33
|
-
end
|
34
|
-
|
35
|
-
i = 0
|
36
|
-
c.consume_once do |d|
|
37
|
-
i = i + 1
|
38
|
-
assert d
|
39
|
-
assert_not_nil d.probe
|
40
|
-
assert_equal "test_provider_create_usdt#{$$.to_s}:test_provider_create_usdt.#{Config::CONFIG['DLEXT']}:test_probe:test-probe", d.probe.to_s
|
41
|
-
assert_equal 1, d.data.length
|
42
|
-
assert_equal "test_argument", d.data[0].value
|
43
|
-
end
|
44
|
-
assert_equal 1, i
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_create_usdt_argtypes
|
48
|
-
Dtrace::Provider.create :test_provider_create_usdt_argtypes do |p|
|
49
|
-
p.probe :test_probe_string, :string
|
50
|
-
p.probe :test_probe_int, :integer
|
51
|
-
end
|
52
|
-
|
53
|
-
t = Dtrace.new
|
54
|
-
t.setopt("bufsize", "4m")
|
55
|
-
|
56
|
-
progtext = <<EOD
|
57
|
-
test_provider_create_usdt_argtypes*:::test-probe-string { trace(copyinstr(arg0)); }
|
58
|
-
test_provider_create_usdt_argtypes*:::test-probe-int { trace(arg0); }
|
59
|
-
EOD
|
60
|
-
|
61
|
-
prog = t.compile progtext
|
62
|
-
prog.execute
|
63
|
-
t.go
|
64
|
-
|
65
|
-
c = DtraceConsumer.new(t)
|
66
|
-
|
67
|
-
Dtrace::Probe::TestProviderCreateUsdtArgtypes.test_probe_string do |p|
|
68
|
-
p.fire "test_argument"
|
69
|
-
end
|
70
|
-
|
71
|
-
Dtrace::Probe::TestProviderCreateUsdtArgtypes.test_probe_int do |p|
|
72
|
-
p.fire 42
|
73
|
-
end
|
74
|
-
|
75
|
-
i = 0
|
76
|
-
c.consume_once do |d|
|
77
|
-
assert d
|
78
|
-
assert_not_nil d.probe
|
79
|
-
if d.probe.name == 'test-probe-string'
|
80
|
-
assert_equal "test_argument", d.data[0].value
|
81
|
-
i = i + 1
|
82
|
-
elsif d.probe.name == 'test-probe-int'
|
83
|
-
assert_equal 42, d.data[0].value
|
84
|
-
i = i + 1
|
85
|
-
end
|
86
|
-
end
|
87
|
-
assert_equal 2, i
|
88
|
-
end
|
89
|
-
|
90
|
-
def test_create_usdt_manyargs
|
91
|
-
Dtrace::Provider.create :test_provider_create_usdt_manyargs do |p|
|
92
|
-
p.probe :test_probe, :string, :string, :string, :string, :string, :string, :string, :string
|
93
|
-
end
|
94
|
-
|
95
|
-
t = Dtrace.new
|
96
|
-
t.setopt("bufsize", "4m")
|
97
|
-
|
98
|
-
progtext = <<EOD
|
99
|
-
test_provider_create_usdt_manyargs*:::test-probe
|
100
|
-
{
|
101
|
-
trace(copyinstr(arg0));
|
102
|
-
trace(copyinstr(arg1));
|
103
|
-
trace(copyinstr(arg2));
|
104
|
-
trace(copyinstr(arg3));
|
105
|
-
trace(copyinstr(arg4));
|
106
|
-
trace(copyinstr(arg5));
|
107
|
-
trace(copyinstr(arg6));
|
108
|
-
trace(copyinstr(arg7));
|
109
|
-
}
|
110
|
-
EOD
|
111
|
-
|
112
|
-
prog = t.compile progtext
|
113
|
-
prog.execute
|
114
|
-
t.go
|
115
|
-
|
116
|
-
c = DtraceConsumer.new(t)
|
117
|
-
|
118
|
-
Dtrace::Probe::TestProviderCreateUsdtManyargs.test_probe do |p|
|
119
|
-
values_list = (0..7).map {|i| "value #{i.to_s}" }
|
120
|
-
p.fire(*values_list)
|
121
|
-
end
|
122
|
-
|
123
|
-
i = 0
|
124
|
-
c.consume_once do |d|
|
125
|
-
i = i + 1
|
126
|
-
assert_equal 8, d.data.length
|
127
|
-
(0..7).each do |j|
|
128
|
-
assert_equal "value #{j.to_s}", d.data[j].value
|
129
|
-
end
|
130
|
-
end
|
131
|
-
assert_equal 1, i
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
|