google-cloud-debugger 0.30.0 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +111 -75
- data/ext/google/cloud/debugger/debugger_c/evaluator.c +14 -9
- data/lib/google-cloud-debugger.rb +55 -0
- data/lib/google/cloud/debugger.rb +140 -22
- data/lib/google/cloud/debugger/agent.rb +4 -4
- data/lib/google/cloud/debugger/breakpoint.rb +2 -2
- data/lib/google/cloud/debugger/breakpoint/evaluator.rb +885 -828
- data/lib/google/cloud/debugger/breakpoint/source_location.rb +1 -2
- data/lib/google/cloud/debugger/breakpoint/validator.rb +6 -6
- data/lib/google/cloud/debugger/breakpoint/variable.rb +7 -8
- data/lib/google/cloud/debugger/breakpoint_manager.rb +1 -1
- data/lib/google/cloud/debugger/credentials.rb +7 -7
- data/lib/google/cloud/debugger/debuggee.rb +4 -8
- data/lib/google/cloud/debugger/debuggee/app_uniquifier_generator.rb +0 -2
- data/lib/google/cloud/debugger/logpoint.rb +1 -1
- data/lib/google/cloud/debugger/middleware.rb +16 -18
- data/lib/google/cloud/debugger/project.rb +2 -28
- data/lib/google/cloud/debugger/rails.rb +21 -9
- data/lib/google/cloud/debugger/service.rb +4 -2
- data/lib/google/cloud/debugger/snappoint.rb +1 -1
- data/lib/google/cloud/debugger/tracer.rb +2 -1
- data/lib/google/cloud/debugger/transmitter.rb +1 -1
- data/lib/google/cloud/debugger/version.rb +1 -1
- metadata +11 -11
@@ -22,9 +22,9 @@ module Google
|
|
22
22
|
#
|
23
23
|
# A collection of static methods to help validate a given breakpoint.
|
24
24
|
module Validator
|
25
|
-
FILE_NOT_FOUND_MSG = "File not found."
|
26
|
-
WRONG_FILE_TYPE_MSG = "File must be a `.rb` file."
|
27
|
-
INVALID_LINE_MSG = "Invalid line."
|
25
|
+
FILE_NOT_FOUND_MSG = "File not found.".freeze
|
26
|
+
WRONG_FILE_TYPE_MSG = "File must be a `.rb` file.".freeze
|
27
|
+
INVALID_LINE_MSG = "Invalid line.".freeze
|
28
28
|
|
29
29
|
##
|
30
30
|
# Validate a given breakpoint. Set breakpoint to error state if
|
@@ -52,7 +52,7 @@ module Google
|
|
52
52
|
# @private Verifies the given file path exists
|
53
53
|
def self.verify_file_path file_path
|
54
54
|
File.exist? file_path
|
55
|
-
rescue
|
55
|
+
rescue StandardError
|
56
56
|
false
|
57
57
|
end
|
58
58
|
|
@@ -61,7 +61,7 @@ module Google
|
|
61
61
|
def self.verify_file_type file_path
|
62
62
|
File.extname(file_path) == ".rb" ||
|
63
63
|
File.basename(file_path) == "config.ru"
|
64
|
-
rescue
|
64
|
+
rescue StandardError
|
65
65
|
false
|
66
66
|
end
|
67
67
|
|
@@ -82,7 +82,7 @@ module Google
|
|
82
82
|
comment_line = line =~ /^\s*#.*$/
|
83
83
|
|
84
84
|
blank_line || comment_line ? false : true
|
85
|
-
rescue
|
85
|
+
rescue StandardError
|
86
86
|
false
|
87
87
|
end
|
88
88
|
end
|
@@ -99,11 +99,12 @@ module Google
|
|
99
99
|
##
|
100
100
|
# @private Message to display on variables when snapshot buffer is
|
101
101
|
# full.
|
102
|
-
BUFFER_FULL_MSG =
|
102
|
+
BUFFER_FULL_MSG =
|
103
|
+
"Buffer full. Use an expression to see more data.".freeze
|
103
104
|
|
104
105
|
##
|
105
106
|
# @private Error message when variable can't be converted.
|
106
|
-
FAIL_CONVERSION_MSG = "Error: Unable to inspect value"
|
107
|
+
FAIL_CONVERSION_MSG = "Error: Unable to inspect value".freeze
|
107
108
|
|
108
109
|
##
|
109
110
|
# @private Name of the variable, if any.
|
@@ -249,7 +250,7 @@ module Google
|
|
249
250
|
else
|
250
251
|
from_primitive_var source, name: name, limit: limit
|
251
252
|
end
|
252
|
-
rescue
|
253
|
+
rescue StandardError
|
253
254
|
new.tap do |var|
|
254
255
|
var.name = name.to_s if name
|
255
256
|
var.set_error_state FAIL_CONVERSION_MSG
|
@@ -576,11 +577,9 @@ module Google
|
|
576
577
|
# @private Exports the Variable var_table_index attribute to
|
577
578
|
# an Int32Value gRPC struct
|
578
579
|
def var_table_index_to_grpc
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
nil
|
583
|
-
end
|
580
|
+
return unless var_table_index
|
581
|
+
|
582
|
+
Google::Protobuf::Int32Value.new value: var_table_index
|
584
583
|
end
|
585
584
|
|
586
585
|
##
|
@@ -39,20 +39,20 @@ module Google
|
|
39
39
|
# debugger.project_id #=> "my-project"
|
40
40
|
#
|
41
41
|
class Credentials < Google::Auth::Credentials
|
42
|
-
SCOPE = ["https://www.googleapis.com/auth/cloud_debugger"] +
|
43
|
-
|
44
|
-
PATH_ENV_VARS = %w
|
42
|
+
SCOPE = (["https://www.googleapis.com/auth/cloud_debugger"] +
|
43
|
+
Google::Cloud::Logging::Credentials::SCOPE).freeze
|
44
|
+
PATH_ENV_VARS = %w[DEBUGGER_CREDENTIALS
|
45
45
|
GOOGLE_CLOUD_CREDENTIALS
|
46
46
|
DEBUGGER_KEYFILE
|
47
47
|
GOOGLE_CLOUD_KEYFILE
|
48
|
-
GCLOUD_KEYFILE
|
49
|
-
JSON_ENV_VARS = %w
|
48
|
+
GCLOUD_KEYFILE].freeze
|
49
|
+
JSON_ENV_VARS = %w[DEBUGGER_CREDENTIALS_JSON
|
50
50
|
GOOGLE_CLOUD_CREDENTIALS_JSON
|
51
51
|
DEBUGGER_KEYFILE_JSON
|
52
52
|
GOOGLE_CLOUD_KEYFILE_JSON
|
53
|
-
GCLOUD_KEYFILE_JSON
|
53
|
+
GCLOUD_KEYFILE_JSON].freeze
|
54
54
|
DEFAULT_PATHS = \
|
55
|
-
["~/.config/gcloud/application_default_credentials.json"]
|
55
|
+
["~/.config/gcloud/application_default_credentials.json"].freeze
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -86,7 +86,7 @@ module Google
|
|
86
86
|
begin
|
87
87
|
response = service.register_debuggee to_grpc
|
88
88
|
@id = response.debuggee.id
|
89
|
-
rescue
|
89
|
+
rescue StandardError
|
90
90
|
revoke_registration
|
91
91
|
end
|
92
92
|
|
@@ -134,12 +134,8 @@ module Google
|
|
134
134
|
debuggee_args[:id] = id if id
|
135
135
|
|
136
136
|
source_context = read_app_json_file "source-context.json"
|
137
|
-
|
138
|
-
|
139
|
-
source_contexts = read_app_json_file "source-contexts.json"
|
140
|
-
if source_contexts
|
141
|
-
debuggee_args[:ext_source_contexts] = source_contexts
|
142
|
-
elsif source_context
|
137
|
+
if source_context
|
138
|
+
debuggee_args[:source_contexts] = [source_context]
|
143
139
|
debuggee_args[:ext_source_contexts] = [{ context: source_context }]
|
144
140
|
end
|
145
141
|
|
@@ -219,7 +215,7 @@ module Google
|
|
219
215
|
# @private Helper method to parse json file
|
220
216
|
def read_app_json_file file_path
|
221
217
|
JSON.parse File.read(file_path), symbolize_names: true
|
222
|
-
rescue
|
218
|
+
rescue StandardError
|
223
219
|
nil
|
224
220
|
end
|
225
221
|
end
|
@@ -49,8 +49,8 @@ module Google
|
|
49
49
|
@debugger = debugger
|
50
50
|
else
|
51
51
|
@debugger =
|
52
|
-
Debugger.new(
|
53
|
-
|
52
|
+
Debugger.new(project_id: configuration.project_id,
|
53
|
+
credentials: configuration.credentials,
|
54
54
|
service_name: configuration.service_name,
|
55
55
|
service_version: configuration.service_version)
|
56
56
|
|
@@ -98,16 +98,17 @@ module Google
|
|
98
98
|
# already.
|
99
99
|
#
|
100
100
|
def load_config **kwargs
|
101
|
-
|
102
|
-
|
103
|
-
configuration.project_id
|
104
|
-
configuration.keyfile = kwargs[:keyfile] ||
|
105
|
-
configuration.keyfile
|
101
|
+
project_id = kwargs[:project] || kwargs[:project_id]
|
102
|
+
configuration.project_id = project_id unless project_id.nil?
|
106
103
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
104
|
+
creds = kwargs[:credentials] || kwargs[:keyfile]
|
105
|
+
configuration.credentials = creds unless creds.nil?
|
106
|
+
|
107
|
+
service_name = kwargs[:service_name]
|
108
|
+
configuration.service_name = service_name unless service_name.nil?
|
109
|
+
|
110
|
+
service_vers = kwargs[:service_version]
|
111
|
+
configuration.service_version = service_vers unless service_vers.nil?
|
111
112
|
|
112
113
|
init_default_config
|
113
114
|
end
|
@@ -115,13 +116,10 @@ module Google
|
|
115
116
|
##
|
116
117
|
# Fallback to default configuration values if not defined already
|
117
118
|
def init_default_config
|
118
|
-
configuration.project_id ||=
|
119
|
-
|
120
|
-
configuration.
|
121
|
-
|
122
|
-
configuration.service_name ||= Debugger::Project.default_service_name
|
123
|
-
configuration.service_version ||=
|
124
|
-
Debugger::Project.default_service_version
|
119
|
+
configuration.project_id ||= Debugger.default_project_id
|
120
|
+
configuration.credentials ||= Debugger.default_credentials
|
121
|
+
configuration.service_name ||= Debugger.default_service_name
|
122
|
+
configuration.service_version ||= Debugger.default_service_version
|
125
123
|
end
|
126
124
|
|
127
125
|
##
|
@@ -14,7 +14,6 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
require "google/cloud/errors"
|
17
|
-
require "google/cloud/env"
|
18
17
|
require "google/cloud/debugger/agent"
|
19
18
|
require "google/cloud/debugger/credentials"
|
20
19
|
require "google/cloud/debugger/middleware"
|
@@ -74,32 +73,7 @@ module Google
|
|
74
73
|
def project_id
|
75
74
|
service.project
|
76
75
|
end
|
77
|
-
|
78
|
-
|
79
|
-
##
|
80
|
-
# @private Default project.
|
81
|
-
def self.default_project_id
|
82
|
-
ENV["DEBUGGER_PROJECT"] ||
|
83
|
-
ENV["GOOGLE_CLOUD_PROJECT"] ||
|
84
|
-
ENV["GCLOUD_PROJECT"] ||
|
85
|
-
Google::Cloud.env.project_id
|
86
|
-
end
|
87
|
-
|
88
|
-
##
|
89
|
-
# @private Default service name identifier.
|
90
|
-
def self.default_service_name
|
91
|
-
ENV["DEBUGGER_SERVICE_NAME"] ||
|
92
|
-
Google::Cloud.env.app_engine_service_id ||
|
93
|
-
"ruby-app"
|
94
|
-
end
|
95
|
-
|
96
|
-
##
|
97
|
-
# @private Default service version identifier.
|
98
|
-
def self.default_service_version
|
99
|
-
ENV["DEBUGGER_SERVICE_VERSION"] ||
|
100
|
-
Google::Cloud.env.app_engine_service_version ||
|
101
|
-
""
|
102
|
-
end
|
76
|
+
alias project project_id
|
103
77
|
|
104
78
|
##
|
105
79
|
# Start the Stackdriver Debugger Agent.
|
@@ -114,7 +88,7 @@ module Google
|
|
114
88
|
def start
|
115
89
|
agent.start
|
116
90
|
end
|
117
|
-
|
91
|
+
alias attach start
|
118
92
|
|
119
93
|
##
|
120
94
|
# Stop the Stackdriver Debugger Agent.
|
@@ -80,7 +80,7 @@ module Google
|
|
80
80
|
# Verify credentials and set use_debugger to false if
|
81
81
|
# credentials are invalid
|
82
82
|
unless valid_credentials? Debugger.configure.project_id,
|
83
|
-
Debugger.configure.
|
83
|
+
Debugger.configure.credentials
|
84
84
|
Cloud.configure.use_debugger = false
|
85
85
|
return
|
86
86
|
end
|
@@ -90,6 +90,8 @@ module Google
|
|
90
90
|
Google::Cloud.configure.use_debugger ||= Rails.env.production?
|
91
91
|
end
|
92
92
|
|
93
|
+
# rubocop:disable all
|
94
|
+
|
93
95
|
##
|
94
96
|
# @private Merge Rails configuration into Debugger instrumentation
|
95
97
|
# configuration.
|
@@ -99,20 +101,30 @@ module Google
|
|
99
101
|
|
100
102
|
Cloud.configure.use_debugger ||= gcp_config.use_debugger
|
101
103
|
Debugger.configure do |config|
|
102
|
-
config.project_id ||=
|
103
|
-
|
104
|
-
|
105
|
-
|
104
|
+
config.project_id ||= begin
|
105
|
+
config.project || dbg_config.project_id || dbg_config.project
|
106
|
+
gcp_config.project_id || gcp_config.project
|
107
|
+
end
|
108
|
+
config.credentials ||= begin
|
109
|
+
config.keyfile || dbg_config.credentials || dbg_config.keyfile
|
110
|
+
gcp_config.credentials || gcp_config.keyfile
|
111
|
+
end
|
112
|
+
config.service_name ||= \
|
113
|
+
(dbg_config.service_name || gcp_config.service_name)
|
114
|
+
config.service_version ||= \
|
115
|
+
(dbg_config.service_version || gcp_config.service_version)
|
106
116
|
end
|
107
117
|
end
|
108
118
|
|
119
|
+
# rubocop:enable all
|
120
|
+
|
109
121
|
##
|
110
122
|
# Fallback to default config values if config parameters not provided.
|
111
123
|
def self.init_default_config
|
112
124
|
config = Debugger.configure
|
113
|
-
config.project_id ||= Debugger
|
114
|
-
config.service_name ||= Debugger
|
115
|
-
config.service_version ||= Debugger
|
125
|
+
config.project_id ||= Debugger.default_project_id
|
126
|
+
config.service_name ||= Debugger.default_service_name
|
127
|
+
config.service_version ||= Debugger.default_service_version
|
116
128
|
end
|
117
129
|
|
118
130
|
##
|
@@ -126,7 +138,7 @@ module Google
|
|
126
138
|
# if credentials is not a Credentials object, create one
|
127
139
|
Debugger::Credentials.new credentials
|
128
140
|
end
|
129
|
-
rescue => e
|
141
|
+
rescue StandardError => e
|
130
142
|
STDOUT.puts "Note: Google::Cloud::Debugger is disabled because " \
|
131
143
|
"it failed to authorize with the service. (#{e.message})"
|
132
144
|
return false
|
@@ -44,7 +44,8 @@ module Google
|
|
44
44
|
timeout: timeout,
|
45
45
|
client_config: client_config,
|
46
46
|
lib_name: "gccl",
|
47
|
-
lib_version: Google::Cloud::Debugger::VERSION
|
47
|
+
lib_version: Google::Cloud::Debugger::VERSION
|
48
|
+
)
|
48
49
|
end
|
49
50
|
attr_accessor :mocked_debugger
|
50
51
|
|
@@ -56,7 +57,8 @@ module Google
|
|
56
57
|
timeout: timeout,
|
57
58
|
client_config: client_config,
|
58
59
|
lib_name: "gccl",
|
59
|
-
lib_version: Google::Cloud::Debugger::VERSION
|
60
|
+
lib_version: Google::Cloud::Debugger::VERSION
|
61
|
+
)
|
60
62
|
end
|
61
63
|
attr_accessor :mocked_transmitter
|
62
64
|
|
@@ -81,7 +81,8 @@ module Google
|
|
81
81
|
breakpoints_hash[breakpoint_path] ||= {}
|
82
82
|
breakpoints_hash[breakpoint_path][breakpoint_line] ||= []
|
83
83
|
breakpoints_hash[breakpoint_path][breakpoint_line].push(
|
84
|
-
active_breakpoint
|
84
|
+
active_breakpoint
|
85
|
+
)
|
85
86
|
end
|
86
87
|
|
87
88
|
# Tracer is explicitly designed to not have a lock. This should be the
|
@@ -97,7 +97,7 @@ module Google
|
|
97
97
|
return if breakpoint.nil?
|
98
98
|
begin
|
99
99
|
service.update_active_breakpoint agent.debuggee.id, breakpoint
|
100
|
-
rescue => e
|
100
|
+
rescue StandardError => e
|
101
101
|
warn ["#{e.class}: #{e.message}", e.backtrace].join("\n\t")
|
102
102
|
@last_exception = e
|
103
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google-cloud-debugger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Heng Xiong
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: binding_of_caller
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.2'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.2'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: google-cloud-logging
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.3'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.3'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: minitest
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -154,16 +154,16 @@ dependencies:
|
|
154
154
|
name: rubocop
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - "
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 0.50.0
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - "
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 0.50.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: simplecov
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -328,7 +328,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
328
328
|
version: '0'
|
329
329
|
requirements: []
|
330
330
|
rubyforge_project:
|
331
|
-
rubygems_version: 2.7.
|
331
|
+
rubygems_version: 2.7.6
|
332
332
|
signing_key:
|
333
333
|
specification_version: 4
|
334
334
|
summary: API Client and instrumentation library for Stackdriver Debugger
|