mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-09-08 19:13:27 +02:00
Bug 215416 - Patch for Alena - remove the hardcoding of some of the MI timeouts.
This commit is contained in:
parent
93b72e6097
commit
0d547afec5
3 changed files with 26 additions and 21 deletions
|
@ -633,8 +633,9 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
|
||||||
try {
|
try {
|
||||||
miSession.getMIInferior().interrupt();
|
miSession.getMIInferior().interrupt();
|
||||||
// Wait till the EventManager tell us the go ahead
|
// Wait till the EventManager tell us the go ahead
|
||||||
|
long maxSec = miSession.getCommandTimeout()/1000 + 1;
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
for (int i = 0; !suspended && i < 6; i++) {
|
for (int i = 0; !suspended && i < maxSec; i++) {
|
||||||
try {
|
try {
|
||||||
wait(1000);
|
wait(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -209,9 +209,10 @@ public class MIInferior extends Process {
|
||||||
session.postCommand(interrupt);
|
session.postCommand(interrupt);
|
||||||
// call getMIInfo() even if we discard the value;
|
// call getMIInfo() even if we discard the value;
|
||||||
interrupt.getMIInfo();
|
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) {
|
synchronized(this) {
|
||||||
for (int i = 0;(state == RUNNING) && i < 5; i++) {
|
for (int i = 0;(state == RUNNING) && i < maxSec; i++) {
|
||||||
try {
|
try {
|
||||||
wait(1000);
|
wait(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
|
|
@ -29,6 +29,7 @@ public class MIProcessAdapter implements MIProcess {
|
||||||
|
|
||||||
Process fGDBProcess;
|
Process fGDBProcess;
|
||||||
private static final int ONE_SECOND = 1000;
|
private static final int ONE_SECOND = 1000;
|
||||||
|
private long commandTimeout;
|
||||||
|
|
||||||
public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
|
public MIProcessAdapter(String[] args, IProgressMonitor monitor) throws IOException {
|
||||||
this(args, 0, monitor);
|
this(args, 0, monitor);
|
||||||
|
@ -36,6 +37,7 @@ public class MIProcessAdapter implements MIProcess {
|
||||||
|
|
||||||
public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
|
public MIProcessAdapter(String[] args, int launchTimeout, IProgressMonitor monitor) throws IOException {
|
||||||
fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
|
fGDBProcess = getGDBProcess(args, launchTimeout, monitor);
|
||||||
|
commandTimeout = MIPlugin.getCommandTimeout();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,16 +114,10 @@ public class MIProcessAdapter implements MIProcess {
|
||||||
|
|
||||||
public void interrupt(MIInferior inferior) {
|
public void interrupt(MIInferior inferior) {
|
||||||
if (fGDBProcess instanceof Spawner) {
|
if (fGDBProcess instanceof Spawner) {
|
||||||
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
if (inferior.isRunning()) {
|
||||||
gdbSpawner.interrupt();
|
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
||||||
synchronized (inferior) {
|
gdbSpawner.interrupt();
|
||||||
// Allow (5 secs) for the interrupt to propagate.
|
waitForInterrupt(inferior);
|
||||||
for (int i = 0; inferior.isRunning() && i < 5; i++) {
|
|
||||||
try {
|
|
||||||
inferior.wait(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If we are still running try to drop the sig to the PID
|
// If we are still running try to drop the sig to the PID
|
||||||
if (inferior.isRunning() && inferior.getInferiorPID() > 0) {
|
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.
|
* Send an interrupt to the inferior process.
|
||||||
*
|
*
|
||||||
|
@ -141,14 +151,7 @@ public class MIProcessAdapter implements MIProcess {
|
||||||
if (fGDBProcess instanceof Spawner) {
|
if (fGDBProcess instanceof Spawner) {
|
||||||
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
Spawner gdbSpawner = (Spawner) fGDBProcess;
|
||||||
gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
|
gdbSpawner.raise(inferior.getInferiorPID(), gdbSpawner.INT);
|
||||||
synchronized (inferior) {
|
waitForInterrupt(inferior);
|
||||||
for (int i = 0; inferior.isRunning() && i < 5; i++) {
|
|
||||||
try {
|
|
||||||
inferior.wait(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue