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.
Files changed (81) hide show
  1. data/History.txt +21 -0
  2. data/Manifest.txt +86 -19
  3. data/README.txt +48 -6
  4. data/Rakefile +61 -20
  5. data/examples/scsi.rb +1 -1
  6. data/ext/dof/Makefile +154 -0
  7. data/ext/dof/constants.c +57 -0
  8. data/ext/dof/dof.h +56 -0
  9. data/ext/dof/dof_api.c +58 -0
  10. data/ext/dof/dof_helper.c +82 -0
  11. data/ext/dof/extconf.rb +4 -0
  12. data/ext/dof/file.c +90 -0
  13. data/ext/dof/generator.c +9 -0
  14. data/ext/dof/header.c +79 -0
  15. data/ext/dof/mkmf.log +10 -0
  16. data/ext/dof/parser.c +415 -0
  17. data/ext/dof/parser.h +10 -0
  18. data/ext/dof/section.c +312 -0
  19. data/ext/dtrace_aggdata.c +2 -2
  20. data/ext/dtrace_api.c +46 -34
  21. data/ext/dtrace_api.h +31 -7
  22. data/ext/dtrace_bufdata.c +3 -3
  23. data/ext/dtrace_hdl.c +66 -3
  24. data/ext/dtrace_probedata.c +4 -4
  25. data/ext/{dtrace_probe.c → dtrace_probedesc.c} +7 -7
  26. data/ext/extconf.rb +25 -0
  27. data/ext/i386-darwin/dtrace_probe.c +278 -0
  28. data/ext/i386-solaris/dtrace_probe.c +225 -0
  29. data/ext/stubs.txt +78 -0
  30. data/lib/dtrace.rb +34 -13
  31. data/lib/dtrace/aggregate.rb +40 -0
  32. data/lib/dtrace/aggregateset.rb +19 -0
  33. data/lib/dtrace/consumer.rb +174 -0
  34. data/lib/dtrace/data.rb +82 -0
  35. data/lib/dtrace/dof.rb +8 -0
  36. data/lib/dtrace/dof/file.rb +64 -0
  37. data/lib/dtrace/dof/section.rb +75 -0
  38. data/lib/dtrace/dof/section/strtab.rb +28 -0
  39. data/lib/{dtraceprintfrecord.rb → dtrace/printfrecord.rb} +4 -2
  40. data/lib/dtrace/probe.rb +3 -6
  41. data/lib/dtrace/probedata.rb +23 -0
  42. data/lib/dtrace/probedesc.rb +15 -0
  43. data/lib/dtrace/provider.rb +190 -169
  44. data/lib/dtrace/provider/klass.rb +33 -0
  45. data/lib/dtrace/provider/probedef.rb +24 -0
  46. data/lib/{dtracerecord.rb → dtrace/record.rb} +4 -2
  47. data/lib/{dtracestackrecord.rb → dtrace/stackrecord.rb} +10 -8
  48. data/lib/dtrace/version.rb +9 -0
  49. data/lib/dtraceconsumer.rb +3 -167
  50. data/plugin/dtrace/lib/dtracer.rb +4 -4
  51. data/test/apple-dof +0 -0
  52. data/test/disabled_probe_effect.txt +19 -0
  53. data/test/dof +0 -0
  54. data/test/dof2 +0 -0
  55. data/test/test_disabled_probe_effect.rb +56 -0
  56. data/test/test_dof_generator.rb +142 -0
  57. data/test/test_dof_helper.rb +106 -0
  58. data/test/test_dof_parser.rb +27 -0
  59. data/test/test_dof_providers.rb +278 -0
  60. data/test/test_dof_strtabs.rb +98 -0
  61. data/test/test_dtrace.rb +67 -1
  62. data/test/test_dtrace_aggregates.rb +5 -5
  63. data/test/test_dtrace_drops_errors.rb +5 -5
  64. data/test/test_dtrace_probe.rb +385 -0
  65. data/test/test_dtrace_probes.rb +414 -0
  66. data/test/test_dtrace_processes.rb +2 -2
  67. data/test/test_dtrace_profile.rb +12 -12
  68. data/test/test_dtrace_provider.rb +138 -0
  69. data/test/test_dtrace_repeat.rb +1 -1
  70. data/test/test_dtrace_rubyprobe.rb +3 -1
  71. data/test/test_dtrace_typefilter.rb +9 -9
  72. data/test/test_legacy_consumer.rb +56 -0
  73. metadata +112 -71
  74. data/lib/dtrace/provider/osx.rb +0 -25
  75. data/lib/dtrace/provider/solaris.rb +0 -29
  76. data/lib/dtraceaggregate.rb +0 -37
  77. data/lib/dtraceaggregateset.rb +0 -17
  78. data/lib/dtracedata.rb +0 -80
  79. data/lib/dtraceprobe.rb +0 -13
  80. data/lib/dtraceprobedata.rb +0 -21
  81. data/test/test_dynusdt.rb +0 -135
