Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0b8062b2b1681b7851e1ac2d537205000ded7b92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
/*******************************************************************************
 * Copyright (c) 2008, 2018 Red Hat, Inc.
 * 
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *    Elliott Baron <ebaron@redhat.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.internal.valgrind.memcheck;

import java.util.Arrays;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.linuxtools.internal.valgrind.launch.LaunchConfigurationConstants;
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;
import org.osgi.framework.Version;

public class MemcheckToolPage extends AbstractLaunchConfigurationTab implements IValgrindToolPage {
    private static final Version VER_3_4_0 = new Version(3, 4, 0);
    private static final Version VER_3_6_0 = new Version(3, 6, 0);

    // MEMCHECK controls
    private Button leakCheckButton;
    private Combo leakResCombo;
    private Button showReachableButton;
    private Spinner freelistSpinner;
    private Button partialLoadsButton;
    private Button undefValueButton;
    private Button gccWorkaroundButton;
    private Button alignmentButton;
    private Spinner alignmentSpinner;
    private Button mallocFillButton;
    private Text mallocFillText;
    private Button freeFillButton;
    private Text freeFillText;
    private List ignoreRangesList;

    // VG >= 3.4.0
    private Button trackOriginsButton;

    // VG >= 3.6.0
    private Button showPossiblyLostButton;

    private boolean isInitializing = false;
    private Version valgrindVersion;
    private CoreException ex = null;

    private SelectionListener selectListener = SelectionListener.widgetSelectedAdapter(e -> updateLaunchConfigurationDialog());
    private ModifyListener modifyListener = e -> updateLaunchConfigurationDialog();

    @Override
    public void createControl(Composite parent) {
        Composite top = new Composite(parent, SWT.NONE);
        GridLayout memcheckLayout = new GridLayout(2, true);
        top.setLayout(memcheckLayout);
        top.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        leakCheckButton = new Button(top, SWT.CHECK);
        leakCheckButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        leakCheckButton.setText(Messages.getString("MemcheckToolPage.leak_check")); //$NON-NLS-1$
        leakCheckButton.addSelectionListener(selectListener);

        Composite leakResTop = new Composite(top, SWT.NONE);
        leakResTop.setLayout(new GridLayout(2, false));
        leakResTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label leakResLabel = new Label(leakResTop, SWT.NONE);
        leakResLabel.setText(Messages.getString("MemcheckToolPage.leak_resolution")); //$NON-NLS-1$
        leakResCombo = new Combo(leakResTop, SWT.READ_ONLY);
        String[] leakResOpts = { MemcheckLaunchConstants.LEAK_RES_LOW, MemcheckLaunchConstants.LEAK_RES_MED, MemcheckLaunchConstants.LEAK_RES_HIGH };
        leakResCombo.setItems(leakResOpts);
        leakResCombo.addSelectionListener(selectListener);

        Composite freelistTop = new Composite(top, SWT.NONE);
        freelistTop.setLayout(new GridLayout(2, false));
        freelistTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        Label freelistLabel = new Label(freelistTop, SWT.NONE);
        freelistLabel.setText(Messages.getString("MemcheckToolPage.freelist_size")); //$NON-NLS-1$
        freelistSpinner = new Spinner(freelistTop, SWT.BORDER);
        freelistSpinner.setMaximum(Integer.MAX_VALUE);
        freelistSpinner.addModifyListener(modifyListener);

        showReachableButton = new Button(top, SWT.CHECK);
        showReachableButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        showReachableButton.setText(Messages.getString("MemcheckToolPage.show_reachable")); //$NON-NLS-1$
        showReachableButton.addSelectionListener(selectListener);

        partialLoadsButton = new Button(top, SWT.CHECK);
        partialLoadsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        partialLoadsButton.setText(Messages.getString("MemcheckToolPage.allow_partial")); //$NON-NLS-1$
        partialLoadsButton.addSelectionListener(selectListener);

        undefValueButton = new Button(top, SWT.CHECK);
        undefValueButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        undefValueButton.setText(Messages.getString("MemcheckToolPage.undef_value_errors")); //$NON-NLS-1$
        undefValueButton.addSelectionListener(selectListener);

        // VG >= 3.4.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
            trackOriginsButton = new Button(top, SWT.CHECK);
            trackOriginsButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            trackOriginsButton.setText(Messages.getString("MemcheckToolPage.Track_origins")); //$NON-NLS-1$
            trackOriginsButton.addSelectionListener(selectListener);
        }

        gccWorkaroundButton = new Button(top, SWT.CHECK);
        gccWorkaroundButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        gccWorkaroundButton.setText(Messages.getString("MemcheckToolPage.gcc_296_workarounds")); //$NON-NLS-1$
        gccWorkaroundButton.addSelectionListener(selectListener);

        Composite alignmentTop = new Composite(top, SWT.NONE);
        GridLayout alignmentLayout = new GridLayout(2, false);
        alignmentLayout.marginWidth = alignmentLayout.marginHeight = 0;
        alignmentTop.setLayout(alignmentLayout);
        alignmentTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        alignmentButton = new Button(alignmentTop, SWT.CHECK);
        alignmentButton.setText(Messages.getString("MemcheckToolPage.minimum_heap_block")); //$NON-NLS-1$
		alignmentButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
			checkAlignmentEnablement();
			updateLaunchConfigurationDialog();
		}));
        alignmentSpinner = new Spinner(alignmentTop, SWT.BORDER);
        alignmentSpinner.setMinimum(0);
        alignmentSpinner.setMaximum(4096);
        alignmentSpinner.addModifyListener(modifyListener);

        // VG >= 3.6.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
            showPossiblyLostButton = new Button(top, SWT.CHECK);
            showPossiblyLostButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            showPossiblyLostButton.setText(Messages.getString("MemcheckToolPage.Show_Possibly_Lost")); //$NON-NLS-1$
            showPossiblyLostButton.addSelectionListener(selectListener);
        }

        Composite mallocFillTop = new Composite(top, SWT.NONE);
        GridLayout mallocFillLayout = new GridLayout(2, false);
        mallocFillLayout.marginWidth = mallocFillLayout.marginHeight = 0;
        mallocFillTop.setLayout(mallocFillLayout);
        mallocFillTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        mallocFillButton = new Button(mallocFillTop, SWT.CHECK);
        mallocFillButton.setText(Messages.getString("MemcheckToolPage.Malloc_Fill")); //$NON-NLS-1$
		mallocFillButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
			checkMallocFillEnablement();
			updateLaunchConfigurationDialog();
		}));
        mallocFillText = new Text(mallocFillTop, SWT.BORDER);
        mallocFillText.setTextLimit(8);
        mallocFillText.addModifyListener(modifyListener);


        Composite freeFillTop = new Composite(top, SWT.NONE);
        GridLayout freeFillLayout = new GridLayout(2, false);
        freeFillLayout.marginWidth = freeFillLayout.marginHeight = 0;
        freeFillTop.setLayout(freeFillLayout);
        freeFillTop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

        freeFillButton = new Button(freeFillTop, SWT.CHECK);
        freeFillButton.setText(Messages.getString("MemcheckToolPage.Free_Fill")); //$NON-NLS-1$
		freeFillButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
			checkFreeFillEnablement();
			updateLaunchConfigurationDialog();
		}));
        freeFillText = new Text(freeFillTop, SWT.BORDER);
        mallocFillText.setTextLimit(8);
        freeFillText.addModifyListener(modifyListener);

        Composite ignoreRangesTop = new Composite(top, SWT.NONE);
        ignoreRangesTop.setLayout(new GridLayout(3, false));
        ignoreRangesTop.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));

        Label ignoreRangesLabel = new Label(ignoreRangesTop, SWT.NONE);
        ignoreRangesLabel.setText(Messages.getString("MemcheckToolPage.Ignore_Ranges")); //$NON-NLS-1$
        ignoreRangesLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

        createIgnoreRangesControls(ignoreRangesTop);
}

    private void createIgnoreRangesControls(Composite top) {

        ignoreRangesList = new List(top, SWT.BORDER | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
        FontMetrics fm = MemcheckPlugin.getFontMetrics(ignoreRangesList);
        ignoreRangesList.setLayoutData(new GridData(Dialog.convertWidthInCharsToPixels(fm, 50), Dialog.convertHeightInCharsToPixels(fm, 5)));

        Composite ignoreButtons = new Composite(top, SWT.NONE);
        GridLayout ignoreButtonsLayout = new GridLayout();
        ignoreButtonsLayout.marginWidth = ignoreButtonsLayout.marginHeight = 0;
        ignoreButtons.setLayout(ignoreButtonsLayout);
        ignoreButtons.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));

        Button newButton = new Button(ignoreButtons, SWT.PUSH);
        newButton.setText(Messages.getString("MemcheckToolPage.New")); //$NON-NLS-1$
        newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		newButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
			handleIgnoreNewButtonPressed();
			updateLaunchConfigurationDialog();
		}));

        Button removeButton = new Button(ignoreButtons, SWT.PUSH);
        removeButton.setText(Messages.getString("MemcheckToolPage.Remove")); //$NON-NLS-1$
        removeButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		removeButton.addSelectionListener(SelectionListener.widgetSelectedAdapter(e -> {
			handleIgnoreRemoveButtonPressed();
			updateLaunchConfigurationDialog();
		}));
    }

    private void handleIgnoreNewButtonPressed() {
        InputDialog dialog = new InputDialog(getShell(), Messages.getString("MemcheckToolPage.Ignore_Ranges"), Messages.getString("MemcheckToolPage.Range"), "", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        if (dialog.open() == Window.OK) {
            String function = dialog.getValue();
            if (!function.equals("")) { //$NON-NLS-1$
                ignoreRangesList.add(function);
            }
        }
    }

    private void handleIgnoreRemoveButtonPressed() {
        int[] selections = ignoreRangesList.getSelectionIndices();
        ignoreRangesList.remove(selections);
    }

    private void checkAlignmentEnablement() {
        alignmentSpinner.setEnabled(alignmentButton.getSelection());
    }

    private void checkMallocFillEnablement() {
        mallocFillText.setEnabled(mallocFillButton.getSelection());
    }

    private void checkFreeFillEnablement() {
        freeFillText.setEnabled(freeFillButton.getSelection());
    }

    @Override
    public String getName() {
        return Messages.getString("MemcheckToolPage.Memcheck_Options"); //$NON-NLS-1$
    }

    @Override
    public void initializeFrom(ILaunchConfiguration configuration) {
        isInitializing = true;
        try {
            leakCheckButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKCHECK, MemcheckLaunchConstants.DEFAULT_MEMCHECK_LEAKCHECK));
            leakResCombo.setText(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKRES, MemcheckLaunchConstants.DEFAULT_MEMCHECK_LEAKRES));
            showReachableButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_SHOWREACH, MemcheckLaunchConstants.DEFAULT_MEMCHECK_SHOWREACH));
            freelistSpinner.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREELIST, MemcheckLaunchConstants.DEFAULT_MEMCHECK_FREELIST));
            partialLoadsButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_PARTIAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_PARTIAL));
            undefValueButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_UNDEF, MemcheckLaunchConstants.DEFAULT_MEMCHECK_UNDEF));
            gccWorkaroundButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_GCCWORK, MemcheckLaunchConstants.DEFAULT_MEMCHECK_GCCWORK));
            alignmentButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_ALIGNMENT_BOOL));
            checkAlignmentEnablement();
            alignmentSpinner.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_VAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_ALIGNMENT_VAL));

            // VG >= 3.4.0
            if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
                trackOriginsButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_TRACKORIGINS, MemcheckLaunchConstants.DEFAULT_MEMCHECK_TRACKORIGINS));
            }

            // VG >= 3.6.0
            if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
                showPossiblyLostButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_POSSIBLY_LOST_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_POSSIBLY_LOST_BOOL));
            }

            mallocFillButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_MALLOCFILL_BOOL));
            checkMallocFillEnablement();
            mallocFillText.setText(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_VAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_MALLOCFILL_VAL));
            freeFillButton.setSelection(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_FREEFILL_BOOL));
            checkFreeFillEnablement();
            freeFillText.setText(configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_VAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_FREEFILL_VAL));
            java.util.List<String> ignoreFns = configuration.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_IGNORE_RANGES, MemcheckLaunchConstants.DEFAULT_MEMCHECK_IGNORE_RANGES);
            ignoreRangesList.setItems(ignoreFns.toArray(new String[ignoreFns.size()]));


        } catch (CoreException e) {
            ex = e;
        }
        isInitializing = false;
    }

    @Override
    public void performApply(ILaunchConfigurationWorkingCopy configuration) {
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKCHECK, leakCheckButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKRES, leakResCombo.getText());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_SHOWREACH, showReachableButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREELIST, freelistSpinner.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_PARTIAL, partialLoadsButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_UNDEF, undefValueButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_GCCWORK, gccWorkaroundButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_BOOL, alignmentButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_VAL, alignmentSpinner.getSelection());

        // VG >= 3.4.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
            configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_TRACKORIGINS, trackOriginsButton.getSelection());
        }

        // VG >= 3.6.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
            configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_POSSIBLY_LOST_BOOL, showPossiblyLostButton.getSelection());
        }

        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_BOOL, mallocFillButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_MALLOCFILL_VAL, mallocFillText.getText());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_BOOL, freeFillButton.getSelection());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREEFILL_VAL, freeFillText.getText());
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_IGNORE_RANGES, Arrays.asList(ignoreRangesList.getItems()));
    }

    @Override
    public boolean isValid(ILaunchConfiguration launchConfig) {
        setErrorMessage(null);

        boolean result = false;
        try {
            // check alignment
            int alignment = launchConfig.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_VAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_ALIGNMENT_VAL);
            result = (alignment & (alignment - 1)) == 0; // is power of two?
            if (!result) {
                setErrorMessage(Messages.getString("MemcheckToolPage.Alignment_must_be_power_2")); //$NON-NLS-1$
            }
            else {
                // VG >= 3.4.0
                if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
                    // check track-origins
                    boolean trackOrigins = launchConfig.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_TRACKORIGINS, MemcheckLaunchConstants.DEFAULT_MEMCHECK_TRACKORIGINS);
                    if (trackOrigins) {
                        // undef-value-errors must be selected
                        result = launchConfig.getAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_UNDEF, MemcheckLaunchConstants.DEFAULT_MEMCHECK_UNDEF);
                        if (!result) {
                            setErrorMessage(NLS.bind(Messages.getString("MemcheckToolPage.Track_origins_needs_undef"), Messages.getString("MemcheckToolPage.Track_origins"), Messages.getString("MemcheckToolPage.undef_value_errors"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        }
                    }
                }
            }
        } catch (CoreException e) {
            ex = e;
        }

        if (ex != null) {
            setErrorMessage(ex.getLocalizedMessage());
        }
        return result;
    }

    @Override
    public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
        configuration.setAttribute(LaunchConfigurationConstants.ATTR_TOOL, MemcheckPlugin.TOOL_ID);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKCHECK, MemcheckLaunchConstants.DEFAULT_MEMCHECK_LEAKCHECK);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_LEAKRES, MemcheckLaunchConstants.DEFAULT_MEMCHECK_LEAKRES);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_SHOWREACH, MemcheckLaunchConstants.DEFAULT_MEMCHECK_SHOWREACH);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_FREELIST, MemcheckLaunchConstants.DEFAULT_MEMCHECK_FREELIST);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_PARTIAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_PARTIAL);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_UNDEF, MemcheckLaunchConstants.DEFAULT_MEMCHECK_UNDEF);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_GCCWORK, MemcheckLaunchConstants.DEFAULT_MEMCHECK_GCCWORK);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_ALIGNMENT_BOOL);
        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_ALIGNMENT_VAL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_ALIGNMENT_VAL);

        // VG >= 3.4.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_4_0) >= 0) {
            configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_TRACKORIGINS, MemcheckLaunchConstants.DEFAULT_MEMCHECK_TRACKORIGINS);
        }

        // VG >= 3.6.0
        if (valgrindVersion == null || valgrindVersion.compareTo(VER_3_6_0) >= 0) {
            configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_POSSIBLY_LOST_BOOL, MemcheckLaunchConstants.DEFAULT_MEMCHECK_POSSIBLY_LOST_BOOL);
        }

        configuration.setAttribute(MemcheckLaunchConstants.ATTR_MEMCHECK_IGNORE_RANGES, MemcheckLaunchConstants.DEFAULT_MEMCHECK_IGNORE_RANGES);
    }

    @Override
    public void setValgrindVersion(Version ver) {
        valgrindVersion = ver;
    }

    @Override
    public void updateLaunchConfigurationDialog() {
        if (!isInitializing) {
            super.updateLaunchConfigurationDialog();
        }
    }

    public Button getLeakCheckButton() {
        return leakCheckButton;
    }

    public Combo getLeakResCombo() {
        return leakResCombo;
    }

    public Button getShowReachableButton() {
        return showReachableButton;
    }

    public Spinner getFreelistSpinner() {
        return freelistSpinner;
    }

    public Button getPartialLoadsButton() {
        return partialLoadsButton;
    }

    public Button getUndefValueButton() {
        return undefValueButton;
    }

    public Button getGccWorkaroundButton() {
        return gccWorkaroundButton;
    }

    public Button getAlignmentButton() {
        return alignmentButton;
    }

    public Spinner getAlignmentSpinner() {
        return alignmentSpinner;
    }

    public Button getTrackOriginsButton() {
        return trackOriginsButton;
    }
}

Back to the top