@@ -37,6 +37,8 @@ export class MI2DebugSession extends DebugSession {
37
37
protected debugReady : boolean ;
38
38
protected miDebugger : MI2 ;
39
39
protected commandServer : net . Server ;
40
+ protected threadGroupPids = new Map < string , string > ( ) ;
41
+ protected threadToPid = new Map < number , string > ( ) ;
40
42
41
43
public constructor ( debuggerLinesStartAt1 : boolean , isServer : boolean = false ) {
42
44
super ( debuggerLinesStartAt1 , isServer ) ;
@@ -54,6 +56,8 @@ export class MI2DebugSession extends DebugSession {
54
56
this . miDebugger . on ( "signal-stop" , this . handlePause . bind ( this ) ) ;
55
57
this . miDebugger . on ( "thread-created" , this . threadCreatedEvent . bind ( this ) ) ;
56
58
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 ) ) ;
57
61
this . sendEvent ( new InitializedEvent ( ) ) ;
58
62
try {
59
63
this . commandServer = net . createServer ( c => {
@@ -138,16 +142,35 @@ export class MI2DebugSession extends DebugSession {
138
142
}
139
143
140
144
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 ) ) ;
142
151
}
143
152
144
153
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" ) ) ;
146
163
}
147
164
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
+ }
151
174
}
152
175
153
176
protected launchError ( err : any ) {
@@ -276,7 +299,13 @@ export class MI2DebugSession extends DebugSession {
276
299
if ( threadName === undefined ) {
277
300
threadName = "<unnamed>" ;
278
301
}
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 ) ) ;
280
309
}
281
310
this . sendResponse ( response ) ;
282
311
} ) ;
@@ -584,7 +613,7 @@ export class MI2DebugSession extends DebugSession {
584
613
}
585
614
}
586
615
587
- protected pauseRequest ( response : DebugProtocol . ContinueResponse , args : DebugProtocol . ContinueArguments ) : void {
616
+ protected pauseRequest ( response : DebugProtocol . PauseResponse , args : DebugProtocol . PauseArguments ) : void {
588
617
this . miDebugger . interrupt ( ) . then ( done => {
589
618
this . sendResponse ( response ) ;
590
619
} , msg => {
@@ -594,6 +623,7 @@ export class MI2DebugSession extends DebugSession {
594
623
595
624
protected reverseContinueRequest ( response : DebugProtocol . ReverseContinueResponse , args : DebugProtocol . ReverseContinueArguments ) : void {
596
625
this . miDebugger . continue ( true ) . then ( done => {
626
+ response . body . allThreadsContinued = true ;
597
627
this . sendResponse ( response ) ;
598
628
} , msg => {
599
629
this . sendErrorResponse ( response , 2 , `Could not continue: ${ msg } ` ) ;
@@ -602,6 +632,7 @@ export class MI2DebugSession extends DebugSession {
602
632
603
633
protected continueRequest ( response : DebugProtocol . ContinueResponse , args : DebugProtocol . ContinueArguments ) : void {
604
634
this . miDebugger . continue ( ) . then ( done => {
635
+ response . body . allThreadsContinued = true ;
605
636
this . sendResponse ( response ) ;
606
637
} , msg => {
607
638
this . sendErrorResponse ( response , 2 , `Could not continue: ${ msg } ` ) ;
0 commit comments