@@ -285,19 +285,13 @@ protected boolean doIsDebuggerAttachSupported() {
285
285
// NOTE: when we support multi-process in all-stop mode,
286
286
// we will need to interrupt the target to when doing the attach.
287
287
int numConnected = getNumConnected ();
288
- switch (sessionType ) {
289
- case REMOTE :
290
- // In remote session already one process is connected
291
- // Bug 528145
292
- return numConnected == 1 ;
293
- case LOCAL :
294
- return numConnected == 0 ;
295
-
296
- default :
297
- break ;
288
+
289
+ if (numConnected == 1 && sessionType == SessionType .REMOTE ) {
290
+ // Bug 528145: Special case for remote sessions with an existing connection.
291
+ return true ;
298
292
}
299
293
300
- return false ;
294
+ return numConnected == 0 ;
301
295
}
302
296
303
297
return true ;
@@ -333,38 +327,38 @@ public void attachDebuggerToProcess(final IProcessDMContext procCtx, final Strin
333
327
public void execute (final RequestMonitor rm ) {
334
328
// The remote session is already connected to the process
335
329
// Bug 528145
336
- if (fBackend .getSessionType () == SessionType .REMOTE ) {
330
+ if (fBackend .getSessionType () == SessionType .REMOTE
331
+ && doCanDetachDebuggerFromProcess ()) {
337
332
rm .done ();
338
- } else {
339
- getProcessesBeingDebugged (procCtx ,
340
- new ImmediateDataRequestMonitor <IDMContext []>(rm ) {
341
- @ Override
342
- protected void handleSuccess () {
343
- assert getData () != null ;
344
-
345
- boolean found = false ;
346
- for (IDMContext dmc : getData ()) {
347
- IProcessDMContext procDmc = DMContexts .getAncestorOfType (dmc ,
348
- IProcessDMContext .class );
349
- if (procCtx .equals (procDmc )) {
350
- found = true ;
351
- }
352
- }
353
- if (found ) {
354
- // abort the sequence
355
- Status failedStatus = new Status (IStatus .ERROR ,
356
- GdbPlugin .PLUGIN_ID , REQUEST_FAILED ,
357
- MessageFormat .format (
358
- Messages .Already_connected_process_err ,
359
- ((IMIProcessDMContext ) procCtx ).getProcId ()),
360
- null );
361
- rm .done (failedStatus );
362
- return ;
363
- }
364
- super .handleSuccess ();
365
- }
366
- });
333
+ return ;
367
334
}
335
+
336
+ getProcessesBeingDebugged (procCtx , new ImmediateDataRequestMonitor <IDMContext []>(rm ) {
337
+ @ Override
338
+ protected void handleSuccess () {
339
+ assert getData () != null ;
340
+
341
+ boolean found = false ;
342
+ for (IDMContext dmc : getData ()) {
343
+ IProcessDMContext procDmc = DMContexts .getAncestorOfType (dmc ,
344
+ IProcessDMContext .class );
345
+ if (procCtx .equals (procDmc )) {
346
+ found = true ;
347
+ }
348
+ }
349
+ if (found ) {
350
+ // abort the sequence
351
+ Status failedStatus = new Status (IStatus .ERROR , GdbPlugin .PLUGIN_ID ,
352
+ REQUEST_FAILED ,
353
+ MessageFormat .format (Messages .Already_connected_process_err ,
354
+ ((IMIProcessDMContext ) procCtx ).getProcId ()),
355
+ null );
356
+ rm .done (failedStatus );
357
+ return ;
358
+ }
359
+ super .handleSuccess ();
360
+ }
361
+ });
368
362
}
369
363
},
370
364
@@ -477,24 +471,25 @@ protected void handleCompleted() {
477
471
public void execute (RequestMonitor rm ) {
478
472
// This call end the current attach to the gdbserver in remote session
479
473
// Bug 528145
480
- if (fBackend .getSessionType () == SessionType .REMOTE ) {
474
+ if (fBackend .getSessionType () == SessionType .REMOTE
475
+ && doCanDetachDebuggerFromProcess ()) {
481
476
rm .done ();
482
- } else {
483
- // For non-stop mode, we do a non-interrupting attach
484
- // Bug 333284
485
- boolean shouldInterrupt = true ;
486
- IMIRunControl runControl = getServicesTracker ().getService (IMIRunControl .class );
487
- if (runControl != null && runControl .getRunMode () == MIRunMode .NON_STOP ) {
488
- shouldInterrupt = false ;
489
- }
477
+ return ;
478
+ }
490
479
491
- boolean extraNewline = targetAttachRequiresTrailingNewline ();
492
- ICommand < MIInfo > miTargetAttach = fCommandFactory . createMITargetAttach (
493
- fContainerDmc , (( IMIProcessDMContext ) procCtx ). getProcId (), shouldInterrupt ,
494
- extraNewline );
495
- fCommandControl . queueCommand ( miTargetAttach ,
496
- new ImmediateDataRequestMonitor < MIInfo >( rm )) ;
480
+ // For non-stop mode, we do a non-interrupting attach
481
+ // Bug 333284
482
+ boolean shouldInterrupt = true ;
483
+ IMIRunControl runControl = getServicesTracker (). getService ( IMIRunControl . class );
484
+ if ( runControl != null && runControl . getRunMode () == MIRunMode . NON_STOP ) {
485
+ shouldInterrupt = false ;
497
486
}
487
+
488
+ boolean extraNewline = targetAttachRequiresTrailingNewline ();
489
+ ICommand <MIInfo > miTargetAttach = fCommandFactory .createMITargetAttach (fContainerDmc ,
490
+ ((IMIProcessDMContext ) procCtx ).getProcId (), shouldInterrupt , extraNewline );
491
+ fCommandControl .queueCommand (miTargetAttach ,
492
+ new ImmediateDataRequestMonitor <MIInfo >(rm ));
498
493
}
499
494
500
495
},
0 commit comments