diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java index d0bb8be90b5..2e6b158fcdd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java @@ -79,7 +79,7 @@ public abstract class AbstractMIControl extends AbstractDsfService // MI did not always support the --thread/--frame options // This boolean is used to know if we should use -thread-select and -stack-select-frame instead - private boolean fUseThreadAndFrameOptions; + private final boolean fUseThreadAndFrameOptions; // currentStackLevel and currentThreadId are only necessary when // we must use -thread-select and -stack-select-frame private int fCurrentStackLevel = -1; @@ -142,14 +142,14 @@ public abstract class AbstractMIControl extends AbstractDsfService * to disable tracing. * @since 2.0 */ - protected void setMITracingStream(OutputStream tracingStream) { + protected synchronized void setMITracingStream(OutputStream tracingStream) { fTracingStream = tracingStream; } /** * Returns the MI tracing stream. */ - private OutputStream getMITracingStream() { + private synchronized OutputStream getMITracingStream() { return fTracingStream; } @@ -564,26 +564,22 @@ public abstract class AbstractMIControl extends AbstractDsfService fOutputStream.flush(); GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + str); - getExecutor().execute(new DsfRunnable() { - public void run() { - if (getMITracingStream() != null) { - try { - String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$ - while (message.length() > 100) { - String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$ - message = message.substring(100); - getMITracingStream().write(partial.getBytes()); - } - getMITracingStream().write(message.getBytes()); - } catch (IOException e) { - // The tracing stream could be closed at any time - // since the user can set a preference to turn off - // this tracing. - setMITracingStream(null); - } + if (getMITracingStream() != null) { + try { + String message = GdbPlugin.getDebugTime() + " " + str; //$NON-NLS-1$ + while (message.length() > 100) { + String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$ + message = message.substring(100); + getMITracingStream().write(partial.getBytes()); } + getMITracingStream().write(message.getBytes()); + } catch (IOException e) { + // The tracing stream could be closed at any time + // since the user can set a preference to turn off + // this tracing. + setMITracingStream(null); } - }); + } } } catch (IOException e) { // Shutdown thread in case of IO error. @@ -618,26 +614,22 @@ public abstract class AbstractMIControl extends AbstractDsfService GdbPlugin.debug(GdbPlugin.getDebugTime() + MI_TRACE_IDENTIFIER + line + "\n"); //$NON-NLS-1$ final String finalLine = line; - getExecutor().execute(new DsfRunnable() { - public void run() { - if (getMITracingStream() != null) { - try { - String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ - while (message.length() > 100) { - String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$ - message = message.substring(100); - getMITracingStream().write(partial.getBytes()); - } - getMITracingStream().write(message.getBytes()); - } catch (IOException e) { - // The tracing stream could be closed at any time - // since the user can set a preference to turn off - // this tracing. - setMITracingStream(null); - } - } + if (getMITracingStream() != null) { + try { + String message = GdbPlugin.getDebugTime() + " " + finalLine + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ + while (message.length() > 100) { + String partial = message.substring(0, 100) + "\\\n"; //$NON-NLS-1$ + message = message.substring(100); + getMITracingStream().write(partial.getBytes()); + } + getMITracingStream().write(message.getBytes()); + } catch (IOException e) { + // The tracing stream could be closed at any time + // since the user can set a preference to turn off + // this tracing. + setMITracingStream(null); } - }); + } processMIOutput(line); }