Skip to content

Commit

Permalink
Bug 580259: Not all remote session have a connected process (#49)
Browse files Browse the repository at this point in the history
Contributed by STMicroelectronics

Change-Id: I21f9cc095e7a4f6ba0af4ef344e74fdbe8f6c43a
Signed-off-by: Torbjörn Svensson <torbjorn.svensson@st.com>
  • Loading branch information
Torbjorn-Svensson committed Aug 22, 2022
1 parent 66761c6 commit dc4cc80
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion dsf-gdb/org.eclipse.cdt.dsf.gdb/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.cdt.dsf.gdb;singleton:=true
Bundle-Version: 6.6.0.qualifier
Bundle-Version: 6.6.1.qualifier
Bundle-Activator: org.eclipse.cdt.dsf.gdb.internal.GdbPlugin
Bundle-Localization: plugin
Require-Bundle: org.eclipse.core.runtime,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -660,13 +660,18 @@ public void stepAttachToProcess(final RequestMonitor requestMonitor) {
@Execute
public void stepAttachRemoteToDebugger(final RequestMonitor requestMonitor) {
if (fGDBBackend.getIsAttachSession() && fGDBBackend.getSessionType() == SessionType.REMOTE) {
IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(),
MIProcesses.UNKNOWN_PROCESS_ID);
fProcService.attachDebuggerToProcess(processContext,
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
} else {
requestMonitor.done();
DataRequestMonitor<Boolean> rm = new DataRequestMonitor<>(getExecutor(), null);
fProcService.canDetachDebuggerFromProcess(null, rm);

if (rm.getData()) {
IProcessDMContext processContext = fProcService.createProcessContext(fCommandControl.getContext(),
MIProcesses.UNKNOWN_PROCESS_ID);
fProcService.attachDebuggerToProcess(processContext,
new DataRequestMonitor<IDMContext>(getExecutor(), requestMonitor));
return;
}
}
requestMonitor.done();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,19 +285,13 @@ protected boolean doIsDebuggerAttachSupported() {
// NOTE: when we support multi-process in all-stop mode,
// we will need to interrupt the target to when doing the attach.
int numConnected = getNumConnected();
switch (sessionType) {
case REMOTE:
// In remote session already one process is connected
// Bug 528145
return numConnected == 1;
case LOCAL:
return numConnected == 0;

default:
break;

if (numConnected == 1 && sessionType == SessionType.REMOTE) {
// Bug 528145: Special case for remote sessions with an existing connection.
return true;
}

return false;
return numConnected == 0;
}

return true;
Expand Down Expand Up @@ -333,38 +327,38 @@ public void attachDebuggerToProcess(final IProcessDMContext procCtx, final Strin
public void execute(final RequestMonitor rm) {
// The remote session is already connected to the process
// Bug 528145
if (fBackend.getSessionType() == SessionType.REMOTE) {
if (fBackend.getSessionType() == SessionType.REMOTE
&& doCanDetachDebuggerFromProcess()) {
rm.done();
} else {
getProcessesBeingDebugged(procCtx,
new ImmediateDataRequestMonitor<IDMContext[]>(rm) {
@Override
protected void handleSuccess() {
assert getData() != null;

boolean found = false;
for (IDMContext dmc : getData()) {
IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc,
IProcessDMContext.class);
if (procCtx.equals(procDmc)) {
found = true;
}
}
if (found) {
// abort the sequence
Status failedStatus = new Status(IStatus.ERROR,
GdbPlugin.PLUGIN_ID, REQUEST_FAILED,
MessageFormat.format(
Messages.Already_connected_process_err,
((IMIProcessDMContext) procCtx).getProcId()),
null);
rm.done(failedStatus);
return;
}
super.handleSuccess();
}
});
return;
}

getProcessesBeingDebugged(procCtx, new ImmediateDataRequestMonitor<IDMContext[]>(rm) {
@Override
protected void handleSuccess() {
assert getData() != null;

boolean found = false;
for (IDMContext dmc : getData()) {
IProcessDMContext procDmc = DMContexts.getAncestorOfType(dmc,
IProcessDMContext.class);
if (procCtx.equals(procDmc)) {
found = true;
}
}
if (found) {
// abort the sequence
Status failedStatus = new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID,
REQUEST_FAILED,
MessageFormat.format(Messages.Already_connected_process_err,
((IMIProcessDMContext) procCtx).getProcId()),
null);
rm.done(failedStatus);
return;
}
super.handleSuccess();
}
});
}
},

Expand Down Expand Up @@ -477,24 +471,25 @@ protected void handleCompleted() {
public void execute(RequestMonitor rm) {
// This call end the current attach to the gdbserver in remote session
// Bug 528145
if (fBackend.getSessionType() == SessionType.REMOTE) {
if (fBackend.getSessionType() == SessionType.REMOTE
&& doCanDetachDebuggerFromProcess()) {
rm.done();
} else {
// For non-stop mode, we do a non-interrupting attach
// Bug 333284
boolean shouldInterrupt = true;
IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class);
if (runControl != null && runControl.getRunMode() == MIRunMode.NON_STOP) {
shouldInterrupt = false;
}
return;
}

boolean extraNewline = targetAttachRequiresTrailingNewline();
ICommand<MIInfo> miTargetAttach = fCommandFactory.createMITargetAttach(
fContainerDmc, ((IMIProcessDMContext) procCtx).getProcId(), shouldInterrupt,
extraNewline);
fCommandControl.queueCommand(miTargetAttach,
new ImmediateDataRequestMonitor<MIInfo>(rm));
// For non-stop mode, we do a non-interrupting attach
// Bug 333284
boolean shouldInterrupt = true;
IMIRunControl runControl = getServicesTracker().getService(IMIRunControl.class);
if (runControl != null && runControl.getRunMode() == MIRunMode.NON_STOP) {
shouldInterrupt = false;
}

boolean extraNewline = targetAttachRequiresTrailingNewline();
ICommand<MIInfo> miTargetAttach = fCommandFactory.createMITargetAttach(fContainerDmc,
((IMIProcessDMContext) procCtx).getProcId(), shouldInterrupt, extraNewline);
fCommandControl.queueCommand(miTargetAttach,
new ImmediateDataRequestMonitor<MIInfo>(rm));
}

},
Expand Down

0 comments on commit dc4cc80

Please sign in to comment.