trace_tree 0.3.3 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/trace_tree/point/ccall_kernel_extend.rb +1 -1
- data/lib/trace_tree/point/ccall_module_include.rb +1 -1
- data/lib/trace_tree/point/ccall_module_prepend.rb +1 -1
- data/lib/trace_tree/point.rb +19 -22
- data/lib/trace_tree/points_markdown_table.rb +60 -0
- data/lib/trace_tree/version.rb +1 -1
- data/lib/trace_tree.rb +2 -2
- data/trace_tree.gemspec +1 -2
- metadata +5 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd2acac6d571e0747380b7a119f10ceae8b047677da86922aacf86d61f230e1e
|
4
|
+
data.tar.gz: 9f99a54c748d8e36b92e11dba833e7059da16ee5fa486412e5c70c35c2186ffc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7597b9d86bf09817082dbdec9dd31a7a18f80afda328b437d7b7d023ff8e77983e09399e53e2d7f6e8026f13100aac29a48feecfd98ad1fc1319389ffeda7eb9
|
7
|
+
data.tar.gz: a69bef456553b83d05d749973c8e923080708bd27a3793b2639b13869f44932fbb85589a52c0695790ff9661043c7bfa55de9db0cc211521cebef7a7fbf6804a
|
data/README.md
CHANGED
@@ -58,7 +58,7 @@ end
|
|
58
58
|
* `: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.
|
59
59
|
* `: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.
|
60
60
|
* `: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.
|
61
|
-
*
|
61
|
+
* `:transcode => false` by default. Set it true to convert unknown character into `"?"` when you see `Encoding::UndefinedConversionError`.
|
62
62
|
|
63
63
|
### Methods' return values
|
64
64
|
|
@@ -78,7 +78,12 @@ Try to remove a non-existing index:
|
|
78
78
|
ArgumentError: Index name 'index_cars_on_online_at' on table 'cars' does not exist
|
79
79
|
```
|
80
80
|
|
81
|
-
Then find the result HTML in tmp dir. Move your mouse on any method name, and
|
81
|
+
Then find the result HTML in tmp dir. Move your mouse on any method name, and:
|
82
|
+
|
83
|
+
- press `f`/`u` to fold/unfold it's callee
|
84
|
+
- press `p`/`n` to jump to it's previous/next sibling call
|
85
|
+
- press `r` to print return value in console
|
86
|
+
- press `a` to print ascii tree in console
|
82
87
|
|
83
88
|
You may type `group_by_file()` in console, to group callees defined in same file, under additional `li` tag. Type `group_by_file()` once again to switch back.
|
84
89
|
|
@@ -3,7 +3,7 @@ class TraceTree
|
|
3
3
|
class CcallKernelExtend < Point
|
4
4
|
def parameters
|
5
5
|
first_callee = callees[0]
|
6
|
-
first_callee.respond_to?(:mixin) ? first_callee.mixin : first_callee.
|
6
|
+
first_callee.respond_to?(:mixin) ? first_callee.mixin : first_callee.class_name
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.event_class_method
|
@@ -9,7 +9,7 @@ class TraceTree
|
|
9
9
|
# first callee should be append_features(), check if it is native or custom
|
10
10
|
def parameters
|
11
11
|
first_callee = callees[0]
|
12
|
-
Module == first_callee.class_name ? first_callee.return_value : first_callee.
|
12
|
+
Module == first_callee.class_name ? first_callee.return_value : first_callee.class_name
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -8,7 +8,7 @@ class TraceTree
|
|
8
8
|
|
9
9
|
def parameters
|
10
10
|
first_callee = callees[0]
|
11
|
-
Module == first_callee.class_name ? first_callee.return_value : first_callee.
|
11
|
+
Module == first_callee.class_name ? first_callee.return_value : first_callee.class_name
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
data/lib/trace_tree/point.rb
CHANGED
@@ -7,7 +7,8 @@ class TraceTree
|
|
7
7
|
include TreeGraphable
|
8
8
|
include TreeHtmlable
|
9
9
|
|
10
|
-
attr_reader :
|
10
|
+
attr_reader :thread, :frame_env
|
11
|
+
attr_reader :call_symbol, :class_name
|
11
12
|
attr_accessor :terminal, :config
|
12
13
|
|
13
14
|
Interfaces = [:event, :defined_class, :method_id, :path, :lineno]
|
@@ -73,24 +74,31 @@ EOM
|
|
73
74
|
|
74
75
|
@return_value = trace_point.return_value if x_return?
|
75
76
|
@thread = Thread.current
|
77
|
+
return if thread?
|
76
78
|
|
77
|
-
|
78
|
-
|
79
|
-
@
|
80
|
-
@
|
79
|
+
if event == :c_call || event == :c_return
|
80
|
+
@call_symbol = '#'
|
81
|
+
@frame_env = method_id
|
82
|
+
@class_name = defined_class
|
83
|
+
return
|
81
84
|
end
|
85
|
+
|
86
|
+
there = trace_point.binding.of_caller(3)
|
87
|
+
current = BindingOfCallers::Revealed.new there
|
88
|
+
@call_symbol = current.call_symbol
|
89
|
+
@frame_env = current.frame_env.to_sym
|
90
|
+
@class_name = current.klass
|
82
91
|
rescue => e
|
83
|
-
puts e
|
92
|
+
puts e.message
|
93
|
+
puts(Interfaces.each_with_object({}){|attr, h| h[attr] = send(attr)})
|
94
|
+
puts e.backtrace
|
95
|
+
raise e
|
84
96
|
end
|
85
97
|
|
86
98
|
def b_call?
|
87
99
|
event == :b_call
|
88
100
|
end
|
89
101
|
|
90
|
-
def c_call?
|
91
|
-
event == :c_call
|
92
|
-
end
|
93
|
-
|
94
102
|
def class?
|
95
103
|
event == :class
|
96
104
|
end
|
@@ -157,22 +165,12 @@ EOM
|
|
157
165
|
@km ||= "#{class_name}#{call_symbol}#{method_name}"
|
158
166
|
end
|
159
167
|
|
160
|
-
def class_name
|
161
|
-
c_call? ? defined_class : current.klass
|
162
|
-
rescue
|
163
|
-
puts event
|
164
|
-
end
|
165
|
-
|
166
168
|
def method_name
|
167
|
-
return method_id if c_call
|
169
|
+
return method_id if event == :c_call
|
168
170
|
return frame_env if b_call? || class?
|
169
171
|
(method_id == frame_env) ? method_id : "#{method_id} -> #{frame_env}"
|
170
172
|
end
|
171
173
|
|
172
|
-
def call_symbol
|
173
|
-
c_call? ? '#' : current.call_symbol
|
174
|
-
end
|
175
|
-
|
176
174
|
def source_location
|
177
175
|
"#{path}:#{lineno}"
|
178
176
|
end
|
@@ -182,7 +180,6 @@ EOM
|
|
182
180
|
end
|
183
181
|
|
184
182
|
class Loader
|
185
|
-
|
186
183
|
attr_reader :point_classes, :config
|
187
184
|
|
188
185
|
def initialize *enhancement, config
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class TraceTree
|
2
|
+
class PointsMarkdownTable
|
3
|
+
HEADERS = [:event, :defined_class, :method_id, :frame_env, :path, :lineno, :thread, :return_value]
|
4
|
+
COL_SEPERATOR = '|'
|
5
|
+
HEADER_BOTTOM = '-'
|
6
|
+
NEWLINE = "\n"
|
7
|
+
RETURN = /return/
|
8
|
+
|
9
|
+
LT_RAW = /</
|
10
|
+
LT_ESC = '<'
|
11
|
+
GT_RAW= />/
|
12
|
+
GT_ESC = '>'
|
13
|
+
COL_RAW = '|'
|
14
|
+
COL_ESC = '|'
|
15
|
+
|
16
|
+
def initialize(points)
|
17
|
+
@points = points
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@buffer = []
|
22
|
+
generate_headers
|
23
|
+
generate_rows
|
24
|
+
@buffer.join
|
25
|
+
end
|
26
|
+
|
27
|
+
def generate_headers
|
28
|
+
HEADERS.each{ |h| @buffer << COL_SEPERATOR << h }
|
29
|
+
@buffer << COL_SEPERATOR
|
30
|
+
@buffer << NEWLINE
|
31
|
+
HEADERS.each{ |h| @buffer << COL_SEPERATOR << HEADER_BOTTOM }
|
32
|
+
end_row
|
33
|
+
end
|
34
|
+
|
35
|
+
def generate_rows
|
36
|
+
@points.each do |point|
|
37
|
+
point_to_row(point.event)
|
38
|
+
point_to_row(point.defined_class)
|
39
|
+
point_to_row(point.method_id)
|
40
|
+
point_to_row(point.thread? ? nil : point.frame_env)
|
41
|
+
point_to_row(point.path)
|
42
|
+
point_to_row(point.lineno)
|
43
|
+
point_to_row(point.thread)
|
44
|
+
point_to_row(point.event =~ RETURN ? point.return_value : nil)
|
45
|
+
end_row
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def end_row
|
50
|
+
@buffer << COL_SEPERATOR << NEWLINE
|
51
|
+
end
|
52
|
+
|
53
|
+
def point_to_row(info)
|
54
|
+
info = info.to_s.gsub(LT_RAW, LT_ESC)
|
55
|
+
info.gsub!(GT_RAW, GT_ESC)
|
56
|
+
info.gsub!(COL_RAW, COL_ESC)
|
57
|
+
@buffer << COL_SEPERATOR << info
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/trace_tree/version.rb
CHANGED
data/lib/trace_tree.rb
CHANGED
@@ -9,8 +9,8 @@ require 'trace_tree/tmp_file'
|
|
9
9
|
require 'trace_tree/timer'
|
10
10
|
require 'trace_tree/config'
|
11
11
|
require 'trace_tree/warm'
|
12
|
+
require 'trace_tree/points_markdown_table'
|
12
13
|
require 'thread'
|
13
|
-
require 'terminal-tableofhashes'
|
14
14
|
|
15
15
|
class Binding
|
16
16
|
def trace_tree *log, **opt, &to_do
|
@@ -115,7 +115,7 @@ class TraceTree
|
|
115
115
|
end
|
116
116
|
|
117
117
|
def table_of_points
|
118
|
-
|
118
|
+
PointsMarkdownTable.new(trace_points_array)
|
119
119
|
rescue => e
|
120
120
|
log.puts "#{__method__}", e.inspect, e.backtrace
|
121
121
|
end
|
data/trace_tree.gemspec
CHANGED
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency "binding_of_callers", "~> 0.2.3"
|
29
29
|
spec.add_dependency "tree_graph", "~> 0.2.4"
|
30
|
-
spec.add_dependency "tree_html", "~> 0.1.
|
31
|
-
spec.add_dependency "terminal-tableofhashes", "~> 0.1.0"
|
30
|
+
spec.add_dependency "tree_html", "~> 0.1.10"
|
32
31
|
|
33
32
|
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.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,28 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.1.
|
103
|
+
version: 0.1.10
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: terminal-tableofhashes
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: 0.1.0
|
118
|
-
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - "~>"
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: 0.1.0
|
110
|
+
version: 0.1.10
|
125
111
|
description:
|
126
112
|
email:
|
127
113
|
- block24block@gmail.com
|
@@ -162,6 +148,7 @@ files:
|
|
162
148
|
- lib/trace_tree/point/omit.rb
|
163
149
|
- lib/trace_tree/point/threadbegin.rb
|
164
150
|
- lib/trace_tree/point/threadend.rb
|
151
|
+
- lib/trace_tree/points_markdown_table.rb
|
165
152
|
- lib/trace_tree/return_value.rb
|
166
153
|
- lib/trace_tree/short_gem_path.rb
|
167
154
|
- lib/trace_tree/timer.rb
|