rbtrace 0.3.18 → 0.3.19
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.
- checksums.yaml +7 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/bin/rbtrace +31 -12
- data/ext/extconf.rb +1 -0
- data/ext/rbtrace.c +33 -0
- data/rbtrace.gemspec +1 -1
- data/server.rb +1 -1
- data/test.sh +13 -17
- metadata +60 -85
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae8cd64167eb2f3275caf66175c00370018c43fe
|
4
|
+
data.tar.gz: 8d389f4891f37cbbb9e93c4e623542ba213bd88c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54aef3a098fb9be86926238e33fe47fea73d64f89aa3762a282ebf71d6bdb7010eb40b51afe3738b79852eacd1fa2387e4e8795d503ffd878e1be44eeeeb1470
|
7
|
+
data.tar.gz: 115be7ca55f189ad6a1a5dfcc0f84346752141ab6a9b8dab3b42ed545af78d72261d92411778599143aa2b6d5a833ca90756572133cc7e26bc3de7f9ce5ec56c
|
data/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
gemspec
|
data/Gemfile.lock
CHANGED
data/bin/rbtrace
CHANGED
@@ -43,7 +43,7 @@ module MsgQ
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.recv_cmd(q, block=true)
|
46
|
-
MsgQ.rb_enable_interrupt if RUBY_VERSION > '1.9'
|
46
|
+
MsgQ.rb_enable_interrupt if RUBY_VERSION > '1.9' && RUBY_VERSION < '2.0'
|
47
47
|
|
48
48
|
msg = EventMsg.new
|
49
49
|
ret = MsgQ.msgrcv(q, msg, BUF_SIZE, 0, block ? 0 : IPC_NOWAIT)
|
@@ -57,7 +57,7 @@ module MsgQ
|
|
57
57
|
|
58
58
|
msg[:buf].to_ptr.read_string_length(BUF_SIZE)
|
59
59
|
ensure
|
60
|
-
MsgQ.rb_disable_interrupt if RUBY_VERSION > '1.9'
|
60
|
+
MsgQ.rb_disable_interrupt if RUBY_VERSION > '1.9' && RUBY_VERSION < '2.0'
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -65,7 +65,7 @@ module MsgQ
|
|
65
65
|
attach_function :msgrcv, [:int, EventMsg.ptr, :size_t, :long, :int], :int
|
66
66
|
attach_function :msgsnd, [:int, EventMsg.ptr, :size_t, :int], :int
|
67
67
|
|
68
|
-
if RUBY_VERSION > '1.9'
|
68
|
+
if RUBY_VERSION > '1.9' && RUBY_VERSION < '2.0'
|
69
69
|
attach_function :rb_enable_interrupt, [], :void
|
70
70
|
attach_function :rb_disable_interrupt, [], :void
|
71
71
|
end
|
@@ -629,18 +629,37 @@ class RBTracer
|
|
629
629
|
@max_nesting = nesting if nesting > @max_nesting
|
630
630
|
@last_nesting = nesting
|
631
631
|
|
632
|
-
when '
|
632
|
+
when 'gc_start'
|
633
633
|
time, = *cmd
|
634
|
+
@gc_start = time
|
635
|
+
print 'garbage_collect'
|
634
636
|
|
637
|
+
when 'gc_end'
|
638
|
+
time, = *cmd
|
639
|
+
diff = time - @gc_start
|
640
|
+
# if @gc_mark
|
641
|
+
# mark = ((@gc_mark - @gc_start) * 100.0 / diff).to_i
|
642
|
+
# print '(mark: %d%%, sweep: %d%%)' % [mark, 100-mark]
|
643
|
+
# end
|
644
|
+
print ' <%f>' % (diff/1_000_000.0) if @show_duration
|
645
|
+
@gc_start = nil
|
635
646
|
newline
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
647
|
+
|
648
|
+
when 'gc'
|
649
|
+
time, = *cmd
|
650
|
+
@gc_mark = time
|
651
|
+
|
652
|
+
unless @gc_start
|
653
|
+
newline
|
654
|
+
if @show_time
|
655
|
+
t = Time.at(time/1_000_000)
|
656
|
+
print t.strftime("%H:%M:%S.")
|
657
|
+
print "%06d " % (time - t.to_f*1_000_000).round
|
658
|
+
end
|
659
|
+
print @prefix*@last_nesting if @last_nesting > 0
|
660
|
+
print "garbage_collect"
|
661
|
+
puts if @watch_slow
|
640
662
|
end
|
641
|
-
print @prefix*@last_nesting if @last_nesting > 0
|
642
|
-
print "garbage_collect"
|
643
|
-
puts if @watch_slow
|
644
663
|
|
645
664
|
else
|
646
665
|
puts "unknown event #{event}: #{cmd.inspect}"
|
@@ -870,7 +889,7 @@ EOS
|
|
870
889
|
list = `ps aux`.split("\n")
|
871
890
|
filtered = list.grep(Regexp.new opts[:ps])
|
872
891
|
filtered.reject! do |line|
|
873
|
-
line =~ /^\w+\s
|
892
|
+
line =~ /^\w+\s+(#{Process.pid}|#{Process.ppid})\s+/ # cannot trace self
|
874
893
|
end
|
875
894
|
|
876
895
|
if filtered.size > 0
|
data/ext/extconf.rb
CHANGED
data/ext/rbtrace.c
CHANGED
@@ -304,8 +304,10 @@ event_hook(rb_event_t event, NODE *node, VALUE self, ID mid, VALUE klass)
|
|
304
304
|
if (in_event_hook) return;
|
305
305
|
in_event_hook++;
|
306
306
|
|
307
|
+
#ifdef ID_ALLOCATOR
|
307
308
|
// skip allocators
|
308
309
|
if (mid == ID_ALLOCATOR) goto out;
|
310
|
+
#endif
|
309
311
|
|
310
312
|
#ifdef RUBY_VM
|
311
313
|
if (mid == 0) {
|
@@ -531,6 +533,29 @@ event_hook_remove()
|
|
531
533
|
}
|
532
534
|
}
|
533
535
|
|
536
|
+
#ifdef HAVE_RB_GC_ADD_EVENT_HOOK
|
537
|
+
// requires https://github.com/tmm1/brew2deb/blob/master/packages/ruby/patches/gc-hooks.patch
|
538
|
+
static void
|
539
|
+
rbtrace_gc_event_hook(rb_gc_event_t gc_event, VALUE obj)
|
540
|
+
{
|
541
|
+
switch(gc_event)
|
542
|
+
{
|
543
|
+
case RUBY_GC_EVENT_START:
|
544
|
+
rbtrace__send_event(1,
|
545
|
+
"gc_start",
|
546
|
+
'n'
|
547
|
+
);
|
548
|
+
break;
|
549
|
+
case RUBY_GC_EVENT_END:
|
550
|
+
rbtrace__send_event(1,
|
551
|
+
"gc_end",
|
552
|
+
'n'
|
553
|
+
);
|
554
|
+
break;
|
555
|
+
}
|
556
|
+
}
|
557
|
+
#endif
|
558
|
+
|
534
559
|
static int
|
535
560
|
rbtracer_remove(char *query, int id)
|
536
561
|
{
|
@@ -609,6 +634,11 @@ rbtracer_detach()
|
|
609
634
|
if (rbtracer.klass_tbl)
|
610
635
|
st_free_table(rbtracer.klass_tbl);
|
611
636
|
rbtracer.klass_tbl = NULL;
|
637
|
+
|
638
|
+
event_hook_remove();
|
639
|
+
#ifdef HAVE_RB_GC_ADD_EVENT_HOOK
|
640
|
+
rb_gc_remove_event_hook(rbtrace_gc_event_hook);
|
641
|
+
#endif
|
612
642
|
}
|
613
643
|
|
614
644
|
static int
|
@@ -900,6 +930,9 @@ rbtrace__process_event(msgpack_object cmd)
|
|
900
930
|
|
901
931
|
} else if (0 == strncmp("gc", str.ptr, str.size)) {
|
902
932
|
rbtracer.gc = true;
|
933
|
+
#ifdef HAVE_RB_GC_ADD_EVENT_HOOK
|
934
|
+
rb_gc_add_event_hook(rbtrace_gc_event_hook, RUBY_GC_EVENT_START|RUBY_GC_EVENT_END);
|
935
|
+
#endif
|
903
936
|
|
904
937
|
} else if (0 == strncmp("devmode", str.ptr, str.size)) {
|
905
938
|
rbtracer.devmode = true;
|
data/rbtrace.gemspec
CHANGED
data/server.rb
CHANGED
data/test.sh
CHANGED
@@ -24,28 +24,24 @@ trace() {
|
|
24
24
|
echo ./bin/rbtrace -p $PID $*
|
25
25
|
echo ------------------------------------------
|
26
26
|
./bin/rbtrace -p $PID $* &
|
27
|
-
sleep
|
27
|
+
sleep 2
|
28
28
|
kill $!
|
29
29
|
wait $! || true
|
30
30
|
echo
|
31
31
|
}
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
trace
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
# trace --slow=250 --slow-methods sleep
|
46
|
-
# trace --gc -m Dir. --slow=250 --slow-methods sleep
|
47
|
-
# trace --gc -m Dir. --slow=250
|
48
|
-
# trace -m Process. Dir.pwd "Proc#call"
|
33
|
+
trace -m Test.run --devmode
|
34
|
+
trace -m sleep
|
35
|
+
trace -m sleep Dir.chdir Dir.pwd Process.pid "String#gsub" "String#*"
|
36
|
+
trace -m "Kernel#"
|
37
|
+
trace -m "String#gsub(self,@test)" "String#*(self,__source__)" "String#multiply_vowels(self,self.length,num)"
|
38
|
+
trace --gc --slow=200
|
39
|
+
trace --gc -m Dir.
|
40
|
+
trace --slow=250
|
41
|
+
trace --slow=250 --slow-methods sleep
|
42
|
+
trace --gc -m Dir. --slow=250 --slow-methods sleep
|
43
|
+
trace --gc -m Dir. --slow=250
|
44
|
+
trace -m Process. Dir.pwd "Proc#call"
|
49
45
|
# trace --firehose
|
50
46
|
|
51
47
|
cleanup
|
metadata
CHANGED
@@ -1,80 +1,66 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbtrace
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 18
|
10
|
-
version: 0.3.18
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.19
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Aman Gupta
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
22
14
|
name: ffi
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
- - ">="
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
hash: 27
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 0
|
33
|
-
- 6
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
34
19
|
version: 1.0.6
|
35
20
|
type: :runtime
|
36
|
-
version_requirements: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: trollop
|
39
21
|
prerelease: false
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.6
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: trollop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
50
33
|
version: 1.16.2
|
51
34
|
type: :runtime
|
52
|
-
version_requirements: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: msgpack
|
55
35
|
prerelease: false
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.16.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: msgpack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
66
47
|
version: 0.4.3
|
67
48
|
type: :runtime
|
68
|
-
|
69
|
-
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.4.3
|
55
|
+
description: rbtrace shows you method calls happening inside another ruby process
|
56
|
+
in real time.
|
70
57
|
email: aman@tmm1.net
|
71
|
-
executables:
|
58
|
+
executables:
|
72
59
|
- rbtrace
|
73
|
-
extensions:
|
60
|
+
extensions:
|
74
61
|
- ext/extconf.rb
|
75
62
|
extra_rdoc_files: []
|
76
|
-
|
77
|
-
files:
|
63
|
+
files:
|
78
64
|
- .gitignore
|
79
65
|
- Gemfile
|
80
66
|
- Gemfile.lock
|
@@ -94,39 +80,28 @@ files:
|
|
94
80
|
- tracers/redis.tracer
|
95
81
|
- tracers/testunit.tracer
|
96
82
|
- tracers/unicorn.tracer
|
97
|
-
has_rdoc: true
|
98
83
|
homepage: http://github.com/tmm1/rbtrace
|
99
84
|
licenses: []
|
100
|
-
|
85
|
+
metadata: {}
|
101
86
|
post_install_message:
|
102
87
|
rdoc_options: []
|
103
|
-
|
104
|
-
require_paths:
|
88
|
+
require_paths:
|
105
89
|
- lib
|
106
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
none: false
|
117
|
-
requirements:
|
118
|
-
- - ">="
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
hash: 3
|
121
|
-
segments:
|
122
|
-
- 0
|
123
|
-
version: "0"
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
124
100
|
requirements: []
|
125
|
-
|
126
101
|
rubyforge_project:
|
127
|
-
rubygems_version:
|
102
|
+
rubygems_version: 2.0.0
|
128
103
|
signing_key:
|
129
|
-
specification_version:
|
130
|
-
summary:
|
104
|
+
specification_version: 4
|
105
|
+
summary: 'rbtrace: like strace but for ruby code'
|
131
106
|
test_files: []
|
132
|
-
|
107
|
+
has_rdoc:
|