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
-
#action ⇒ Symbol
Action to take when a breakpoint is hit.
-
#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.
-
#evaluated_log_message ⇒ Object
The evaluated log message when action is LOG.
-
#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.
-
#log_level ⇒ Object
Indicates the severity of the log.
-
#log_message_format ⇒ Object
Only relevant when action is LOG.
-
#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.
-
#evaluate(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
#action ⇒ Symbol
Action to take when a breakpoint is hit. Either :CAPTURE or :LOG.
35 36 37 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 35 def action @action end |
#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.
62 63 64 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 62 def condition @condition end |
#create_time ⇒ Time
Time this breakpoint was created by the server in seconds resolution.
91 92 93 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 91 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.
86 87 88 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 86 def evaluated_expressions @evaluated_expressions end |
#evaluated_log_message ⇒ Object
The evaluated log message when action is LOG.
51 52 53 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 51 def @evaluated_log_message 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.
76 77 78 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 76 def expressions @expressions end |
#final_time ⇒ Time
Time this breakpoint was finalized as seen by the server in seconds resolution.
97 98 99 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 97 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.
68 69 70 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 68 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.
134 135 136 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 134 def labels @labels end |
#location ⇒ Google::Cloud::Debugger::Breakpoint::SourceLocation
Breakpoint source location.
56 57 58 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 56 def location @location end |
#log_level ⇒ Object
Indicates the severity of the log. Only relevant when action is LOG.
47 48 49 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 47 def log_level @log_level end |
#log_message_format ⇒ Object
Only relevant when action is LOG. Defines the message to log when the breakpoint hits. The message may include parameter placeholders $0, $1, etc. These placeholders are replaced with the evaluated value of the appropriate expression. Expressions not referenced in logMessageFormat are not logged.
43 44 45 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 43 def @log_message_format end |
#stack_frames ⇒ Array<Google::Cloud::Debugger::Breakpoint::StackFrame>
The stack at breakpoint time.
139 140 141 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 139 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.
112 113 114 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 112 def status @status end |
#user_email ⇒ Object
E-mail address of the user that created this breakpoint
101 102 103 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 101 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.
254 255 256 257 258 259 260 261 262 263 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 254 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.
214 215 216 217 218 219 220 221 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 214 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
289 290 291 292 293 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 289 def eql? other id == other.id && path == other.path && line == other.line end |
#evaluate(call_stack_bindings) ⇒ Boolean
Evaluate the breakpoint unless it's already marked as completed. Store evaluted results in @evaluated_expressions, @stack_frames, and @evaluated_log_message, depends on the action of breakpoint. Mark breakpoint complete if successfully evaluated a breakpoint with :CAPTURE action.
278 279 280 281 282 283 284 285 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 278 def evaluate call_stack_bindings case action when :CAPTURE evaluate_snapshot_point call_stack_bindings when :LOG evaluate_logpoint call_stack_bindings[0] end end |
#line ⇒ Integer
Get the line number of this breakpoint
241 242 243 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 241 def line location.nil? ? nil : location.line end |
#path ⇒ String
Get the file path of this breakpoint
231 232 233 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 231 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.
335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 335 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 |