diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java index 70a4d05f244..2f7af7da225 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2011 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 @@ -38,6 +38,17 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang */ private boolean fTracingEnabled = false; + /** + * The maximum number of characters that are allowed per console + */ + private int fMaxNumCharacters = 500000; + + /** + * The number of characters that will be kept in the console once we + * go over fMaxNumCharacters and that we must remove some characters + */ + private int fMinNumCharacters = 400000; + /** * Start the tracing console. We don't do this in a constructor, because * we need to use this. @@ -47,6 +58,8 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang store.addPropertyChangeListener(this); fTracingEnabled = store.getBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE); + int maxChars = store.getInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES); + setWaterMarks(maxChars); if (fTracingEnabled) { toggleTracing(true); @@ -110,7 +123,11 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) { fTracingEnabled = (Boolean)event.getNewValue(); toggleTracing(fTracingEnabled); + } else if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES)) { + int maxChars = (Integer)event.getNewValue(); + updateAllConsoleWaterMarks(maxChars); } + } protected void addConsole(ILaunch launch) { @@ -121,6 +138,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang if (launch.isTerminated() == false) { // Create and new tracing console. TracingConsole console = new TracingConsole(launch, ConsoleMessages.ConsoleMessages_trace_console_name); + console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters); ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console}); } // else we don't display a new console for a terminated launch } @@ -162,4 +180,33 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang } return null; } + + /** @since 2.2 */ + protected void setWaterMarks(int maxChars) { + if (maxChars < 10000) maxChars = 10000; + + fMaxNumCharacters = maxChars; + // If the max number of chars is anything below 105000, we only keep 5000 once we truncate. + // If the max number of chars is bigger than 105000, we truncate 100000 chars. + fMinNumCharacters = maxChars < 105000 ? 5000 : maxChars - 100000; + } + + /** @since 2.2 */ + protected void updateAllConsoleWaterMarks(int maxChars) { + setWaterMarks(maxChars); + ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches(); + for (ILaunch launch : launches) { + updateConsoleWaterMarks(launch); + } + } + + /** @since 2.2 */ + protected void updateConsoleWaterMarks(ILaunch launch) { + if (launch instanceof ITracedLaunch) { + TracingConsole console = getConsole(launch); + if (console != null) { + console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters); + } + } + } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index a605a54d248..8bf103a54ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2011 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 @@ -137,6 +137,17 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements boolField.fillIntoGrid(group, 3); addField(boolField); + + IntegerFieldEditor maxCharactersField = new IntegerFieldEditor( + IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, + MessagesForPreferences.GdbDebugPreferencePage_maxGdbTraces_label, + group); + // Instead of using Integer.MAX_VALUE which is some obscure number, using 2 billion is nice and readable + maxCharactersField.setValidRange(10000, 2000000000); + + maxCharactersField.fillIntoGrid(group, 3); + addField(maxCharactersField); + // need to set layout again group.setLayout(groupLayout); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java index fbcf6b94bdb..15e30b25c17 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbPreferenceInitializer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2011 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 @@ -25,6 +25,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer { public void initializeDefaultPreferences() { IPreferenceStore store = GdbUIPlugin.getDefault().getPreferenceStore(); store.setDefault(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true); + store.setDefault(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, 500000); store.setDefault(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true); store.setDefault(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true); store.setDefault(IGdbDebugPreferenceConstants.PREF_ENABLE_PRETTY_PRINTING, true); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java index 4a046edf4af..43f30999338 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2011 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 @@ -20,19 +20,21 @@ class MessagesForPreferences extends NLS { public static String GdbDebugPreferencePage_description; public static String GdbDebugPreferencePage_traces_label; public static String GdbDebugPreferencePage_enableTraces_label; + /** @since 2.2 */ + public static String GdbDebugPreferencePage_maxGdbTraces_label; public static String GdbDebugPreferencePage_termination_label; public static String GdbDebugPreferencePage_autoTerminateGdb_label; public static String GdbDebugPreferencePage_hover_label; public static String GdbDebugPreferencePage_useInspectorHover_label; - /** @since 3.0 */ + /** @since 2.2 */ public static String GdbDebugPreferencePage_prettyPrinting_label; - /** @since 3.0 */ + /** @since 2.2 */ public static String GdbDebugPreferencePage_enablePrettyPrinting_label1; - /** @since 3.0 */ + /** @since 2.2 */ public static String GdbDebugPreferencePage_enablePrettyPrinting_label2; - /** @since 3.0 */ + /** @since 2.2 */ public static String GdbDebugPreferencePage_initialChildCountLimitForCollections_label; - /** @since 3.0 */ + /** @since 2.2 */ public static String GdbDebugPreferencePage_defaults_label; static { // initialize resource bundle diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties index fb2cc17df33..70e5c7c68f2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/MessagesForPreferences.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2009, 2010 Ericsson and others. +# Copyright (c) 2009, 2011 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 @@ -14,7 +14,7 @@ GdbDebugPreferencePage_description=General settings for GDB Debugging GdbDebugPreferencePage_traces_label=Traces GdbDebugPreferencePage_enableTraces_label=Enable GDB traces - +GdbDebugPreferencePage_maxGdbTraces_label=Limit GDB traces output (# characters): GdbDebugPreferencePage_termination_label=Termination GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java index 083b9bb45c3..a94ef50db71 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/IGdbDebugPreferenceConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2010 Ericsson and others. + * Copyright (c) 2009, 2011 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 @@ -26,6 +26,12 @@ public interface IGdbDebugPreferenceConstants { */ public static final String PREF_TRACES_ENABLE = "tracesEnable"; //$NON-NLS-1$ + /** + * The maximum number of characters in the GDB trace console. Default is 500000 characters. + * @since 4.0 + */ + public static final String PREF_MAX_GDB_TRACES = "maxGdbTraces"; //$NON-NLS-1$ + /** * Boolean preference whether to automatically terminate GDB when the inferior exists. Default is true. */