@@ -37,6 +37,8 @@ export class MI2DebugSession extends DebugSession {
3737 protected debugReady : boolean ;
3838 protected miDebugger : MI2 ;
3939 protected commandServer : net . Server ;
40+ protected threadGroupPids = new Map < string , string > ( ) ;
41+ protected threadToPid = new Map < number , string > ( ) ;
4042
4143 public constructor ( debuggerLinesStartAt1 : boolean , isServer : boolean = false ) {
4244 super ( debuggerLinesStartAt1 , isServer ) ;
@@ -54,6 +56,8 @@ export class MI2DebugSession extends DebugSession {
5456 this . miDebugger . on ( "signal-stop" , this . handlePause . bind ( this ) ) ;
5557 this . miDebugger . on ( "thread-created" , this . threadCreatedEvent . bind ( this ) ) ;
5658 this . miDebugger . on ( "thread-exited" , this . threadExitedEvent . bind ( this ) ) ;
59+ this . miDebugger . on ( "thread-group-started" , this . threadGroupStartedEvent . bind ( this ) ) ;
60+ this . miDebugger . on ( "thread-group-exited" , this . threadGroupExitedEvent . bind ( this ) ) ;
5761 this . sendEvent ( new InitializedEvent ( ) ) ;
5862 try {
5963 this . commandServer = net . createServer ( c => {
@@ -138,16 +142,35 @@ export class MI2DebugSession extends DebugSession {
138142 }
139143
140144 protected threadCreatedEvent ( info : MINode ) {
141- this . sendEvent ( new ThreadEvent ( "started" , info . record ( "id" ) ) ) ;
145+ let threadId = parseInt ( info . record ( "id" ) , 10 ) ;
146+
147+ let threadPid = this . threadGroupPids . get ( info . record ( "group-id" ) ) ;
148+ this . threadToPid . set ( threadId , threadPid ) ;
149+
150+ this . sendEvent ( new ThreadEvent ( "started" , threadId ) ) ;
142151 }
143152
144153 protected threadExitedEvent ( info : MINode ) {
145- this . sendEvent ( new ThreadEvent ( "exited" , info . record ( "id" ) ) ) ;
154+ let threadId = parseInt ( info . record ( "id" ) , 10 ) ;
155+
156+ this . threadToPid . delete ( info . record ( "group-id" ) ) ;
157+
158+ this . sendEvent ( new ThreadEvent ( "exited" , threadId ) ) ;
159+ }
160+
161+ protected threadGroupStartedEvent ( info : MINode ) {
162+ this . threadGroupPids . set ( info . record ( "id" ) , info . record ( "pid" ) ) ;
146163 }
147164
148- protected quitEvent ( ) {
149- this . quit = true ;
150- this . sendEvent ( new TerminatedEvent ( ) ) ;
165+ protected threadGroupExitedEvent ( info : MINode ) {
166+ this . threadGroupPids . delete ( info . record ( "id" ) ) ;
167+ }
168+
169+ protected quitEvent ( info ?: MINode ) {
170+ if ( this . threadGroupPids . size == 0 ) {
171+ this . quit = true ;
172+ this . sendEvent ( new TerminatedEvent ( ) ) ;
173+ }
151174 }
152175
153176 protected launchError ( err : any ) {
@@ -276,7 +299,13 @@ export class MI2DebugSession extends DebugSession {
276299 if ( threadName === undefined ) {
277300 threadName = "<unnamed>" ;
278301 }
279- response . body . threads . push ( new Thread ( thread . id , thread . id + ":" + threadName ) ) ;
302+ if ( this . threadGroupPids . size > 1 ) {
303+ let pid = this . threadToPid . get ( thread . id ) ;
304+ threadName = `(${ pid } ) ${ thread . id } :${ threadName } ` ;
305+ } else {
306+ threadName = `${ thread . id } :${ threadName } ` ;
307+ }
308+ response . body . threads . push ( new Thread ( thread . id , threadName ) ) ;
280309 }
281310 this . sendResponse ( response ) ;
282311 } ) ;
@@ -584,7 +613,7 @@ export class MI2DebugSession extends DebugSession {
584613 }
585614 }
586615
587- protected pauseRequest ( response : DebugProtocol . ContinueResponse , args : DebugProtocol . ContinueArguments ) : void {
616+ protected pauseRequest ( response : DebugProtocol . PauseResponse , args : DebugProtocol . PauseArguments ) : void {
588617 this . miDebugger . interrupt ( ) . then ( done => {
589618 this . sendResponse ( response ) ;
590619 } , msg => {
@@ -594,6 +623,7 @@ export class MI2DebugSession extends DebugSession {
594623
595624 protected reverseContinueRequest ( response : DebugProtocol . ReverseContinueResponse , args : DebugProtocol . ReverseContinueArguments ) : void {
596625 this . miDebugger . continue ( true ) . then ( done => {
626+ response . body . allThreadsContinued = true ;
597627 this . sendResponse ( response ) ;
598628 } , msg => {
599629 this . sendErrorResponse ( response , 2 , `Could not continue: ${ msg } ` ) ;
@@ -602,6 +632,7 @@ export class MI2DebugSession extends DebugSession {
602632
603633 protected continueRequest ( response : DebugProtocol . ContinueResponse , args : DebugProtocol . ContinueArguments ) : void {
604634 this . miDebugger . continue ( ) . then ( done => {
635+ response . body . allThreadsContinued = true ;
605636 this . sendResponse ( response ) ;
606637 } , msg => {
607638 this . sendErrorResponse ( response , 2 , `Could not continue: ${ msg } ` ) ;
0 commit comments