From 5c88b5c611c8f30d24eb027869d8a1f9a1f0cb1c Mon Sep 17 00:00:00 2001 From: Alain Magloire Date: Thu, 24 Oct 2002 02:43:18 +0000 Subject: [PATCH] processCLICommand() new method. --- .../eclipse/cdt/debug/mi/core/TxThread.java | 48 ++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) 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 0ab245c488a..e269e95336e 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 @@ -8,7 +8,10 @@ package org.eclipse.cdt.debug.mi.core; import java.io.IOException; import java.io.OutputStream; +import org.eclipse.cdt.debug.mi.core.command.CLICommand; import org.eclipse.cdt.debug.mi.core.command.Command; +import org.eclipse.cdt.debug.mi.core.event.MIEvent; +import org.eclipse.cdt.debug.mi.core.event.MIRunningEvent; /** * Transmission command thread blocks on the command Queue @@ -55,7 +58,12 @@ public class TxThread extends Thread { cmd.notifyAll(); } } - + + // May need to fire event. + if (cmd instanceof CLICommand) { + processCLICommand((CLICommand)cmd); + } + // shove in the pipe String str = cmd.toString(); if (out != null) { @@ -79,4 +87,42 @@ public class TxThread extends Thread { } } } + + /** + * An attempt to discover the command type and + * fire an event if necessary. + */ + void processCLICommand(CLICommand cmd) { + String operation = cmd.getOperation(); + int indx = operation.indexOf(' '); + if (indx != -1) { + operation = operation.substring(0, indx).trim(); + } else { + operation = operation.trim(); + } + + // Check the type of command + int type = -1; + // if it was a step instruction set state running + if (operation.equals("n") || operation.equals("next")) { + type = MIRunningEvent.NEXT; + } else if (operation.equals("ni") || operation.equals("nexti")) { + type = MIRunningEvent.NEXTI; + } else if (operation.equals("s") || operation.equals("step")) { + type = MIRunningEvent.STEP; + } else if (operation.equals("si") || operation.equals("stepi")) { + type = MIRunningEvent.STEPI; + } else if (operation.equals("u") || operation.startsWith("unt")) { + type = MIRunningEvent.UNTIL; + } else if (operation.startsWith("fin")) { + type = MIRunningEvent.FINISH; + } else if (operation.equals("c") || operation.equals("fg") || operation.startsWith("cont")) { + type = MIRunningEvent.CONTINUE; + } + if (type != -1) { + session.getMIInferior().setRunning(); + MIEvent event = new MIRunningEvent(type); + session.fireEvent(event); + } + } }