1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 371198: Restart is not supported in a remote debug session.

This commit is contained in:
Marc Khouzam 2012-02-29 12:17:47 -05:00
parent 7d58e68849
commit 35530262d8
3 changed files with 35 additions and 6 deletions

View file

@ -101,7 +101,12 @@ public class BaseTestCase {
public synchronized MIStoppedEvent getInitialStoppedEvent() { return fInitialStoppedEvent; } 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 * 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 * 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 * get to the breakpoint state, as we have no further need to monitor events

View file

@ -634,10 +634,10 @@ public class SyncUtil {
return null; return null;
} }
/** /**
* Restart the program. * Check if the restart operation is supported
*/ */
public static MIStoppedEvent restart(final GdbLaunch launch) throws Throwable { public static boolean canRestart() throws Throwable {
final IContainerDMContext containerDmc = getContainerContext(); final IContainerDMContext containerDmc = getContainerContext();
// Check if restart is allowed // Check if restart is allowed
@ -659,7 +659,17 @@ public class SyncUtil {
fGdbControl.getExecutor().execute(query); fGdbControl.getExecutor().execute(query);
boolean canRestart = query.get(500, TimeUnit.MILLISECONDS); 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")); throw new CoreException(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID, "Unable to restart"));
} }

View file

@ -109,6 +109,13 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
*/ */
@Test @Test
public void restartWhileTargetRunningKillGDB() throws Throwable { 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) // First set the preference to kill GDB (although it should not happen in this test)
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
@ -132,6 +139,13 @@ public class OperationsWhileTargetIsRunningTest extends BaseTestCase {
*/ */
@Test @Test
public void restartWhileTargetRunningGDBAlive() throws Throwable { 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 // First set the preference not to kill gdb
Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID); Preferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false); node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, false);