Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 127073 Details for
Bug 249227
[console][cdi] Add support for "verbose" tracing of MI commands in console
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
TracingConsoleManager solution
zpatch.txt (text/plain), 35.10 KB, created by
Marc Khouzam
on 2009-02-28 03:18:51 EST
(
hide
)
Description:
TracingConsoleManager solution
Filename:
MIME Type:
Creator:
Marc Khouzam
Created:
2009-02-28 03:18:51 EST
Size:
35.10 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.cdt.dsf.gdb.ui >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/META-INF/MANIFEST.MF,v >retrieving revision 1.2 >diff -u -r1.2 MANIFEST.MF >--- META-INF/MANIFEST.MF 23 Jan 2009 18:07:21 -0000 1.2 >+++ META-INF/MANIFEST.MF 28 Feb 2009 08:08:55 -0000 >@@ -18,7 +18,8 @@ > org.eclipse.cdt.ui, > org.eclipse.ui.ide, > org.eclipse.core.variables, >- org.eclipse.core.expressions >+ org.eclipse.core.expressions, >+ org.eclipse.ui.console > Bundle-ActivationPolicy: lazy > Bundle-RequiredExecutionEnvironment: J2SE-1.5 > Export-Package: org.eclipse.cdt.dsf.gdb.internal.ui.actions;x-internal:=true, >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java,v >retrieving revision 1.1 >diff -u -r1.1 GdbUIPlugin.java >--- src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java 8 Jan 2009 21:06:29 -0000 1.1 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbUIPlugin.java 28 Feb 2009 08:08:55 -0000 >@@ -11,6 +11,7 @@ > *******************************************************************************/ > package org.eclipse.cdt.dsf.gdb.internal.ui; > >+import org.eclipse.cdt.dsf.gdb.internal.ui.tracing.TracingConsoleManager; > import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; > import org.eclipse.cdt.dsf.gdb.launching.LaunchMessages; > import org.eclipse.core.runtime.IStatus; >@@ -37,6 +38,7 @@ > > private static BundleContext fgBundleContext; > >+ private static TracingConsoleManager fTracingConsoleManager; > /** > * The constructor > */ >@@ -52,6 +54,9 @@ > fgBundleContext = context; > super.start(context); > plugin = this; >+ >+ fTracingConsoleManager = new TracingConsoleManager(); >+ fTracingConsoleManager.startup(); > } > > /* >@@ -60,6 +65,8 @@ > */ > @Override > public void stop(BundleContext context) throws Exception { >+ fTracingConsoleManager.shutdown(); >+ > disposeAdapterSets(); > plugin = null; > super.stop(context); >Index: plugin.properties >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties,v >retrieving revision 1.2 >diff -u -r1.2 plugin.properties >--- plugin.properties 23 Jan 2009 18:07:21 -0000 1.2 >+++ plugin.properties 28 Feb 2009 08:08:55 -0000 >@@ -35,3 +35,5 @@ > command.uncall.name = Uncall > command.uncall.description = Perform Uncall > command.uncall.label = Uncall >+ >+gdbPreferencePage.name = GDB >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml,v >retrieving revision 1.4 >diff -u -r1.4 plugin.xml >--- plugin.xml 20 Feb 2009 19:26:18 -0000 1.4 >+++ plugin.xml 28 Feb 2009 08:08:55 -0000 >@@ -552,5 +552,20 @@ > type="org.eclipse.ui.IWorkbenchPart"> > </propertyTester> > </extension> >+ <extension >+ point="org.eclipse.ui.preferencePages"> >+ <page >+ category="org.eclipse.cdt.dsf.debug.ui.preferences" >+ class="org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbDebugPreferencePage" >+ id="org.eclipse.cdt.dsf.gdb.ui.preferences" >+ name="%gdbPreferencePage.name"> >+ </page> >+ </extension> >+ <extension >+ point="org.eclipse.core.runtime.preferences"> >+ <initializer >+ class="org.eclipse.cdt.dsf.gdb.internal.ui.preferences.GdbPreferenceInitializer"> >+ </initializer> >+ </extension> > > </plugin> >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * 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.internal.ui.preferences; >+ >+import org.eclipse.osgi.util.NLS; >+ >+/** >+ * Preference strings. >+ */ >+class MessagesForPreferences extends NLS { >+ private static final String BUNDLE_NAME= "org.eclipse.cdt.dsf.gdb.internal.ui.preferences.messages"; //$NON-NLS-1$ >+ >+ public static String GdbDebugPreferencePage_description; >+ public static String GdbDebugPreferencePage_traces_label; >+ public static String GdbDebugPreferencePage_enableTraces_label; >+ >+ static { >+ // initialize resource bundle >+ NLS.initializeMessages(BUNDLE_NAME, MessagesForPreferences.class); >+ } >+ >+ private MessagesForPreferences() { >+ } >+} >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/IGdbDebugPreferenceConstants.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,39 @@ >+/******************************************************************************* >+ * 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 implementation >+ *******************************************************************************/ >+package org.eclipse.cdt.dsf.gdb.internal.ui.preferences; >+ >+import org.eclipse.debug.ui.IDebugUIConstants; >+ >+ >+/** >+ * @noimplement This interface is not intended to be implemented by clients. >+ * @since 2.0 >+ */ >+public interface IGdbDebugPreferenceConstants { >+ >+ /** >+ * Debug UI plug-in identifier (value <code>"org.eclipse.cdt.dsf.gdb.ui"</code>). >+ */ >+ public static final String PLUGIN_ID = "org.eclipse.cdt.dsf.gdb.ui"; //$NON-NLS-1$; >+ >+ /** >+ * Boolean preference whether to enable GDB traces. Default is <code>true</code>. >+ * >+ */ >+ public static final String PREF_TRACES_ENABLE = "tracesEnable"; //$NON-NLS-1$ >+ >+ /** >+ * Help prefixes. >+ */ >+ public static final String PREFIX = IDebugUIConstants.PLUGIN_ID + "."; //$NON-NLS-1$ >+ >+ public static final String PREFERENCE_PAGE= PREFIX + "preference_page_context"; //$NON-NLS-1$ >+} >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,76 @@ >+/******************************************************************************* >+ * 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.internal.ui.preferences; >+ >+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; >+import org.eclipse.jface.preference.BooleanFieldEditor; >+import org.eclipse.jface.preference.FieldEditorPreferencePage; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+import org.eclipse.ui.IWorkbench; >+import org.eclipse.ui.IWorkbenchPreferencePage; >+import org.eclipse.ui.PlatformUI; >+ >+/** >+ * A preference page for settings that are currently only supported in GDB. >+ */ >+public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { >+ >+ public GdbDebugPreferencePage() { >+ super(FLAT); >+ IPreferenceStore store= GdbUIPlugin.getDefault().getPreferenceStore(); >+ setPreferenceStore(store); >+ setDescription(MessagesForPreferences.GdbDebugPreferencePage_description); >+ } >+ >+ public void init(IWorkbench workbench) { >+ } >+ >+ @Override >+ public void createControl(Composite parent) { >+ super.createControl(parent); >+ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IGdbDebugPreferenceConstants.PREFERENCE_PAGE); >+ } >+ >+ @Override >+ protected void createFieldEditors() { >+ final Composite parent= getFieldEditorParent(); >+ final GridLayout layout= new GridLayout(); >+ layout.marginWidth= 0; >+ parent.setLayout(layout); >+ >+ Group tracesGroup= new Group(parent, SWT.NONE); >+ tracesGroup.setText(MessagesForPreferences.GdbDebugPreferencePage_traces_label); >+ GridLayout groupLayout= new GridLayout(3, false); >+ tracesGroup.setLayout(groupLayout); >+ tracesGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); >+ >+ BooleanFieldEditor traces= new BooleanFieldEditor( >+ IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, >+ MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label, >+ tracesGroup); >+ >+ traces.fillIntoGrid(tracesGroup, 3); >+ addField(traces); >+ >+ // need to set layout again >+ tracesGroup.setLayout(groupLayout); >+ } >+ >+ @Override >+ protected void adjustGridLayout() { >+ // do nothing >+ } >+} >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,26 @@ >+/******************************************************************************* >+ * 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.internal.ui.preferences; >+ >+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; >+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; >+import org.eclipse.jface.preference.IPreferenceStore; >+ >+/** >+ * Initialize the GDB preferences. >+ */ >+public class GdbPreferenceInitializer extends AbstractPreferenceInitializer { >+ @Override >+ public void initializeDefaultPreferences() { >+ IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); >+ store.setDefault(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true); >+ } >+} >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/messages.properties 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,14 @@ >+############################################################################### >+# 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 >+############################################################################### >+ >+GdbDebugPreferencePage_description=General settings for GDB Debugging >+GdbDebugPreferencePage_traces_label=Traces >+GdbDebugPreferencePage_enableTraces_label=Enable GDB traces >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsole.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsole.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsole.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsole.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,182 @@ >+/******************************************************************************* >+ * 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.internal.ui.tracing; >+ >+import java.io.IOException; >+import java.io.OutputStream; >+import java.util.concurrent.RejectedExecutionException; >+ >+import org.eclipse.cdt.dsf.concurrent.DsfRunnable; >+import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService.ICommandControlInitializedDMEvent; >+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; >+import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch; >+import org.eclipse.cdt.dsf.gdb.service.command.IGDBControl; >+import org.eclipse.cdt.dsf.service.DsfServiceEventHandler; >+import org.eclipse.cdt.dsf.service.DsfServicesTracker; >+import org.eclipse.cdt.dsf.service.DsfSession; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchConfiguration; >+import org.eclipse.debug.ui.DebugUITools; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.console.IOConsole; >+ >+/** >+ * A console that is used to print traces. The console is attached to a launch. >+ * >+ * Any input to this console is read and discarded, since this console should be >+ * read-only. We don't actually make the console read-only because it is nice >+ * for the user to be able to add delimiters such as empty lines within the traces. >+ */ >+public class TracingConsole extends IOConsole { >+ private ILaunch fLaunch; >+ private OutputStream fTracingStream = null; >+ private DsfSession fSession = null; >+ private String fLabel = ""; //$NON-NLS-1$ >+ >+ public TracingConsole(ILaunch launch, String label) { >+ super("", null, null, true); //$NON-NLS-1$ >+ fLaunch = launch; >+ fTracingStream = newOutputStream(); >+ fSession = ((GdbLaunch)launch).getSession(); >+ fLabel = label; >+ >+ resetName(); >+ >+ // Start a job to swallow all the input from the user >+ new InputReadJob().schedule(); >+ >+ // This is needed if the service has already been created. >+ // For example, if we turn on tracing after a launch is started. >+ setStreamInService(); >+ } >+ >+ @Override >+ protected void init() { >+ super.init(); >+ fSession.addServiceEventListener(this, null); >+ } >+ >+ @Override >+ protected void dispose() { >+ try { >+ fTracingStream.close(); >+ } catch (IOException e) { >+ } >+ super.dispose(); >+ } >+ >+ public ILaunch getLaunch() { return fLaunch; } >+ >+ private void setStreamInService() { >+ try { >+ fSession.getExecutor().submit(new DsfRunnable() { >+ public void run() { >+ DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); >+ IGDBControl control = tracker.getService(IGDBControl.class); >+ tracker.dispose(); >+ if (control != null) { >+ // Special method that need not be called on the executor >+ control.setTracingStream(fTracingStream); >+ } >+ } >+ }); >+ } catch (RejectedExecutionException e) { >+ } >+ } >+ >+ protected String computeName() { >+ String label = fLabel; >+ >+ ILaunchConfiguration config = fLaunch.getLaunchConfiguration(); >+ if (config != null && !DebugUITools.isPrivate(config)) { >+ String type = null; >+ try { >+ type = config.getType().getName(); >+ } catch (CoreException e) { >+ } >+ StringBuffer buffer = new StringBuffer(); >+ buffer.append(config.getName()); >+ if (type != null) { >+ buffer.append(" ["); //$NON-NLS-1$ >+ buffer.append(type); >+ buffer.append("] "); //$NON-NLS-1$ >+ } >+ buffer.append(label); >+ label = buffer.toString(); >+ } >+ >+ if (fLaunch.isTerminated()) { >+ return "<terminated> " + label; >+ } >+ >+ return label; >+ } >+ >+ public void resetName() { >+ final String newName = computeName(); >+ String name = getName(); >+ if (!name.equals(newName)) { >+ Runnable r = new Runnable() { >+ public void run() { >+ setName(newName); >+ } >+ }; >+ PlatformUI.getWorkbench().getDisplay().asyncExec(r); >+ } >+ } >+ >+ @DsfServiceEventHandler >+ public final void eventDispatched(ICommandControlInitializedDMEvent event) { >+ // Now that the service is started, we can set the stream. >+ // We won't receive this event if we enable tracing after a launch >+ // has been started. >+ setStreamInService(); >+ } >+ >+ /** >+ * A reading Job which will prevent the input stream >+ * from filling up. We don't actually do anything with >+ * the data we read, since the Trace console should not >+ * accept input. >+ * >+ * But instead of making the console read-only, we allow >+ * the user to type things to allow for comments to be >+ * inserted within the traces. >+ */ >+ private class InputReadJob extends Job { >+ { >+ setSystem(true); >+ } >+ >+ InputReadJob() { >+ super("Traces Input Job"); //$NON-NLS-1$ >+ } >+ >+ @Override >+ protected IStatus run(IProgressMonitor monitor) { >+ try { >+ byte[] b = new byte[1024]; >+ int read = 0; >+ while (getInputStream() != null && read >= 0) { >+ // Read the input and swallow it. >+ read = getInputStream().read(b); >+ } >+ } catch (IOException e) { >+ } >+ return Status.OK_STATUS; >+ } >+ } >+} >Index: src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java >diff -N src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/internal/ui/tracing/TracingConsoleManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,158 @@ >+/******************************************************************************* >+ * 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.internal.ui.tracing; >+ >+import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin; >+import org.eclipse.cdt.dsf.gdb.internal.ui.preferences.IGdbDebugPreferenceConstants; >+import org.eclipse.cdt.dsf.gdb.launching.ITracedLaunch; >+import org.eclipse.debug.core.DebugPlugin; >+import org.eclipse.debug.core.ILaunch; >+import org.eclipse.debug.core.ILaunchesListener2; >+import org.eclipse.jface.preference.IPreferenceStore; >+import org.eclipse.jface.util.IPropertyChangeListener; >+import org.eclipse.jface.util.PropertyChangeEvent; >+import org.eclipse.ui.console.ConsolePlugin; >+import org.eclipse.ui.console.IConsole; >+import org.eclipse.ui.console.IConsoleManager; >+ >+/** >+ * A tracing console manager which adds and removes tracing consoles >+ * based on launch events and preference events. >+ */ >+public class TracingConsoleManager implements ILaunchesListener2, IPropertyChangeListener { >+ >+ /** >+ * Member to keep track of the preference. >+ * We keep it up-to-date by registering as an IPropertyChangeListener >+ */ >+ private boolean fTracingEnabled = false; >+ >+ /** >+ * Start the tracing console. We don't do this in a constructor, because >+ * we need to use <code>this</code>. >+ */ >+ public void startup() { >+ GdbUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); >+ >+ IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); >+ fTracingEnabled = store.getBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE); >+ >+ if (fTracingEnabled) { >+ toggleTracing(true); >+ } >+ } >+ >+ public void shutdown() { >+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); >+ GdbUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); >+ removeAllConsoles(); >+ } >+ >+ protected void toggleTracing(boolean enabled) { >+ if (enabled) { >+ DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this); >+ addAllConsoles(); >+ } else { >+ DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this); >+ removeAllConsoles(); >+ } >+ } >+ >+ protected void addAllConsoles() { >+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); >+ for (ILaunch launch : launches) { >+ addConsole(launch); >+ } >+ } >+ >+ protected void removeAllConsoles() { >+ ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); >+ for (ILaunch launch : launches) { >+ removeConsole(launch); >+ } >+ } >+ >+ public void launchesAdded(ILaunch[] launches) { >+ for (ILaunch launch : launches) { >+ addConsole(launch); >+ } >+ } >+ >+ public void launchesChanged(ILaunch[] launches) { >+ } >+ >+ public void launchesRemoved(ILaunch[] launches) { >+ for (ILaunch launch : launches) { >+ removeConsole(launch); >+ } >+ } >+ >+ public void launchesTerminated(ILaunch[] launches) { >+ for (ILaunch launch : launches) { >+ // Since we already had a console, don't get rid of it >+ // just yet. Simply rename it to show it is terminated. >+ renameConsole(launch); >+ } >+ } >+ >+ public void propertyChange(PropertyChangeEvent event) { >+ if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) { >+ fTracingEnabled = (Boolean)event.getNewValue(); >+ toggleTracing(fTracingEnabled); >+ } >+ } >+ >+ protected void addConsole(ILaunch launch) { >+ // Tracing consoles are only added to ITracingLaunches >+ if (launch instanceof ITracedLaunch) { >+ // Make sure we didn't already add this console >+ if (getConsole(launch) == null) { >+ if (launch.isTerminated() == false) { >+ // Create and new tracing console. >+ TracingConsole console = new TracingConsole(launch, "gdb traces"); >+ ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console}); >+ } // else we don't display a new console for a terminated launch >+ } >+ } >+ } >+ >+ protected void removeConsole(ILaunch launch) { >+ if (launch instanceof ITracedLaunch) { >+ TracingConsole console = getConsole(launch); >+ if (console != null) { >+ ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{console}); >+ } >+ } >+ } >+ >+ protected void renameConsole(ILaunch launch) { >+ if (launch instanceof ITracedLaunch) { >+ TracingConsole console = getConsole(launch); >+ if (console != null) { >+ console.resetName(); >+ } >+ } >+ } >+ >+ private TracingConsole getConsole(ILaunch launch) { >+ IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager(); >+ IConsole[] consoles = manager.getConsoles(); >+ for (IConsole console : consoles) { >+ if (console instanceof TracingConsole) { >+ TracingConsole tracingConsole = (TracingConsole)console; >+ if (tracingConsole.getLaunch().equals(launch)) { >+ return tracingConsole; >+ } >+ } >+ } >+ return null; >+ } >+} >#P org.eclipse.cdt.dsf.gdb >Index: src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java,v >retrieving revision 1.1 >diff -u -r1.1 AbstractMIControl.java >--- src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java 8 Jan 2009 21:05:46 -0000 1.1 >+++ src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java 28 Feb 2009 08:08:58 -0000 >@@ -110,6 +110,13 @@ > * 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 <code>null</code> to disable tracing. >+ */ >+ private OutputStream fTracingStream = null; >+ > > public AbstractMIControl(DsfSession session) { > super(session); >@@ -125,6 +132,25 @@ > } > > /** >+ * 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. > * To be invoked by the initialization routine of the extending class. > * >@@ -524,6 +550,22 @@ > 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 @@ > 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); > } > } >Index: src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java,v >retrieving revision 1.1 >diff -u -r1.1 GdbLaunch.java >--- src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java 8 Jan 2009 21:05:46 -0000 1.1 >+++ src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java 28 Feb 2009 08:08:57 -0000 >@@ -58,7 +58,7 @@ > */ > @ThreadSafe > public class GdbLaunch extends Launch >- implements ITerminate, IDisconnect >+ implements ITerminate, IDisconnect, ITracedLaunch > { > private DefaultDsfExecutor fExecutor; > private DsfSession fSession; >Index: src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java,v >retrieving revision 1.1 >diff -u -r1.1 GDBControl.java >--- src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java 8 Jan 2009 21:05:46 -0000 1.1 >+++ src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl.java 28 Feb 2009 08:08:57 -0000 >@@ -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 @@ > 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. >Index: src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java,v >retrieving revision 1.1 >diff -u -r1.1 IGDBControl.java >--- src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java 8 Jan 2009 21:05:46 -0000 1.1 >+++ src/org/eclipse/cdt/dsf/gdb/service/command/IGDBControl.java 28 Feb 2009 08:08:57 -0000 >@@ -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 @@ > AbstractCLIProcess getCLIProcess(); > > MIInferiorProcess getInferiorProcess(); >+ >+ /** >+ * @since 2.0 >+ */ >+ void setTracingStream(OutputStream tracingStream); > } >\ No newline at end of file >Index: src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java,v >retrieving revision 1.5 >diff -u -r1.5 GDBControl_7_0.java >--- src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java 9 Feb 2009 21:34:15 -0000 1.5 >+++ src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java 28 Feb 2009 08:08:57 -0000 >@@ -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 @@ > 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. >Index: src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java >=================================================================== >RCS file: src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java >diff -N src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/cdt/dsf/gdb/launching/ITracedLaunch.java 1 Jan 1970 00:00:00 -0000 >@@ -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 { >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 249227
:
114171
|
114208
|
114346
|
114801
|
115257
|
126220
|
126257
|
126334
| 127073 |
127081