rookout 0.1.52 → 0.1.53
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 +4 -4
- data/lib/rookout/augs/aug.rb +5 -5
- data/lib/rookout/augs/locations/location.rb +2 -2
- data/lib/rookout/commit.rb +1 -1
- data/lib/rookout/exceptions.rb +6 -0
- data/lib/rookout/processor/namespace_serializer2.rb +5 -5
- data/lib/rookout/processor/namespaces/frame_namespace.rb +18 -15
- data/lib/rookout/processor/namespaces/stack_namespace.rb +5 -4
- data/lib/rookout/processor/namespaces/traceback_namespace.rb +9 -10
- data/lib/rookout/services/tracer.rb +22 -14
- data/lib/rookout/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc61fe37a93f9e71f499fce1d5edfc2de6b2eb1203b9885c5b4cdbcc0b0af6f2
|
4
|
+
data.tar.gz: 5d48b072987c67593ecc81a68d3d96dd217aca001a3a49fd581a97ae72ae6903
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6afa9d0c7fa12fba84e4bd679ac752eecf6463bf0bc82fef67f80dbd6fa1df576f7a0095f7f246116ed5bc0d4a5418a7afc078ffcba40fe1fc8804501422e83d
|
7
|
+
data.tar.gz: 605af10354982b51166cce1382572be5f816d90512a2506ce23acb61ea175b155b1b9b435488cafe47269b5b119e9a7c6e4df4449a7c227b647185c97bbad65d
|
data/lib/rookout/augs/aug.rb
CHANGED
@@ -24,7 +24,7 @@ module Rookout
|
|
24
24
|
|
25
25
|
attr_reader :id
|
26
26
|
|
27
|
-
def execute
|
27
|
+
def execute frame_binding, stack_trace, extracted, output
|
28
28
|
return unless @enabled
|
29
29
|
|
30
30
|
if output.user_messages_queue_full?
|
@@ -32,7 +32,7 @@ module Rookout
|
|
32
32
|
return
|
33
33
|
end
|
34
34
|
|
35
|
-
namespace = create_namespaces
|
35
|
+
namespace = create_namespaces frame_binding, stack_trace, extracted
|
36
36
|
return if @condition && !@condition.evaluate(namespace)
|
37
37
|
|
38
38
|
should_skip_limiters = @condition.nil? && !@executed
|
@@ -46,10 +46,10 @@ module Rookout
|
|
46
46
|
|
47
47
|
private
|
48
48
|
|
49
|
-
def create_namespaces
|
49
|
+
def create_namespaces frame_binding, stack_trace, extracted
|
50
50
|
Processor::Namespaces::ContainerNamespace.new(
|
51
|
-
"frame" => Processor::Namespaces::FrameNamespace.new(
|
52
|
-
"stack" => Processor::Namespaces::StackNamespace.new(
|
51
|
+
"frame" => Processor::Namespaces::FrameNamespace.new(frame_binding, stack_trace[0]),
|
52
|
+
"stack" => Processor::Namespaces::StackNamespace.new(stack_trace),
|
53
53
|
"extracted" => Processor::Namespaces::ContainerNamespace.new(extracted),
|
54
54
|
"store" => Processor::Namespaces::ContainerNamespace.new,
|
55
55
|
"temp" => Processor::Namespaces::ContainerNamespace.new,
|
@@ -20,10 +20,10 @@ module Rookout
|
|
20
20
|
@aug.id
|
21
21
|
end
|
22
22
|
|
23
|
-
def execute
|
23
|
+
def execute frame_binding, stack_trace, extracted
|
24
24
|
UserWarnings.with self do
|
25
25
|
begin
|
26
|
-
@aug.execute
|
26
|
+
@aug.execute frame_binding, stack_trace, extracted, @output
|
27
27
|
rescue SystemExit
|
28
28
|
raise
|
29
29
|
rescue Exception => e
|
data/lib/rookout/commit.rb
CHANGED
data/lib/rookout/exceptions.rb
CHANGED
@@ -258,5 +258,11 @@ module Rookout
|
|
258
258
|
super "Live Logger is not supported. Try using Rookout Live Debugger instead."
|
259
259
|
end
|
260
260
|
end
|
261
|
+
|
262
|
+
class RookLocalsUnavailable < ToolException
|
263
|
+
def initialize
|
264
|
+
super "Can't collect local variables up the stack"
|
265
|
+
end
|
266
|
+
end
|
261
267
|
end
|
262
268
|
end
|
@@ -314,12 +314,12 @@ module Rookout
|
|
314
314
|
|
315
315
|
namespace.depth.times do |i|
|
316
316
|
position = i + namespace.offset
|
317
|
-
break if position >= namespace.
|
318
|
-
|
317
|
+
break if position >= namespace.stack_trace.length
|
318
|
+
frame_info = namespace.stack_trace[position]
|
319
319
|
|
320
|
-
code_object = Com::Rookout::Variant::CodeObject.new filename:
|
321
|
-
lineno:
|
322
|
-
name:
|
320
|
+
code_object = Com::Rookout::Variant::CodeObject.new filename: frame_info.path,
|
321
|
+
lineno: frame_info.lineno,
|
322
|
+
name: frame_info.label
|
323
323
|
variant.code_values << code_object
|
324
324
|
# See dump_code_object
|
325
325
|
@estimated_pending_bytes += 14 # Header + size + (header + number) * 4
|
@@ -7,33 +7,35 @@ module Rookout
|
|
7
7
|
require_relative "../../exceptions"
|
8
8
|
|
9
9
|
class FrameNamespace < Namespace
|
10
|
-
def initialize
|
10
|
+
def initialize frame_binding, top_frame_info
|
11
11
|
super()
|
12
|
-
@
|
12
|
+
@frame_binding = frame_binding
|
13
|
+
@top_frame_info = top_frame_info
|
13
14
|
end
|
14
15
|
|
15
16
|
def read_attribute name
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
raise Exceptions::RookLocalsUnavailable if @frame_binding.nil?
|
18
|
+
return RubyObjectNamespace.new @frame_binding.receiver if name == "self"
|
19
|
+
raise Exceptions::RookAttributeNotFound, name unless @frame_binding.local_variable_defined? name
|
20
|
+
RubyObjectNamespace.new @frame_binding.local_variable_get name
|
19
21
|
end
|
20
22
|
|
21
23
|
def call_method name, args
|
22
24
|
case name
|
23
25
|
when "filename", "module"
|
24
|
-
RubyObjectNamespace.new @
|
26
|
+
RubyObjectNamespace.new @top_frame_info.path
|
25
27
|
when "line"
|
26
|
-
RubyObjectNamespace.new @
|
28
|
+
RubyObjectNamespace.new @top_frame_info.lineno
|
27
29
|
when "function"
|
28
|
-
RubyObjectNamespace.new @
|
30
|
+
RubyObjectNamespace.new @top_frame_info.label
|
29
31
|
when "locals"
|
30
32
|
locals args
|
31
33
|
when "dump"
|
32
34
|
result = {
|
33
|
-
"filename" => RubyObjectNamespace.new(@
|
34
|
-
"line" => RubyObjectNamespace.new(@
|
35
|
-
"function" => RubyObjectNamespace.new(@
|
36
|
-
"module" => RubyObjectNamespace.new(@
|
35
|
+
"filename" => RubyObjectNamespace.new(@top_frame_info.path),
|
36
|
+
"line" => RubyObjectNamespace.new(@top_frame_info.lineno),
|
37
|
+
"function" => RubyObjectNamespace.new(@top_frame_info.label),
|
38
|
+
"module" => RubyObjectNamespace.new(@top_frame_info.path),
|
37
39
|
"locals" => locals(args)
|
38
40
|
}
|
39
41
|
ContainerNamespace.new result
|
@@ -43,19 +45,20 @@ module Rookout
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def locals args
|
48
|
+
raise Exceptions::RookLocalsUnavailable if @frame_binding.nil?
|
46
49
|
dump_config = nil
|
47
50
|
unless args.nil?
|
48
51
|
dump_config = OBJECT_DUMP_TABLE[args.downcase]
|
49
52
|
end
|
50
53
|
|
51
54
|
hash = {}
|
52
|
-
local_variables = @
|
55
|
+
local_variables = @frame_binding.local_variables
|
53
56
|
local_variables.each do |var|
|
54
|
-
value = @
|
57
|
+
value = @frame_binding.local_variable_get var
|
55
58
|
hash[var.to_s] = RubyObjectNamespace.new value, dump_config
|
56
59
|
end
|
57
60
|
|
58
|
-
hash["self"] = RubyObjectNamespace.new @
|
61
|
+
hash["self"] = RubyObjectNamespace.new @frame_binding.receiver, dump_config
|
59
62
|
|
60
63
|
ContainerNamespace.new hash
|
61
64
|
end
|
@@ -5,15 +5,16 @@ module Rookout
|
|
5
5
|
require_relative "frame_namespace"
|
6
6
|
require_relative "traceback_namespace"
|
7
7
|
|
8
|
+
|
8
9
|
class StackNamespace < Namespace
|
9
|
-
def initialize
|
10
|
+
def initialize stack_trace, offset = 0
|
10
11
|
super()
|
11
|
-
@
|
12
|
+
@stack_trace = stack_trace
|
12
13
|
@offset = offset
|
13
14
|
end
|
14
15
|
|
15
16
|
def read_key key
|
16
|
-
FrameNamespace.new @
|
17
|
+
FrameNamespace.new nil, @stack_trace[key + @offset]
|
17
18
|
end
|
18
19
|
|
19
20
|
def call_method name, args
|
@@ -23,7 +24,7 @@ module Rookout
|
|
23
24
|
|
24
25
|
def create_traceback args
|
25
26
|
args = 1000 if args == ""
|
26
|
-
TracebackNamespace.new @
|
27
|
+
TracebackNamespace.new @stack_trace, @offset, args.to_i
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -3,23 +3,22 @@ module Rookout
|
|
3
3
|
module Namespaces
|
4
4
|
require_relative "namespace"
|
5
5
|
require_relative "frame_namespace"
|
6
|
-
|
7
6
|
require_relative "../../protobuf/variant_pb"
|
8
7
|
|
9
8
|
class TracebackNamespace < Namespace
|
10
|
-
def initialize
|
9
|
+
def initialize stack_trace, offset, depth
|
11
10
|
super()
|
12
|
-
@
|
11
|
+
@stack_trace = stack_trace
|
13
12
|
@offset = offset
|
14
13
|
@depth = depth
|
15
14
|
end
|
16
15
|
|
17
|
-
attr_reader :
|
16
|
+
attr_reader :stack_trace
|
18
17
|
attr_reader :offset
|
19
18
|
attr_reader :depth
|
20
19
|
|
21
20
|
def read_key key
|
22
|
-
FrameNamespace.new @
|
21
|
+
FrameNamespace.new nil, @stack_trace[key + @offset]
|
23
22
|
end
|
24
23
|
|
25
24
|
def dump _log_object_errors
|
@@ -27,12 +26,12 @@ module Rookout
|
|
27
26
|
|
28
27
|
@depth.times do |i|
|
29
28
|
position = i + @offset
|
30
|
-
break if position >= @
|
31
|
-
|
29
|
+
break if position >= @stack_trace.length
|
30
|
+
frame_info = @stack_trace[position]
|
32
31
|
|
33
|
-
code_object = Com::Rookout::Variant::CodeObject.new filename:
|
34
|
-
lineno:
|
35
|
-
name:
|
32
|
+
code_object = Com::Rookout::Variant::CodeObject.new filename: frame_info.path,
|
33
|
+
lineno: frame_info.lineno,
|
34
|
+
name: frame_info.label
|
36
35
|
|
37
36
|
traceback.locations << code_object
|
38
37
|
end
|
@@ -3,9 +3,6 @@ module Rookout
|
|
3
3
|
require_relative "../logger"
|
4
4
|
|
5
5
|
class Tracer
|
6
|
-
require "binding_of_caller"
|
7
|
-
include BindingOfCaller::BindingExtensions
|
8
|
-
|
9
6
|
def initialize
|
10
7
|
@trace_points = {}
|
11
8
|
@augs = {}
|
@@ -17,22 +14,25 @@ module Rookout
|
|
17
14
|
aug_trace_points = []
|
18
15
|
positions.each do |position|
|
19
16
|
trace_point = create_trace_point aug
|
20
|
-
|
21
17
|
begin
|
22
18
|
trace_point.enable target: position.method, target_line: position.lineno
|
23
19
|
rescue RuntimeError, ArgumentError => e
|
20
|
+
trace_point.disable # just to make sure if something was partially added to clear everything
|
24
21
|
if e.message.include? "can not enable any hooks"
|
25
22
|
raise Exceptions::RookInvalidPositionException.new(aug.filename, position.lineno)
|
26
23
|
end
|
27
24
|
raise Exceptions::RookSetTracepointFailed.new(position.lineno, e)
|
25
|
+
ensure
|
26
|
+
# We add and remove a dummy trace point to re-align the tracing mechanism as a result of some bug in adding
|
27
|
+
# a breakpoint https://bugs.ruby-lang.org/issues/17302
|
28
|
+
begin
|
29
|
+
dummy_trace_point = TracePoint.new(:line) {} # Dummy
|
30
|
+
dummy_trace_point.enable target: position.method, target_line: position.lineno
|
31
|
+
dummy_trace_point.disable
|
32
|
+
rescue
|
33
|
+
# IGNORE
|
34
|
+
end
|
28
35
|
end
|
29
|
-
|
30
|
-
# We add and remove a dummy trace point to re-align the tracing mechanism as a result of some bug in adding
|
31
|
-
# a breakpoint
|
32
|
-
dummy_trace_point = TracePoint.new(:line) {} # Dummy
|
33
|
-
dummy_trace_point.enable target: position.method, target_line: position.lineno
|
34
|
-
dummy_trace_point.disable
|
35
|
-
|
36
36
|
aug_trace_points.push trace_point
|
37
37
|
end
|
38
38
|
|
@@ -71,11 +71,19 @@ module Rookout
|
|
71
71
|
private
|
72
72
|
|
73
73
|
def create_trace_point aug
|
74
|
-
TracePoint.new :line do
|
74
|
+
TracePoint.new :line do |tp|
|
75
75
|
begin
|
76
76
|
begin
|
77
|
-
#
|
78
|
-
|
77
|
+
# tp.binding - Binding object of the frame in the location that triggered the TracePoint.
|
78
|
+
# This allows us to collect locals.
|
79
|
+
# caller_locations - returns the stacktrace. Allows us to collect files, lines and function names.
|
80
|
+
# We used to also collect the Bindings up the stack (allowed us to also collect locals up the stack),
|
81
|
+
# but we don't actually need that. If we'll ever need this functionality again, we'll have to use the
|
82
|
+
# binding_of_caller gem:
|
83
|
+
# require "binding_of_caller"
|
84
|
+
# include BindingOfCaller::BindingExtensions
|
85
|
+
# callers_bindings = callers - The "callers" function retrieves the bindings up the stack
|
86
|
+
aug.execute tp.binding, caller_locations, nil
|
79
87
|
rescue Exception => e
|
80
88
|
Logger.instance.exception "Exception calling aug", e
|
81
89
|
end
|
data/lib/rookout/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rookout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Liran Haimovitch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-03-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: binding_of_caller
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0.7'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0.7'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: concurrent-ruby
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|