Skip to main content

%Atelier.v1.XDebugAgent

Class %Atelier.v1.XDebugAgent Extends %CSP.WebSocket

This class serves as a debug agent for debugging processes. It receives client debugging commands, sends then to the debug target, gets responses, and sends them back to the client. The implementation is based on the XDEBUG DBGP protocol used by the eclipse DLTK.
http://xdebug.org/docs-dbgp.php

Parameters

DOMAIN

Parameter DOMAIN = "%XDEBUG";

Parameter for Localization

SECURITYRESOURCE

Parameter SECURITYRESOURCE = "%Development";

Require development resource

NULLSTATE

Parameter NULLSTATE = 0;

EXITSTATE

Parameter EXITSTATE = 1;

STOP

Parameter STOP = 2;

IDLE

Parameter IDLE = "OnIdle";

TIMEOUT

Parameter TIMEOUT = 0.1;

CLASS

Parameter CLASS = 2;

This is the CLASS context for variable display in the IDE

PUBLIC

Parameter PUBLIC = 1;

This is the PUBLIC context for variable display in the IDE

PRIVATE

Parameter PRIVATE = 0;

This is the PRIVATE context for variable display in the IDE

Properties

Command

Property Command As %String [ MultiDimensional ];

This holds the current command

DebugTarget

Property DebugTarget As %String;

This holds the debug_target (passsed to us by set_feature)

NextState

Property NextState As %String [ InitialExpression = {..#NULLSTATE} ];

This holds the next state to switch to

State

Property State As %String [ InitialExpression = {..#NULLSTATE}, Internal ];

This holds the current state of the FSM, Initial state is "{..#NULLSTATE}" Before the machine can run a valid state needs to be established

Debug

Property Debug As %Debugger.System;

This holds the debugger instance

Trace

Property Trace As %Boolean [ InitialExpression = {$Get(^IRIS.Temp.Atelier("debug"))>0} ];

This holds the TRACE flag

TraceNode

Property TraceNode As %Integer;

This holds the TRACE global node for this session

DeviceList

Property DeviceList As %List;

This holds the device list for $System.Socket.Select

WebSocketDevice

Property WebSocketDevice As %String;

This holds the websocket device

TargetOrPID

Property TargetOrPID As %String;

This holds the target OR PID

Attached

Property Attached As %Boolean [ InitialExpression = 0 ];

This holds the attached flag

Launched

Property Launched As %Boolean [ InitialExpression = 0 ];

This holds the launched flag

ContinuationCmdIssued

Property ContinuationCmdIssued As %Boolean [ InitialExpression = 0 ];

This holds the Continuation command issued flag

TransactionId

Property TransactionId As %String [ MultiDimensional ];

This holds the current transaction identifier

BreakPoints

Property BreakPoints As %String [ MultiDimensional ];

Breakpoints

LastContinuationCmd

Property LastContinuationCmd As %String;

This holds the last 'continuation' command issued Continuation commands are 'run','step_into','step_over','step_out' 'stop' and 'detach'. We need to record this so that the appropriate status message can be reported to the client when a breakpoint is hit or the program ends.

StackLevelMappings

Property StackLevelMappings As %Integer [ MultiDimensional ];

This holds the mappings from server stack level to IDE stack level

Features

Property Features As %String [ MultiDimensional ];

This holds the values of the features set by the IDE

FirstRunCommandSeen

Property FirstRunCommandSeen As %Boolean [ InitialExpression = 0 ];

This holds the first run command flag

Methods

Server

Method Server() As %Status

The WebSocket Server

OnIdle

Method OnIdle() As %Status [ Internal, Private ]

This where we receive and dispatch commands and pump debuggee output

GetInitMsg

Method GetInitMsg(Output pInitMsg) As %Status

Get InitMsg

TidyUp

Method TidyUp(pStatus) As %Status

Here we do state specific tidy up (will be called if an error has occurred)

OnPreServer

Method OnPreServer() As %Status

Event handler for the PreServer event: this is invoked before starting the WebSockets Server. Changes to the SharedConnection flag must be made here.

InitTrace

Method InitTrace()

Intialize the trace (if required)

Trace

Method Trace(pMsg As %String)

Log a trace if tracing enabled

ParseCommand

Method ParseCommand(pCmdString As %String, Output pParsed) As %Status

Parse XDebug command Definition:- cmd : cmdname [ arglist ]; cmdname : lowercase STRING arglist : arg | [ arg arglist ]; arg : argid argval argid : '-' CHAR argval : STRING Example:- feature_get -i 6 -n language_supports_threads The command string is parsed into this structure:- var="feature_get" var("-i")=6 var("-n")="language_supports_threads"

MapCommandToHandler

Method MapCommandToHandler(pCmdString As %String) As %Status

Map the command to the associated handler (assumes valid command) Some commands are handled inline

ReportEvent

Method ReportEvent(pEvent As %String, pXmlData = "") As %Status

Report an event by writing to the WebSocket

ReportError

Method ReportError(pErrorText As %String) As %Status

Report an event by writing to the WebSocket

Interpolate

ClassMethod Interpolate(pString, pTerm, pValue) As %String [ CodeMode = expression ]

Utility method to interpolate values in a string

Attach

Method Attach() As %Status

Utility method to launch the target given the properties set by set_feature

Launch

Method Launch() As %Status

Utility method to launch the target given the properties set by set_feature

stop

Method stop()

IDE Command handler FOR 'stop' command

"feature_get"

Method "feature_get"() As %Status

IDE Command handler FOR 'feature_get' command

"feature_set"

Method "feature_set"() As %Status

IDE Command handler FOR 'feature_set' command

break

Method break() As %Status

IDE Command handler FOR 'break' command

"watchpoint_set"

Method "watchpoint_set"() As %Status

IDE (pseudo) Command handler FOR 'watchpoint_set' command breakpoint_set -m DebugMe -n 2 -r 0 -s enabled -t watch -f file:///Users/haiodo/Develop/workspaces/runtime-New_configuration222/Demo3/User.Debug.cls -i 22 -- WA==

"breakpoint_set"

Method "breakpoint_set"() As %Status

IDE Command handler FOR 'breakpoint_set' command breakpoint_set -m DebugMe -n 3 -r 0 -s enabled -t line -f file:///Users/jamien/eclipse/runtime-EclipseApplication/XDebug/User.Debug.cls -i 10"

"breakpoint_get"

Method "breakpoint_get"() As %Status

breakpoint_get -d User.Debug.cls:DebugMe:3 -i 51"

"breakpoint_list"

Method "breakpoint_list"() As %Status

breakpoint_list

"breakpoint_remove"

Method "breakpoint_remove"() As %Status

breakpoint_remove

"breakpoint_update"

Method "breakpoint_update"() As %Status

breakpoint_update

"context_names"

Method "context_names"() As %Status

IDE Command handler FOR 'context_names' command

"context_get"

Method "context_get"() As %Status

IDE Command handler FOR 'context_get' command

eval

Method eval() As %Status

IDE Command handler for 'eval' command

"property_set"

Method "property_set"() As %Status

IDE Command handler for 'property_set' command

"property_get"

Method "property_get"() As %Status

IDE Command handler for 'property_get' command

"property_value"

Method "property_value"() As %Status

IDE Command handler for 'property_value' command

run

Method run() As %Status

IDE Command handler FOR 'run' command

"step_into"

Method "step_into"() As %Status

IDE Command handler for 'step_into' command

"step_over"

Method "step_over"() As %Status

IDE Command handler for 'step_over' command

"step_out"

Method "step_out"() As %Status

IDE Command handler for 'step_over' command

stderr

Method stderr() As %Status

stdout

Method stdout() As %Status

stdin

Method stdin() As %Status

IDE Command handler FOR 'stdin' command

"stack_get"

Method "stack_get"() As %Status

IDE Command handler FOR 'stack_get' command

CreateErrorResponse

Method CreateErrorResponse(pCmd As %String, pErrorCode As %Integer, pTransactionId As %Integer, pMsg As %String) As %String

Create an error response including error code and message to be displayed by IDE

CreatePropertyResponse

Method CreatePropertyResponse(pVarName As %String, pVarValue As %String, Output pXML As %String, pNumChildren = 0) As %Status

Given a variable name and a value, create a property for reporting to the IDE

GetClassProperties

Method GetClassProperties(Output pPropList As %String) As %Status

Get the properties for the CLASS context

GetStackProperties

Method GetStackProperties(pContext As %Integer, pServerLevel As %Integer, Output pPropList As %String) As %Status

Given a context (LOCAL,GLOBAL) and stack level, get the variables defined at that level

GetClientPosFromDebugPos

ClassMethod GetClientPosFromDebugPos(pServerIntPos, Output pMapped, ByRef pNameSpace, Output pDocName, Output pLabel, Output pOffset)

This method is given the debugger position (in the INT code) and returns a logical docname,label and offset The client will have to perform addtional logic to find exactly where in the source document the location is If pMapped is 0, then there is no source

requote

ClassMethod requote(value As %String) As %String

Given a string that is the output of Quote(), check for control characters that were left inside a quoted literal. If found, Quote that literal and insert it back into the original string. This is done carefully so we don't end up with double-double quotes.