rbtrace 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/Gemfile.lock ADDED
@@ -0,0 +1,20 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rbtrace (0.2.3)
5
+ ffi (>= 1.0.5)
6
+ trollop (>= 1.16.2)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ ffi (1.0.5)
12
+ rake (>= 0.8.7)
13
+ rake (0.8.7)
14
+ trollop (1.16.2)
15
+
16
+ PLATFORMS
17
+ ruby
18
+
19
+ DEPENDENCIES
20
+ rbtrace!
data/bin/rbtrace CHANGED
@@ -176,7 +176,7 @@ class RBTracer
176
176
  # Returns nothing.
177
177
  def add(methods)
178
178
  Array(methods).each do |func|
179
- func.strip!
179
+ func = func.strip
180
180
 
181
181
  if func =~ /^(.+)\((.+?)\)$/
182
182
  func, args = $1, $2
@@ -195,8 +195,20 @@ class RBTracer
195
195
  #
196
196
  # Returns nothing.
197
197
  def detach
198
- send_cmd('detach')
198
+ begin
199
+ send_cmd('detach')
200
+ rescue Errno::ESRCH
201
+ end
202
+
199
203
  puts
204
+
205
+ # drain queue
206
+ 5.times do
207
+ begin
208
+ true while recv_cmd(false)
209
+ rescue
210
+ end
211
+ end
200
212
  end
201
213
 
202
214
  # Process events from the traced process.
@@ -364,7 +376,7 @@ class RBTracer
364
376
  opts = Trollop.options do
365
377
  version <<-EOS
366
378
  rbtrace: like strace, but for ruby code
367
- version 0.2.3
379
+ version 0.2.4
368
380
  (c) 2011 Aman Gupta (tmm1)
369
381
  http://github.com/tmm1/rbtrace
370
382
  EOS
data/ext/rbtrace.c CHANGED
@@ -22,6 +22,10 @@
22
22
  #include <node.h>
23
23
  #define rb_sourcefile() (ruby_current_node ? ruby_current_node->nd_file : 0)
24
24
  #define rb_sourceline() (ruby_current_node ? nd_line(ruby_current_node) : 0)
25
+ #else
26
+ // this is a nasty hack, and will probably break on anything except 1.9.2p136
27
+ int rb_thread_method_id_and_class(void *th, ID *idp, VALUE *klassp);
28
+ RUBY_EXTERN void *ruby_current_thread;
25
29
  #endif
26
30
 
27
31
  #ifndef RSTRING_PTR
@@ -141,6 +145,18 @@ event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
141
145
  // skip allocators
142
146
  if (mid == ID_ALLOCATOR) goto out;
143
147
 
148
+ // some serious 1.9.2 hax
149
+ #ifdef RUBY_VM
150
+ if (mid == 0 && ruby_current_thread) {
151
+ ID _mid;
152
+ VALUE _klass;
153
+ rb_thread_method_id_and_class(ruby_current_thread, &_mid, &_klass);
154
+
155
+ mid = _mid;
156
+ klass = _klass;
157
+ }
158
+ #endif
159
+
144
160
  // normalize klass and check for class-level methods
145
161
  bool singleton = 0;
146
162
  if (klass) {
@@ -215,8 +231,8 @@ event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
215
231
  }
216
232
 
217
233
  switch (event) {
218
- case RUBY_EVENT_C_CALL:
219
234
  case RUBY_EVENT_CALL:
235
+ case RUBY_EVENT_C_CALL:
220
236
  SEND_EVENT(
221
237
  "%s,%d,%s,%d,%s",
222
238
  event == RUBY_EVENT_CALL ? "call" : "ccall",
@@ -269,8 +285,8 @@ event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
269
285
  }
270
286
  break;
271
287
 
272
- case RUBY_EVENT_C_RETURN:
273
288
  case RUBY_EVENT_RETURN:
289
+ case RUBY_EVENT_C_RETURN:
274
290
  SEND_EVENT(
275
291
  "%s,%d",
276
292
  event == RUBY_EVENT_RETURN ? "return" : "creturn",
data/rbtrace.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rbtrace'
3
- s.version = '0.2.3'
3
+ s.version = '0.2.4'
4
4
  s.homepage = 'http://github.com/tmm1/rbtrace'
5
5
 
6
6
  s.authors = "Aman Gupta"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbtrace
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 3
10
- version: 0.2.3
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Aman Gupta
@@ -59,7 +59,9 @@ extensions:
59
59
  extra_rdoc_files: []
60
60
 
61
61
  files:
62
+ - .gitignore
62
63
  - Gemfile
64
+ - Gemfile.lock
63
65
  - README.md
64
66
  - bin/rbtrace
65
67
  - ext/.gitignore