@@ -128,6 +128,9 @@ export abstract class Breakpoint {
128128 case "conditional" :
129129 // eslint-disable-next-line @typescript-eslint/no-use-before-define
130130 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 ) ;
131134 default :
132135 throw new Error ( `Invalid type ${ breakpointNode . getAttribute ( "type" ) } ` ) ;
133136 }
@@ -260,6 +263,29 @@ export class ConditionalBreakpoint extends Breakpoint {
260263 }
261264}
262265
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+
263289/** Response to a breakpoint_set command */
264290export class BreakpointSetResponse extends Response {
265291 public breakpointId : number ;
@@ -738,7 +764,7 @@ export class Connection extends DbgpConnection {
738764
739765 /**
740766 * 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
742768 * @returns Promise.<BreakpointSetResponse>
743769 */
744770 public async sendBreakpointSetCommand ( breakpoint : Breakpoint ) : Promise < BreakpointSetResponse > {
@@ -760,6 +786,14 @@ export class Connection extends DbgpConnection {
760786 args += ` -n ${ breakpoint . line } ` ;
761787 }
762788 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` ;
763797 }
764798 return new BreakpointSetResponse ( await this . _enqueueCommand ( "breakpoint_set" , args , data ) , this ) ;
765799 }
0 commit comments