@@ -45,6 +45,7 @@ module.exports = class CiPlugin extends Plugin {
45
45
constructor ( ...args ) {
46
46
super ( ...args )
47
47
48
+ this . fileLineToProbeId = new Map ( )
48
49
this . rootDir = process . cwd ( ) // fallback in case :session:start events are not emitted
49
50
50
51
this . addSub ( `ci:${ this . constructor . id } :library-configuration` , ( { onDone } ) => {
@@ -335,7 +336,22 @@ module.exports = class CiPlugin extends Plugin {
335
336
} )
336
337
}
337
338
338
- removeDiProbe ( probeId ) {
339
+ removeAllDiProbes ( ) {
340
+ if ( this . fileLineToProbeId . size === 0 ) {
341
+ return Promise . resolve ( )
342
+ }
343
+ log . debug ( 'Removing all Dynamic Instrumentation probes' )
344
+ return Promise . all ( Array . from ( this . fileLineToProbeId . keys ( ) )
345
+ . map ( ( fileLine ) => {
346
+ const [ file , line ] = fileLine . split ( ':' )
347
+ return this . removeDiProbe ( { file, line } )
348
+ } ) )
349
+ }
350
+
351
+ removeDiProbe ( { file, line } ) {
352
+ const probeId = this . fileLineToProbeId . get ( `${ file } :${ line } ` )
353
+ log . warn ( `Removing probe from ${ file } :${ line } , with id: ${ probeId } ` )
354
+ this . fileLineToProbeId . delete ( probeId )
339
355
return this . di . removeProbe ( probeId )
340
356
}
341
357
@@ -346,9 +362,27 @@ module.exports = class CiPlugin extends Plugin {
346
362
log . warn ( 'Could not add breakpoint for dynamic instrumentation' )
347
363
return
348
364
}
365
+ log . debug ( 'Adding breakpoint for Dynamic Instrumentation' )
366
+
367
+ this . testErrorStackIndex = stackIndex
368
+ const activeProbeKey = `${ file } :${ line } `
369
+
370
+ if ( this . fileLineToProbeId . has ( activeProbeKey ) ) {
371
+ log . warn ( 'Probe already set for this line' )
372
+ const oldProbeId = this . fileLineToProbeId . get ( activeProbeKey )
373
+ return {
374
+ probeId : oldProbeId ,
375
+ setProbePromise : Promise . resolve ( ) ,
376
+ stackIndex,
377
+ file,
378
+ line
379
+ }
380
+ }
349
381
350
382
const [ probeId , setProbePromise ] = this . di . addLineProbe ( { file, line } , this . onDiBreakpointHit . bind ( this ) )
351
383
384
+ this . fileLineToProbeId . set ( activeProbeKey , probeId )
385
+
352
386
return {
353
387
probeId,
354
388
setProbePromise,
0 commit comments