google-cloud-debugger 0.36.1 → 0.42.0

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/AUTHENTICATION.md +2 -1
  3. data/CHANGELOG.md +47 -0
  4. data/CONTRIBUTING.md +4 -4
  5. data/LOGGING.md +1 -1
  6. data/OVERVIEW.md +28 -59
  7. data/TROUBLESHOOTING.md +2 -8
  8. data/ext/google/cloud/debugger/debugger_c/tracer.c +8 -33
  9. data/lib/google-cloud-debugger.rb +14 -15
  10. data/lib/google/cloud/debugger.rb +18 -16
  11. data/lib/google/cloud/debugger/agent.rb +4 -1
  12. data/lib/google/cloud/debugger/breakpoint.rb +9 -9
  13. data/lib/google/cloud/debugger/breakpoint/evaluator.rb +19 -25
  14. data/lib/google/cloud/debugger/breakpoint/source_location.rb +6 -6
  15. data/lib/google/cloud/debugger/breakpoint/stack_frame.rb +5 -5
  16. data/lib/google/cloud/debugger/breakpoint/status_message.rb +4 -6
  17. data/lib/google/cloud/debugger/breakpoint/variable.rb +8 -11
  18. data/lib/google/cloud/debugger/breakpoint/variable_table.rb +1 -1
  19. data/lib/google/cloud/debugger/credentials.rb +9 -6
  20. data/lib/google/cloud/debugger/debuggee.rb +4 -4
  21. data/lib/google/cloud/debugger/middleware.rb +1 -1
  22. data/lib/google/cloud/debugger/rails.rb +2 -2
  23. data/lib/google/cloud/debugger/service.rb +28 -66
  24. data/lib/google/cloud/debugger/snappoint.rb +4 -7
  25. data/lib/google/cloud/debugger/transmitter.rb +1 -1
  26. data/lib/google/cloud/debugger/version.rb +1 -1
  27. metadata +14 -72
  28. data/lib/google/cloud/debugger/v2.rb +0 -243
  29. data/lib/google/cloud/debugger/v2/controller2_client.rb +0 -373
  30. data/lib/google/cloud/debugger/v2/controller2_client_config.json +0 -41
  31. data/lib/google/cloud/debugger/v2/credentials.rb +0 -42
  32. data/lib/google/cloud/debugger/v2/debugger2_client.rb +0 -481
  33. data/lib/google/cloud/debugger/v2/debugger2_client_config.json +0 -51
  34. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/controller.rb +0 -91
  35. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/data.rb +0 -443
  36. data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/debugger.rb +0 -151
  37. data/lib/google/cloud/debugger/v2/doc/google/devtools/source/v1/source_context.rb +0 -162
  38. data/lib/google/cloud/debugger/v2/doc/google/protobuf/empty.rb +0 -29
  39. data/lib/google/cloud/debugger/v2/doc/google/protobuf/timestamp.rb +0 -113
  40. data/lib/google/devtools/clouddebugger/v2/controller_pb.rb +0 -50
  41. data/lib/google/devtools/clouddebugger/v2/controller_services_pb.rb +0 -98
  42. data/lib/google/devtools/clouddebugger/v2/data_pb.rb +0 -108
  43. data/lib/google/devtools/clouddebugger/v2/debugger_pb.rb +0 -77
  44. data/lib/google/devtools/clouddebugger/v2/debugger_services_pb.rb +0 -66
  45. data/lib/google/devtools/source/v1/source_context_pb.rb +0 -90
@@ -67,8 +67,6 @@ module Google
67
67
  # * `https://www.googleapis.com/auth/logging.admin`
68
68
  #
69
69
  # @param [Integer] timeout Default timeout to use in requests. Optional.
70
- # @param [Hash] client_config A hash of values to override the default
71
- # behavior of the API client. Optional.
72
70
  # @param [String] endpoint Override of the endpoint host name. Optional.
73
71
  # If the param is nil, uses the default endpoint.
