mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 17:25:38 +02:00
Bug 335895: GDB Traces Console has infinite capacity
This commit is contained in:
parent
615c1345eb
commit
bc169066cd
3 changed files with 38 additions and 12 deletions
|
@ -32,6 +32,18 @@ import org.eclipse.ui.console.IConsoleManager;
|
|||
*/
|
||||
public class TracingConsoleManager implements ILaunchesListener2, IPropertyChangeListener {
|
||||
|
||||
/**
|
||||
* The number of characters that should be deleted once the GDB traces console
|
||||
* reaches its configurable maximum.
|
||||
*/
|
||||
private static final int NUMBER_OF_CHARS_TO_DELETE = 100000;
|
||||
|
||||
/**
|
||||
* The minimum number of characters that should be kept when truncating
|
||||
* the console output.
|
||||
*/
|
||||
private static final int MIN_NUMBER_OF_CHARS_TO_KEEP = 5000;
|
||||
|
||||
/**
|
||||
* Member to keep track of the preference.
|
||||
* We keep it up-to-date by registering as an IPropertyChangeListener
|
||||
|
@ -47,7 +59,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
|||
* 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;
|
||||
private int fMinNumCharacters = fMaxNumCharacters - NUMBER_OF_CHARS_TO_DELETE;
|
||||
|
||||
/**
|
||||
* Start the tracing console. We don't do this in a constructor, because
|
||||
|
@ -183,12 +195,17 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang
|
|||
|
||||
/** @since 2.2 */
|
||||
protected void setWaterMarks(int maxChars) {
|
||||
if (maxChars < 10000) maxChars = 10000;
|
||||
if (maxChars < (MIN_NUMBER_OF_CHARS_TO_KEEP * 2)) {
|
||||
maxChars = MIN_NUMBER_OF_CHARS_TO_KEEP * 2;
|
||||
}
|
||||
|
||||
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;
|
||||
// If the max number of chars is anything below the number of chars we are going to delete
|
||||
// (plus our minimum buffer), we only keep the minimum.
|
||||
// If the max number of chars is bigger than the number of chars we are going to delete (plus
|
||||
// the minimum buffer), we truncate a fixed amount chars.
|
||||
fMinNumCharacters = maxChars < (NUMBER_OF_CHARS_TO_DELETE + MIN_NUMBER_OF_CHARS_TO_KEEP)
|
||||
? MIN_NUMBER_OF_CHARS_TO_KEEP : maxChars - NUMBER_OF_CHARS_TO_DELETE;
|
||||
}
|
||||
|
||||
/** @since 2.2 */
|
||||
|
|
|
@ -130,15 +130,15 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
|||
group.setLayout(groupLayout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
BooleanFieldEditor boolField= new BooleanFieldEditor(
|
||||
final ListenableBooleanFieldEditor enableGdbTracesField = new ListenableBooleanFieldEditor(
|
||||
IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE,
|
||||
MessagesForPreferences.GdbDebugPreferencePage_enableTraces_label,
|
||||
group);
|
||||
SWT.NONE, group);
|
||||
|
||||
boolField.fillIntoGrid(group, 3);
|
||||
addField(boolField);
|
||||
enableGdbTracesField.fillIntoGrid(group, 3);
|
||||
addField(enableGdbTracesField);
|
||||
|
||||
IntegerFieldEditor maxCharactersField = new IntegerFieldEditor(
|
||||
final IntegerFieldEditor maxCharactersField = new IntegerFieldEditor(
|
||||
IGdbDebugPreferenceConstants.PREF_MAX_GDB_TRACES,
|
||||
MessagesForPreferences.GdbDebugPreferencePage_maxGdbTraces_label,
|
||||
group);
|
||||
|
@ -148,6 +148,15 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
|||
maxCharactersField.fillIntoGrid(group, 3);
|
||||
addField(maxCharactersField);
|
||||
|
||||
final Group finalGroup = group;
|
||||
enableGdbTracesField.getChangeControl(group).addSelectionListener(new SelectionAdapter() {
|
||||
@Override
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
boolean enabled = enableGdbTracesField.getBooleanValue();
|
||||
maxCharactersField.setEnabled(enabled, finalGroup);
|
||||
}
|
||||
});
|
||||
|
||||
// need to set layout again
|
||||
group.setLayout(groupLayout);
|
||||
|
||||
|
@ -157,7 +166,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements
|
|||
group.setLayout(groupLayout);
|
||||
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
||||
|
||||
boolField= new BooleanFieldEditor(
|
||||
BooleanFieldEditor boolField= new BooleanFieldEditor(
|
||||
IGdbDebugPreferenceConstants.PREF_AUTO_TERMINATE_GDB,
|
||||
MessagesForPreferences.GdbDebugPreferencePage_autoTerminateGdb_label,
|
||||
group);
|
||||
|
|
|
@ -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_maxGdbTraces_label=Limit GDB traces output (number of characters):
|
||||
GdbDebugPreferencePage_termination_label=Termination
|
||||
GdbDebugPreferencePage_autoTerminateGdb_label=Terminate GDB when last process exits
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue