From 14259c32e5fe3b53a475b4dcb85c7fd040e76f56 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 29 Feb 2008 16:46:33 +0000 Subject: [PATCH] Bug 220959 Do not sent target output generated by CLI commands to the target console. --- .../mi/service/command/MIInferiorProcess.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java index 9cbe94eaa20..83bdc774da0 100644 --- a/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java +++ b/plugins/org.eclipse.dd.mi/src/org/eclipse/dd/mi/service/command/MIInferiorProcess.java @@ -38,6 +38,7 @@ import org.eclipse.dd.dsf.debug.service.command.IEventListener; import org.eclipse.dd.dsf.service.DsfSession; import org.eclipse.dd.dsf.service.IDsfService; import org.eclipse.dd.mi.internal.MIPlugin; +import org.eclipse.dd.mi.service.command.commands.CLICommand; import org.eclipse.dd.mi.service.command.commands.CLIExecAbort; import org.eclipse.dd.mi.service.command.commands.MIGDBShowExitCode; import org.eclipse.dd.mi.service.command.output.MIConst; @@ -78,6 +79,20 @@ public class MIInferiorProcess extends Process @ConfinedToDsfExecutor("fSession#getExecutor") private boolean fDisposed = false; + + /** + * Counter for tracking console commands sent by services. + * + * The CLI 'monitor' command produces target output which should + * not be written to the target console, since it is in response to a CLI + * command. In fact, CLI commands should never have their output sent + * to the target console. + * + * This counter is incremented any time a CLI command is seen. It is + * decremented whenever a CLI command is finished. When counter + * value is 0, the inferior process writes the target output. + */ + private int fSuppressTargetOutputCounter = 0; Integer fExitCode = null; @@ -357,6 +372,7 @@ public class MIInferiorProcess extends Process } } } else if (oobr instanceof MITargetStreamOutput) { + if (fSuppressTargetOutputCounter > 0) return; MITargetStreamOutput tgtOut = (MITargetStreamOutput)oobr; if (fInputStreamPiped != null && tgtOut.getString() != null) { try { @@ -374,14 +390,20 @@ public class MIInferiorProcess extends Process } public void commandSent(ICommand command) { - // No action + if (command instanceof CLICommand) { + fSuppressTargetOutputCounter++; + } } public void commandRemoved(ICommand command) { // No action } - public void commandDone(ICommand cmd, ICommandResult result) { + public void commandDone(ICommand command, ICommandResult result) { + if (command instanceof CLICommand) { + fSuppressTargetOutputCounter--; + } + MIInfo cmdResult = (MIInfo) result ; MIOutput output = cmdResult.getMIOutput(); MIResultRecord rr = output.getMIResultRecord();