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/validator.rb,
lib/google/cloud/debugger/breakpoint/stack_frame.rb,
lib/google/cloud/debugger/breakpoint/status_message.rb,
lib/google/cloud/debugger/breakpoint/variable_table.rb,
lib/google/cloud/debugger/breakpoint/source_location.rb
Overview
Breakpoint
Abstract class that represents a breakpoint, which can be set and triggered in a debuggee application. Maps to gRPC struct Devtools::Clouddebugger::V2::Breakpoint.
Defined Under Namespace
Modules: Evaluator, Validator Classes: SourceLocation, StackFrame, StatusMessage, Variable, VariableTable
Instance Attribute Summary collapse
-
#action ⇒ Symbol
Action to take when a breakpoint is hit.
-
#app_root ⇒ String
Absolute path to the debuggee Ruby application root directory.
-
#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
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.
-
#variable_table ⇒ Object
The variable_table exists to aid with computation, memory and network traffic optimization.
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.
-
#complete? ⇒ Boolean
Check if the breakpoint has been evaluated or set to a final error state.
-
#eql?(other) ⇒ Boolean
Check if two breakpoints are equal to each other.
-
#full_path ⇒ Object
Get full absolute file path by combining the relative file path with application root directory path.
-
#line ⇒ Integer
Get the line number of this breakpoint.
-
#path ⇒ String
Get the file path of this breakpoint.
-
#set_error_state(message, refers_to: StatusMessage::UNSPECIFIED, is_final: true) ⇒ Google::Cloud::Debugger::Breakpoint::StatusMessage
Set breakpoint to an error state, which initializes the @status instance variable with the error message.
-
#valid? ⇒ Boolean
Check if the breakpoint is valid or not.
Instance Attribute Details
#action ⇒ Symbol
Action to take when a breakpoint is hit. Either :CAPTURE or :LOG.
45 46 47 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 45 def action @action end |
#app_root ⇒ String
Absolute path to the debuggee Ruby application root directory.
50 51 52 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 50 def app_root @app_root 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.
77 78 79 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 77 def condition @condition end |
#create_time ⇒ Time
Time this breakpoint was created by the server in seconds resolution.
106 107 108 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 106 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.
101 102 103 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 101 def evaluated_expressions @evaluated_expressions end |
#evaluated_log_message ⇒ Object
The evaluated log message when action is LOG.
66 67 68 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 66 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.
91 92 93 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 91 def expressions @expressions end |
#final_time ⇒ Time
Time this breakpoint was finalized as seen by the server in seconds resolution.
112 113 114 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 112 def final_time @final_time end |
#id ⇒ Object
Breakpoint identifier, unique in the scope of the debuggee.
40 41 42 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 40 def id @id end |
#is_final_state ⇒ Boolean
When true, indicates that this is a final result and the breakpoint state will not change from here on.
83 84 85 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 83 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.
148 149 150 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 148 def labels @labels end |
#location ⇒ Google::Cloud::Debugger::Breakpoint::SourceLocation
Breakpoint source location.
71 72 73 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 71 def location @location end |
#log_level ⇒ Object
Indicates the severity of the log. Only relevant when action is LOG.
62 63 64 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 62 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.
58 59 60 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 58 def @log_message_format end |
#stack_frames ⇒ Array<Google::Cloud::Debugger::Breakpoint::StackFrame>
The stack at breakpoint time.
153 154 155 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 153 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.
127 128 129 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 127 def status @status end |
#user_email ⇒ Object
E-mail address of the user that created this breakpoint
116 117 118 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 116 def user_email @user_email end |
#variable_table ⇒ Object
The variable_table exists to aid with computation, memory and network traffic optimization. It enables storing a variable once and reference it from multiple variables, including variables stored in the variable_table itself. For example, the same this object, which may appear at many levels of the stack, can have all of its data stored once in this table. The stack frame variables then would hold only a reference to it.
The variable var_table_index field is an index into this repeated field. The stored objects are nameless and get their name from the referencing variable. The effective variable is a merge of the referencing variable and the referenced variable.
142 143 144 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 142 def variable_table @variable_table 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 or there isn't a condition; otherwise false. Set breakpoint to error state if exception happens.
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 303 def check_condition binding return true if condition.nil? || condition.empty? condition_result = Evaluator.readonly_eval_expression binding, condition if condition_result.is_a?(Exception) && condition_result.instance_variable_get(:@mutation_cause) set_error_state "Error: #{condition_result.}", refers_to: StatusMessage::BREAKPOINT_CONDITION return false end condition_result ? true : false rescue => e set_error_state "Error: #{e.}", refers_to: StatusMessage::BREAKPOINT_CONDITION false 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.
246 247 248 249 250 251 252 253 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 246 def complete synchronize do return if complete? @is_final_state = true @final_time = Time.now end end |
#complete? ⇒ Boolean
Check if the breakpoint has been evaluated or set to a final error state.
258 259 260 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 258 def complete? is_final_state ? true : false end |
#eql?(other) ⇒ Boolean
Check if two breakpoints are equal to each other
326 327 328 329 330 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 326 def eql? other id == other.id && path == other.path && line == other.line end |
#full_path ⇒ Object
Get full absolute file path by combining the relative file path with application root directory path.
389 390 391 392 393 394 395 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 389 def full_path if app_root.nil? || app_root.empty? path else File.join app_root, path end end |
#line ⇒ Integer
Get the line number of this breakpoint
289 290 291 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 289 def line location.nil? ? nil : location.line end |
#path ⇒ String
Get the file path of this breakpoint
278 279 280 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 278 def path location.nil? ? nil : location.path end |
#set_error_state(message, refers_to: StatusMessage::UNSPECIFIED, is_final: true) ⇒ Google::Cloud::Debugger::Breakpoint::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.
373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 373 def set_error_state , refers_to: StatusMessage::UNSPECIFIED, is_final: true @status = StatusMessage.new.tap do |s| s.is_error = true s.refers_to = refers_to s.description = end complete if is_final @status end |
#valid? ⇒ Boolean
Check if the breakpoint is valid or not. Invoke validation function if breakpoint hasn't been finallized yet.
265 266 267 268 269 |
# File 'lib/google/cloud/debugger/breakpoint.rb', line 265 def valid? Validator.validate self unless complete? status && status.is_error ? false : true end |