@@ -0,0 +1,138 @@
1
+ #
2
+ # Ruby-Dtrace
3
+ # (c) 2008 Chris Andrews <chris@nodnol.org>
4
+ #
5
+
6
+ require 'dtrace'
7
+ require 'dtrace/provider'
8
+ require 'test/unit'
9
+
10
+ class TestDtraceProvider < Test::Unit::TestCase
11
+
12
+ def test_massive_provider
13
+ probecount = 2950
14
+ Dtrace::Provider.create :test_massive1 do |p|
15
+ (1 .. probecount).each do |i|
16
+ p.probe "#{i}".to_sym
17
+ end
18
+ end
19
+
20
+ t = Dtrace.new
21
+ matches = 0
22
+ t.each_probe("test_massive1#{$$}:ruby:test_massive_provider:") do |p|
23
+ matches += 1
24
+ end
25
+ assert_equal probecount, matches
26
+ end
27
+
28
+ def test_probe_with_function_no_args
29
+ Dtrace::Provider.create :test10 do |p|
30
+ p.probe :test, { :function => :foo }
31
+ end
32
+
33
+ t = Dtrace.new
34
+ matches = 0
35
+ t.each_probe("test10#{$$}:ruby:foo:test") do |p|
36
+ matches += 1
37
+ end
38
+ assert_equal 1, matches
39
+ end
40
+
41
+ def test_probe_with_function_and_args
42
+ Dtrace::Provider.create :test11 do |p|
43
+ p.probe :test, { :function => :foo }, :integer, :integer
44
+ end
45
+
46
+ t = Dtrace.new
47
+ matches = 0
48
+ t.each_probe("test11#{$$}:ruby:foo:test") do |p|
49
+ matches += 1
50
+ end
51
+ assert_equal 1, matches
52
+ end
53
+
54
+ def test_probe_no_args_module
55
+ Dtrace::Provider.create :test1, { :module => 'testmodule' } do |p|
56
+ p.probe :test
57
+ end
58
+
59
+ t = Dtrace.new
60
+ matches = 0
61
+ t.each_probe("test1#{$$}:testmodule:test_probe_no_args_module:test") do |p|
62
+ matches += 1
63
+ end
64
+ assert_equal 1, matches
65
+ end
66
+
67
+ def test_probe_with_char_arg
68
+ Dtrace::Provider.create :test2 do |p|
69
+ p.probe :test, :string
70
+ end
71
+
72
+ t = Dtrace.new
73
+ matches = 0
74
+ t.each_probe("test2#{$$}:ruby:test_probe_with_char_arg:test") do |p|
75
+ matches += 1
76
+ end
77
+ assert_equal 1, matches
78
+ end
79
+
80
+ def test_probe_with_int_arg
81
+ Dtrace::Provider.create :test3 do |p|
82
+ p.probe :test, :integer
83
+ end
84
+
85
+ t = Dtrace.new
86
+ matches = 0
87
+ t.each_probe("test3#{$$}:ruby:test_probe_with_int_arg:test") do |p|
88
+ matches += 1
89
+ end
90
+ assert_equal 1, matches
91
+ end
92
+
93
+ def test_probe_with_two_args
94
+ Dtrace::Provider.create :test4 do |p|
95
+ p.probe :test, :integer, :integer
96
+ end
97
+
98
+ t = Dtrace.new
99
+ matches = 0
100
+ t.each_probe("test4#{$$}:ruby:test_probe_with_two_args:test") do |p|
101
+ matches += 1
102
+ end
103
+ assert_equal 1, matches
104
+ end
105
+
106
+ def test_multiple_probes_with_two_args
107
+ Dtrace::Provider.create :test5 do |p|
108
+ p.probe :test1, :integer, :integer
109
+ p.probe :test2, :integer, :integer
110
+ end
111
+
112
+ t = Dtrace.new
113
+ matches = 0
114
+ t.each_probe("test5#{$$}:ruby:test_multiple_probes_with_two_args:") do |p|
115
+ matches += 1
116
+ end
117
+ assert_equal 2, matches
118
+ end
119
+
120
+ def test_multiple_probes
121
+ Dtrace::Provider.create :test6 do |p|
122
+ p.probe :test1, :integer
123
+ p.probe :test2, :integer
124
+ p.probe :test3, :integer
125
+ p.probe :test4, :integer
126
+ p.probe :test5, :integer
127
+ end
128
+
129
+ t = Dtrace.new
130
+ matches = 0
131
+ t.each_probe("test6#{$$}:ruby:test_multiple_probes:") do |p|
132
+ matches += 1
133
+ end
134
+ assert_equal 5, matches
135
+ end
136
+
137
+ end
138
+
@@ -28,7 +28,7 @@ class TestDtraceRepeat < Test::Unit::TestCase
28
28
  # Let some activity happen.
29
29
  sleep 1
30
30
 
31
- c = DtraceConsumer.new(t)
31
+ c = Dtrace::Consumer.new(t)
32
32
  assert c
33
33
 
34
34
  i = 0
@@ -8,6 +8,8 @@ require 'test/unit'
8
8
 
9
9
  class TestDtrace < Test::Unit::TestCase
10
10
  def test_rubyprobe
11
+ flunk # platform test for Joyent patched Ruby
12
+
11
13
  t = Dtrace.new
12
14
  t.setopt("bufsize", "4m")
13
15
 
@@ -23,7 +25,7 @@ EOD
23
25
  prog.execute
24
26
  t.go
25
27
 
26
- c = DtraceConsumer.new(t)
28
+ c = Dtrace::Consumer.new(t)
27
29
 
28
30
  # Leopard's ruby-probe is DTracer, Solaris's is Tracer.
29
31
  begin
@@ -36,20 +36,20 @@ EOD
36
36
 
37
37
  sleep 1
38
38
 
39
- c = DtraceConsumer.new(t)
39
+ c = Dtrace::Consumer.new(t)
40
40
  assert c
41
41
 
42
42
  data = []
43
- c.consume_once(DtraceAggregateSet) do |d|
43
+ c.consume_once(Dtrace::AggregateSet) do |d|
44
44
  data << d
45
45
  end
46
46
 
47
47
  assert data.length > 0
48
48
  data.each do |d|
49
49
  assert d
50
- assert_equal DtraceData, d.class
50
+ assert_equal Dtrace::Data, d.class
51
51
  d.data.each do |agg|
52
- assert_equal DtraceAggregateSet, agg.class
52
+ assert_equal Dtrace::AggregateSet, agg.class
53
53
  end
54
54
  end
55
55
 
@@ -82,23 +82,23 @@ EOD
82
82
 
83
83
  sleep 1
