Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Schaefer2008-01-28 14:42:43 -0500
committerDoug Schaefer2008-01-28 14:42:43 -0500
commitfd8ae3684d74372b87fceb8c17cad4d70288a4ec (patch)
treedb43a6f7eaaf50e7fa374dab0712e2ebe84292c7
parent9b3f5ab9ccf0b7305dd463bc8012870a2e250963 (diff)
downloadorg.eclipse.cdt-fd8ae3684d74372b87fceb8c17cad4d70288a4ec.tar.gz
org.eclipse.cdt-fd8ae3684d74372b87fceb8c17cad4d70288a4ec.tar.xz
org.eclipse.cdt-fd8ae3684d74372b87fceb8c17cad4d70288a4ec.zip
Bug 215416 - patch for Elena. Turn hardcode timeouts into ones driven by the user.
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java4
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIInferior.java5
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java39
3 files changed, 26 insertions, 22 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
index 365373d860..fe61a1bf2f 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
@@ -36,7 +36,6 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariableDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
@@ -631,8 +630,9 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
try {
miSession.getMIInferior().interrupt();
// Wait till the EventManager tell us the go ahead
+ long maxSec = miSession.getCommandTimeout()/1000 + 1;
synchronized (this) {
- for (int i = 0; !suspended && i < 6; i++) {
+ for (int i = 0; !suspended && i < maxSec; i++) {
try {
wait(1000);
} catch (InterruptedException e) {
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIInferior.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIInferior.java
index c685a52fb6..952967874d 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIInferior.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MIInferior.java
@@ -209,9 +209,10 @@ public class MIInferior extends Process {
session.postCommand(interrupt);
// call getMIInfo() even if we discard the value;
interrupt.getMIInfo();
- // Allow (5 secs) for the interrupt to propagate.
+ // Allow MI command timeout for the interrupt to propagate.
+ long maxSec = session.getCommandTimeout()/1000 + 1;
synchronized(this) {
- for (int i = 0;(state == RUNNING) && i < 5; i++) {
+ for (int i = 0;(state == RUNNING) && i < maxSec; i++) {
try {
wait(1000);
} catch (InterruptedException e) {
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java
index f04d396c56..678503a665 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIProcessAdapter.java
@@ -29,6 +29,7 @@ public class MIProcessAdapter implements MIProcess {
Process fGDBProcess;
private static final int ONE_SECOND = 1000;
+ private long commandTimeout;
public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
this(args, 0, monitor);
@@ -36,6 +37,7 @@ public class MIProcessAdapter implements MIProcess {
public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
+ commandTimeout = MIPlugin.getCommandTimeout();
}
/**
@@ -112,16 +114,10 @@ public class MIProcessAdapter implements MIProcess {
public void interrupt(MIInferior inferior) {
if (fGDBProcess instanceof Spawner) {
- Spawner gdbSpawner = (Spawner) fGDBProcess;
- gdbSpawner.interrupt();
- synchronized (inferior) {
- // Allow (5 secs) for the interrupt to propagate.
- for (int i = 0; inferior.isRunning() && i < 5; i++) {
- try {
- inferior.wait(1000);
- } catch (InterruptedException e) {
- }
- }
+ if (inferior.isRunning()) {
+ Spawner gdbSpawner = (Spawner) fGDBProcess;
+ gdbSpawner.interrupt();
+ waitForInterrupt(inferior);
}
// If we are still running try to drop the sig to the PID
if (inferior.isRunning() && inferior.getInferiorPID() > 0) {
@@ -132,6 +128,20 @@ public class MIProcessAdapter implements MIProcess {
}
+ protected boolean waitForInterrupt(MIInferior inferior) {
+ synchronized (inferior) {
+ // Allow MI command timeout for the interrupt to propagate.
+ long maxSec = commandTimeout / ONE_SECOND + 1;
+ for (int i = 0; inferior.isRunning() && i < maxSec; i++) {
+ try {
+ inferior.wait(ONE_SECOND);
+ } catch (InterruptedException e) {
+ }
+ }
+ return inferior.isRunning();
+ }
+ }
+
/**
* Send an interrupt to the inferior process.
*
@@ -141,14 +151,7 @@ public class MIProcessAdapter implements MIProcess {
if (fGDBProcess instanceof Spawner) {
Spawner gdbSpawner = (Spawner) fGDBProcess;
gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
- synchronized (inferior) {
- for (int i = 0; inferior.isRunning() && i < 5; i++) {
- try {
- inferior.wait(1000);
- } catch (InterruptedException e) {
- }
- }
- }
+ waitForInterrupt(inferior);
}
}

Back to the top