@@ -143,10 +143,12 @@ export abstract class Breakpoint {
143
143
public state : BreakpointState ;
144
144
/** The connection this breakpoint is set on */
145
145
public connection : Connection ;
146
+ /** The value of the `hitCondition` property of the input `DebugProtocol.SourceBreakpoint` */
147
+ public hitCondition ?: string ;
146
148
/** Constructs a breakpoint object from an XML node from a XDebug response */
147
149
public constructor ( breakpointNode : Element , connection : Connection ) ;
148
150
/** To create a new breakpoint in derived classes */
149
- public constructor ( type : BreakpointType ) ;
151
+ public constructor ( type : BreakpointType , hitCondition ?: string ) ;
150
152
public constructor ( ...rest : any [ ] ) {
151
153
if ( typeof rest [ 0 ] === "object" ) {
152
154
// from XML
@@ -157,6 +159,7 @@ export abstract class Breakpoint {
157
159
this . state = breakpointNode . getAttribute ( "state" ) as BreakpointState ;
158
160
} else {
159
161
this . type = rest [ 0 ] ;
162
+ this . hitCondition = rest [ 1 ] . trim ( ) ;
160
163
this . state = "enabled" ;
161
164
}
162
165
}
@@ -175,7 +178,7 @@ export class LineBreakpoint extends Breakpoint {
175
178
/** constructs a line breakpoint from an XML node */
176
179
public constructor ( breakpointNode : Element , connection : Connection ) ;
177
180
/** contructs a line breakpoint for passing to sendSetBreakpointCommand */
178
- public constructor ( fileUri : string , line : number ) ;
181
+ public constructor ( fileUri : string , line : number , hitCondition ?: string ) ;
179
182
public constructor ( ...rest : any [ ] ) {
180
183
if ( typeof rest [ 0 ] === "object" ) {
181
184
const breakpointNode : Element = rest [ 0 ] ;
@@ -185,7 +188,7 @@ export class LineBreakpoint extends Breakpoint {
185
188
this . fileUri = breakpointNode . getAttribute ( "filename" ) ;
186
189
} else {
187
190
// construct from arguments
188
- super ( "line" ) ;
191
+ super ( "line" , rest [ 2 ] ) ;
189
192
this . fileUri = rest [ 0 ] ;
190
193
this . line = rest [ 1 ] ;
191
194
}
@@ -197,7 +200,7 @@ export class ClassLineBreakpoint extends LineBreakpoint {
197
200
public methodOffset : number ;
198
201
199
202
/** contructs a line breakpoint for passing to sendSetBreakpointCommand */
200
- public constructor ( fileUri : string , line : number , method : string , methodOffset : number ) ;
203
+ public constructor ( fileUri : string , line : number , method : string , methodOffset : number , hitCondition ?: string ) ;
201
204
public constructor ( ...rest : any [ ] ) {
202
205
if ( typeof rest [ 0 ] === "object" ) {
203
206
const breakpointNode : Element = rest [ 0 ] ;
@@ -206,7 +209,7 @@ export class ClassLineBreakpoint extends LineBreakpoint {
206
209
this . line = parseInt ( breakpointNode . getAttribute ( "lineno" ) , 10 ) ;
207
210
this . fileUri = breakpointNode . getAttribute ( "filename" ) ;
208
211
} else {
209
- super ( rest [ 0 ] , rest [ 1 ] ) ;
212
+ super ( rest [ 0 ] , rest [ 1 ] , rest [ 4 ] ) ;
210
213
this . method = rest [ 2 ] ;
211
214
this . methodOffset = rest [ 3 ] ;
212
215
}
@@ -218,7 +221,7 @@ export class RoutineLineBreakpoint extends LineBreakpoint {
218
221
public methodOffset : number ;
219
222
220
223
/** contructs a line breakpoint for passing to sendSetBreakpointCommand */
221
- public constructor ( fileUri : string , line : number , method : string , methodOffset : number ) ;
224
+ public constructor ( fileUri : string , line : number , method : string , methodOffset : number , hitCondition ?: string ) ;
222
225
public constructor ( ...rest : any [ ] ) {
223
226
if ( typeof rest [ 0 ] === "object" ) {
224
227
const breakpointNode : Element = rest [ 0 ] ;
@@ -227,7 +230,7 @@ export class RoutineLineBreakpoint extends LineBreakpoint {
227
230
this . line = parseInt ( breakpointNode . getAttribute ( "lineno" ) , 10 ) ;
228
231
this . fileUri = breakpointNode . getAttribute ( "filename" ) ;
229
232
} else {
230
- super ( rest [ 0 ] , rest [ 1 ] ) ;
233
+ super ( rest [ 0 ] , rest [ 1 ] , rest [ 4 ] ) ;
231
234
this . method = rest [ 2 ] ;
232
235
this . methodOffset = rest [ 3 ] ;
233
236
}
@@ -245,7 +248,7 @@ export class ConditionalBreakpoint extends Breakpoint {
245
248
/** Constructs a breakpoint object from an XML node from a XDebug response */
246
249
public constructor ( breakpointNode : Element , connection : Connection ) ;
247
250
/** Contructs a breakpoint object for passing to sendSetBreakpointCommand */
248
- public constructor ( expression : string , fileUri : string , line ?: number ) ;
251
+ public constructor ( expression : string , fileUri : string , line ?: number , hitCondition ?: string ) ;
249
252
public constructor ( ...rest : any [ ] ) {
250
253
if ( typeof rest [ 0 ] === "object" ) {
251
254
// from XML
@@ -255,14 +258,68 @@ export class ConditionalBreakpoint extends Breakpoint {
255
258
this . expression = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
256
259
} else {
257
260
// from arguments
258
- super ( "conditional" ) ;
261
+ super ( "conditional" , rest [ 3 ] ) ;
259
262
this . expression = rest [ 0 ] ;
260
263
this . fileUri = rest [ 1 ] ;
261
264
this . line = rest [ 2 ] ;
262
265
}
263
266
}
264
267
}
265
268
269
+ export class ClassConditionalBreakpoint extends ConditionalBreakpoint {
270
+ public method : string ;
271
+ public methodOffset : number ;
272
+
273
+ /** contructs a conditional breakpoint for passing to sendSetBreakpointCommand */
274
+ public constructor (
275
+ expression : string ,
276
+ fileUri : string ,
277
+ line : number ,
278
+ method : string ,
279
+ methodOffset : number ,
280
+ hitCondition ?: string
281
+ ) ;
282
+ public constructor ( ...rest : any [ ] ) {
283
+ if ( typeof rest [ 0 ] === "object" ) {
284
+ const breakpointNode : Element = rest [ 0 ] ;
285
+ const connection : Connection = rest [ 1 ] ;
286
+ super ( breakpointNode , connection ) ;
287
+ this . expression = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
288
+ } else {
289
+ super ( rest [ 0 ] , rest [ 1 ] , rest [ 2 ] , rest [ 5 ] ) ;
290
+ this . method = rest [ 3 ] ;
291
+ this . methodOffset = rest [ 4 ] ;
292
+ }
293
+ }
294
+ }
295
+
296
+ export class RoutineConditionalBreakpoint extends ConditionalBreakpoint {
297
+ public method : string ;
298
+ public methodOffset : number ;
299
+
300
+ /** contructs a conditional breakpoint for passing to sendSetBreakpointCommand */
301
+ public constructor (
302
+ expression : string ,
303
+ fileUri : string ,
304
+ line : number ,
305
+ method : string ,
306
+ methodOffset : number ,
307
+ hitCondition ?: string
308
+ ) ;
309
+ public constructor ( ...rest : any [ ] ) {
310
+ if ( typeof rest [ 0 ] === "object" ) {
311
+ const breakpointNode : Element = rest [ 0 ] ;
312
+ const connection : Connection = rest [ 1 ] ;
313
+ super ( breakpointNode , connection ) ;
314
+ this . expression = breakpointNode . getAttribute ( "expression" ) ; // Base64 encoded?
315
+ } else {
316
+ super ( rest [ 0 ] , rest [ 1 ] , rest [ 2 ] , rest [ 5 ] ) ;
317
+ this . method = rest [ 3 ] ;
318
+ this . methodOffset = rest [ 4 ] ;
319
+ }
320
+ }
321
+ }
322
+
266
323
/** class for watch breakpoints. Returned from a breakpoint_list or passed to sendBreakpointSetCommand */
267
324
export class Watchpoint extends Breakpoint {
268
325
/** The variable to watch */
@@ -782,8 +839,10 @@ export class Connection extends DbgpConnection {
782
839
}
783
840
} else if ( breakpoint instanceof ConditionalBreakpoint ) {
784
841
args += ` -f ${ breakpoint . fileUri } ` ;
785
- if ( typeof breakpoint . line === "number" ) {
786
- args += ` -n ${ breakpoint . line } ` ;
842
+ if ( breakpoint instanceof ClassConditionalBreakpoint ) {
843
+ args += ` -m ${ breakpoint . method } -n ${ breakpoint . methodOffset } ` ;
844
+ } else if ( breakpoint instanceof RoutineConditionalBreakpoint ) {
845
+ args += ` -n ${ breakpoint . methodOffset } ` ;
787
846
}
788
847
data = breakpoint . expression ;
789
848
} else if ( breakpoint instanceof Watchpoint ) {
@@ -795,6 +854,9 @@ export class Connection extends DbgpConnection {
795
854
args += ` -m PLACEHOLDER` ;
796
855
args += ` -n PLACEHOLDER` ;
797
856
}
857
+ if ( breakpoint . hitCondition ) {
858
+ args += ` -h ${ breakpoint . hitCondition } ` ;
859
+ }
798
860
return new BreakpointSetResponse ( await this . _enqueueCommand ( "breakpoint_set" , args , data ) , this ) ;
799
861
}
800
862
0 commit comments