@@ -116,7 +116,7 @@ export class StatusResponse extends Response {
116116 }
117117}
118118
119- export type BreakpointType = "line" | "call" | " return" | "exception " | "conditional" | "watch" ;
119+ export type BreakpointType = "line" | "return" | "conditional" | "watch" ;
120120export type BreakpointState = "enabled" | "disabled" ;
121121
122122/** Abstract base class for all breakpoints */
@@ -130,9 +130,6 @@ export abstract class Breakpoint {
130130 case "conditional" :
131131 // eslint-disable-next-line @typescript-eslint/no-use-before-define
132132 return new ConditionalBreakpoint ( breakpointNode , connection ) ;
133- case "call" :
134- // eslint-disable-next-line @typescript-eslint/no-use-before-define
135- return new CallBreakpoint ( breakpointNode , connection ) ;
136133 default :
137134 throw new Error ( `Invalid type ${ breakpointNode . getAttribute ( "type" ) } ` ) ;
138135 }
@@ -159,6 +156,7 @@ export abstract class Breakpoint {
159156 this . state = breakpointNode . getAttribute ( "state" ) as BreakpointState ;
160157 } else {
161158 this . type = rest [ 0 ] ;
159+ this . state = "enabled" ;
162160 }
163161 }
164162 /** Removes the breakpoint by sending a breakpoint_remove command */
@@ -214,39 +212,13 @@ export class ClassLineBreakpoint extends LineBreakpoint {
214212 }
215213}
216214
217- /** class for call breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
218- export class CallBreakpoint extends Breakpoint {
219- /** the function to break on */
220- public fn : string ;
221- /** optional expression that must evaluate to true */
222- public expression : string ;
223- /** constructs a call breakpoint from an XML node */
224- public constructor ( breakpointNode : Element , connection : Connection ) ;
225- /** contructs a call breakpoint for passing to sendSetBreakpointCommand */
226- public constructor ( fn : string , expression ?: string ) ;
227- public constructor ( ...rest ) {
228- if ( typeof rest [ 0 ] === "object" ) {
229- const breakpointNode : Element = rest [ 0 ] ;
230- const connection : Connection = rest [ 1 ] ;
231- super ( breakpointNode , connection ) ;
232- this . fn = breakpointNode . getAttribute ( "function" ) ;
233- this . expression = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
234- } else {
235- // construct from arguments
236- super ( "call" ) ;
237- this . fn = rest [ 0 ] ;
238- this . expression = rest [ 1 ] ;
239- }
240- }
241- }
242-
243215/** class for conditional breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
244216export class ConditionalBreakpoint extends Breakpoint {
245217 /** File URI */
246218 public fileUri : string ;
247219 /** Line (optional) */
248220 public line : number ;
249- /** The PHP expression under which to break on */
221+ /** The expression under which to break on */
250222 public expression : string ;
251223 /** Constructs a breakpoint object from an XML node from a XDebug response */
252224 public constructor ( breakpointNode : Element , connection : Connection ) ;
@@ -543,6 +515,18 @@ export class FeatureSetResponse extends Response {
543515 }
544516}
545517
518+ export class FeatureGetResponse extends Response {
519+ /** the feature that was get */
520+ public feature : string ;
521+ /** supported flag for the feature */
522+ public supported : boolean ;
523+ public constructor ( document : XMLDocument , connection : Connection ) {
524+ super ( document , connection ) ;
525+ this . feature = document . documentElement . getAttribute ( "feature" ) ;
526+ this . supported = document . documentElement . getAttribute ( "supported" ) === "1" ;
527+ }
528+ }
529+
546530/** A command inside the queue */
547531interface Command {
548532 /** The name of the command, like breakpoint_list */
@@ -555,7 +539,7 @@ interface Command {
555539 resolveFn : ( response : XMLDocument ) => any ;
556540 /** callback that gets called if an error happened while parsing the response */
557541 rejectFn : ( error ?: Error ) => any ;
558- /** whether command results in PHP code being executed or not */
542+ /** whether command results in code being executed or not */
559543 isExecuteCommand : boolean ;
560544}
561545
@@ -564,7 +548,7 @@ interface Command {
564548 */
565549export class Connection extends DbgpConnection {
566550 /**
567- * Whether a command was started that executes PHP , which means the connection will be blocked from
551+ * Whether a command was started that executes code , which means the connection will be blocked from
568552 * running any additional commands until the execution gets to the next stopping point or exits.
569553 */
570554 public get isPendingExecuteCommand ( ) : boolean {
@@ -682,8 +666,8 @@ export class Connection extends DbgpConnection {
682666 * - notify_ok
683667 * or any command.
684668 */
685- public async sendFeatureGetCommand ( feature : string ) : Promise < XMLDocument > {
686- return await this . _enqueueCommand ( "feature_get" , `-n ${ feature } ` ) ;
669+ public async sendFeatureGetCommand ( feature : string ) : Promise < FeatureGetResponse > {
670+ return new FeatureGetResponse ( await this . _enqueueCommand ( "feature_get" , `-n ${ feature } ` ) , this ) ;
687671 }
688672
689673 /**
@@ -712,8 +696,8 @@ export class Connection extends DbgpConnection {
712696 public async sendBreakpointSetCommand ( breakpoint : Breakpoint ) : Promise < BreakpointSetResponse > {
713697 let args = `-t ${ breakpoint . type } ` ;
714698 let data : string | undefined ;
699+ args += ` -s ${ breakpoint . state } ` ;
715700 if ( breakpoint instanceof LineBreakpoint ) {
716- args += ` -s enabled` ;
717701 args += ` -f ${ breakpoint . fileUri } ` ;
718702 if ( breakpoint instanceof ClassLineBreakpoint ) {
719703 args += ` -m ${ breakpoint . method } -n ${ breakpoint . methodOffset } ` ;
@@ -726,9 +710,6 @@ export class Connection extends DbgpConnection {
726710 args += ` -n ${ breakpoint . line } ` ;
727711 }
728712 data = breakpoint . expression ;
729- } else if ( breakpoint instanceof CallBreakpoint ) {
730- args += ` -m ${ breakpoint . fn } ` ;
731- data = breakpoint . expression ;
732713 }
733714 return new BreakpointSetResponse ( await this . _enqueueCommand ( "breakpoint_set" , args , data ) , this ) ;
734715 }
@@ -767,7 +748,17 @@ export class Connection extends DbgpConnection {
767748
768749 /** sends a stop command */
769750 public async sendStopCommand ( ) : Promise < StatusResponse > {
770- return new StatusResponse ( await this . _enqueueCommand ( "stop" ) , this ) ;
751+ return new StatusResponse ( await this . _immediateCommand ( "stop" ) , this ) ;
752+ }
753+
754+ /** sends an detach command */
755+ public async sendDetachCommand ( ) : Promise < StatusResponse > {
756+ return new StatusResponse ( await this . _immediateCommand ( "detach" ) , this ) ;
757+ }
758+
759+ /** sends an break command */
760+ public async sendBreakCommand ( ) : Promise < StatusResponse > {
761+ return new StatusResponse ( await this . _immediateCommand ( "break" ) , this ) ;
771762 }
772763
773764 // ------------------------------ stack ----------------------------------------
@@ -835,8 +826,21 @@ export class Connection extends DbgpConnection {
835826 } ) ;
836827 }
837828
829+ private _immediateCommand ( name : string , args ?: string , data ?: string ) : Promise < XMLDocument > {
830+ return new Promise ( ( resolveFn , rejectFn ) : void => {
831+ this . _executeCommand ( {
832+ name,
833+ args,
834+ data,
835+ resolveFn,
836+ rejectFn,
837+ isExecuteCommand : false ,
838+ } ) ;
839+ } ) ;
840+ }
841+
838842 /**
839- * Pushes a new execute command (one that results in executing PHP code)
843+ * Pushes a new execute command (one that results in executing code)
840844 * to the queue that will be executed after all the previous
841845 * commands have finished and we received a response.
842846 * If the queue is empty AND there are no pending transactions
0 commit comments