@@ -16,6 +16,7 @@ export function escape(str: string) {
1616
1717const nonOutput = / ^ (?: \d * | u n d e f i n e d ) [ \* \+ \= ] | [ \~ \@ \& \^ ] / ;
1818const gdbMatch = / (?: \d * | u n d e f i n e d ) \( g d b \) / ;
19+ const numRegex = / \d + / ;
1920
2021function couldBeOutput ( line : string ) {
2122 if ( nonOutput . exec ( line ) )
@@ -232,8 +233,7 @@ export class MI2 extends EventEmitter implements IBackend {
232233 this . buffer = this . buffer . substr ( end + 1 ) ;
233234 }
234235 if ( this . buffer . length ) {
235- if ( this . onOutputPartial ( this . buffer ) )
236- {
236+ if ( this . onOutputPartial ( this . buffer ) ) {
237237 this . buffer = "" ;
238238 }
239239 }
@@ -358,7 +358,7 @@ export class MI2 extends EventEmitter implements IBackend {
358358 let to = setTimeout ( ( ) => {
359359 proc . signal ( "KILL" ) ;
360360 } , 1000 ) ;
361- this . stream . on ( "exit" , function ( code ) {
361+ this . stream . on ( "exit" , function ( code ) {
362362 clearTimeout ( to ) ;
363363 } )
364364 this . sendRaw ( "-gdb-exit" ) ;
@@ -368,7 +368,7 @@ export class MI2 extends EventEmitter implements IBackend {
368368 let to = setTimeout ( ( ) => {
369369 process . kill ( - proc . pid ) ;
370370 } , 1000 ) ;
371- this . process . on ( "exit" , function ( code ) {
371+ this . process . on ( "exit" , function ( code ) {
372372 clearTimeout ( to ) ;
373373 } ) ;
374374 this . sendRaw ( "-gdb-exit" ) ;
@@ -380,7 +380,7 @@ export class MI2 extends EventEmitter implements IBackend {
380380 let to = setTimeout ( ( ) => {
381381 process . kill ( - proc . pid ) ;
382382 } , 1000 ) ;
383- this . process . on ( "exit" , function ( code ) {
383+ this . process . on ( "exit" , function ( code ) {
384384 clearTimeout ( to ) ;
385385 } ) ;
386386 this . sendRaw ( "-target-detach" ) ;
@@ -465,10 +465,23 @@ export class MI2 extends EventEmitter implements IBackend {
465465 if ( this . breakpoints . has ( breakpoint ) )
466466 return resolve ( false ) ;
467467 let location = "" ;
468+ if ( breakpoint . countCondition ) {
469+ if ( breakpoint . countCondition [ 0 ] == ">" )
470+ location += "-i " + numRegex . exec ( breakpoint . countCondition . substr ( 1 ) ) [ 0 ] + " " ;
471+ else {
472+ let match = numRegex . exec ( breakpoint . countCondition ) [ 0 ] ;
473+ if ( match . length != breakpoint . countCondition . length ) {
474+ this . log ( "stderr" , "Unsupported break count expression: '" + breakpoint . countCondition + "'. Only supports 'X' for breaking once after X times or '>X' for ignoring the first X breaks" ) ;
475+ location += "-t " ;
476+ }
477+ else if ( parseInt ( match ) != 0 )
478+ location += "-t -i " + parseInt ( match ) + " " ;
479+ }
480+ }
468481 if ( breakpoint . raw )
469- location = '"' + escape ( breakpoint . raw ) + '"' ;
482+ location + = '"' + escape ( breakpoint . raw ) + '"' ;
470483 else
471- location = '"' + escape ( breakpoint . file ) + ":" + breakpoint . line + '"' ;
484+ location + = '"' + escape ( breakpoint . file ) + ":" + breakpoint . line + '"' ;
472485 this . sendCommand ( "break-insert -f " + location ) . then ( ( result ) => {
473486 if ( result . resultRecords . resultClass == "done" ) {
474487 let bkptNum = parseInt ( result . result ( "bkpt.number" ) ) ;
0 commit comments