Class: Google::Cloud::Debugger::Breakpoint
- Inherits:
-
Object
- Object
- Google::Cloud::Debugger::Breakpoint
- Includes:
- MonitorMixin
- Defined in:
- lib/google/cloud/debugger/breakpoint.rb,
lib/google/cloud/debugger/breakpoint/variable.rb,
lib/google/cloud/debugger/breakpoint/evaluator.rb,
lib/google/cloud/debugger/breakpoint/stack_frame.rb,
lib/google/cloud/debugger/breakpoint/source_location.rb
Defined Under Namespace
Modules: Evaluator Classes: SourceLocation, StackFrame, Variable
Instance Attribute Summary collapse
-
#condition ⇒ Object
Condition that triggers the breakpoint.
-
#create_time ⇒ Time
Time this breakpoint was created by the server in seconds resolution.
-
#evaluated_expressions ⇒ Array<Google::Cloud::Debugger::Breakpoint::Variable>
Values of evaluated expressions at breakpoint time.
-
#expressions ⇒ Array<String>
List of read-only expressions to evaluate at the breakpoint location.
-
#final_time ⇒ Time
Time this breakpoint was finalized as seen by the server in seconds resolution.
-
#id ⇒ Object
Breakpoint identifier, unique in the scope of the debuggee.
-
#is_final_state ⇒ Boolean
(also: #complete?)
When true, indicates that this is a final result and the breakpoint state will not change from here on.
-
#labels ⇒ Hash<String, String>
A set of custom breakpoint properties, populated by the agent, to be displayed to the user.
-
#location ⇒ Google::Cloud::Debugger::Breakpoint::SourceLocation
Breakpoint source location.
-
#stack_frames ⇒ Array<Google::Cloud::Debugger::Breakpoint::StackFrame>
The stack at breakpoint time.
-
#status ⇒ Object
Breakpoint status.
-
#user_email ⇒ Object
E-mail address of the user that created this breakpoint.
Instance Method Summary collapse
-
#check_condition(binding) ⇒ Boolean
Evaluate the breakpoint's condition expression against a given binding object.
-
#complete ⇒ Object
Marks a breakpoint as complete if this breakpoint isn't completed already.
-
#eql?(other) ⇒ Boolean
Check if two breakpoints are equal to each other.
-
#eval_call_stack(call_stack_bindings) ⇒ Boolean
Evaluate the breakpoint unless it's already marked as completed.
-
#line ⇒ Integer
Get the line number of this breakpoint.
-
#path ⇒ String
Get the file path of this breakpoint.
-
#set_error_state(message, refers_to: :UNSPECIFIED, is_final: true) ⇒ Google::Devtools::Clouddebugger::V2::StatusMessage
Set breakpoint to an error state, which initializes the @status instance variable with the error message.
Instance Attribute Details
#condition ⇒ Object
Condition that triggers the breakpoint. The condition is a compound boolean expression composed using expressions in a programming language at the source location.
46 47 48 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 46 def condition @condition end |
#create_time ⇒ Time
Time this breakpoint was created by the server in seconds resolution.
75 76 77 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 75 def create_time @create_time end |
#evaluated_expressions ⇒ Array<Google::Cloud::Debugger::Breakpoint::Variable>
Values of evaluated expressions at breakpoint time. The evaluated expressions appear in exactly the same order they are listed in the expressions field. The name field holds the original expression text, the value or members field holds the result of the evaluated expression. If the expression cannot be evaluated, the status inside the Variable will indicate an error and contain the error text.
70 71 72 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 70 def evaluated_expressions @evaluated_expressions end |
#expressions ⇒ Array<String>
List of read-only expressions to evaluate at the breakpoint location. The expressions are composed using expressions in the programming language at the source location. If the breakpoint action is LOG, the evaluated expressions are included in log statements.
60 61 62 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 60 def expressions @expressions end |
#final_time ⇒ Time
Time this breakpoint was finalized as seen by the server in seconds resolution.
81 82 83 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 81 def final_time @final_time end |
#id ⇒ Object
Breakpoint identifier, unique in the scope of the debuggee.
30 31 32 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 30 def id @id end |
#is_final_state ⇒ Boolean Also known as: complete?
When true, indicates that this is a final result and the breakpoint state will not change from here on.
52 53 54 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 52 def is_final_state @is_final_state end |
#labels ⇒ Hash<String, String>
A set of custom breakpoint properties, populated by the agent, to be displayed to the user.
118 119 120 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 118 def labels @labels end |
#location ⇒ Google::Cloud::Debugger::Breakpoint::SourceLocation
Breakpoint source location.
40 41 42 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 40 def location @location end |
#stack_frames ⇒ Array<Google::Cloud::Debugger::Breakpoint::StackFrame>
The stack at breakpoint time.
123 124 125 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 123 def stack_frames @stack_frames end |
#status ⇒ Object
Breakpoint status.
The status includes an error flag and a human readable message. This field is usually unset. The message can be either informational or an error message. Regardless, clients should always display the text message back to the user.
Error status indicates complete failure of the breakpoint.
96 97 98 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 96 def status @status end |
#user_email ⇒ Object
E-mail address of the user that created this breakpoint
85 86 87 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 85 def user_email @user_email end |
Instance Method Details
#check_condition(binding) ⇒ Boolean
Evaluate the breakpoint's condition expression against a given binding object. Returns true if the condition expression evalutes to true; false if error happens or the expression evaluates to false.
234 235 236 237 238 239 240 241 242 243 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 234 def check_condition binding return true if condition.nil? || condition.empty? begin Evaluator.eval_condition binding, condition rescue set_error_state "Unable to evaluate condition", refers_to: :BREAKPOINT_CONDITION false end end |
#complete ⇒ Object
Marks a breakpoint as complete if this breakpoint isn't completed already. Set @is_final_state to true and set @final_time.
194 195 196 197 198 199 200 201 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 194 def complete synchronize do return if complete? @is_final_state = true @final_time = Time.now end end |
#eql?(other) ⇒ Boolean
Check if two breakpoints are equal to each other
282 283 284 285 286 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 282 def eql? other id == other.id && path == other.path && line == other.line end |
#eval_call_stack(call_stack_bindings) ⇒ Boolean
Evaluate the breakpoint unless it's already marked as completed. Use "@stack_frames" and "@evaluated_expressions" instance variables to store the result snapshot. Set breakpoint to complete when done.
256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 256 def eval_call_stack call_stack_bindings synchronize do return false if complete? top_frame_binding = call_stack_bindings[0] # Abort evaluation if breakpoint condition isn't met return false unless check_condition top_frame_binding begin @stack_frames = Evaluator.eval_call_stack call_stack_bindings unless expressions.empty? @evaluated_expressions = Evaluator.eval_expressions top_frame_binding, @expressions end rescue return false end complete end true end |
#line ⇒ Integer
Get the line number of this breakpoint
221 222 223 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 221 def line location.nil? ? nil : location.line end |
#path ⇒ String
Get the file path of this breakpoint
211 212 213 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 211 def path location.nil? ? nil : location.path end |
#set_error_state(message, refers_to: :UNSPECIFIED, is_final: true) ⇒ Google::Devtools::Clouddebugger::V2::StatusMessage
Set breakpoint to an error state, which initializes the @status instance variable with the error message. Also mark this breakpoint as completed if is_final is true.
328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 328 def set_error_state , refers_to: :UNSPECIFIED, is_final: true description = Google::Devtools::Clouddebugger::V2::FormatMessage.new( format: ) @status = Google::Devtools::Clouddebugger::V2::StatusMessage.new( is_error: true, refers_to: refers_to, description: description ) complete if is_final @status end |