trace_tree 0.2.18 → 0.2.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0e3749fd5cfe77879935127aff043e0f0e1dd824
4
- data.tar.gz: f198631aa1b43c03471a8ad64726b18360399f86
2
+ SHA256:
3
+ metadata.gz: 62deca45905349bd526ed97929de96a290b0bc72444d4142ddddadb8724f063b
4
+ data.tar.gz: 2e34e08a382e0cd249184a5ee92fbac613e06dce30806c6e8d521eee779764ca
5
5
  SHA512:
6
- metadata.gz: aa48ccce8ea838085360474808485d59ce3e1f3db4251084f8d9b3c7a6615803db01228805bb87ef2d680adefdaad28a7730fed432463ff67dd451b0f54e98aa
7
- data.tar.gz: d5b83842c96349de9bb0f1c8a1237dfefd0f82461be4fbcfa400a7c2c49c2096d9942852e3568da2d5b2519f23aaa9d445673c89d16b60d5deb5e23665a4144e
6
+ metadata.gz: 53a7bcc1fcfba7bccb113c777022c98ad6bc38fe14b5b6c88985a4d26f3ab452e8d541301fa259274f26807d9d666d65593fb0746998e8bc557a98be4f5d4879
7
+ data.tar.gz: b8bad2dea2b574bee4f0a1c82241587bcc708a2d2b042cbcf2fa18cedde6726d80b257b21b6c4a74f5795a754ebfbfa82c41b6894a76203872b1e3baf0be7801
data/README.md CHANGED
@@ -58,7 +58,7 @@ end
58
58
  * `:no_methods => nil` by default. Give it regexp(s) to hide stack under matching methods. Useful when you want to dump stack of a rack middleware but lower middlewares.
59
59
  * `:warm => nil` by default. Set it something unique to the code block so that the code block will be traced only when it's called second time, in case we dump lots of code loading and initialization.
60
60
  * `:timer => nil` by default. Set it true if you want to know how much time spent in tracing and drawing tree. Notice the `file` should be appendable, otherwise the time will overwrite the tree.
61
- * `:debug => nil` by default. Give it somthing like what for `:tmp` to output a whole list of TracePoints in file for debug.
61
+ * `:debug => nil` by default. Give it `STDOUT`/`STDERR` or anything responds to `:puts` to output a whole list of TracePoints. Or give it a file name in the default tmp dir of your system.
62
62
 
63
63
  ### Example 1: Output to HTML
64
64
 
@@ -10,5 +10,5 @@ require "trace_tree"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require "irb"
14
- IRB.start(__FILE__)
13
+ require "pry"
14
+ pry
@@ -42,7 +42,7 @@ class TraceTree
42
42
  def generate *log, **opt, &to_do
43
43
  @opt = opt
44
44
  @log = dump_location *log
45
- @debug = TmpFile.new opt[:debug] if opt[:debug]
45
+ @debug = debug_location
46
46
  enhance_point
47
47
  @build_command = (opt[:html] || opt[:htmp]) ? :tree_html_full : :tree_graph
48
48
  make_filter
@@ -66,6 +66,13 @@ class TraceTree
66
66
 
67
67
  attr_reader :bi, :trace_points, :log, :build_command, :timer, :opt, :point_loader, :config
68
68
 
69
+ def debug_location
70
+ loc = opt[:debug]
71
+ return nil unless loc
72
+ return loc if loc.respond_to? :puts
73
+ TmpFile.new loc
74
+ end
75
+
69
76
  def dump_location *log
70
77
  return TmpFile.new opt[:tmp] if opt[:tmp]
71
78
  return TmpFile.new(opt[:htmp] + '.html') if opt[:htmp]
@@ -89,7 +96,7 @@ class TraceTree
89
96
  timer[:tree]
90
97
  tree = sort(trace_points_array).send build_command
91
98
  timer[:tree]
92
- @debug.puts table_of_points if defined? @debug
99
+ @debug.puts table_of_points if @debug
93
100
  log.puts tree
94
101
  log.puts timer.to_s if opt[:timer]
95
102
  rescue => e
@@ -18,10 +18,6 @@ class TraceTree
18
18
  bases << base
19
19
  end
20
20
 
21
- def classes
22
- @classes ||= bases.each_with_object(Hash.new{|h| h[:common]}){|c, h| h[c.event_class_method] = c}
23
- end
24
-
25
21
  def bases
26
22
  @bases ||= []
27
23
  end
