Stackdriver Debugger Client - Class Breakpoint (1.7.0)

Reference documentation and code samples for the Stackdriver Debugger Client class Breakpoint.

This plain PHP class represents a debugger breakpoint resource.

Example:

use Google\Cloud\Debugger\Breakpoint;

$breakpoint = new Breakpoint([
    'id' => 'breakpoint-id',
    'action' => Breakpoint::ACTION_CAPTURE,
    'location' => [
        'path' => '/path/to/file.php',
        'line' => 10
    ]
]);

Namespace

Google \ Cloud \ Debugger

Methods

__construct

Instantiate a Breakpoint from its JSON representation

Parameters
NameDescription
data array

Breakpoint data.

↳ id string

Breakpoint identifier, unique in the scope of the debuggee.

↳ action string

Action that the agent should perform when the code at the breakpoint location is hit.

↳ location array

Breakpoint source location in JSON form

↳ condition string

Condition that triggers the breakpoint. The condition is a compound boolean expression composed using expressions in a programming language at the source location

↳ expressions 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.

↳ logMessageFormat string

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.

↳ logLevel string

Indicates the severity of the log. Only relevant when action is LOG.

↳ isFinalState bool

When true, indicates that this is a final result and the breakpoint state will not change from here on.

↳ createTime string

Time this breakpoint was created by the server in seconds resolution. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

↳ finalTime string

Time this breakpoint was finalized by the server in seconds resolution. A timestamp in RFC3339 UTC "Zulu" format, accurate to nanoseconds. Example: "2014-10-02T15:01:23.045123456Z".

↳ userEmail string

E-mail address of the user that created this breakpoint

↳ status array

Breakpoint status in JSON form. 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.

↳ stackFrames array

The stack at breakpoint time. Each stackframe is in JSON form.

↳ evaluatedExpressions array

Values of evaluated expressions at breakpoint time in JSON form. 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.

↳ variableTable array

The variableTable 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 variableTable 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. This is an array of Variables in JSON form.

↳ labels array

A set of custom breakpoint properties, populated by the agent, to be displayed to the user. This is an associative array of key value pairs.

id

Return the breakpoint id.

Example:

echo $breakpoint->id();
Returns
TypeDescription
string

action

Return the type of breakpoint.

Example:

echo $breakpoint->action();
Returns
TypeDescription
string

location

Return the source location for this breakpoint.

Example:

$location = $breakpoint->location();
Returns
TypeDescription
Google\Cloud\Debugger\SourceLocation

condition

Return the condition for this breakpoint.

Example:

echo $breakpoint->condition();
Returns
TypeDescription
string

logLevel

Returns the log level for this breakpoint.

Example:

echo $breakpoint->logLevel();
Returns
TypeDescription
string

logMessageFormat

Return the log message format for this breakpoint.

Example:

echo $breakpoint->logMessageFormat();
Returns
TypeDescription
string

expressions

Return the expressions to evaluate for this breakpoint.

Example:

$expressions = $breakpoint->expressions();
Returns
TypeDescription
string[]

stackFrames

Return the list of collected stack frames

Example:

$stackFrames = $breakpoint->stackFrames();
Returns
TypeDescription
array<Google\Cloud\Debugger\StackFrame>

status

Return the status for this breakpoint

Returns
TypeDescription
Google\Cloud\Debugger\StatusMessage|null

variableTable

Returns the VariableTable

Example:

$variableTable = $breakpoint->variableTable();
Returns
TypeDescription
Google\Cloud\Debugger\VariableTable

evaluate

Evaluate this breakpoint with the provided evaluated expressions and captured stackframe data.

Parameters
NameDescription
evaluatedExpressions array

Key is the expression executed. Value is the execution result.

stackFrames array

Array of stackframe data.

options array

Configuration options.

↳ maxMemberDepth int

Maximum depth of member variables to capture. Defaults to 5.

↳ maxPayloadSize int

Maximum amount of space of captured data. Defaults to 32768.

↳ maxMembers int

Maximum number of member variables captured per variable. Defaults to 1000.

↳ maxValueLength int

Maximum length of the string representing the captured variable. Defaults to 500.

info

Return a serializable version of this object

Returns
TypeDescription
array

finalize

Mark this breakpoint as final state and record the current timestamp.

Example:

$breakpoint->finalize();

addStackFrames

Add collected data to this breakpoint.

Example:

$breakpoint->addStackFrames([
    [
        'filename' => '/path/to/file.php',
        'line' => 10
    ]
]);
$stackFrames = $breakpoint->stackFrames();
Parameter
NameDescription
stackFrames array

Array of stackframe data.

addStackFrame

Add single stackframe of data to this breakpoint.

Example:

$breakpoint->addStackFrame([
    'filename' => '/path/to/file.php',
    'line' => 10
]);
$stackFrames = $breakpoint->stackFrames();
Parameters
NameDescription
stackFrameData array

Stackframe information.

↳ function string

The name of the function executed.

↳ filename string

The name of the file executed.

↳ line int

The line number of the file executed.

↳ locals array

Captured local variables

addEvaluatedExpressions

Add evaluated expression results to this breakpoint.

Example:

$breakpoint->addEvaluatedExpressions([
    '2 + 3' => '5',
    '$foo' => 'variable value'
]);
Parameter
NameDescription
expressions array

Key is the expression executed. Value is the execution result.

validate

Validate that this breakpoint can be executed. If not valid, the status field will be populated with the corresponding error message. This validation does not guarantee that the breakpoint will be reachable.

The primary use case is to reject clearly invalid breakpoints and return a message to the developer via the Debugger console.

Example:

$valid = $breakpoint->validate();
Returns
TypeDescription
bool

resolveLocation

Attempts to resolve the real (full) path to the specified source location. Returns true if a location was resolved.

Example:

$found = $breakpoint->resolveLocation();
Parameter
NameDescription
resolver Google\Cloud\Debugger\SourceLocationResolver

[optional] Defaults to a resolver that uses the current include path.

Returns
TypeDescription
bool

Constants

ACTION_CAPTURE

Value: \Google\Cloud\Debugger\V2\Breakpoint\Action::CAPTURE

ACTION_LOG

Value: \Google\Cloud\Debugger\V2\Breakpoint\Action::LOG

LOG_LEVEL_INFO

Value: \Google\Cloud\Debugger\V2\Breakpoint\LogLevel::INFO

LOG_LEVEL_WARNING

Value: \Google\Cloud\Debugger\V2\Breakpoint\LogLevel::WARNING

LOG_LEVEL_ERROR

Value: \Google\Cloud\Debugger\V2\Breakpoint\LogLevel::ERROR