74
72
  # @param [String] project Project identifier for the Stackdriver Debugger
@@ -84,15 +82,20 @@ module Google
84
82
  # debugger = Google::Cloud::Debugger.new
85
83
  # debugger.start
86
84
  #
87
- def self.new project_id: nil, credentials: nil, service_name: nil,
88
- service_version: nil, scope: nil, timeout: nil,
89
- client_config: nil, endpoint: nil, project: nil, keyfile: nil
85
+ def self.new project_id: nil,
86
+ credentials: nil,
87
+ service_name: nil,
88
+ service_version: nil,
89
+ scope: nil,
90
+ timeout: nil,
91
+ endpoint: nil,
92
+ project: nil,
93
+ keyfile: nil
90
94
  project_id ||= (project || default_project_id)
91
95
  service_name ||= default_service_name
92
96
  service_version ||= default_service_version
93
97
  scope ||= configure.scope
94
98
  timeout ||= configure.timeout
95
- client_config ||= configure.client_config
96
99
  endpoint ||= configure.endpoint
97
100
 
98
101
  service_name = service_name.to_s
@@ -114,14 +117,8 @@ module Google
114
117
  project_id = project_id.to_s # Always cast to a string
115
118
  raise ArgumentError, "project_id is missing" if project_id.empty?
116
119
 
117
- Debugger::Project.new(
118
- Debugger::Service.new(
119
- project_id, credentials,
120
- host: endpoint, timeout: timeout, client_config: client_config
121
- ),
122
- service_name: service_name,
123
- service_version: service_version
124
- )
120
+ service = Debugger::Service.new project_id, credentials, host: endpoint, timeout: timeout
121
+ Debugger::Project.new service, service_name: service_name, service_version: service_version
125
122
  end
126
123
 
127
124
  # rubocop:enable all
@@ -147,8 +144,6 @@ module Google
147
144
  # * `scope` - (String, Array<String>) The OAuth 2.0 scopes controlling
148
145
  # the set of resources and operations that the connection can access.
149
146
  # * `timeout` - (Integer) Default timeout to use in requests.
150
- # * `client_config` - (Hash) A hash of values to override the default
151
- # behavior of the API client.
152
147
  # * `endpoint` - (String) Override of the endpoint host name, or `nil`
153
148
  # to use the default endpoint.
154
149
  # * `allow_mutating_methods` - (boolean) Whether expressions and
@@ -254,4 +249,11 @@ module Google
254
249
  end
255
250
  end
256
251
  end
252
+
253
+ # Aliases for compatibility with older spellings.
254
+ # @private
255
+ module Devtools
256
+ # @private
257
+ Clouddebugger = ::Google::Cloud::Debugger unless const_defined? :Clouddebugger
258
+ end
257
259
  end
@@ -120,7 +120,10 @@ module Google
120
120
  # @param [String] app_root Absolute path to the root directory of
121
121
  # the debuggee application. Default to Rack root.
122
122
  #
123
- def initialize service, logger: nil, service_name:, service_version:,
123
+ def initialize service,
124
+ service_name:,
125
+ service_version:,
126
+ logger: nil,
124
127
  app_root: nil
125
128
  super()
126
129
 
@@ -30,7 +30,7 @@ module Google
30
30
  #
31
31
  # Abstract class that represents a breakpoint, which can be set and
32
32
  # triggered in a debuggee application. Maps to gRPC struct
33
- # {Google::Devtools::Clouddebugger::V2::Breakpoint}.
33
+ # {Google::Cloud::Debugger::V2::Breakpoint}.
34
34
  #
35
35
  class Breakpoint
36
36
  include MonitorMixin
@@ -174,7 +174,7 @@ module Google
174
174
 
175
175
  ##
176
176
  # @private New Google::Cloud::Debugger::Breakpoint
177
- # from a Google::Devtools::Clouddebugger::V2::Breakpoint object.
177
+ # from a Google::Cloud::Debugger::V2::Breakpoint object.
178
178
  def self.from_grpc grpc