84
84
 
85
- c = DtraceConsumer.new(t)
85
+ c = Dtrace::Consumer.new(t)
86
86
  assert c
87
87
 
88
88
  data = []
89
- c.consume_once(DtraceAggregateSet, DtracePrintfRecord) do |d|
89
+ c.consume_once(Dtrace::AggregateSet, Dtrace::PrintfRecord) do |d|
90
90
  data << d
91
91
  end
92
92
 
93
93
  assert data.length > 0
94
94
  data.each do |d|
95
95
  assert d
96
- assert_equal DtraceData, d.class
96
+ assert_equal Dtrace::Data, d.class
97
97
  d.data.each do |r|
98
98
  if r.respond_to?(:add_aggregate)
99
- assert_equal DtraceAggregateSet, r.class
99
+ assert_equal Dtrace::AggregateSet, r.class
100
100
  else
101
- assert_equal DtracePrintfRecord, r.class
101
+ assert_equal Dtrace::PrintfRecord, r.class
102
102
  end
103
103
  end
104
104
  end
@@ -0,0 +1,56 @@
1
+ #
2
+ # Ruby-Dtrace
3
+ # (c) 2007 Chris Andrews <chris@nodnol.org>
4
+ #
5
+
6
+ require 'dtrace'
7
+ require 'test/unit'
8
+
9
+ # Tests using the DTrace profile provider.
10
+
11
+ class TestLegacyConsumer < Test::Unit::TestCase
12
+ def test_aggregate_group
13
+ t = Dtrace.new
14
+ t.setopt("bufsize", "4m")
15
+ t.setopt("aggsize", "4m")
16
+
17
+ progtext =<<EOD
18
+ profile-1000
19
+ {
20
+ @a[execname] = count();
21
+ @b[execname] = count();
22
+ }
23
+
24
+ profile-1
25
+ {
26
+ printa(@a);
27
+ printa(@b);
28
+ }
29
+ EOD
30
+
31
+ prog = t.compile progtext
32
+ prog.execute
33
+ t.go
34
+
35
+ sleep 3
36
+
37
+ c = DtraceConsumer.new(t)
38
+ assert c
39
+
40
+ data = []
41
+ c.consume_once do |d|
42
+ data << d
43
+ end
44
+
45
+ assert data.length > 0
46
+ data.each do |d|
47
+ assert d
48
+ assert_equal Dtrace::Data, d.class
49
+ d.data.each do |agg|
50
+ assert_equal Dtrace::AggregateSet, agg.class
51
+ end
52
+ end
53
+
54
+ end
55
+
56
+ end
metadata CHANGED
@@ -1,40 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.4
3
- specification_version: 1
4
2
  name: ruby-dtrace
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.6
7
- date: 2008-02-17 00:00:00 +00:00
8
- summary: Ruby bindings for libdtrace
9
- require_paths:
10
- - lib
11
- - ext
12
- email: chris@nodnol.org
13
- homepage: http://ruby-dtrace.rubyforge.org/
14
- rubyforge_project: ruby-dtrace
15
- description: ruby-dtrace is Ruby bindings for Dtrace, which lets you write D-based programs in Ruby. It doesn't provide D probes for Ruby, but you can use it with the probes found in the Joyent and Apple builds of Ruby.
16
- autorequire:
17
- default_executable:
18
- bindir: bin
19
- has_rdoc: true
20
- required_ruby_version: !ruby/object:Gem::Version::Requirement
21
- requirements:
22
- - - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
25
- version:
4
+ version: 0.2.8
26
5
  platform: ruby
27
- signing_key:
28
- cert_chain:
29
- post_install_message:
30
6
  authors:
31
7
  - Chris Andrews
32
- files:
33
- - History.txt
34
- - Manifest.txt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-07-23 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: chris@nodnol.org
18
+ executables: []
19
+
20
+ extensions:
21
+ - ext/extconf.rb
22
+ - ext/dof/extconf.rb
23
+ extra_rdoc_files:
35
24
  - README.txt
36
- - Rakefile
25
+ files:
37
26
  - examples/scsi.rb
27
+ - ext/dof
28
+ - ext/dof/constants.c
29
+ - ext/dof/dof.h
30
+ - ext/dof/dof_api.c
31
+ - ext/dof/dof_helper.c
32
+ - ext/dof/extconf.rb
33
+ - ext/dof/file.c
34
+ - ext/dof/generator.c
35
+ - ext/dof/header.c
36
+ - ext/dof/Makefile
37
+ - ext/dof/mkmf.log
38
+ - ext/dof/parser.c
39
+ - ext/dof/parser.h
40
+ - ext/dof/section.c
38
41
  - ext/dtrace_aggdata.c
39
42
  - ext/dtrace_api.c
40
43
  - ext/dtrace_api.h
@@ -42,82 +45,120 @@ files:
42
45
  - ext/dtrace_dropdata.c
43
46
  - ext/dtrace_errdata.c
44
47
  - ext/dtrace_hdl.c
45
- - ext/dtrace_probe.c
46
48
  - ext/dtrace_probedata.c
49
+ - ext/dtrace_probedesc.c
47
50
  - ext/dtrace_process.c
48
51
  - ext/dtrace_program.c
49
52
  - ext/dtrace_programinfo.c
50
53
  - ext/dtrace_recdesc.c
51
54
  - ext/dtrace_util.c
52
55
  - ext/extconf.rb
53
- - lib/dtrace.rb
56
+ - ext/i386-solaris
57
+ - ext/i386-solaris/dtrace_probe.c
58
+ - ext/i386-darwin
59
+ - ext/i386-darwin/dtrace_probe.c
60
+ - ext/stubs.txt
61
+ - lib/dtrace
62
+ - lib/dtrace/aggregate.rb
63
+ - lib/dtrace/aggregateset.rb
64
+ - lib/dtrace/consumer.rb
65
+ - lib/dtrace/data.rb
66
+ - lib/dtrace/dof
67
+ - lib/dtrace/dof/file.rb
68
+ - lib/dtrace/dof/section
69
+ - lib/dtrace/dof/section/strtab.rb
70
+ - lib/dtrace/dof/section.rb
71
+ - lib/dtrace/dof.rb
72
+ - lib/dtrace/printfrecord.rb
54
73
  - lib/dtrace/probe.rb
74
+ - lib/dtrace/probedata.rb
75
+ - lib/dtrace/probedesc.rb
76
+ - lib/dtrace/provider
77
+ - lib/dtrace/provider/probedef.rb
78
+ - lib/dtrace/provider/klass.rb
55
79
  - lib/dtrace/provider.rb
56
- - lib/dtrace/provider/osx.rb
57
- - lib/dtrace/provider/solaris.rb
80
+ - lib/dtrace/record.rb
81
+ - lib/dtrace/stackrecord.rb
58
82
  - lib/dtrace/tracer.rb
59
- - lib/dtraceaggregate.rb
60
- - lib/dtraceaggregateset.rb
83
+ - lib/dtrace/version.rb
84
+ - lib/dtrace.rb
61
85
  - lib/dtraceconsumer.rb
62
- - lib/dtracedata.rb
63
- - lib/dtraceprintfrecord.rb
64
- - lib/dtraceprobe.rb
65
- - lib/dtraceprobedata.rb
66
- - lib/dtracerecord.rb
67
- - lib/dtracestackrecord.rb
68
- - plugin/dtrace/README
69
- - plugin/dtrace/Rakefile
86
+ - plugin/dtrace
87
+ - plugin/dtrace/bin
70
88
  - plugin/dtrace/bin/dtracer.rb
71
89
  - plugin/dtrace/init.rb
90
+ - plugin/dtrace/lib
72
91
  - plugin/dtrace/lib/dtrace_helper.rb
73
92
  - plugin/dtrace/lib/dtrace_report.rb
74
93
  - plugin/dtrace/lib/dtracer.rb
75
94
  - plugin/dtrace/lib/dtracer_client.rb
95
+ - plugin/dtrace/public
96
+ - plugin/dtrace/public/stylesheets
76
97
  - plugin/dtrace/public/stylesheets/dtrace.css
98
+ - plugin/dtrace/Rakefile
99
+ - plugin/dtrace/README
100
+ - plugin/dtrace/scripts
77
101
  - plugin/dtrace/scripts/default.d
78
102
  - plugin/dtrace/scripts/rails_mysql.d
103
+ - plugin/dtrace/tasks
79
104
  - plugin/dtrace/tasks/dtrace.rake
105
+ - plugin/dtrace/test
80
106
  - plugin/dtrace/test/dtrace_test.rb
107
+ - plugin/dtrace/views
108
+ - plugin/dtrace/views/dtrace
81
109
  - plugin/dtrace/views/dtrace/_report.rhtml
110
+ - test/apple-dof
111
+ - test/disabled_probe_effect.txt
112
+ - test/dof
113
+ - test/dof2
114
+ - test/test_disabled_probe_effect.rb
115
+ - test/test_dof_generator.rb
116
+ - test/test_dof_helper.rb
117
+ - test/test_dof_parser.rb
118
+ - test/test_dof_providers.rb
119
+ - test/test_dof_strtabs.rb
82
120
  - test/test_dtrace.rb
83
121
  - test/test_dtrace_aggregates.rb
84
122
  - test/test_dtrace_drops_errors.rb
123
+ - test/test_dtrace_probe.rb
124
+ - test/test_dtrace_probes.rb
85
125
  - test/test_dtrace_processes.rb
86
126
  - test/test_dtrace_profile.rb
127
+ - test/test_dtrace_provider.rb
87
128
  - test/test_dtrace_repeat.rb
88
129
  - test/test_dtrace_rubyprobe.rb
89
130
  - test/test_dtrace_typefilter.rb
90
- - test/test_dynusdt.rb
91
- test_files:
92
- - test/test_dtrace.rb
93
- - test/test_dtrace_aggregates.rb
94
- - test/test_dtrace_drops_errors.rb
95
- - test/test_dtrace_processes.rb
96
- - test/test_dtrace_profile.rb
97
- - test/test_dtrace_repeat.rb
98
- - test/test_dtrace_rubyprobe.rb
99
- - test/test_dtrace_typefilter.rb
100
- - test/test_dynusdt.rb
101
- rdoc_options:
102
- - --main
131
+ - test/test_legacy_consumer.rb
103
132
  - README.txt
104
- extra_rdoc_files:
105
133
  - History.txt
106
134
  - Manifest.txt
107
- - README.txt
108
- executables: []
135
+ - Rakefile
136
+ has_rdoc: true
137
+ homepage: http://ruby-dtrace.rubyforge.org
138
+ post_install_message:
139
+ rdoc_options: []
109
140
 
110
- extensions:
111
- - ext/extconf.rb
141
+ require_paths:
142
+ - lib
143
+ - ext
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: "0"
149
+ version:
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: "0"
155
+ version:
112
156
  requirements: []
113
157
 
114
- dependencies:
115
- - !ruby/object:Gem::Dependency
116
- name: hoe
117
- version_requirement:
118
- version_requirements: !ruby/object:Gem::Version::Requirement
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: 1.4.0
123
- version:
158
+ rubyforge_project: ruby-dtrace
159
+ rubygems_version: 1.0.1
160
+ signing_key:
161
+ specification_version: 2
162
+ summary: Ruby-DTrace is Ruby bindings for Dtrace, which allows you to add DTrace probes to your Ruby programs, and to write D-based programs with Ruby.
163
+ test_files: []
164
+