diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
index 521426d709f..79899995dea 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java
@@ -58,7 +58,7 @@ import org.eclipse.debug.core.model.ITerminate;
*/
@ThreadSafe
public class GdbLaunch extends Launch
- implements ITerminate, IDisconnect
+ implements ITerminate, IDisconnect, ITracedLaunch
{
private DefaultDsfExecutor fExecutor;
private DsfSession fSession;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java
new file mode 100644
index 00000000000..87229b44669
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.launching;
+
+
+/**
+ * This interface is used to indicate that a launch should have
+ * a TracingConsole.
+ *
+ * @see org.eclipse.cdt.dsf.gdb.internal.ui.tracing.TracingConsoleManager
+ * @see org.eclipse.cdt.dsf.gdb.internal.ui.tracing.TracingConsole
+ *
+ * @since 2.0
+ */
+public interface ITracedLaunch {
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
index f861504b82b..80a1ebd9a2b 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java
@@ -13,6 +13,7 @@
package org.eclipse.cdt.dsf.gdb.service.command;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Hashtable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -370,6 +371,13 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
return fInferiorProcess;
}
+ /**
+ * @since 2.0
+ */
+ public void setTracingStream(OutputStream tracingStream) {
+ setMITracingStream(tracingStream);
+ }
+
@DsfServiceEventHandler
public void eventDispatched(ICommandControlShutdownDMEvent e) {
// Handle our "GDB Exited" event and stop processing commands.
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
index cdd9d41897f..41d04f83bbe 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java
@@ -13,6 +13,7 @@
package org.eclipse.cdt.dsf.gdb.service.command;
import java.io.IOException;
+import java.io.OutputStream;
import java.util.Hashtable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -509,6 +510,13 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
return fInferiorProcess;
}
+ /**
+ * @since 2.0
+ */
+ public void setTracingStream(OutputStream tracingStream) {
+ setMITracingStream(tracingStream);
+ }
+
@DsfServiceEventHandler
public void eventDispatched(ICommandControlShutdownDMEvent e) {
// Handle our "GDB Exited" event and stop processing commands.
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java
index 3027a783581..9cc16bff965 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Ericsson and others.
+ * Copyright (c) 2009 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,8 @@
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service.command;
+import java.io.OutputStream;
+
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
@@ -33,4 +35,9 @@ public interface IGDBControl extends ICommandControlService {
AbstractCLIProcess getCLIProcess();
MIInferiorProcess getInferiorProcess();
+
+ /**
+ * @since 2.0
+ */
+ void setTracingStream(OutputStream tracingStream);
}
\ No newline at end of file
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 bcace281b8b..8a445093171 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
@@ -110,6 +110,13 @@ public abstract class AbstractMIControl extends AbstractDsfService
* Flag indicating that the command control has stopped processing commands.
*/
private boolean fStoppedCommandProcessing = false;
+
+ /**
+ * An output stream that MI communication should be output to.
+ * It serves for debugging. Can be null
to disable tracing.
+ */
+ private OutputStream fTracingStream = null;
+
public AbstractMIControl(DsfSession session) {
super(session);
@@ -124,6 +131,25 @@ public abstract class AbstractMIControl extends AbstractDsfService
fUseThreadAndFrameOptions = useThreadAndFrameOptions;
}
+ /**
+ * Set the tracing stream for the MI communication. If this method is never
+ * called, tracing will be off, by default.
+ *
+ * @param tracingStream The stream to use. Can be null
+ * to disable tracing.
+ * @since 2.0
+ */
+ protected void setMITracingStream(OutputStream tracingStream) {
+ fTracingStream = tracingStream;
+ }
+
+ /**
+ * Returns the MI tracing stream.
+ */
+ private OutputStream getMITracingStream() {
+ return fTracingStream;
+ }
+
/**
* Starts the threads that process the debugger input/output channels.
* To be invoked by the initialization routine of the extending class.
@@ -524,6 +550,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
fOutputStream.flush();
GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + str); //$NON-NLS-1$
+ getExecutor().execute(new DsfRunnable() {
+ public void run() {
+ if (getMITracingStream() != null) {
+ try {
+ getMITracingStream().write(GdbPlugin.getDebugTime().getBytes());
+ getMITracingStream().write(' ');
+ getMITracingStream().write(str.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.
@@ -556,6 +598,26 @@ public abstract class AbstractMIControl extends AbstractDsfService
while ((line = reader.readLine()) != null) {
if (line.length() != 0) {
GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + line +"\n"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ final String finalLine = line;
+ getExecutor().execute(new DsfRunnable() {
+ public void run() {
+ if (getMITracingStream() != null) {
+ try {
+ getMITracingStream().write(GdbPlugin.getDebugTime().getBytes());
+ getMITracingStream().write(' ');
+ getMITracingStream().write(finalLine.getBytes());
+ getMITracingStream().write('\n');
+ } 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);
}
}