@@ -598,11 +598,17 @@ export class MI2 extends EventEmitter implements IBackend {
598598 async getThreads ( ) : Promise < Thread [ ] > {
599599 if ( trace ) this . log ( "stderr" , "getThreads" ) ;
600600
601- const command = "thread-info" ;
602- const result = await this . sendCommand ( command ) ;
603- const threads = result . result ( "threads" ) ;
601+ if ( ! this . cacheThreads || ! this . cachedThreads ) {
602+ this . log ( "stderr" , "Fetching thread list, this might take a while." ) ;
603+ const command = "thread-info" ;
604+ const result = await this . sendCommand ( command ) ;
605+ this . cachedThreads = result . result ( "threads" ) ;
606+ } else {
607+ this . log ( "stderr" , "Using cached threads list" ) ;
608+ }
609+
604610 const ret : Thread [ ] = [ ] ;
605- return threads . map ( element => {
611+ return this . cachedThreads . map ( element => {
606612 const ret : Thread = {
607613 id : parseInt ( MINode . valueOf ( element , "id" ) ) ,
608614 targetId : MINode . valueOf ( element , "target-id" )
@@ -796,6 +802,7 @@ export class MI2 extends EventEmitter implements IBackend {
796802 prettyPrint : boolean = true ;
797803 printCalls : boolean ;
798804 debugOutput : boolean ;
805+ cacheThreads : boolean ;
799806 public procEnv : any ;
800807 protected isSSH : boolean ;
801808 protected sshReady : boolean ;
@@ -807,4 +814,5 @@ export class MI2 extends EventEmitter implements IBackend {
807814 protected process : ChildProcess . ChildProcess ;
808815 protected stream ;
809816 protected sshConn ;
817+ protected cachedThreads ;
810818}
0 commit comments