rookout 0.1.52 → 0.1.53

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
2
  SHA256:
3
- metadata.gz: 8854b65da599e09232b62dadbe87cb092dccd93e2a3153dae13e5aa703fcd4e0
4
- data.tar.gz: 8fb0f255e23b6eac93f293632a4230e7b24fa80fcdd49d0288d78582ebd121e0
3
+ metadata.gz: fc61fe37a93f9e71f499fce1d5edfc2de6b2eb1203b9885c5b4cdbcc0b0af6f2
4
+ data.tar.gz: 5d48b072987c67593ecc81a68d3d96dd217aca001a3a49fd581a97ae72ae6903
5
5
  SHA512:
6
- metadata.gz: a0008b3f484e1967418b7cd8bd9db5b8550658a1eb211b5f1ce6f6e731a9fca6733361fd03413f1904dd2aebea889be20418b5fcde963ffd14d116290e8421cf
7
- data.tar.gz: 3d2282c21829a747f961e6063435433aa19e88be46ae3f572c8239355ef6dfda585fd12c8d12c4b401d427d7fd0f9040c744b0c27a673b2d9a87a0ac6705ca56
6
+ metadata.gz: 6afa9d0c7fa12fba84e4bd679ac752eecf6463bf0bc82fef67f80dbd6fa1df576f7a0095f7f246116ed5bc0d4a5418a7afc078ffcba40fe1fc8804501422e83d
7
+ data.tar.gz: 605af10354982b51166cce1382572be5f816d90512a2506ce23acb61ea175b155b1b9b435488cafe47269b5b119e9a7c6e4df4449a7c227b647185c97bbad65d
@@ -24,7 +24,7 @@ module Rookout
24
24
 
25
25
  attr_reader :id
26
26
 
27
- def execute frame, extracted, output
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 frame, extracted
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 frame, extracted
49
+ def create_namespaces frame_binding, stack_trace, extracted
50
50
  Processor::Namespaces::ContainerNamespace.new(
51
- "frame" => Processor::Namespaces::FrameNamespace.new(frame[1]),
52
- "stack" => Processor::Namespaces::StackNamespace.new(frame, 1),
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 frame, extracted
23
+ def execute frame_binding, stack_trace, extracted
24
24
  UserWarnings.with self do
25
25
  begin
26
- @aug.execute frame, extracted, @output
26
+ @aug.execute frame_binding, stack_trace, extracted, @output
27
27
  rescue SystemExit
28
28
  raise
29
29
  rescue Exception => e
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- COMMIT = "3e5cbb5882385eff12a3113f93dfde79418d5061".freeze
2
+ COMMIT = "24373c28244fc83259758e74b7fd12d5a6964eb5".freeze
3
3
  end
@@ -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.backtrace.length
318
- frame = namespace.backtrace[position]
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: frame.source_location[0],
321
- lineno: frame.source_location[1],
322
- name: frame.eval("__method__").to_s
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 binding
10
+ def initialize frame_binding, top_frame_info
11
11
  super()
12
- @binding = binding
12
+ @frame_binding = frame_binding
13
+ @top_frame_info = top_frame_info
13
14
  end
14
15
 
15
16
  def read_attribute name
16
- return RubyObjectNamespace.new @binding.receiver if name == "self"
17
- raise Exceptions::RookAttributeNotFound, name unless @binding.local_variable_defined? name
18
- RubyObjectNamespace.new @binding.local_variable_get name
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 @binding.source_location[0]
26
+ RubyObjectNamespace.new @top_frame_info.path
25
27
  when "line"
26
- RubyObjectNamespace.new @binding.source_location[1]
28
+ RubyObjectNamespace.new @top_frame_info.lineno
27
29
  when "function"
28
- RubyObjectNamespace.new @binding.eval("__method__").to_s
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(@binding.source_location[0]),
34
- "line" => RubyObjectNamespace.new(@binding.source_location[1]),
35
- "function" => RubyObjectNamespace.new(@binding.eval("__method__").to_s),
36
- "module" => RubyObjectNamespace.new(@binding.source_location[0]),
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 = @binding.local_variables
55
+ local_variables = @frame_binding.local_variables
53
56
  local_variables.each do |var|
54
- value = @binding.local_variable_get var
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 @binding.receiver, dump_config
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 backtrace, offset = 0
10
+ def initialize stack_trace, offset = 0
10
11
  super()
11
- @backtrace = backtrace
12
+ @stack_trace = stack_trace
12
13
  @offset = offset
13
14
  end
14
15
 
15
16
  def read_key key
16
- FrameNamespace.new @backtrace[key + @offset]
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 @backtrace, @offset, args.to_i
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 backtrace, offset, depth
9
+ def initialize stack_trace, offset, depth
11
10
  super()
12
- @backtrace = backtrace
11
+ @stack_trace = stack_trace
13
12
  @offset = offset
14
13
  @depth = depth
15
14
  end
16
15
 
17
- attr_reader :backtrace
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 @backtrace[key + @offset]
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 >= @backtrace.length
31
- frame = @backtrace[position]
29
+ break if position >= @stack_trace.length
30
+ frame_info = @stack_trace[position]
32
31
 
33
- code_object = Com::Rookout::Variant::CodeObject.new filename: frame.source_location[0],
34
- lineno: frame.source_location[1],
35
- name: frame.eval("__method__").to_s
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
- # TODO: consider delaying callers (get bindings) until we actually need them in Aug.rb
78
- aug.execute callers, nil
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
@@ -1,3 +1,3 @@
1
1
  module Rookout
2
- VERSION = "0.1.52".freeze
2
+ VERSION = "0.1.53".freeze
3
3
  end
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.52
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-02-26 00:00:00.000000000 Z
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