rbtrace 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +0 -1
- data/bin/rbtrace +51 -10
- data/ext/rbtrace.c +1 -1
- data/rbtrace.gemspec +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -157,7 +157,6 @@ rbtrace works on ruby 1.8 and 1.9, running on linux or mac osx.
|
|
157
157
|
* switch ipc to [msgpack](https://github.com/dhotson/msgpack/tree/master/c) instead of csv
|
158
158
|
* add triggers to start tracing slow methods only inside another method
|
159
159
|
* optimize local variable lookup to avoid instance_eval
|
160
|
-
* let bin/rbtrace read methods selectors and expressions from a config file
|
161
160
|
* use shared memory region for symbol table to avoid lookup on every event
|
162
161
|
* use another shm for class name lookup, and wipe on every GC
|
163
162
|
* investigate mach_msg on osx since msgget(2) has hard kernel limits
|
data/bin/rbtrace
CHANGED
@@ -178,7 +178,7 @@ class RBTracer
|
|
178
178
|
Array(methods).each do |func|
|
179
179
|
func = func.strip
|
180
180
|
|
181
|
-
if func =~ /^(.+)\((
|
181
|
+
if func =~ /^(.+)\((.+)\)$/
|
182
182
|
func, args = $1, $2
|
183
183
|
args = args.split(',').map{ |a| a.strip }
|
184
184
|
end
|
@@ -373,10 +373,13 @@ class RBTracer
|
|
373
373
|
end
|
374
374
|
|
375
375
|
def self.run
|
376
|
-
|
376
|
+
check_msgmnb
|
377
|
+
cleanup_queues
|
378
|
+
|
379
|
+
parser = Trollop::Parser.new do
|
377
380
|
version <<-EOS
|
378
381
|
rbtrace: like strace, but for ruby code
|
379
|
-
version 0.2.
|
382
|
+
version 0.2.6
|
380
383
|
(c) 2011 Aman Gupta (tmm1)
|
381
384
|
http://github.com/tmm1/rbtrace
|
382
385
|
EOS
|
@@ -459,23 +462,61 @@ EOS
|
|
459
462
|
"prefix nested method calls with N spaces",
|
460
463
|
:default => 1,
|
461
464
|
:short => '-r'
|
465
|
+
|
466
|
+
opt :config,
|
467
|
+
"config file",
|
468
|
+
:type => String,
|
469
|
+
:short => '-c'
|
470
|
+
end
|
471
|
+
|
472
|
+
opts = Trollop.with_standard_exception_handling(parser) do
|
473
|
+
raise Trollop::HelpNeeded if ARGV.empty?
|
474
|
+
parser.parse(ARGV)
|
462
475
|
end
|
463
476
|
|
464
|
-
|
465
|
-
|
477
|
+
slow = nil
|
478
|
+
firehose = nil
|
479
|
+
methods = nil
|
480
|
+
|
481
|
+
if opts[:slow_given]
|
482
|
+
slow = opts[:slow]
|
483
|
+
|
484
|
+
elsif opts[:firehose]
|
485
|
+
firehose = true
|
486
|
+
|
487
|
+
elsif opts[:methods]
|
488
|
+
methods = opts[:methods]
|
489
|
+
|
490
|
+
elsif opts[:config_given]
|
491
|
+
if File.exists?(config = opts[:config])
|
492
|
+
methods = []
|
493
|
+
File.readlines(config).each do |line|
|
494
|
+
next if line =~ /^#/
|
495
|
+
methods << line.strip
|
496
|
+
end
|
497
|
+
|
498
|
+
else
|
499
|
+
parser.die :config, "invalid config file"
|
500
|
+
end
|
501
|
+
|
502
|
+
else
|
503
|
+
$stderr.puts "Error: --slow, --firehose, --methods or --config required."
|
504
|
+
$stderr.puts "Try --help for help."
|
505
|
+
exit(-1)
|
506
|
+
end
|
466
507
|
|
467
508
|
begin
|
468
509
|
begin
|
469
510
|
tracer = RBTracer.new(opts[:pid])
|
470
511
|
rescue ArgumentError => e
|
471
|
-
|
512
|
+
parser.die :pid, "invalid (#{e.message})"
|
472
513
|
end
|
473
514
|
|
474
|
-
if
|
475
|
-
tracer.watch(
|
476
|
-
elsif
|
515
|
+
if slow
|
516
|
+
tracer.watch(slow)
|
517
|
+
elsif firehose
|
477
518
|
tracer.firehose
|
478
|
-
elsif methods
|
519
|
+
elsif methods
|
479
520
|
tracer.add(methods)
|
480
521
|
end
|
481
522
|
|
data/ext/rbtrace.c
CHANGED
@@ -259,7 +259,7 @@ event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
|
|
259
259
|
snprintf(buffer, len+150, "\"%s:%d\"", rb_sourcefile(), rb_sourceline());
|
260
260
|
result = buffer;
|
261
261
|
|
262
|
-
} else if (len >
|
262
|
+
} else if (len > 2 && expr[0] == '@' && expr[1] != '@') {
|
263
263
|
val = rb_inspect(rb_ivar_get(self, rb_intern(expr)));
|
264
264
|
|
265
265
|
} else if (event == RUBY_EVENT_CALL) {
|
data/rbtrace.gemspec
CHANGED
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aman Gupta
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-16 00:00:00 -08:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|