mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Hide 'gdb traces' by default.
Since users don't usually care about seeing the communication between CDT and GDB, we should not show it by default. However, once a problem happens it would be nice to be able to look at the traces even if they were previously hidden. This patch has the gdb traces always enabled, but hides the actual console from the user. When the user enables the traces, they will be shown in the Console view, with all previous traces available. Change-Id: Ifd312aa19e4421b6764169b6199b5e935cf25f87
This commit is contained in:
parent
6c4576281d
commit
c7526e8a04
5 changed files with 65 additions and 65 deletions
|
@ -50,7 +50,7 @@ public class TracingConsole extends IOConsole {
|
||||||
private String fLabel = ""; //$NON-NLS-1$
|
private String fLabel = ""; //$NON-NLS-1$
|
||||||
|
|
||||||
public TracingConsole(ILaunch launch, String label) {
|
public TracingConsole(ILaunch launch, String label) {
|
||||||
super("", null, null, true); //$NON-NLS-1$
|
super("", null, null, false); //$NON-NLS-1$
|
||||||
fLaunch = launch;
|
fLaunch = launch;
|
||||||
fTracingStream = newOutputStream();
|
fTracingStream = newOutputStream();
|
||||||
fSession = ((GdbLaunch)launch).getSession();
|
fSession = ((GdbLaunch)launch).getSession();
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
package org.eclipse.cdt.dsf.gdb.internal.ui.console;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
import org.eclipse.cdt.dsf.gdb.IGdbDebugPreferenceConstants;
|
||||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||||
import org.eclipse.cdt.dsf.gdb.launching.ITracedLaunch;
|
import org.eclipse.cdt.dsf.gdb.launching.ITracedLaunch;
|
||||||
|
@ -21,11 +23,12 @@ import org.eclipse.jface.util.IPropertyChangeListener;
|
||||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||||
import org.eclipse.ui.console.ConsolePlugin;
|
import org.eclipse.ui.console.ConsolePlugin;
|
||||||
import org.eclipse.ui.console.IConsole;
|
import org.eclipse.ui.console.IConsole;
|
||||||
import org.eclipse.ui.console.IConsoleManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tracing console manager which adds and removes tracing consoles
|
* A tracing console manager which adds and removes tracing consoles
|
||||||
* based on launch events and preference events.
|
* based on launch events and preference events.
|
||||||
|
* TracingConsoles are always running but are only shown in the console
|
||||||
|
* view if enabled by the user preference.
|
||||||
*
|
*
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
* This class was moved from package org.eclipse.cdt.dsf.gdb.internal.ui.tracing
|
* This class was moved from package org.eclipse.cdt.dsf.gdb.internal.ui.tracing
|
||||||
|
@ -61,6 +64,13 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
*/
|
*/
|
||||||
private int fMinNumCharacters = fMaxNumCharacters - NUMBER_OF_CHARS_TO_DELETE;
|
private int fMinNumCharacters = fMaxNumCharacters - NUMBER_OF_CHARS_TO_DELETE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A map of all TracingConsoles for their corresponding launch.
|
||||||
|
* We keep this list because TracingConsoles may not be registered
|
||||||
|
* with the ConsoleManager, so we need another way to find them.
|
||||||
|
*/
|
||||||
|
private HashMap<ITracedLaunch, TracingConsole> fTracingConsoles = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start the tracing console. We don't do this in a constructor, because
|
* Start the tracing console. We don't do this in a constructor, because
|
||||||
* we need to use <code>this</code>.
|
* we need to use <code>this</code>.
|
||||||
|
@ -73,9 +83,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
int maxChars = store.getInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES);
|
int maxChars = store.getInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES);
|
||||||
setWaterMarks(maxChars);
|
setWaterMarks(maxChars);
|
||||||
|
|
||||||
if (fTracingEnabled) {
|
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
||||||
toggleTracing(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
|
@ -84,20 +92,13 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
removeAllConsoles();
|
removeAllConsoles();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void toggleTracing(boolean enabled) {
|
protected void toggleTracingVisibility(boolean visible) {
|
||||||
if (enabled) {
|
if (visible) {
|
||||||
DebugPlugin.getDefault().getLaunchManager().addLaunchListener(this);
|
ConsolePlugin.getDefault().getConsoleManager().addConsoles(
|
||||||
addAllConsoles();
|
fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()]));
|
||||||
} else {
|
} else {
|
||||||
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener(this);
|
ConsolePlugin.getDefault().getConsoleManager().removeConsoles(
|
||||||
removeAllConsoles();
|
fTracingConsoles.values().toArray(new IConsole[fTracingConsoles.size()]));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void addAllConsoles() {
|
|
||||||
ILaunch[] launches = DebugPlugin.getDefault().getLaunchManager().getLaunches();
|
|
||||||
for (ILaunch launch : launches) {
|
|
||||||
addConsole(launch);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,12 +140,11 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
public void propertyChange(PropertyChangeEvent event) {
|
public void propertyChange(PropertyChangeEvent event) {
|
||||||
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) {
|
if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) {
|
||||||
fTracingEnabled = (Boolean)event.getNewValue();
|
fTracingEnabled = (Boolean)event.getNewValue();
|
||||||
toggleTracing(fTracingEnabled);
|
toggleTracingVisibility(fTracingEnabled);
|
||||||
} else if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES)) {
|
} else if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES)) {
|
||||||
int maxChars = (Integer)event.getNewValue();
|
int maxChars = (Integer)event.getNewValue();
|
||||||
updateAllConsoleWaterMarks(maxChars);
|
updateAllConsoleWaterMarks(maxChars);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addConsole(ILaunch launch) {
|
protected void addConsole(ILaunch launch) {
|
||||||
|
@ -152,50 +152,40 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
if (launch instanceof ITracedLaunch) {
|
if (launch instanceof ITracedLaunch) {
|
||||||
// Make sure we didn't already add this console
|
// Make sure we didn't already add this console
|
||||||
if (getConsole(launch) == null) {
|
if (getConsole(launch) == null) {
|
||||||
if (launch.isTerminated() == false) {
|
if (!launch.isTerminated()) {
|
||||||
// Create and new tracing console.
|
// Create a new tracing console.
|
||||||
TracingConsole console = new TracingConsole(launch, ConsoleMessages.ConsoleMessages_trace_console_name);
|
TracingConsole console = new TracingConsole(launch, ConsoleMessages.ConsoleMessages_trace_console_name);
|
||||||
|
console.initialize();
|
||||||
console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters);
|
console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters);
|
||||||
|
|
||||||
|
fTracingConsoles.put((ITracedLaunch)launch, console);
|
||||||
|
if (fTracingEnabled) {
|
||||||
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console});
|
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{console});
|
||||||
|
}
|
||||||
} // else we don't display a new console for a terminated launch
|
} // else we don't display a new console for a terminated launch
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeConsole(ILaunch launch) {
|
protected void removeConsole(ILaunch launch) {
|
||||||
if (launch instanceof ITracedLaunch) {
|
TracingConsole console = fTracingConsoles.remove(launch);
|
||||||
TracingConsole console = getConsole(launch);
|
|
||||||
if (console != null) {
|
if (console != null) {
|
||||||
|
console.destroy();
|
||||||
|
if (fTracingEnabled) {
|
||||||
ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{console});
|
ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new IConsole[]{console});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void renameConsole(ILaunch launch) {
|
protected void renameConsole(ILaunch launch) {
|
||||||
if (launch instanceof ITracedLaunch) {
|
|
||||||
TracingConsole console = getConsole(launch);
|
TracingConsole console = getConsole(launch);
|
||||||
if (console != null) {
|
if (console != null) {
|
||||||
console.resetName();
|
console.resetName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private TracingConsole getConsole(ILaunch launch) {
|
private TracingConsole getConsole(ILaunch launch) {
|
||||||
ConsolePlugin plugin = ConsolePlugin.getDefault();
|
return fTracingConsoles.get(launch);
|
||||||
if (plugin != null) {
|
|
||||||
// I've seen the plugin be null when running headless JUnit tests
|
|
||||||
IConsoleManager manager = plugin.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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @since 2.2 */
|
/** @since 2.2 */
|
||||||
|
@ -224,11 +214,9 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
||||||
|
|
||||||
/** @since 2.2 */
|
/** @since 2.2 */
|
||||||
protected void updateConsoleWaterMarks(ILaunch launch) {
|
protected void updateConsoleWaterMarks(ILaunch launch) {
|
||||||
if (launch instanceof ITracedLaunch) {
|
|
||||||
TracingConsole console = getConsole(launch);
|
TracingConsole console = getConsole(launch);
|
||||||
if (console != null) {
|
if (console != null) {
|
||||||
console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters);
|
console.setWaterMarks(fMinNumCharacters, fMaxNumCharacters);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -233,9 +233,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
protected Control createDialogArea( Composite parent ) {
|
protected Control createDialogArea( Composite parent ) {
|
||||||
getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Advanced_Timeout_Settings );
|
getShell().setText( MessagesForPreferences.GdbDebugPreferencePage_Advanced_Timeout_Settings );
|
||||||
|
@ -661,16 +658,34 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
||||||
// Need to set layout again.
|
// Need to set layout again.
|
||||||
group2.setLayout(groupLayout);
|
group2.setLayout(groupLayout);
|
||||||
|
|
||||||
final IntegerWithBooleanFieldEditor enableGdbTracesField = new IntegerWithBooleanFieldEditor(
|
boolField= new BooleanFieldEditor(
|
||||||
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
|
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
|
||||||
IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES,
|
|
||||||
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
|
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
|
||||||
group2);
|
group2);
|
||||||
|
|
||||||
|
boolField.fillIntoGrid(group2, 1);
|
||||||
|
addField(boolField);
|
||||||
|
group2.setLayout(groupLayout);
|
||||||
|
|
||||||
|
// The field below sets the size of the buffer for the gdb traces.
|
||||||
|
// It is located to the right of the previous field (which shows or not the
|
||||||
|
// gdb traces) and uses its label. However, we don't want to tightly
|
||||||
|
// couple the two fields using IntegerWithBooleanFieldEditor because
|
||||||
|
// we want the gdb traces limit to stay enabled even when the gdb traces
|
||||||
|
// are not actually shown (when the above preference is not selected).
|
||||||
|
// The reason is that since the gdb traces record even when they are not
|
||||||
|
// shown, we want the user to be able to set the limit on those consoles,
|
||||||
|
// even if they are not currently shown.
|
||||||
|
final IntegerFieldEditor gdbTracesLimit = new IntegerFieldEditor(
|
||||||
|
IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES,
|
||||||
|
"", // Empty title as we reuse the string of the previous field //$NON-NLS-1$
|
||||||
|
group2);
|
||||||
|
|
||||||
// Instead of using Integer.MAX_VALUE which is some obscure number,
|
// Instead of using Integer.MAX_VALUE which is some obscure number,
|
||||||
// using 2 billion is nice and readable.
|
// using 2 billion is nice and readable.
|
||||||
enableGdbTracesField.setValidRange(10000, 2000000000);
|
gdbTracesLimit.setValidRange(10000, 2000000000);
|
||||||
enableGdbTracesField.fillIntoGrid(group2, 2);
|
gdbTracesLimit.fillIntoGrid(group2, 2);
|
||||||
addField(enableGdbTracesField);
|
addField(gdbTracesLimit);
|
||||||
// Need to set layout again.
|
// Need to set layout again.
|
||||||
group2.setLayout(groupLayout);
|
group2.setLayout(groupLayout);
|
||||||
|
|
||||||
|
@ -781,9 +796,6 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
||||||
updateTimeoutButtons();
|
updateTimeoutButtons();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public boolean performOk() {
|
public boolean performOk() {
|
||||||
getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() );
|
getPreferenceStore().setValue( IGdbDebugPreferenceConstants.PREF_COMMAND_CUSTOM_TIMEOUTS, fCustomTimeouts.getMemento() );
|
||||||
|
|
|
@ -18,7 +18,7 @@ GdbDebugPreferencePage_Add_button=Add
|
||||||
GdbDebugPreferencePage_description=General settings for GDB Debugging
|
GdbDebugPreferencePage_description=General settings for GDB Debugging
|
||||||
|
|
||||||
GdbDebugPreferencePage_general_behavior_label=General Behavior
|
GdbDebugPreferencePage_general_behavior_label=General Behavior
|
||||||
GdbDebugPreferencePage_enableTraces_label=Enable GDB traces with character limit:
|
GdbDebugPreferencePage_enableTraces_label=Show the GDB traces consoles with character limit:
|
||||||
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
|
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
|
||||||
GdbDebugPreferencePage_Command_column_name=GDB/MI Command
|
GdbDebugPreferencePage_Command_column_name=GDB/MI Command
|
||||||
GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
|
GdbDebugPreferencePage_Command_field_can_not_be_empty='Command' field can not be empty
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class GdbPreferenceInitializer extends AbstractPreferenceInitializer {
|
||||||
@Override
|
@Override
|
||||||
public void initializeDefaultPreferences() {
|
public void initializeDefaultPreferences() {
|
||||||
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
|
IEclipsePreferences node = DefaultScope.INSTANCE.getNode(GdbPlugin.PLUGIN_ID);
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, true);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE, false);
|
||||||
node.putInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, 500000);
|
node.putInt(IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES, 500000);
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB, true);
|
||||||
node.putBoolean(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true);
|
node.putBoolean(IGdbDebugPreferenceConstants.PREF_USE_INSPECTOR_HOVER, true);
|
||||||
|
|
Loading…
Add table
Reference in a new issue