179
179
  return new if grpc.nil?
180
180
 
@@ -265,7 +265,7 @@ module Google
265
265
  def valid?
266
266
  Validator.validate self unless complete?
267
267
 
268
- status && status.is_error ? false : true
268
+ status&.is_error ? false : true
269
269
  end
270
270
 
271
271
  ##
@@ -337,9 +337,9 @@ module Google
337
337
 
338
338
  ##
339
339
  # @private Exports the Breakpoint to a
340
- # Google::Devtools::Clouddebugger::V2::Breakpoint object.
340
+ # Google::Cloud::Debugger::V2::Breakpoint object.
341
341
  def to_grpc
342
- Google::Devtools::Clouddebugger::V2::Breakpoint.new(
342
+ Google::Cloud::Debugger::V2::Breakpoint.new(
343
343
  id: id.to_s,
344
344
  location: location.to_grpc,
345
345
  condition: condition.to_s,
@@ -398,7 +398,7 @@ module Google
398
398
 
399
399
  ##
400
400
  # @private Formats the labels so they can be saved to a
401
- # Google::Devtools::Clouddebugger::V2::Breakpoint object.
401
+ # Google::Cloud::Debugger::V2::Breakpoint object.
402
402
  def labels_to_grpc
403
403
  # Coerce symbols to strings
404
404
  Hash[labels.map do |k, v|
@@ -408,21 +408,21 @@ module Google
408
408
 
409
409
  ##
410
410
  # @private Exports the Breakpoint stack_frames to an array of
411
- # Google::Devtools::Clouddebugger::V2::StackFrame objects.
411
+ # Google::Cloud::Debugger::V2::StackFrame objects.
412
412
  def stack_frames_to_grpc
413
413
  stack_frames.nil? ? [] : stack_frames.map(&:to_grpc)
414
414
  end
415
415
 
416
416
  ##
417
417
  # @private Exports the Breakpoint stack_frames to an array of
418
- # Google::Devtools::Clouddebugger::V2::Variable objects.
418
+ # Google::Cloud::Debugger::V2::Variable objects.
419
419
  def evaluated_expressions_to_grpc
420
420
  evaluated_expressions.nil? ? [] : evaluated_expressions.map(&:to_grpc)
421
421
  end
422
422
 
423
423
  ##
424
424
  # @private Exports Breakpoint status to
425
- # Google::Devtools::Clouddebugger::V2::StatusMessage object
425
+ # Google::Cloud::Debugger::V2::StatusMessage object
426
426
  def status_to_grpc
427
427
  status.nil? ? nil : status.to_grpc
428
428
  end
@@ -89,7 +89,7 @@ module Google
89
89
  ##
90
90
  # @private Predefined regex. Saves time during runtime.
91
91
  FUNC_CALL_FLAG_BLACKLIST_REGEX =
92
- /<callinfo!.+#{FUNC_CALL_FLAG_BLACKLIST.join '|'}/.freeze
92
+ /<call(info|data)!.+#{FUNC_CALL_FLAG_BLACKLIST.join '|'}/.freeze
93
93
 
94
94
  ##
95
95
  # @private Predefined regex. Saves time during runtime.
@@ -849,20 +849,18 @@ module Google
849
849
  # do evaluation in a new thread, where function calls can be
850
850
  # traced.
851
851
  thr = Thread.new do
852
- begin
853
- Thread.current.thread_variable_set EVALUATOR_REFERENCE, self
854
- binding.eval wrap_expression(expression)
855
- rescue StandardError, EvaluationError => e
856
- # Treat all StandardError as mutation and set @mutation_cause
857
- unless e.instance_variable_get :@mutation_cause
858
- e.instance_variable_set(
859
- :@mutation_cause,
860
- Google::Cloud::Debugger::EvaluationError::UNKNOWN_CAUSE
861
- )
862
- end
863
-
864
- e
852
+ Thread.current.thread_variable_set EVALUATOR_REFERENCE, self
853
+ binding.eval wrap_expression(expression)
854
+ rescue StandardError, EvaluationError => e
855
+ # Treat all StandardError as mutation and set @mutation_cause
856
+ unless e.instance_variable_get :@mutation_cause
857
+ e.instance_variable_set(
858
+ :@mutation_cause,
859
+ Google::Cloud::Debugger::EvaluationError::UNKNOWN_CAUSE
860
+ )
865
861
  end
862
+
863
+ e
866
864
  end
867
865
 
868
866
  thr.join @time_limit
@@ -942,7 +940,7 @@ module Google
942
940
  ##
943
941
  # @private Wraps expression with tracing code
944
942
  def wrap_expression expression
945
- """
943
+ <<~CODE
946
944
  begin
947
945
  ::Google::Cloud::Debugger::Breakpoint::Evaluator.send(
948
946
  :enable_method_trace_for_thread)
@@ -951,11 +949,9 @@ module Google
951
949
  ::Google::Cloud::Debugger::Breakpoint::Evaluator.send(
952
950
  :disable_method_trace_for_thread)
953
951
  end
954
- """
952
+ CODE
955
953
  end
956
954
 
957
- # rubocop:disable Layout/RescueEnsureAlignment
958
-
959
955
  ##
960
956
  # @private Evaluation tracing callback function. This is called
961
957
  # everytime a Ruby function is called during evaluation of
@@ -994,8 +990,6 @@ module Google
994
990
  )
995
991
  end
996
992
 
997
- # rubocop:enable Layout/RescueEnsureAlignment
998
-
999
993
  ##
1000
994
  # @private Evaluation tracing callback function. This is called
1001
995
  # everytime a C function is called during evaluation of
@@ -1011,12 +1005,12 @@ module Google
1011
1005
  #
1012
1006
  def trace_c_func_callback receiver, defined_class, mid
1013
1007
  return if @allow_mutating_methods
1014
- if receiver.is_a?(Class) || receiver.is_a?(Module)
1015
- invalid_op =
1008
+ invalid_op =
1009
+ if receiver.is_a?(Class) || receiver.is_a?(Module)
1016
1010
  !validate_c_class_method(defined_class, receiver, mid)
1017
- else
1018
- invalid_op = !validate_c_instance_method(defined_class, mid)
1019
- end
1011
+ else
1012
+ !validate_c_instance_method(defined_class, mid)
1013
+ end
1020
1014
 
1021
1015
  return unless invalid_op
1022
1016
 
@@ -37,11 +37,12 @@ module Google
37
37
 
38
38
  ##
39
39
  # @private Create an empty SourceLocation object.
40
- def initialize; end
40
+ def initialize
41
+ end
41
42
 
42
43
  ##
43
44
  # @private New Google::Cloud::Debugger::Breakpoint::SourceLocation
44
- # from a Google::Devtools::Clouddebugger::V2::SourceLocation object.
45
+ # from a Google::Cloud::Debugger::V2::SourceLocation object.
45
46
  def self.from_grpc grpc
46
47
  return new if grpc.nil?
47
48
  new.tap do |o|
@@ -53,16 +54,15 @@ module Google
53
54
  ##
54
55
  # @private Determines if the SourceLocation has any data.
55
56
  def empty?
56
- path.nil? &&
57
- line.nil?
57
+ path.nil? && line.nil?
58
58
  end
59
59
 
60
60
  ##
61
61
  # @private Exports the SourceLocation to a
62
- # Google::Devtools::Clouddebugger::V2::SourceLocation object.
62
+ # Google::Cloud::Debugger::V2::SourceLocation object.
63
63
  def to_grpc
64
64
  return nil if empty?
65
- Google::Devtools::Clouddebugger::V2::SourceLocation.new(
65
+ Google::Cloud::Debugger::V2::SourceLocation.new(
66
66
  path: path.to_s,
67
67
  line: line
68
68
  )
@@ -55,7 +55,7 @@ module Google
55
55
 
56
56
  ##
57
57
  # @private New Google::Cloud::Debugger::Breakpoint::SourceLocation
58
- # from a Google::Devtools::Clouddebugger::V2::SourceLocation object.
58
+ # from a Google::Cloud::Debugger::V2::SourceLocation object.
59
59
  def self.from_grpc grpc
60
60
  new.tap do |o|
61
61
  o.function = grpc.function
@@ -76,10 +76,10 @@ module Google
76
76
 
77
77
  ##
78
78
  # @private Exports the StackFrame to a
79
- # Google::Devtools::Clouddebugger::V2::StackFrame object.
79
+ # Google::Cloud::Debugger::V2::StackFrame object.
80
80
  def to_grpc
81
81
  return nil if empty?
82
- Google::Devtools::Clouddebugger::V2::StackFrame.new(
82
+ Google::Cloud::Debugger::V2::StackFrame.new(
83
83
  function: function.to_s,
84
84
  location: location.to_grpc,
85
85
  arguments: arguments_to_grpc,
@@ -91,14 +91,14 @@ module Google
91
91
 
92
92
  ##
93
93
  # @private Exports the StackFrame arguments to an array of
94
- # Google::Devtools::Clouddebugger::V2::Variable objects.
94
+ # Google::Cloud::Debugger::V2::Variable objects.
95
95
  def arguments_to_grpc
96
96
  arguments.nil? ? [] : arguments.map(&:to_grpc)
97
97
  end
98
98
 
99
99
  ##
100
100
  # @private Exports the StackFrame locals to an array of
101
- # Google::Devtools::Clouddebugger::V2::Variable objects.
101
+ # Google::Cloud::Debugger::V2::Variable objects.
102
102
  def locals_to_grpc
103
103
  locals.nil? ? [] : locals.map(&:to_grpc)
104
104
  end
@@ -50,7 +50,7 @@ module Google
50
50
 
51
51
  ##
52
52
  # New Google::Cloud::Debugger::Breakpoint::StatusMessage
53
- # from a Google::Devtools::Clouddebugger::V2::StatusMessage object.
53
+ # from a Google::Cloud::Debugger::V2::StatusMessage object.
54
54
  def self.from_grpc grpc
55
55
  return nil if grpc.nil?
56
56
  new.tap do |s|
@@ -76,14 +76,12 @@ module Google
76
76
 
77
77
  ##
78
78
  # Exports the StatusMessage to a
79
- # Google::Devtools::Clouddebugger::V2::StatusMessage object.
79
+ # Google::Cloud::Debugger::V2::StatusMessage object.
80
80
  def to_grpc
81
81
  return nil if empty?
82
- description_grpc =
83
- Google::Devtools::Clouddebugger::V2::FormatMessage.new \
84
- format: description.to_s
82
+ description_grpc = Google::Cloud::Debugger::V2::FormatMessage.new format: description.to_s
85
83
 
86
- Google::Devtools::Clouddebugger::V2::StatusMessage.new \
84
+ Google::Cloud::Debugger::V2::StatusMessage.new \
87
85
  is_error: true,
88
86
  refers_to: refers_to,
89
87
  description: description_grpc
@@ -244,7 +244,7 @@ module Google
244
244
 
245
245
  # If source is a non-empty Array or Hash, or source has instance
246
246
  # variables, evaluate source as a compound variable.
247
- if compound_var?(source) && depth > 0
247
+ if compound_var?(source) && depth.positive?
248
248
  from_compound_var source, name: name, depth: depth,
249
249
  var_table: var_table, limit: limit
250
250
  else
@@ -358,9 +358,7 @@ module Google
358
358
 
359
359
  limit = deduct_limit limit, member_var.total_size
360
360
 
361
- buffer_full = (limit && limit < 0) ||
362
- i >= MAX_MEMBERS ||
363
- member_var.buffer_full_variable?
361
+ buffer_full = limit&.negative? || i >= MAX_MEMBERS || member_var.buffer_full_variable?
364
362
 
365
363
  if buffer_full
366
364
  var.members << Variable.new.tap do |last_var|
@@ -384,8 +382,7 @@ module Google
384
382
  new.tap do |var|
385
383
  var.name = name if name
386
384
 
387
- if var_table && var_table.first &&
388
- var_table.first.buffer_full_variable?
385
+ if var_table&.first&.buffer_full_variable?
389
386
  var.var_table = var_table
390
387
  var.var_table_index = 0
391
388
  else
@@ -408,7 +405,7 @@ module Google
408
405
 
409
406
  ##
410
407
  # @private New Google::Cloud::Debugger::Breakpoint::Variable
411
- # from a Google::Devtools::Clouddebugger::V2::Variable object.
408
+ # from a Google::Cloud::Debugger::V2::Variable object.
412
409
  def self.from_grpc grpc
413
410
  return new if grpc.nil?
414
411
  new.tap do |o|
@@ -423,7 +420,7 @@ module Google
423
420
 
424
421
  ##
425
422
  # @private New array of Google::Cloud::Debugger::Breakpoint::Variable
426
- # from an array of Google::Devtools::Clouddebugger::V2::Variable
423
+ # from an array of Google::Cloud::Debugger::V2::Variable
427
424
  # objects.
428
425
  def self.from_grpc_list grpc_list
429
426
  return [] if grpc_list.nil?
@@ -458,10 +455,10 @@ module Google
458
455
 
459
456
  ##
460
457
  # Exports the Variable to a
461
- # Google::Devtools::Clouddebugger::V2::Variable object.
458
+ # Google::Cloud::Debugger::V2::Variable object.
462
459
  def to_grpc
463
460
  return nil if empty?
464
- Google::Devtools::Clouddebugger::V2::Variable.new(
461
+ Google::Cloud::Debugger::V2::Variable.new(
465
462
  name: name.to_s,
466
463
  value: value.to_s,
467
464
  type: type.to_s,
@@ -584,7 +581,7 @@ module Google
584
581
 
585
582
  ##
586
583
  # @private Exports the Variable members to an array of
587
- # Google::Devtools::Clouddebugger::V2::Variable objects.
584
+ # Google::Cloud::Debugger::V2::Variable objects.
588
585
  def members_to_grpc
589
586
  members.nil? ? nil : members.map(&:to_grpc)
590
587
  end
@@ -68,7 +68,7 @@ module Google
68
68
  # object_id, return the array index if found.
69
69
  def rb_var_index rb_var
70
70
  variables.each_with_index do |var, i|
71
- return i if var.source_var.object_id == rb_var.object_id
71
+ return i if var.source_var.equal? rb_var
72
72
  end
73
73
 
74
74
  nil
@@ -12,9 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
-
16
- require "google/cloud/debugger/v2/credentials"
17
- require "google/cloud/logging/credentials"
15
+ require "google/cloud/debugger/v2/debugger/credentials"
18
16
 
19
17
  module Google
20
18
  module Cloud
@@ -38,9 +36,14 @@ module Google
38
36
  #
39
37
  # debugger.project_id #=> "my-project"
40
38
  #
41
- class Credentials < Google::Cloud::Debugger::V2::Credentials
42
- SCOPE = (Google::Cloud::Debugger::V2::Credentials::SCOPE +
43
- Google::Cloud::Logging::Credentials::SCOPE).uniq.freeze
39
+ class Credentials < Google::Cloud::Debugger::V2::Debugger::Credentials
40
+ self.scope = [
41
+ "https://www.googleapis.com/auth/cloud-platform",
42
+ "https://www.googleapis.com/auth/cloud_debugger",
43
+ "https://www.googleapis.com/auth/logging.admin",
44
+ "https://www.googleapis.com/auth/logging.read",
45
+ "https://www.googleapis.com/auth/logging.write"
46
+ ]
44
47
  end
45
48
  end
46
49
  end