mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Bug 312813 - [Launch] MIInferiorProcess.exitValue() never returns
This commit is contained in:
parent
1c2aa84166
commit
06e479681f
8 changed files with 43 additions and 18 deletions
|
@ -276,7 +276,8 @@ public class MIInferiorProcess extends Process
|
|||
protected void execute(final DataRequestMonitor<Integer> rm) {
|
||||
// Guard against session disposed.
|
||||
if (!DsfSession.isSessionActive(fSession.getId())) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ public class DsfCastToTypeSupport {
|
|||
final DsfSession session = DsfSession.getSession(
|
||||
dmvmProvider.getSession().getId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -483,7 +483,8 @@ public class ModuleDetailPane extends ModulesAbstractDetailPane implements IAdap
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -506,7 +507,8 @@ public class ModuleDetailPane extends ModulesAbstractDetailPane implements IAdap
|
|||
* We're in another dispatch, so we must guard against executor shutdown again.
|
||||
*/
|
||||
if (!DsfSession.isSessionActive(session.getId())) {
|
||||
GetModuleDetailsQuery.this.cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
super.handleCompleted();
|
||||
|
|
|
@ -21,10 +21,10 @@ import org.eclipse.cdt.dsf.concurrent.ThreadSafe;
|
|||
import org.eclipse.cdt.dsf.concurrent.ThreadSafeAndProhibitedFromDsfExecutor;
|
||||
import org.eclipse.cdt.dsf.datamodel.DMContexts;
|
||||
import org.eclipse.cdt.dsf.datamodel.IDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.FormattedValueDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRegisters;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IBitFieldDMContext;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IBitFieldDMData;
|
||||
import org.eclipse.cdt.dsf.debug.service.IRegisters.IMnemonic;
|
||||
|
@ -60,7 +60,7 @@ public class SyncRegisterDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class SyncVariableDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class SyncVariableDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ public class SyncVariableDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
@ -395,7 +395,7 @@ public class SyncVariableDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
@ -488,7 +488,7 @@ public class SyncVariableDataAccess {
|
|||
*/
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -152,6 +152,7 @@ abstract public class Query<V> extends DsfRunnable
|
|||
completed = fRm.isCompleted();
|
||||
if (!completed) {
|
||||
fRm.cancel();
|
||||
fRm.notifyAll();
|
||||
}
|
||||
}
|
||||
return !completed;
|
||||
|
@ -161,7 +162,8 @@ abstract public class Query<V> extends DsfRunnable
|
|||
|
||||
public boolean isDone() {
|
||||
synchronized (fRm) {
|
||||
return fRm.isCompleted() || (fRm.isCanceled() && !fRm.isExecuted());
|
||||
// If future is canceled, return right away.
|
||||
return fRm.isCompleted() || fRm.isCanceled();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,6 +182,7 @@ abstract public class Query<V> extends DsfRunnable
|
|||
* @deprecated Query implementations should call the request monitor to
|
||||
* set the exception status directly.
|
||||
*/
|
||||
@Deprecated
|
||||
protected void doneException(Throwable t) {
|
||||
fRm.setStatus(new Status(IStatus.ERROR, DsfPlugin.PLUGIN_ID, IDsfStatusConstants.INTERNAL_ERROR, "Exception", t)); //$NON-NLS-1$
|
||||
fRm.done();
|
||||
|
|
|
@ -193,7 +193,8 @@ public class TriggerCellModifier implements ICellModifier {
|
|||
// In that case, cancel to notify waiting thread.
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -234,7 +235,8 @@ public class TriggerCellModifier implements ICellModifier {
|
|||
// Guard against terminated session
|
||||
final DsfSession session = DsfSession.getSession(fDmc.getSessionId());
|
||||
if (session == null) {
|
||||
cancel(false);
|
||||
rm.setStatus(new Status(IStatus.ERROR, DsfExamplesPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Debug session already shut down.", null)); //$NON-NLS-1$
|
||||
rm.done();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ public class DsfQueryTests {
|
|||
@Test
|
||||
public void doneExceptionTest() throws InterruptedException, ExecutionException {
|
||||
Query<Integer> q = new Query<Integer>() {
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected void execute(DataRequestMonitor<Integer> rm) {
|
||||
doneException(new Throwable());
|
||||
|
@ -246,10 +247,7 @@ public class DsfQueryTests {
|
|||
Assert.assertTrue(cancelCalled[0]);
|
||||
Assert.assertTrue(rmHolder[0].isCanceled());
|
||||
Assert.assertTrue(q.isCancelled());
|
||||
Assert.assertFalse(q.isDone());
|
||||
|
||||
// Complete rm and query.
|
||||
rmHolder[0].done();
|
||||
Assert.assertTrue(q.isDone());
|
||||
|
||||
// Retrieve data
|
||||
try {
|
||||
|
@ -260,6 +258,25 @@ public class DsfQueryTests {
|
|||
Assert.assertTrue(q.isDone());
|
||||
Assert.assertTrue(q.isCancelled());
|
||||
}
|
||||
|
||||
// Complete rm and query.
|
||||
@SuppressWarnings("unchecked")
|
||||
DataRequestMonitor<Integer> drm = (DataRequestMonitor<Integer>)rmHolder[0];
|
||||
drm.setData(new Integer(1));
|
||||
rmHolder[0].done();
|
||||
|
||||
// Try to retrieve data again, it should still result in
|
||||
// cancellation exception.
|
||||
try {
|
||||
q.get();
|
||||
} catch (CancellationException e) {
|
||||
return; // Success
|
||||
} finally {
|
||||
Assert.assertTrue(q.isDone());
|
||||
Assert.assertTrue(q.isCancelled());
|
||||
}
|
||||
|
||||
|
||||
Assert.assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue