From 2e8a72022ab27d50d622af8be3ca397a6fdce93f Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Fri, 30 Jan 2004 17:15:50 +0000 Subject: [PATCH] Allow the client to overload the interrupt --- debug/org.eclipse.cdt.debug.mi.core/ChangeLog | 9 ++++++ .../eclipse/cdt/debug/mi/core/MIInferior.java | 32 ++++++++++++------- .../eclipse/cdt/debug/mi/core/TxThread.java | 2 +- .../debug/mi/core/command/CommandFactory.java | 2 +- .../cdt/debug/mi/core/command/MICommand.java | 4 +++ 5 files changed, 36 insertions(+), 13 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog index 22ab5ed6219..949bc620686 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.mi.core/ChangeLog @@ -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 The CDT debug ui prefers things to be in ascending diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java index 8ecb0b45c1c..3e100d5f6c2 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/MIInferior.java @@ -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.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.MIInfoProgram; 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.MIInfo; import org.eclipse.cdt.debug.mi.core.output.MIInfoProgramInfo; import org.eclipse.cdt.utils.pty.PTY; import org.eclipse.cdt.utils.spawner.Spawner; @@ -171,7 +173,24 @@ public class MIInferior extends Process { public synchronized void interrupt() throws MIException { 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; gdbSpawner.interrupt(); // 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 (state == RUNNING) { throw new MIException("Failed to interrupt"); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/TxThread.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/TxThread.java index eaad1eb1fa8..d5857b04644 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/TxThread.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/TxThread.java @@ -59,7 +59,7 @@ public class TxThread extends Thread { // shove in the pipe String str = cmd.toString(); - if (out != null) { + if (out != null && str.length() > 0) { out.write(str.getBytes()); out.flush(); } diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java index 5d9b5f330f1..e7eede96ba2 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/CommandFactory.java @@ -134,7 +134,7 @@ public class CommandFactory { } public MIExecInterrupt createMIExecInterrupt() { - return new MIExecInterrupt(); + return null; } public MIExecNext createMIExecNext() { diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MICommand.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MICommand.java index 55fb82144e8..5742a3e7944 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MICommand.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/MICommand.java @@ -40,6 +40,10 @@ public class MICommand extends Command { return operation; } + protected void setOperation(String op) { + operation = op; + } + /** * Returns an array of command's options. An empty collection is * returned if there are no options.