mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
[249227] New TracingConsole solution to allow for GDB traces to be printed.
This commit is contained in:
parent
516d06123b
commit
0f18d800c1
6 changed files with 111 additions and 2 deletions
|
@ -58,7 +58,7 @@ import org.eclipse.debug.core.model.ITerminate;
|
||||||
*/
|
*/
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
public class GdbLaunch extends Launch
|
public class GdbLaunch extends Launch
|
||||||
implements ITerminate, IDisconnect
|
implements ITerminate, IDisconnect, ITracedLaunch
|
||||||
{
|
{
|
||||||
private DefaultDsfExecutor fExecutor;
|
private DefaultDsfExecutor fExecutor;
|
||||||
private DsfSession fSession;
|
private DsfSession fSession;
|
||||||
|
|
|
@ -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 {
|
||||||
|
}
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.dsf.gdb.service.command;
|
package org.eclipse.cdt.dsf.gdb.service.command;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -370,6 +371,13 @@ public class GDBControl extends AbstractMIControl implements IGDBControl {
|
||||||
return fInferiorProcess;
|
return fInferiorProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public void setTracingStream(OutputStream tracingStream) {
|
||||||
|
setMITracingStream(tracingStream);
|
||||||
|
}
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||||
// Handle our "GDB Exited" event and stop processing commands.
|
// Handle our "GDB Exited" event and stop processing commands.
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
package org.eclipse.cdt.dsf.gdb.service.command;
|
package org.eclipse.cdt.dsf.gdb.service.command;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -509,6 +510,13 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl {
|
||||||
return fInferiorProcess;
|
return fInferiorProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
public void setTracingStream(OutputStream tracingStream) {
|
||||||
|
setMITracingStream(tracingStream);
|
||||||
|
}
|
||||||
|
|
||||||
@DsfServiceEventHandler
|
@DsfServiceEventHandler
|
||||||
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
public void eventDispatched(ICommandControlShutdownDMEvent e) {
|
||||||
// Handle our "GDB Exited" event and stop processing commands.
|
// Handle our "GDB Exited" event and stop processing commands.
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse License v1.0
|
* are made available under the terms of the Eclipse License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.service.command;
|
package org.eclipse.cdt.dsf.gdb.service.command;
|
||||||
|
|
||||||
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
|
||||||
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
|
||||||
|
@ -33,4 +35,9 @@ public interface IGDBControl extends ICommandControlService {
|
||||||
AbstractCLIProcess getCLIProcess();
|
AbstractCLIProcess getCLIProcess();
|
||||||
|
|
||||||
MIInferiorProcess getInferiorProcess();
|
MIInferiorProcess getInferiorProcess();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 2.0
|
||||||
|
*/
|
||||||
|
void setTracingStream(OutputStream tracingStream);
|
||||||
}
|
}
|
|
@ -110,6 +110,13 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
* Flag indicating that the command control has stopped processing commands.
|
* Flag indicating that the command control has stopped processing commands.
|
||||||
*/
|
*/
|
||||||
private boolean fStoppedCommandProcessing = false;
|
private boolean fStoppedCommandProcessing = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An output stream that MI communication should be output to.
|
||||||
|
* It serves for debugging. Can be <code>null</code> to disable tracing.
|
||||||
|
*/
|
||||||
|
private OutputStream fTracingStream = null;
|
||||||
|
|
||||||
|
|
||||||
public AbstractMIControl(DsfSession session) {
|
public AbstractMIControl(DsfSession session) {
|
||||||
super(session);
|
super(session);
|
||||||
|
@ -124,6 +131,25 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
fUseThreadAndFrameOptions = useThreadAndFrameOptions;
|
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 <code>null</code>
|
||||||
|
* 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.
|
* Starts the threads that process the debugger input/output channels.
|
||||||
* To be invoked by the initialization routine of the extending class.
|
* To be invoked by the initialization routine of the extending class.
|
||||||
|
@ -524,6 +550,22 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
fOutputStream.flush();
|
fOutputStream.flush();
|
||||||
|
|
||||||
GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + str); //$NON-NLS-1$
|
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) {
|
} catch (IOException e) {
|
||||||
// Shutdown thread in case of IO error.
|
// Shutdown thread in case of IO error.
|
||||||
|
@ -556,6 +598,26 @@ public abstract class AbstractMIControl extends AbstractDsfService
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
if (line.length() != 0) {
|
if (line.length() != 0) {
|
||||||
GdbPlugin.debug(GdbPlugin.getDebugTime() + " " + line +"\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
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);
|
processMIOutput(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue