@@ -128,6 +128,9 @@ export abstract class Breakpoint {
128
128
case "conditional" :
129
129
// eslint-disable-next-line @typescript-eslint/no-use-before-define
130
130
return new ConditionalBreakpoint ( breakpointNode , connection ) ;
131
+ case "watch" :
132
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
133
+ return new Watchpoint ( breakpointNode , connection ) ;
131
134
default :
132
135
throw new Error ( `Invalid type ${ breakpointNode . getAttribute ( "type" ) } ` ) ;
133
136
}
@@ -260,6 +263,29 @@ export class ConditionalBreakpoint extends Breakpoint {
260
263
}
261
264
}
262
265
266
+ /** class for watch breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
267
+ export class Watchpoint extends Breakpoint {
268
+ /** The variable to watch */
269
+ public variable : string ;
270
+ /** Constructs a breakpoint object from an XML node from a XDebug response */
271
+ public constructor ( breakpointNode : Element , connection : Connection ) ;
272
+ /** Contructs a breakpoint object for passing to sendSetBreakpointCommand */
273
+ public constructor ( variable : string ) ;
274
+ public constructor ( ...rest : any [ ] ) {
275
+ if ( typeof rest [ 0 ] === "object" ) {
276
+ // from XML
277
+ const breakpointNode : Element = rest [ 0 ] ;
278
+ const connection : Connection = rest [ 1 ] ;
279
+ super ( breakpointNode , connection ) ;
280
+ this . variable = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
281
+ } else {
282
+ // from arguments
283
+ super ( "watch" ) ;
284
+ this . variable = rest [ 0 ] ;
285
+ }
286
+ }
287
+ }
288
+
263
289
/** Response to a breakpoint_set command */
264
290
export class BreakpointSetResponse extends Response {
265
291
public breakpointId : number ;
@@ -738,7 +764,7 @@ export class Connection extends DbgpConnection {
738
764
739
765
/**
740
766
* Sends a breakpoint_set command that sets a breakpoint.
741
- * @param {Breakpoint } breakpoint - an instance of LineBreakpoint, ConditionalBreakpoint or ExceptionBreakpoint
767
+ * @param {Breakpoint } breakpoint - an instance of LineBreakpoint, ConditionalBreakpoint, ExceptionBreakpoint or Watchpoint
742
768
* @returns Promise.<BreakpointSetResponse>
743
769
*/
744
770
public async sendBreakpointSetCommand ( breakpoint : Breakpoint ) : Promise < BreakpointSetResponse > {
@@ -760,6 +786,14 @@ export class Connection extends DbgpConnection {
760
786
args += ` -n ${ breakpoint . line } ` ;
761
787
}
762
788
data = breakpoint . expression ;
789
+ } else if ( breakpoint instanceof Watchpoint ) {
790
+ data = breakpoint . variable ;
791
+
792
+ // These placeholders are needed due to a bug on the server
793
+ // They have no effect on the watchpoint functionality
794
+ args += ` -f PLACEHOLDER` ;
795
+ args += ` -m PLACEHOLDER` ;
796
+ args += ` -n PLACEHOLDER` ;
763
797
}
764
798
return new BreakpointSetResponse ( await this . _enqueueCommand ( "breakpoint_set" , args , data ) , this ) ;
765
799
}
0 commit comments