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

Allow the client to overload the interrupt

This commit is contained in:
Alain Magloire 2004-01-30 17:15:50 +00:00
parent 672ff00623
commit 2e8a72022a
5 changed files with 36 additions and 13 deletions

View file

@ -1,3 +1,12 @@
2004-01-30 Alain Magloire
Allow the clients to override the interrupt.
* src/org/eclipse/cdt/debug/mi/core/MIInferior.java
* src/org/eclipse/cdt/debug/mi/core/TxThread.java
* src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java
* src/org/eclipse/cdt/debug/mi/core/command/MICommand.java
2004-01-29 Alain Magloire 2004-01-29 Alain Magloire
The CDT debug ui prefers things to be in ascending The CDT debug ui prefers things to be in ascending

View file

@ -12,10 +12,12 @@ import java.io.PipedOutputStream;
import org.eclipse.cdt.debug.mi.core.command.CommandFactory; import org.eclipse.cdt.debug.mi.core.command.CommandFactory;
import org.eclipse.cdt.debug.mi.core.command.MIExecAbort; import org.eclipse.cdt.debug.mi.core.command.MIExecAbort;
import org.eclipse.cdt.debug.mi.core.command.MIExecInterrupt;
import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode; import org.eclipse.cdt.debug.mi.core.command.MIGDBShowExitCode;
import org.eclipse.cdt.debug.mi.core.command.MIInfoProgram; import org.eclipse.cdt.debug.mi.core.command.MIInfoProgram;
import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent; import org.eclipse.cdt.debug.mi.core.event.MIInferiorExitEvent;
import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo; import org.eclipse.cdt.debug.mi.core.output.MIGDBShowExitCodeInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfo;
import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo;
import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.cdt.utils.pty.PTY;
import org.eclipse.cdt.utils.spawner.Spawner; import org.eclipse.cdt.utils.spawner.Spawner;
@ -171,7 +173,24 @@ public class MIInferior extends Process {
public synchronized void interrupt() throws MIException { public synchronized void interrupt() throws MIException {
Process gdb = session.getGDBProcess(); Process gdb = session.getGDBProcess();
if (gdb instanceof Spawner) { // Check if they can handle the interrupt
// Try the exec-interrupt; this will be for "gdb --async"
CommandFactory factory = session.getCommandFactory();
MIExecInterrupt interrupt = factory.createMIExecInterrupt();
if (interrupt != null) {
try {
session.postCommand(interrupt);
MIInfo info = interrupt.getMIInfo();
// Allow (5 secs) for the interrupt to propagate.
for (int i = 0;(state == RUNNING) && i < 5; i++) {
try {
wait(1000);
} catch (InterruptedException e) {
}
}
} catch (MIException e) {
}
} else if (gdb instanceof Spawner) {
Spawner gdbSpawner = (Spawner) gdb; Spawner gdbSpawner = (Spawner) gdb;
gdbSpawner.interrupt(); gdbSpawner.interrupt();
// Allow (5 secs) for the interrupt to propagate. // Allow (5 secs) for the interrupt to propagate.
@ -191,17 +210,8 @@ public class MIInferior extends Process {
} }
} }
} }
} else {
// Try the exec-interrupt; this will be for "gdb --async"
// CommandFactory factory = session.getCommandFactory();
// MIExecInterrupt interrupt = factory.createMIExecInterrupt();
// try {
// session.postCommand(interrupt);
// MIInfo info = interrupt.getMIInfo();
// } catch (MIException e) {
// }
//throw new MIException("Interruption no supported");
} }
// If we've failed throw an exception up. // If we've failed throw an exception up.
if (state == RUNNING) { if (state == RUNNING) {
throw new MIException("Failed to interrupt"); throw new MIException("Failed to interrupt");

View file

@ -59,7 +59,7 @@ public class TxThread extends Thread {
// shove in the pipe // shove in the pipe
String str = cmd.toString(); String str = cmd.toString();
if (out != null) { if (out != null && str.length() > 0) {
out.write(str.getBytes()); out.write(str.getBytes());
out.flush(); out.flush();
} }

View file

@ -134,7 +134,7 @@ public class CommandFactory {
} }
public MIExecInterrupt createMIExecInterrupt() { public MIExecInterrupt createMIExecInterrupt() {
return new MIExecInterrupt(); return null;
} }
public MIExecNext createMIExecNext() { public MIExecNext createMIExecNext() {

View file

@ -40,6 +40,10 @@ public class MICommand extends Command {
return operation; return operation;
} }
protected void setOperation(String op) {
operation = op;
}
/** /**
* Returns an array of command's options. An empty collection is * Returns an array of command's options. An empty collection is
* returned if there are no options. * returned if there are no options.