@@ -194,14 +190,36 @@ EOM
194
190
 
195
191
  def initialize *enhancement, config
196
192
  @config = config
197
- return @point_classes = Point.classes if enhancement.empty?
198
- @point_classes = Point.classes.each_with_object(Point.classes.dup) do |entry, hash|
199
- hash[entry[0]] = entry[1].clone.prepend *enhancement
193
+ @bases = Point.bases
194
+ @bases = @bases.map{ |b| b = b.clone; b.prepend *enhancement; b } unless enhancement.empty?
195
+ sort_bases
196
+ end
197
+
198
+ def sort_bases
199
+ @methods = {}
200
+
201
+ @bases.each do |b|
202
+ event, klass, method = b.event_class_method
203
+ events = (@methods[method] ||= {})
204
+ klasses = (events[event] ||= {})
205
+ klasses[klass] = b
200
206
  end
207
+
208
+ @common = @methods[nil][:common][nil]
201
209
  end
202
210
 
203
211
  def create point
204
- point_klass = point_classes[[point.event, point.defined_class, point.method_id]]
212
+ point_klass =
213
+ if events = @methods[point.method_id]
214
+ if klasses = events[point.event]
215
+ klasses[point.defined_class] || @common
216
+ else
217
+ @common
218
+ end
219
+ else
220
+ @common
221
+ end
222
+
205
223
  poi = point_klass.new point
206
224
  poi.config = config
207
225
  poi
@@ -2,7 +2,8 @@ class TraceTree
2
2
  class Point
3
3
  class CcallKernelExtend < Point
4
4
  def parameters
5
- callees[0].mixin
5
+ first_callee = callees[0]
6
+ first_callee.respond_to?(:mixin) ? first_callee.mixin : first_callee.current.klass
6
7
  end
7
8
 
8
9
  def self.event_class_method
@@ -6,8 +6,10 @@ class TraceTree
6
6
  [:c_call, Module, :include]
7
7
  end
8
8
 
9
+ # first callee should be append_features(), check if it is native or custom
9
10
  def parameters
10
- callees[0].parameters
11
+ first_callee = callees[0]
12
+ Module == first_callee.class_name ? first_callee.return_value : first_callee.current.klass
11
13
  end
12
14
 
13
15
  end
@@ -7,7 +7,8 @@ class TraceTree
7
7
  end
8
8
 
9
9
  def parameters
10
- callees[0].parameters
10
+ first_callee = callees[0]
11
+ Module == first_callee.class_name ? first_callee.return_value : first_callee.current.klass
11
12
  end
12
13
 
13
14
  end
@@ -1,3 +1,3 @@
1
1
  class TraceTree
2
- VERSION = "0.2.18"
2
+ VERSION = "0.2.19"
3
3
  end
@@ -23,11 +23,11 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 1.14"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
25
25
  spec.add_development_dependency "minitest", "~> 5.0"
26
+ spec.add_development_dependency "pry"
26
27
 
27
28
  spec.add_dependency "binding_of_callers", "~> 0.1.5"
28
29
  spec.add_dependency "tree_graph", "~> 0.2.0"
29
30
  spec.add_dependency "tree_html", "~> 0.1.7"
30
31
  spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
31
32
 
32
- spec.extensions << "ext/mkrf_conf.rb"
33
33
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trace_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.18
4
+ version: 0.2.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-23 00:00:00.000000000 Z
11
+ date: 2019-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: binding_of_callers
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -112,8 +126,7 @@ description:
112
126
  email:
113
127
  - block24block@gmail.com
114
128
  executables: []
115
- extensions:
116
- - ext/mkrf_conf.rb
129
+ extensions: []
117
130
  extra_rdoc_files: []
118
131
  files:
119
132
  - ".gitignore"
@@ -125,7 +138,6 @@ files:
125
138
  - Rakefile
126
139
  - bin/console
127
140
  - bin/setup
128
- - ext/mkrf_conf.rb
129
141
  - lib/trace_tree.rb
130
142
  - lib/trace_tree/args.rb
131
143
  - lib/trace_tree/color.rb
@@ -136,22 +148,16 @@ files:
136
148
  - lib/trace_tree/group_by_file.js
137
149
  - lib/trace_tree/native_console.js
138
150
  - lib/trace_tree/point.rb
139
- - lib/trace_tree/point/call_activesupportconcern_appendfeatures.rb
140
- - lib/trace_tree/point/call_modulemutexm_extendobject.rb
141
151
  - lib/trace_tree/point/ccall_classthread_new.rb
142
152
  - lib/trace_tree/point/ccall_kernel_extend.rb
143
153
  - lib/trace_tree/point/ccall_kernel_raise.rb
144
- - lib/trace_tree/point/ccall_module_appendfeatures.rb
145
154
  - lib/trace_tree/point/ccall_module_extendobject.rb
146
155
  - lib/trace_tree/point/ccall_module_include.rb
147
156
  - lib/trace_tree/point/ccall_module_prepend.rb
148
- - lib/trace_tree/point/ccall_module_prependfeatures.rb
149
157
  - lib/trace_tree/point/ccall_thread_initialize.rb
150
158
  - lib/trace_tree/point/common.rb
151
159
  - lib/trace_tree/point/creturn_classthread_new.rb
152
- - lib/trace_tree/point/creturn_module_appendfeatures.rb
153
160
  - lib/trace_tree/point/creturn_module_extendobject.rb
154
- - lib/trace_tree/point/creturn_module_prependfeatures.rb
155
161
  - lib/trace_tree/point/creturn_thread_initialize.rb
156
162
  - lib/trace_tree/point/omit.rb
157
163
  - lib/trace_tree/point/threadbegin.rb
@@ -185,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
191
  version: '0'
186
192
  requirements: []
187
193
  rubyforge_project:
188
- rubygems_version: 2.5.2.3
194
+ rubygems_version: 2.7.6
189
195
  signing_key:
190
196
  specification_version: 4
191
197
  summary: Print TracePoint(:b_call, :b_return, :c_call, :c_return, :call, :return,
@@ -1,32 +0,0 @@
1
- #This file needs to be named mkrf_conf.rb
2
- #so that rubygems will recognize it as a ruby extension
3
- #file and not think it is a C extension file
4
-
5
- require 'rubygems/dependency_installer'
6
-
7
- #Load up the rubygem's dependency installer to
8
- #installer the gems we want based on the version
9
- #of Ruby the user has installed
10
- installer = Gem::DependencyInstaller.new
11
-
12
- begin
13
- if RUBY_VERSION < "2.2.2"
14
- installer.install "activesupport", "< 5.0.0"
15
- elsif RUBY_VERSION < "2.5.0"
16
- installer.install "activesupport", "< 6.0.0"
17
- else
18
- installer.install "activesupport"
19
- end
20
-
21
- rescue => e
22
- puts e.message, e.backtrace
23
- #Exit with a non-zero value to let rubygems something went wrong
24
- exit(1)
25
- end
26
-
27
- #If this was C, rubygems would attempt to run make
28
- #Since this is Ruby, rubygems will attempt to run rake
29
- #If it doesn't find and successfully run a rakefile, it errors out
30
- f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
31
- f.write("task :default\n")
32
- f.close
@@ -1,17 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- class TraceTree
4
- class Point
5
- class CallActivesupportconcernAppendfeatures < Point
6
-
7
- def self.event_class_method
8
- [:call, ActiveSupport::Concern, :append_features]
9
- end
10
-
11
- def parameters
12
- current.lv.values.first
13
- end
14
-
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- require 'mutex_m'
2
-
3
- class TraceTree
4
- class Point
5
- class CallModuleMutexmExtendobject < Point
6
-
7
- def mixin
8
- Mutex_m
9
- end
10
-
11
- def self.event_class_method
12
- [:call, Mutex_m.singleton_class, :extend_object]
13
- end
14
-
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- class TraceTree
2
- class Point
3
- class CcallModuleAppendfeatures < Point
4
-
5
- def self.event_class_method
6
- [:c_call, Module, :append_features]
7
- end
8
-
9
- def parameters
10
- terminal.return_value
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,15 +0,0 @@
1
- class TraceTree
2
- class Point
3
- class CcallModulePrependfeatures < Point
4
-
5
- def self.event_class_method
6
- [:c_call, Module, :prepend_features]
7
- end
8
-
9
- def parameters
10
- terminal.return_value
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- class TraceTree
2
- class Point
3
- class CreturnModuleAppendfeatures < Point
4
-
5
- def self.event_class_method
6
- [:c_return, Module, :append_features]
7
- end
8
-
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- class TraceTree
2
- class Point
3
- class CreturnModulePrependfeatures < Point
4
-
5
- def self.event_class_method
6
- [:c_return, Module, :prepend_features]
7
- end
8
-
9
- end
10
- end
11
- end