@@ -143,8 +143,6 @@ export class MI2 extends EventEmitter implements IBackend {
143143 }
144144 let sshCMD = this . application + " " + this . preargs . concat ( this . extraargs || [ ] ) . join ( " " ) ;
145145 if ( args . bootstrap ) sshCMD = args . bootstrap + " && " + sshCMD ;
146- if ( attach )
147- sshCMD += " -p " + target ;
148146 this . sshConn . exec ( sshCMD , execArgs , ( err , stream ) => {
149147 if ( err ) {
150148 this . log ( "stderr" , "Could not run " + this . application + "(" + sshCMD + ") over ssh!" ) ;
@@ -166,7 +164,10 @@ export class MI2 extends EventEmitter implements IBackend {
166164 } ) . bind ( this ) ) ;
167165 const promises = this . initCommands ( target , cwd , attach ) ;
168166 promises . push ( this . sendCommand ( "environment-cd \"" + escape ( cwd ) + "\"" ) ) ;
169- if ( procArgs && procArgs . length && ! attach )
167+ if ( attach ) {
168+ // Attach to local process
169+ promises . push ( this . sendCommand ( "target-attach " + target ) ) ;
170+ } else if ( procArgs && procArgs . length )
170171 promises . push ( this . sendCommand ( "exec-arguments " + procArgs ) ) ;
171172 Promise . all ( promises ) . then ( ( ) => {
172173 this . emit ( "debug-ready" ) ;
@@ -226,25 +227,22 @@ export class MI2 extends EventEmitter implements IBackend {
226227 let args = [ ] ;
227228 if ( executable && ! path . isAbsolute ( executable ) )
228229 executable = path . join ( cwd , executable ) ;
229- let isExtendedRemote = false ;
230230 args = this . preargs . concat ( this . extraargs || [ ] ) ;
231- if ( target . startsWith ( "extended-remote" ) ) {
232- isExtendedRemote = true ;
233- } else {
234- if ( ! executable )
235- executable = "-p" ;
236- args = args . concat ( [ executable , target ] ) ;
237- }
238231 this . process = ChildProcess . spawn ( this . application , args , { cwd : cwd , env : this . procEnv } ) ;
239232 this . process . stdout . on ( "data" , this . stdout . bind ( this ) ) ;
240233 this . process . stderr . on ( "data" , this . stderr . bind ( this ) ) ;
241234 this . process . on ( "exit" , ( ( ) => { this . emit ( "quit" ) ; } ) . bind ( this ) ) ;
242235 this . process . on ( "error" , ( ( err ) => { this . emit ( "launcherror" , err ) ; } ) . bind ( this ) ) ;
243236 const promises = this . initCommands ( target , cwd , true ) ;
244- if ( isExtendedRemote ) {
237+ if ( target . startsWith ( "extended-remote" ) ) {
245238 promises . push ( this . sendCommand ( "target-select " + target ) ) ;
246239 if ( executable )
247240 promises . push ( this . sendCommand ( "file-symbol-file \"" + escape ( executable ) + "\"" ) ) ;
241+ } else {
242+ // Attach to local process
243+ if ( executable )
244+ promises . push ( this . sendCommand ( "file-exec-and-symbols \"" + escape ( executable ) + "\"" ) ) ;
245+ promises . push ( this . sendCommand ( "target-attach " + target ) ) ;
248246 }
249247 Promise . all ( promises ) . then ( ( ) => {
250248 this . emit ( "debug-ready" ) ;
0 commit comments