diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index ac625339ebb..cbc0901fafb 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -101,7 +101,12 @@ public class BaseTestCase { public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; } - /** + public static boolean isRemoteSession() { + return launchAttributes.get(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE) + .equals(IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE); + } + + /** * We listen for the target to stop at the main breakpoint. This listener is * installed when the session is created and we uninstall ourselves when we * get to the breakpoint state, as we have no further need to monitor events diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java index 2c870308a31..e7173ceb179 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/SyncUtil.java @@ -634,10 +634,10 @@ public class SyncUtil { return null; } - /** - * Restart the program. - */ - public static MIStoppedEvent restart(final GdbLaunch launch) throws Throwable { + /** + * Check if the restart operation is supported + */ + public static boolean canRestart() throws Throwable { final IContainerDMContext containerDmc = getContainerContext(); // Check if restart is allowed @@ -659,7 +659,17 @@ public class SyncUtil { fGdbControl.getExecutor().execute(query); boolean canRestart = query.get(500, TimeUnit.MILLISECONDS); - if (!canRestart) { + return canRestart; + } + + /** + * Restart the program. + */ + public static MIStoppedEvent restart(final GdbLaunch launch) throws Throwable { + final IContainerDMContext containerDmc = getContainerContext(); + + // If we are calling this method, the restart operation should be allowed + if (!canRestart()) { throw new CoreException(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID, "Unable to restart")); } diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java index 3cd6585df6c..b2c1c25c802 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/OperationsWhileTargetIsRunningTest.java @@ -109,6 +109,13 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { */ @Test public void restartWhileTargetRunningKillGDB() throws Throwable { + // Restart is not supported for a remote session + if (BaseTestCase.isRemoteSession()) { + Assert.assertFalse("Restart operation should not be allowed for a remote session", + SyncUtil.canRestart()); + return; + } + // First set the preference to kill GDB (although it should not happen in this test) Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); @@ -132,6 +139,13 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase { */ @Test public void restartWhileTargetRunningGDBAlive() throws Throwable { + // Restart is not supported for a remote session + if (BaseTestCase.isRemoteSession()) { + Assert.assertFalse("Restart operation should not be allowed for a remote session", + SyncUtil.canRestart()); + return; + } + // First set the preference not to kill gdb Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false);