Skip to content

Commit 96839a0

Browse files
Bug 580259: Not all remote session have a connected process
Contributed by STMicroelectronics Change-Id: Idec88f4bf0cbc8326bf19b9f081af9f9f9d437e2 Signed-off-by: Torbjörn Svensson <[email protected]>
1 parent 2481f39 commit 96839a0

File tree

2 files changed

+62
-62
lines changed

2 files changed

+62
-62
lines changed

dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java

+11-6
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,18 @@ public void stepAttachToProcess(final RequestMonitor requestMonitor) {
660660
@Execute
661661
public void stepAttachRemoteToDebugger(final RequestMonitor requestMonitor) {
662662
if (fGDBBackend.getIsAttachSession() && fGDBBackend.getSessionType() == SessionType.REMOTE) {
663-
IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(),
664-
MIProcesses.UNKNOWN_PROCESS_ID);
665-
fProcService.attachDebuggerToProcess(processContext,
666-
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
667-
} else {
668-
requestMonitor.done();
663+
DataRequestMonitor<Boolean> rm = new DataRequestMonitor<>(getExecutor(), null);
664+
fProcService.canDetachDebuggerFromProcess(null, rm);
665+
666+
if (rm.getData()) {
667+
IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(),
668+
MIProcesses.UNKNOWN_PROCESS_ID);
669+
fProcService.attachDebuggerToProcess(processContext,
670+
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
671+
return;
672+
}
669673
}
674+
requestMonitor.done();
670675
}
671676

672677
/**

dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBProcesses_7_2.java

+51-56
Original file line numberDiff line numberDiff line change
@@ -285,19 +285,13 @@ protected boolean doIsDebuggerAttachSupported() {
285285
// NOTE: when we support multi-process in all-stop mode,
286286
// we will need to interrupt the target to when doing the attach.
287287
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;
298292
}
299293

300-
return false;
294+
return numConnected == 0;
301295
}
302296

303297
return true;
@@ -333,38 +327,38 @@ public void attachDebuggerToProcess(final IProcessDMContext procCtx, final Strin
333327
public void execute(final RequestMonitor rm) {
334328
// The remote session is already connected to the process
335329
// Bug 528145
336-
if (fBackend.getSessionType() == SessionType.REMOTE) {
330+
if (fBackend.getSessionType() == SessionType.REMOTE
331+
&& doCanDetachDebuggerFromProcess()) {
337332
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;
367334
}
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+
});
368362
}
369363
},
370364

@@ -477,24 +471,25 @@ protected void handleCompleted() {
477471
public void execute(RequestMonitor rm) {
478472
// This call end the current attach to the gdbserver in remote session
479473
// Bug 528145
480-
if (fBackend.getSessionType() == SessionType.REMOTE) {
474+
if (fBackend.getSessionType() == SessionType.REMOTE
475+
&& doCanDetachDebuggerFromProcess()) {
481476
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+
}
490479

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;
497486
}
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));
498493
}
499494

500495
},

0 commit comments

Comments
 (0)