google-cloud-debugger 0.24.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.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +201 -0
- data/README.md +56 -0
- data/ext/google/cloud/debugger/debugger_c/debugger.c +31 -0
- data/ext/google/cloud/debugger/debugger_c/debugger.h +26 -0
- data/ext/google/cloud/debugger/debugger_c/evaluator.c +78 -0
- data/ext/google/cloud/debugger/debugger_c/evaluator.h +25 -0
- data/ext/google/cloud/debugger/debugger_c/extconf.rb +22 -0
- data/ext/google/cloud/debugger/debugger_c/tracer.c +478 -0
- data/ext/google/cloud/debugger/debugger_c/tracer.h +31 -0
- data/lib/google-cloud-debugger.rb +121 -0
- data/lib/google/cloud/debugger.rb +379 -0
- data/lib/google/cloud/debugger/agent.rb +204 -0
- data/lib/google/cloud/debugger/async_actor.rb +290 -0
- data/lib/google/cloud/debugger/breakpoint.rb +382 -0
- data/lib/google/cloud/debugger/breakpoint/evaluator.rb +1113 -0
- data/lib/google/cloud/debugger/breakpoint/source_location.rb +75 -0
- data/lib/google/cloud/debugger/breakpoint/stack_frame.rb +109 -0
- data/lib/google/cloud/debugger/breakpoint/variable.rb +304 -0
- data/lib/google/cloud/debugger/breakpoint_manager.rb +217 -0
- data/lib/google/cloud/debugger/credentials.rb +41 -0
- data/lib/google/cloud/debugger/debuggee.rb +204 -0
- data/lib/google/cloud/debugger/debuggee/app_uniquifier_generator.rb +78 -0
- data/lib/google/cloud/debugger/middleware.rb +77 -0
- data/lib/google/cloud/debugger/project.rb +135 -0
- data/lib/google/cloud/debugger/rails.rb +141 -0
- data/lib/google/cloud/debugger/service.rb +130 -0
- data/lib/google/cloud/debugger/tracer.rb +165 -0
- data/lib/google/cloud/debugger/transmitter.rb +129 -0
- data/lib/google/cloud/debugger/v2.rb +15 -0
- data/lib/google/cloud/debugger/v2/controller2_client.rb +299 -0
- data/lib/google/cloud/debugger/v2/controller2_client_config.json +43 -0
- data/lib/google/cloud/debugger/v2/debugger2_client.rb +378 -0
- data/lib/google/cloud/debugger/v2/debugger2_client_config.json +53 -0
- data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/data.rb +441 -0
- data/lib/google/cloud/debugger/v2/doc/google/devtools/clouddebugger/v2/debugger.rb +151 -0
- data/lib/google/cloud/debugger/v2/doc/google/devtools/source/v1/source_context.rb +161 -0
- data/lib/google/cloud/debugger/v2/doc/google/protobuf/timestamp.rb +81 -0
- data/lib/google/cloud/debugger/version.rb +22 -0
- data/lib/google/devtools/clouddebugger/v2/controller_pb.rb +47 -0
- data/lib/google/devtools/clouddebugger/v2/controller_services_pb.rb +97 -0
- data/lib/google/devtools/clouddebugger/v2/data_pb.rb +105 -0
- data/lib/google/devtools/clouddebugger/v2/debugger_pb.rb +74 -0
- data/lib/google/devtools/clouddebugger/v2/debugger_services_pb.rb +64 -0
- data/lib/google/devtools/source/v1/source_context_pb.rb +89 -0
- metadata +300 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
# Copyright 2017 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "binding_of_caller"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Debugger
|
21
|
+
##
|
22
|
+
# # Tracer
|
23
|
+
#
|
24
|
+
# When active breakpoints are set for the debugger, the tracer monitors
|
25
|
+
# the running Ruby application and triggers evaluation when the code is
|
26
|
+
# executed at the breakpoint locations.
|
27
|
+
#
|
28
|
+
# The tracer tracks the running application using several Ruby TracePoints
|
29
|
+
# and C level Ruby debugging API.
|
30
|
+
#
|
31
|
+
class Tracer
|
32
|
+
##
|
33
|
+
# The debugger agent this tracer belongs to
|
34
|
+
# @return [Google::Cloud::Debugger::Agent]
|
35
|
+
attr_reader :agent
|
36
|
+
|
37
|
+
##
|
38
|
+
# Ruby application root directory, in absolute path form. The
|
39
|
+
# Stackdriver Debugger Service only knows the relative application file
|
40
|
+
# path. So the tracer needs to combine relative file path with
|
41
|
+
# application root directory to get full file path for tracing purpose
|
42
|
+
# @return [String]
|
43
|
+
attr_accessor :app_root
|
44
|
+
|
45
|
+
##
|
46
|
+
# @private File tracing point that enables line tracing when program
|
47
|
+
# counter enters a file that contains breakpoints
|
48
|
+
attr_reader :file_tracepoint
|
49
|
+
|
50
|
+
##
|
51
|
+
# @private Fiber tracing point that enables line tracing when program
|
52
|
+
# counter enters a file that contains breakpoints through fiber
|
53
|
+
# switching
|
54
|
+
attr_reader :fiber_tracepoint
|
55
|
+
|
56
|
+
##
|
57
|
+
# @private A nested hash structure represent all the active breakpoints.
|
58
|
+
# The structure is optimized for fast access. For example:
|
59
|
+
# {
|
60
|
+
# "path/to/file.rb" => { # The absolute file path
|
61
|
+
# 123 => [ # The line number in file
|
62
|
+
# <Google::Cloud::Debugger::Breakpoint> # List of breakpoints
|
63
|
+
# ]
|
64
|
+
# }
|
65
|
+
# }
|
66
|
+
attr_reader :breakpoints_cache
|
67
|
+
|
68
|
+
##
|
69
|
+
# @private Construct a new instance of Tracer
|
70
|
+
def initialize agent, app_root: nil
|
71
|
+
@agent = agent
|
72
|
+
@file_tracepoint = nil
|
73
|
+
@fiber_tracepoint = nil
|
74
|
+
@breakpoints_cache = {}
|
75
|
+
|
76
|
+
@app_root = app_root
|
77
|
+
@app_root ||= Rack::Directory.new("").root if defined? Rack::Directory
|
78
|
+
|
79
|
+
fail "Unable to determine application root path" unless @app_root
|
80
|
+
end
|
81
|
+
|
82
|
+
##
|
83
|
+
# Update tracer's private breakpoints cache with the list of active
|
84
|
+
# breakpoints from BreakpointManager.
|
85
|
+
#
|
86
|
+
# This methood is atomic for thread safety purpose.
|
87
|
+
def update_breakpoints_cache
|
88
|
+
active_breakpoints = agent.breakpoint_manager.active_breakpoints.dup
|
89
|
+
breakpoints_hash = {}
|
90
|
+
|
91
|
+
active_breakpoints.each do |active_breakpoint|
|
92
|
+
breakpoint_line = active_breakpoint.line
|
93
|
+
breakpoint_path = full_breakpoint_path active_breakpoint.path
|
94
|
+
breakpoints_hash[breakpoint_path] ||= {}
|
95
|
+
breakpoints_hash[breakpoint_path][breakpoint_line] ||= []
|
96
|
+
breakpoints_hash[breakpoint_path][breakpoint_line].push(
|
97
|
+
active_breakpoint)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Tracer is explicitly designed to not have a lock. This should be the
|
101
|
+
# only place writing @breakpoints_cache to ensure thread safety.
|
102
|
+
@breakpoints_cache = breakpoints_hash
|
103
|
+
end
|
104
|
+
|
105
|
+
##
|
106
|
+
# Evaluates a hit breakpoint, and signal BreakpointManager and
|
107
|
+
# Transmitter if this breakpoint is evaluated successfully.
|
108
|
+
#
|
109
|
+
# See {Breakpoint#eval_call_stack} for evaluation details.
|
110
|
+
#
|
111
|
+
# @param [Google::Cloud::Debugger::Breakpoint] breakpoint The breakpoint
|
112
|
+
# to be evaluated
|
113
|
+
# @param [Array<Binding>] call_stack_bindings An array of Ruby Binding
|
114
|
+
# objects, from the each frame of the call stack that leads to the
|
115
|
+
# triggering of the breakpoints.
|
116
|
+
#
|
117
|
+
def eval_breakpoint breakpoint, call_stack_bindings
|
118
|
+
return if breakpoint.nil? || breakpoint.complete?
|
119
|
+
|
120
|
+
breakpoint.eval_call_stack call_stack_bindings
|
121
|
+
|
122
|
+
# Take this completed breakpoint off manager's active breakpoints
|
123
|
+
# list, submit the breakpoint snapshot, and update Tracer's
|
124
|
+
# breakpoints_cache.
|
125
|
+
return unless breakpoint.complete?
|
126
|
+
|
127
|
+
# Signal breakpoint_manager that this breakpoint is evaluated
|
128
|
+
agent.breakpoint_manager.mark_off breakpoint
|
129
|
+
# Signal transmitter to submit this breakpoint
|
130
|
+
agent.transmitter.submit breakpoint
|
131
|
+
|
132
|
+
update_breakpoints_cache
|
133
|
+
|
134
|
+
# Disable all trace points and tracing if all breakpoints are complete
|
135
|
+
disable_traces if @breakpoints_cache.empty?
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# @private Covert breakpoint's relative file path to absolute file
|
140
|
+
# path by combining it with application root directory path.
|
141
|
+
def full_breakpoint_path breakpoint_path
|
142
|
+
if app_root.nil? || app_root.empty?
|
143
|
+
breakpoint_path
|
144
|
+
else
|
145
|
+
"#{app_root}/#{breakpoint_path}"
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
##
|
150
|
+
# Get the sync the breakpoints cache with BreakpointManager. Start
|
151
|
+
# tracing and monitoring if there are any breakpoints.
|
152
|
+
def start
|
153
|
+
update_breakpoints_cache
|
154
|
+
enable_traces unless breakpoints_cache.empty?
|
155
|
+
end
|
156
|
+
|
157
|
+
##
|
158
|
+
# Stops all tracing.
|
159
|
+
def stop
|
160
|
+
disable_traces
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
@@ -0,0 +1,129 @@
|
|
1
|
+
# Copyright 2017 Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/cloud/debugger/async_actor"
|
17
|
+
|
18
|
+
module Google
|
19
|
+
module Cloud
|
20
|
+
module Debugger
|
21
|
+
##
|
22
|
+
# # Transmitter
|
23
|
+
#
|
24
|
+
# Responsible for submit evaluated breakpoints back to Stackdriver
|
25
|
+
# Debugger service asynchronously. It has it's own dedicated child thread,
|
26
|
+
# so it doesn't interfere with main Ruby application threads or the
|
27
|
+
# debugger agent's thread.
|
28
|
+
#
|
29
|
+
# The transmitter is controlled by the debugger agent it belongs to.
|
30
|
+
# Debugger agent submits evaluated breakpoint into a thread safe queue,
|
31
|
+
# and the transmitter operates directly on the queue along with minimal
|
32
|
+
# interaction with the rest debugger agent components
|
33
|
+
#
|
34
|
+
class Transmitter
|
35
|
+
include AsyncActor
|
36
|
+
|
37
|
+
##
|
38
|
+
# @private Default maximum backlog size for the job queue
|
39
|
+
DEFAULT_MAX_QUEUE_SIZE = 1000
|
40
|
+
|
41
|
+
##
|
42
|
+
# @private The gRPC Service object.
|
43
|
+
attr_accessor :service
|
44
|
+
|
45
|
+
##
|
46
|
+
# The debugger agent this transmiter belongs to
|
47
|
+
# @return [Google::Cloud::Debugger::Agent]
|
48
|
+
attr_accessor :agent
|
49
|
+
|
50
|
+
##
|
51
|
+
# Maxium backlog size for this transmitter's queue
|
52
|
+
attr_accessor :max_queue_size
|
53
|
+
|
54
|
+
##
|
55
|
+
# @private Construct a new instance of Tramsnitter
|
56
|
+
def initialize service, agent, max_queue_size = DEFAULT_MAX_QUEUE_SIZE
|
57
|
+
super()
|
58
|
+
@service = service
|
59
|
+
@agent = agent
|
60
|
+
@max_queue_size = max_queue_size
|
61
|
+
@queue = Thread::Queue.new
|
62
|
+
end
|
63
|
+
|
64
|
+
##
|
65
|
+
# Starts the transmitter and its worker thread
|
66
|
+
def start
|
67
|
+
async_start
|
68
|
+
end
|
69
|
+
|
70
|
+
##
|
71
|
+
# Stops the transmitter and its worker thread. Once stopped, cannot be
|
72
|
+
# started again.
|
73
|
+
def stop
|
74
|
+
async_stop
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Enqueue an evaluated breakpoints to be submitted by the transmitter.
|
79
|
+
#
|
80
|
+
# @param [Google::Cloud::Debugger::Breakpoint] breakpoint The evaluated
|
81
|
+
# breakpoint to be submitted
|
82
|
+
def submit breakpoint
|
83
|
+
synchronize do
|
84
|
+
@queue.push breakpoint
|
85
|
+
@lock_cond.broadcast
|
86
|
+
# Discard old entries if queue gets too large
|
87
|
+
@queue.pop while @queue.size > @max_queue_size
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# @private Callback fucntion for AsyncActor module to run the async
|
93
|
+
# job in a loop
|
94
|
+
def run_backgrounder
|
95
|
+
breakpoint = wait_next_item
|
96
|
+
return if breakpoint.nil?
|
97
|
+
begin
|
98
|
+
service.update_active_breakpoint agent.debuggee.id, breakpoint
|
99
|
+
rescue => e
|
100
|
+
@last_exception = e
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
private
|
105
|
+
|
106
|
+
##
|
107
|
+
# @private The the next item from the transmitter queue. If there are
|
108
|
+
# no more item, it blocks the transmitter thread until an item is
|
109
|
+
# enqueued
|
110
|
+
def wait_next_item
|
111
|
+
synchronize do
|
112
|
+
@lock_cond.wait_while do
|
113
|
+
async_state == :suspended ||
|
114
|
+
(async_state == :running && @queue.empty?)
|
115
|
+
end
|
116
|
+
queue_item = nil
|
117
|
+
if @queue.empty?
|
118
|
+
@async_state = :stopped
|
119
|
+
else
|
120
|
+
queue_item = @queue.pop
|
121
|
+
end
|
122
|
+
@lock_cond.broadcast
|
123
|
+
queue_item
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
3
|
+
# you may not use this file except in compliance with the License.
|
4
|
+
# You may obtain a copy of the License at
|
5
|
+
#
|
6
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
7
|
+
#
|
8
|
+
# Unless required by applicable law or agreed to in writing, software
|
9
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
10
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
11
|
+
# See the License for the specific language governing permissions and
|
12
|
+
# limitations under the License.
|
13
|
+
|
14
|
+
require "google/cloud/debugger/v2/controller2_client"
|
15
|
+
require "google/cloud/debugger/v2/debugger2_client"
|
@@ -0,0 +1,299 @@
|
|
1
|
+
# Copyright 2017, Google Inc. All rights reserved.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/devtools/clouddebugger/v2/controller.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
#
|
22
|
+
# The only allowed edits are to method and file documentation. A 3-way
|
23
|
+
# merge preserves those additions if the generated source changes.
|
24
|
+
|
25
|
+
require "json"
|
26
|
+
require "pathname"
|
27
|
+
|
28
|
+
require "google/gax"
|
29
|
+
|
30
|
+
require "google/devtools/clouddebugger/v2/controller_pb"
|
31
|
+
|
32
|
+
module Google
|
33
|
+
module Cloud
|
34
|
+
module Debugger
|
35
|
+
module V2
|
36
|
+
# The Controller service provides the API for orchestrating a collection of
|
37
|
+
# debugger agents to perform debugging tasks. These agents are each attached
|
38
|
+
# to a process of an application which may include one or more replicas.
|
39
|
+
#
|
40
|
+
# The debugger agents register with the Controller to identify the application
|
41
|
+
# being debugged, the Debuggee. All agents that register with the same data,
|
42
|
+
# represent the same Debuggee, and are assigned the same +debuggee_id+.
|
43
|
+
#
|
44
|
+
# The debugger agents call the Controller to retrieve the list of active
|
45
|
+
# Breakpoints. Agents with the same +debuggee_id+ get the same breakpoints
|
46
|
+
# list. An agent that can fulfill the breakpoint request updates the
|
47
|
+
# Controller with the breakpoint result. The controller selects the first
|
48
|
+
# result received and discards the rest of the results.
|
49
|
+
# Agents that poll again for active breakpoints will no longer have
|
50
|
+
# the completed breakpoint in the list and should remove that breakpoint from
|
51
|
+
# their attached process.
|
52
|
+
#
|
53
|
+
# The Controller service does not provide a way to retrieve the results of
|
54
|
+
# a completed breakpoint. This functionality is available using the Debugger
|
55
|
+
# service.
|
56
|
+
#
|
57
|
+
# @!attribute [r] controller2_stub
|
58
|
+
# @return [Google::Devtools::Clouddebugger::V2::Controller2::Stub]
|
59
|
+
class Controller2Client
|
60
|
+
attr_reader :controller2_stub
|
61
|
+
|
62
|
+
# The default address of the service.
|
63
|
+
SERVICE_ADDRESS = "clouddebugger.googleapis.com".freeze
|
64
|
+
|
65
|
+
# The default port of the service.
|
66
|
+
DEFAULT_SERVICE_PORT = 443
|
67
|
+
|
68
|
+
DEFAULT_TIMEOUT = 30
|
69
|
+
|
70
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
71
|
+
# this service.
|
72
|
+
ALL_SCOPES = [
|
73
|
+
"https://www.googleapis.com/auth/cloud-platform",
|
74
|
+
"https://www.googleapis.com/auth/cloud_debugger"
|
75
|
+
].freeze
|
76
|
+
|
77
|
+
# @param service_path [String]
|
78
|
+
# The domain name of the API remote host.
|
79
|
+
# @param port [Integer]
|
80
|
+
# The port on which to connect to the remote host.
|
81
|
+
# @param channel [Channel]
|
82
|
+
# A Channel object through which to make calls.
|
83
|
+
# @param chan_creds [Grpc::ChannelCredentials]
|
84
|
+
# A ChannelCredentials for the setting up the RPC client.
|
85
|
+
# @param client_config[Hash]
|
86
|
+
# A Hash for call options for each method. See
|
87
|
+
# Google::Gax#construct_settings for the structure of
|
88
|
+
# this data. Falls back to the default config if not specified
|
89
|
+
# or the specified config is missing data points.
|
90
|
+
# @param timeout [Numeric]
|
91
|
+
# The default timeout, in seconds, for calls made through this client.
|
92
|
+
def initialize \
|
93
|
+
service_path: SERVICE_ADDRESS,
|
94
|
+
port: DEFAULT_SERVICE_PORT,
|
95
|
+
channel: nil,
|
96
|
+
chan_creds: nil,
|
97
|
+
scopes: ALL_SCOPES,
|
98
|
+
client_config: {},
|
99
|
+
timeout: DEFAULT_TIMEOUT,
|
100
|
+
app_name: nil,
|
101
|
+
app_version: nil,
|
102
|
+
lib_name: nil,
|
103
|
+
lib_version: ""
|
104
|
+
# These require statements are intentionally placed here to initialize
|
105
|
+
# the gRPC module only when it's required.
|
106
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
107
|
+
require "google/gax/grpc"
|
108
|
+
require "google/devtools/clouddebugger/v2/controller_services_pb"
|
109
|
+
|
110
|
+
|
111
|
+
if app_name || app_version
|
112
|
+
warn "`app_name` and `app_version` are no longer being used in the request headers."
|
113
|
+
end
|
114
|
+
|
115
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
116
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
117
|
+
google_api_client << " gapic/0.6.8 gax/#{Google::Gax::VERSION}"
|
118
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
119
|
+
google_api_client.freeze
|
120
|
+
|
121
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
122
|
+
client_config_file = Pathname.new(__dir__).join(
|
123
|
+
"controller2_client_config.json"
|
124
|
+
)
|
125
|
+
defaults = client_config_file.open do |f|
|
126
|
+
Google::Gax.construct_settings(
|
127
|
+
"google.devtools.clouddebugger.v2.Controller2",
|
128
|
+
JSON.parse(f.read),
|
129
|
+
client_config,
|
130
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
131
|
+
timeout,
|
132
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
133
|
+
kwargs: headers
|
134
|
+
)
|
135
|
+
end
|
136
|
+
@controller2_stub = Google::Gax::Grpc.create_stub(
|
137
|
+
service_path,
|
138
|
+
port,
|
139
|
+
chan_creds: chan_creds,
|
140
|
+
channel: channel,
|
141
|
+
scopes: scopes,
|
142
|
+
&Google::Devtools::Clouddebugger::V2::Controller2::Stub.method(:new)
|
143
|
+
)
|
144
|
+
|
145
|
+
@register_debuggee = Google::Gax.create_api_call(
|
146
|
+
@controller2_stub.method(:register_debuggee),
|
147
|
+
defaults["register_debuggee"]
|
148
|
+
)
|
149
|
+
@list_active_breakpoints = Google::Gax.create_api_call(
|
150
|
+
@controller2_stub.method(:list_active_breakpoints),
|
151
|
+
defaults["list_active_breakpoints"]
|
152
|
+
)
|
153
|
+
@update_active_breakpoint = Google::Gax.create_api_call(
|
154
|
+
@controller2_stub.method(:update_active_breakpoint),
|
155
|
+
defaults["update_active_breakpoint"]
|
156
|
+
)
|
157
|
+
end
|
158
|
+
|
159
|
+
# Service calls
|
160
|
+
|
161
|
+
# Registers the debuggee with the controller service.
|
162
|
+
#
|
163
|
+
# All agents attached to the same application should call this method with
|
164
|
+
# the same request content to get back the same stable +debuggee_id+. Agents
|
165
|
+
# should call this method again whenever +google.rpc.Code.NOT_FOUND+ is
|
166
|
+
# returned from any controller method.
|
167
|
+
#
|
168
|
+
# This allows the controller service to disable the agent or recover from any
|
169
|
+
# data loss. If the debuggee is disabled by the server, the response will
|
170
|
+
# have +is_disabled+ set to +true+.
|
171
|
+
#
|
172
|
+
# @param debuggee [Google::Devtools::Clouddebugger::V2::Debuggee]
|
173
|
+
# Debuggee information to register.
|
174
|
+
# The fields +project+, +uniquifier+, +description+ and +agent_version+
|
175
|
+
# of the debuggee must be set.
|
176
|
+
# @param options [Google::Gax::CallOptions]
|
177
|
+
# Overrides the default settings for this call, e.g, timeout,
|
178
|
+
# retries, etc.
|
179
|
+
# @return [Google::Devtools::Clouddebugger::V2::RegisterDebuggeeResponse]
|
180
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
181
|
+
# @example
|
182
|
+
# require "google/cloud/debugger/v2/controller2_client"
|
183
|
+
#
|
184
|
+
# Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
|
185
|
+
# Debuggee = Google::Devtools::Clouddebugger::V2::Debuggee
|
186
|
+
#
|
187
|
+
# controller2_client = Controller2Client.new
|
188
|
+
# debuggee = Debuggee.new
|
189
|
+
# response = controller2_client.register_debuggee(debuggee)
|
190
|
+
|
191
|
+
def register_debuggee \
|
192
|
+
debuggee,
|
193
|
+
options: nil
|
194
|
+
req = Google::Devtools::Clouddebugger::V2::RegisterDebuggeeRequest.new({
|
195
|
+
debuggee: debuggee
|
196
|
+
}.delete_if { |_, v| v.nil? })
|
197
|
+
@register_debuggee.call(req, options)
|
198
|
+
end
|
199
|
+
|
200
|
+
# Returns the list of all active breakpoints for the debuggee.
|
201
|
+
#
|
202
|
+
# The breakpoint specification (location, condition, and expression
|
203
|
+
# fields) is semantically immutable, although the field values may
|
204
|
+
# change. For example, an agent may update the location line number
|
205
|
+
# to reflect the actual line where the breakpoint was set, but this
|
206
|
+
# doesn't change the breakpoint semantics.
|
207
|
+
#
|
208
|
+
# This means that an agent does not need to check if a breakpoint has changed
|
209
|
+
# when it encounters the same breakpoint on a successive call.
|
210
|
+
# Moreover, an agent should remember the breakpoints that are completed
|
211
|
+
# until the controller removes them from the active list to avoid
|
212
|
+
# setting those breakpoints again.
|
213
|
+
#
|
214
|
+
# @param debuggee_id [String]
|
215
|
+
# Identifies the debuggee.
|
216
|
+
# @param wait_token [String]
|
217
|
+
# A wait token that, if specified, blocks the method call until the list
|
218
|
+
# of active breakpoints has changed, or a server selected timeout has
|
219
|
+
# expired. The value should be set from the last returned response.
|
220
|
+
# @param success_on_timeout [true, false]
|
221
|
+
# If set to +true+, returns +google.rpc.Code.OK+ status and sets the
|
222
|
+
# +wait_expired+ response field to +true+ when the server-selected timeout
|
223
|
+
# has expired (recommended).
|
224
|
+
#
|
225
|
+
# If set to +false+, returns +google.rpc.Code.ABORTED+ status when the
|
226
|
+
# server-selected timeout has expired (deprecated).
|
227
|
+
# @param options [Google::Gax::CallOptions]
|
228
|
+
# Overrides the default settings for this call, e.g, timeout,
|
229
|
+
# retries, etc.
|
230
|
+
# @return [Google::Devtools::Clouddebugger::V2::ListActiveBreakpointsResponse]
|
231
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
232
|
+
# @example
|
233
|
+
# require "google/cloud/debugger/v2/controller2_client"
|
234
|
+
#
|
235
|
+
# Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
|
236
|
+
#
|
237
|
+
# controller2_client = Controller2Client.new
|
238
|
+
# debuggee_id = ''
|
239
|
+
# response = controller2_client.list_active_breakpoints(debuggee_id)
|
240
|
+
|
241
|
+
def list_active_breakpoints \
|
242
|
+
debuggee_id,
|
243
|
+
wait_token: nil,
|
244
|
+
success_on_timeout: nil,
|
245
|
+
options: nil
|
246
|
+
req = Google::Devtools::Clouddebugger::V2::ListActiveBreakpointsRequest.new({
|
247
|
+
debuggee_id: debuggee_id,
|
248
|
+
wait_token: wait_token,
|
249
|
+
success_on_timeout: success_on_timeout
|
250
|
+
}.delete_if { |_, v| v.nil? })
|
251
|
+
@list_active_breakpoints.call(req, options)
|
252
|
+
end
|
253
|
+
|
254
|
+
# Updates the breakpoint state or mutable fields.
|
255
|
+
# The entire Breakpoint message must be sent back to the controller
|
256
|
+
# service.
|
257
|
+
#
|
258
|
+
# Updates to active breakpoint fields are only allowed if the new value
|
259
|
+
# does not change the breakpoint specification. Updates to the +location+,
|
260
|
+
# +condition+ and +expression+ fields should not alter the breakpoint
|
261
|
+
# semantics. These may only make changes such as canonicalizing a value
|
262
|
+
# or snapping the location to the correct line of code.
|
263
|
+
#
|
264
|
+
# @param debuggee_id [String]
|
265
|
+
# Identifies the debuggee being debugged.
|
266
|
+
# @param breakpoint [Google::Devtools::Clouddebugger::V2::Breakpoint]
|
267
|
+
# Updated breakpoint information.
|
268
|
+
# The field 'id' must be set.
|
269
|
+
# @param options [Google::Gax::CallOptions]
|
270
|
+
# Overrides the default settings for this call, e.g, timeout,
|
271
|
+
# retries, etc.
|
272
|
+
# @return [Google::Devtools::Clouddebugger::V2::UpdateActiveBreakpointResponse]
|
273
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
274
|
+
# @example
|
275
|
+
# require "google/cloud/debugger/v2/controller2_client"
|
276
|
+
#
|
277
|
+
# Breakpoint = Google::Devtools::Clouddebugger::V2::Breakpoint
|
278
|
+
# Controller2Client = Google::Cloud::Debugger::V2::Controller2Client
|
279
|
+
#
|
280
|
+
# controller2_client = Controller2Client.new
|
281
|
+
# debuggee_id = ''
|
282
|
+
# breakpoint = Breakpoint.new
|
283
|
+
# response = controller2_client.update_active_breakpoint(debuggee_id, breakpoint)
|
284
|
+
|
285
|
+
def update_active_breakpoint \
|
286
|
+
debuggee_id,
|
287
|
+
breakpoint,
|
288
|
+
options: nil
|
289
|
+
req = Google::Devtools::Clouddebugger::V2::UpdateActiveBreakpointRequest.new({
|
290
|
+
debuggee_id: debuggee_id,
|
291
|
+
breakpoint: breakpoint
|
292
|
+
}.delete_if { |_, v| v.nil? })
|
293
|
+
@update_active_breakpoint.call(req, options)
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
end
|