mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
[305178] Improved interface for interrupt()
This commit is contained in:
parent
5cca2caf65
commit
01a10a10bf
4 changed files with 43 additions and 14 deletions
|
@ -377,11 +377,11 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
||||||
/**
|
/**
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public void interrupt(final RequestMonitor rm) {
|
public void interruptAndWait(int timeout, RequestMonitor rm) {
|
||||||
if (fProcess instanceof Spawner) {
|
if (fProcess instanceof Spawner) {
|
||||||
Spawner gdbSpawner = (Spawner) fProcess;
|
Spawner gdbSpawner = (Spawner) fProcess;
|
||||||
gdbSpawner.interrupt();
|
gdbSpawner.interrupt();
|
||||||
fInterruptFailedJob = new MonitorInterruptJob(rm);
|
fInterruptFailedJob = new MonitorInterruptJob(timeout, rm);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Cannot interrupt.", null)); //$NON-NLS-1$
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, IDsfStatusConstants.NOT_SUPPORTED, "Cannot interrupt.", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
@ -653,17 +653,34 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Monitors an ongoing interrupt to be able to properly
|
* Stores the request monitor that must be dealt with for
|
||||||
* deal with the request monitor.
|
* the result of the interrupt operation. If the interrupt
|
||||||
|
* successfully suspends the backend, the request monitor can
|
||||||
|
* be retrieved and completed successfully, and then this job
|
||||||
|
* should be canceled. If this job is not canceled before
|
||||||
|
* the time is up, it will imply the interrupt did not
|
||||||
|
* successfully suspend the backend, and the current job will
|
||||||
|
* indicate this in the request monitor.
|
||||||
|
*
|
||||||
|
* The specified timeout is used to indicate how many milliseconds
|
||||||
|
* this job should wait for. INTERRUPT_TIMEOUT_DEFAULT indicates
|
||||||
|
* to use the default of 500 ms. The default is also use if the
|
||||||
|
* timeout value is 0 or negative.
|
||||||
*/
|
*/
|
||||||
private class MonitorInterruptJob extends Job {
|
private class MonitorInterruptJob extends Job {
|
||||||
|
private final static int TIMEOUT_DEFAULT_VALUE = 500;
|
||||||
private final RequestMonitor fRequestMonitor;
|
private final RequestMonitor fRequestMonitor;
|
||||||
|
|
||||||
public MonitorInterruptJob(RequestMonitor rm) {
|
public MonitorInterruptJob(int timeout, RequestMonitor rm) {
|
||||||
super("Interrupt monitor job.");
|
super("Interrupt monitor job.");
|
||||||
setSystem(true);
|
setSystem(true);
|
||||||
fRequestMonitor = rm;
|
fRequestMonitor = rm;
|
||||||
schedule(5000); // Give the interrupt 5 seconds to succeed
|
|
||||||
|
if (timeout == INTERRUPT_TIMEOUT_DEFAULT || timeout <= 0) {
|
||||||
|
timeout = TIMEOUT_DEFAULT_VALUE; // default of 0.5 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
schedule(timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class GDBRunControl extends MIRunControl {
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
if (getData()) {
|
if (getData()) {
|
||||||
fGdb.interrupt(rm);
|
fGdb.interruptAndWait(IGDBBackend.INTERRUPT_TIMEOUT_DEFAULT, rm);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Context cannot be suspended.", null)); //$NON-NLS-1$
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Context cannot be suspended.", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
|
@ -144,7 +144,7 @@ public class GDBRunControl_7_0 extends MIRunControl implements IReverseRunContro
|
||||||
@Override
|
@Override
|
||||||
protected void handleSuccess() {
|
protected void handleSuccess() {
|
||||||
if (getData()) {
|
if (getData()) {
|
||||||
fGdb.interrupt(rm);
|
fGdb.interruptAndWait(IGDBBackend.INTERRUPT_TIMEOUT_DEFAULT, rm);
|
||||||
} else {
|
} else {
|
||||||
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Context cannot be suspended.", null)); //$NON-NLS-1$
|
rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_STATE, "Context cannot be suspended.", null)); //$NON-NLS-1$
|
||||||
rm.done();
|
rm.done();
|
||||||
|
|
|
@ -40,6 +40,12 @@ import org.eclipse.core.runtime.IPath;
|
||||||
*/
|
*/
|
||||||
public interface IGDBBackend extends IMIBackend {
|
public interface IGDBBackend extends IMIBackend {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID to use when requesting that the interruptAndWait call wait for an
|
||||||
|
* implementation-specific default.
|
||||||
|
* @since 3.0 */
|
||||||
|
public final static int INTERRUPT_TIMEOUT_DEFAULT = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get path of the debugged program on host.
|
* Get path of the debugged program on host.
|
||||||
*
|
*
|
||||||
|
@ -103,14 +109,20 @@ public interface IGDBBackend extends IMIBackend {
|
||||||
public void interrupt();
|
public void interrupt();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interrupts the backend.
|
* Interrupts the backend and wait to confirm the interrupt
|
||||||
* The request monitor indicates if the interrupt succeeded or not;
|
* succeeded. The request monitor indicates to the caller if
|
||||||
* it may or may not indicate that the backend is already interrupted,
|
* the interrupt succeeded or not.
|
||||||
* but does indicate if the backend will become interrupted.
|
|
||||||
*
|
*
|
||||||
|
* @param timeout Maximum number of milliseconds to wait to confirm
|
||||||
|
* that the backend has been interrupted. A value
|
||||||
|
* of INTERRUPT_TIMEOUT_DEFAULT specifies to use an
|
||||||
|
* implementation-specific default value.
|
||||||
|
* Using a value of 0 or a negative value has unspecified
|
||||||
|
* behavior.
|
||||||
|
*
|
||||||
* @since 3.0
|
* @since 3.0
|
||||||
*/
|
*/
|
||||||
public void interrupt(RequestMonitor rm);
|
public void interruptAndWait(int timeout, RequestMonitor rm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The type of the session currently ongoing with the backend
|
* @return The type of the session currently ongoing with the backend
|
||||||
|
|
Loading…
Add table
Reference in a new issue