strace_me 1.0

Sign up to get free protection for your applications and to get access to all the features.
Binary file
@@ -0,0 +1,5 @@
1
+ === 1.0.0 / 2010-06-07
2
+
3
+ * Major Enhancement
4
+ * Birthday!
5
+
@@ -0,0 +1,5 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ lib/strace.rb
@@ -0,0 +1,50 @@
1
+ = strace_me
2
+
3
+ * http://seattlerb.rubyforge.org/strace_me
4
+
5
+ == DESCRIPTION:
6
+
7
+ A wrapper around strace(1) that allows you to perform targetted tracing of a
8
+ block. strace_me allows you to track down problems without wading through
9
+ gobs of ruby startup or other irrelevant noise.
10
+
11
+ == FEATURES/PROBLEMS:
12
+
13
+ * strace only
14
+
15
+ == SYNOPSIS:
16
+
17
+ See Strace::me
18
+
19
+ == REQUIREMENTS:
20
+
21
+ * strace
22
+
23
+ == INSTALL:
24
+
25
+ * sudo gem install strace_me
26
+
27
+ == LICENSE:
28
+
29
+ (The MIT License)
30
+
31
+ Copyright (c) 2010 Eric Hodel
32
+
33
+ Permission is hereby granted, free of charge, to any person obtaining
34
+ a copy of this software and associated documentation files (the
35
+ 'Software'), to deal in the Software without restriction, including
36
+ without limitation the rights to use, copy, modify, merge, publish,
37
+ distribute, sublicense, and/or sell copies of the Software, and to
38
+ permit persons to whom the Software is furnished to do so, subject to
39
+ the following conditions:
40
+
41
+ The above copyright notice and this permission notice shall be
42
+ included in all copies or substantial portions of the Software.
43
+
44
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
45
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
46
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
47
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
48
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
49
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
50
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :git
7
+ Hoe.plugin :minitest
8
+
9
+ Hoe.spec 'strace_me' do
10
+ self.rubyforge_name = 'seattlerb'
11
+ developer 'Eric Hodel', 'drbrain@segment7.net'
12
+
13
+ extra_deps << ['open4', '~> 0.9']
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,62 @@
1
+ require 'open4'
2
+
3
+ ##
4
+ # Simple wrapper of strace(1) for targetted tracing.
5
+
6
+ module Strace
7
+
8
+ ##
9
+ # The version of strace_me you're using
10
+
11
+ VERSION = '1.0'
12
+
13
+ ##
14
+ # Runs strace(1) during the code in the block and returns an IO containing
15
+ # the strace output and the exception raised by the block (if any).
16
+ #
17
+ # Simple example (it doesn't matter if you have a /COPYRIGHT):
18
+ #
19
+ # trace, err = Strace.me do
20
+ # open '/COPYRIGHT' do |io|
21
+ # io.read 1024
22
+ # end
23
+ # end
24
+ #
25
+ # puts "error: #{err.message} (#{err.class})\n\n" if err
26
+ # puts "trace:\n\n#{trace.read}"
27
+ #
28
+ # Tracing an existing library call:
29
+ #
30
+ # alias old_connect connect
31
+ #
32
+ # def connect host, user, password
33
+ # connection = nil
34
+ #
35
+ # trace, err = Strace.me do
36
+ # connection = old_connect host, user, password
37
+ # end
38
+ #
39
+ # $stderr.puts "connect trace:\n\n#{trace.read}"
40
+ #
41
+ # raise err if err
42
+ # connection
43
+ # end
44
+
45
+ def self.me
46
+ pid, i, o, e = Open4.open4 'strace', '-p', $$.to_s
47
+
48
+ i.close
49
+ e.gets # consumes "attached" message, but we know strace is ready
50
+
51
+ begin
52
+ yield
53
+ ensure
54
+ Process.kill 'INT', pid
55
+ Process.waitpid pid
56
+
57
+ return [e, $!]
58
+ end
59
+ end
60
+
61
+ end
62
+
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'minitest/autorun'
3
+ require 'strace'
4
+
5
+ class TestStrace < MiniTest::Unit::TestCase
6
+
7
+ def test_class_me_no_strace
8
+ path = ENV['PATH']
9
+ ENV['PATH'] = nil
10
+
11
+ assert_raises Errno::ENOENT do
12
+ Strace.me do end
13
+ end
14
+
15
+ ensure
16
+ ENV['PATH'] = path
17
+ end
18
+
19
+ end
20
+
metadata ADDED
@@ -0,0 +1,177 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: strace_me
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 1
8
+ - 0
9
+ version: "1.0"
10
+ platform: ruby
11
+ authors:
12
+ - Eric Hodel
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain:
16
+ - |
17
+ -----BEGIN CERTIFICATE-----
18
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
19
+ YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
20
+ ZXQwHhcNMDcxMjIxMDIwNDE0WhcNMDgxMjIwMDIwNDE0WjBBMRAwDgYDVQQDDAdk
21
+ cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
22
+ FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
23
+ LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
24
+ U5ddZCVywn5nnAQ+Ui7jMW54CYt5/H6f2US6U0hQOjJR6cpfiymgxGdfyTiVcvTm
25
+ Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
26
+ mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
27
+ g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
28
+ sCANiQ8BAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
29
+ BBS5k4Z75VSpdM0AclG2UvzFA/VW5DANBgkqhkiG9w0BAQUFAAOCAQEAHagT4lfX
30
+ kP/hDaiwGct7XPuVGbrOsKRVD59FF5kETBxEc9UQ1clKWngf8JoVuEoKD774dW19
31
+ bU0GOVWO+J6FMmT/Cp7nuFJ79egMf/gy4gfUfQMuvfcr6DvZUPIs9P/TlK59iMYF
32
+ DIOQ3DxdF3rMzztNUCizN4taVscEsjCcgW6WkUJnGdqlu3OHWpQxZBJkBTjPCoc6
33
+ UW6on70SFPmAy/5Cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag
34
+ 14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v
35
+ x52qPcexcYZR7w==
36
+ -----END CERTIFICATE-----
37
+
38
+ date: 2010-06-07 00:00:00 -07:00
39
+ default_executable:
40
+ dependencies:
41
+ - !ruby/object:Gem::Dependency
42
+ name: open4
43
+ prerelease: false
44
+ requirement: &id001 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ hash: 25
50
+ segments:
51
+ - 0
52
+ - 9
53
+ version: "0.9"
54
+ type: :runtime
55
+ version_requirements: *id001
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubyforge
58
+ prerelease: false
59
+ requirement: &id002 !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ hash: 9
65
+ segments:
66
+ - 2
67
+ - 0
68
+ - 3
69
+ version: 2.0.3
70
+ type: :development
71
+ version_requirements: *id002
72
+ - !ruby/object:Gem::Dependency
73
+ name: gemcutter
74
+ prerelease: false
75
+ requirement: &id003 !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 11
81
+ segments:
82
+ - 0
83
+ - 5
84
+ - 0
85
+ version: 0.5.0
86
+ type: :development
87
+ version_requirements: *id003
88
+ - !ruby/object:Gem::Dependency
89
+ name: minitest
90
+ prerelease: false
91
+ requirement: &id004 !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 1
99
+ - 5
100
+ - 0
101
+ version: 1.5.0
102
+ type: :development
103
+ version_requirements: *id004
104
+ - !ruby/object:Gem::Dependency
105
+ name: hoe
106
+ prerelease: false
107
+ requirement: &id005 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ hash: 27
113
+ segments:
114
+ - 2
115
+ - 5
116
+ - 0
117
+ version: 2.5.0
118
+ type: :development
119
+ version_requirements: *id005
120
+ description: |-
121
+ A wrapper around strace(1) that allows you to perform targetted tracing of a
122
+ block. strace_me allows you to track down problems without wading through
123
+ gobs of ruby startup or other irrelevant noise.
124
+ email:
125
+ - drbrain@segment7.net
126
+ executables: []
127
+
128
+ extensions: []
129
+
130
+ extra_rdoc_files:
131
+ - History.txt
132
+ - Manifest.txt
133
+ - README.txt
134
+ files:
135
+ - History.txt
136
+ - Manifest.txt
137
+ - README.txt
138
+ - Rakefile
139
+ - lib/strace.rb
140
+ - test/test_strace.rb
141
+ has_rdoc: true
142
+ homepage: http://seattlerb.rubyforge.org/strace_me
143
+ licenses: []
144
+
145
+ post_install_message:
146
+ rdoc_options:
147
+ - --main
148
+ - README.txt
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ none: false
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ hash: 3
157
+ segments:
158
+ - 0
159
+ version: "0"
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ hash: 3
166
+ segments:
167
+ - 0
168
+ version: "0"
169
+ requirements: []
170
+
171
+ rubyforge_project: seattlerb
172
+ rubygems_version: 1.3.7
173
+ signing_key:
174
+ specification_version: 3
175
+ summary: A wrapper around strace(1) that allows you to perform targetted tracing of a block
176
+ test_files:
177
+ - test/test_strace.rb
@@ -0,0 +1 @@
1
+ m;