diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java index a321941aa63..605eb97b977 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePreferenceConstants.java @@ -153,6 +153,12 @@ public class CCorePreferenceConstants { */ public static final String SHOW_SOURCE_FILES_IN_BINARIES = CCorePlugin.PLUGIN_ID + ".showSourceFilesInBinaries"; //$NON-NLS-1$ + /** + * Attempt to (not) show c source not found editor in debug. + * @since 6.3 + */ + public static final String SHOW_SOURCE_NOT_FOUND_EDITOR = CCorePlugin.PLUGIN_ID + ".showSourceNotFoundEditor"; //$NON-NLS-1$ + /** * Show source roots at the top level of projects. * @since 5.2 diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java index 8058207b2a3..2e0077c5783 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/CDebugPreferencePage.java @@ -64,6 +64,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr private PropertyChangeListener fPropertyChangeListener; private Button fShowBinarySourceFilesButton; + + private Button fShowSourceNotFoundEditor; protected class PropertyChangeListener implements IPropertyChangeListener { @@ -123,6 +125,7 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr createCharsetSettingPreferences(composite); createSpacer(composite, 1); createBinarySettings(composite); + createShowSourceNotFoundEditor(composite); setValues(); return composite; } @@ -189,6 +192,9 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr // Set the values for the remaining preferences. fShowBinarySourceFilesButton.setSelection(Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true, null)); + + fShowSourceNotFoundEditor.setSelection(Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, true, null)); } @Override @@ -239,6 +245,12 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr fShowBinarySourceFilesButton = createCheckButton(parent, PreferenceMessages.getString("CDebugPreferencePage.15")); //$NON-NLS-1$ } + + private void createShowSourceNotFoundEditor(Composite parent) + { + fShowSourceNotFoundEditor = createCheckButton(parent, + PreferenceMessages.getString("CDebugPreferencePage.21")); //$NON-NLS-1$ + } /** * Creates a button with the given label and sets the default configuration @@ -341,6 +353,9 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr // Store the other preferences. InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, fShowBinarySourceFilesButton.getSelection()); + + InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, fShowSourceNotFoundEditor.getSelection()); } /** @@ -359,6 +374,8 @@ public class CDebugPreferencePage extends PreferencePage implements IWorkbenchPr fWideCharsetEditor.loadDefault(); fShowBinarySourceFilesButton.setSelection(DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true)); + fShowSourceNotFoundEditor.setSelection(DefaultScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID) + .getBoolean(CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, true)); } private IWorkbench getWorkbench() { diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties index b49542245b3..ead7928f3ff 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/PreferenceMessages.properties @@ -24,6 +24,7 @@ CDebugPreferencePage.16=Wide character encoding CDebugPreferencePage.18=Character encoding CDebugPreferencePage.19=The selected character encoding is not supported. CDebugPreferencePage.20=The selected wide character encoding is not supported. +CDebugPreferencePage.21=Show the Source Not Found editor when debugger stops at an address with no debug information, or if the associated source file cannot be found. SourcePreferencePage.0=Default S&ource Lookup Path: DebuggerTypesPage.0=Select All DebuggerTypesPage.1=Deselect All diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java index fdee44c2b41..b5f23e80e25 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/CSourceNotFoundEditor.java @@ -15,6 +15,8 @@ package org.eclipse.cdt.debug.internal.ui.sourcelookup; import java.util.ArrayList; import java.util.Arrays; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugUtils; @@ -33,6 +35,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; @@ -70,6 +73,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { public static final String UID_DISASSEMBLY_BUTTON = UID_CLASS_NAME + "disassemblyButton"; //$NON-NLS-1$ public static final String UID_LOCATE_FILE_BUTTON = UID_CLASS_NAME + "locateFileButton"; //$NON-NLS-1$ public static final String UID_EDIT_LOOKUP_BUTTON = UID_CLASS_NAME + "editLookupButton"; //$NON-NLS-1$ + public static final String UID_SHOW_SOURCE_NOT_FOUND_EDITOR_CHECKBOX = UID_CLASS_NAME + "dontShowSourceEditorButton"; //$NON-NLS-1$ private String missingFile = ""; //$NON-NLS-1$ private ILaunchConfiguration launch; @@ -84,6 +88,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { private boolean isDebugElement; private boolean isTranslationUnit; private Text fText; + private Button dontShowSourceEditorButton; public CSourceNotFoundEditor() { super(); @@ -179,6 +184,27 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor { @Override protected void createButtons(Composite parent) { + { + GridData data; + dontShowSourceEditorButton = new Button(parent, SWT.CHECK); + data = new GridData(); + data.grabExcessHorizontalSpace = false; + data.grabExcessVerticalSpace = false; + dontShowSourceEditorButton.setLayoutData(data); + dontShowSourceEditorButton.setSelection(true); + dontShowSourceEditorButton.setText(SourceLookupUIMessages.CSourceNotFoundEditor_6); + dontShowSourceEditorButton.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + InstanceScope.INSTANCE.getNode(CCorePlugin.PLUGIN_ID).putBoolean( + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, + dontShowSourceEditorButton.getSelection()); + + }; + }); + dontShowSourceEditorButton.setData(UID_KEY, UID_SHOW_SOURCE_NOT_FOUND_EDITOR_CHECKBOX); + } + if (isDebugElement) { GridData data; disassemblyButton = new Button(parent, SWT.PUSH); diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java index 1270e8e9481..90e3eaec0ef 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java @@ -55,6 +55,7 @@ public class SourceLookupUIMessages extends NLS { public static String CSourceNotFoundEditor_3; public static String CSourceNotFoundEditor_4; public static String CSourceNotFoundEditor_5; + public static String CSourceNotFoundEditor_6; public static String CompilationDirectorySourceContainerDialog_0; public static String CompilationDirectorySourceContainerDialog_1; public static String CompilationDirectorySourceContainerDialog_2; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties index 843cbaa1625..d4bdde4a2e4 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties @@ -52,6 +52,7 @@ CSourceNotFoundEditor_2=Missing Source File CSourceNotFoundEditor_3=No source available for \"{0}\" \n CSourceNotFoundEditor_4=View Disassembly... CSourceNotFoundEditor_5=Edit Source Lookup Path... +CSourceNotFoundEditor_6=Show the Source Not Found editor when debugger stops at an address with no debug information, or if the associated source file cannot be found. CompilationDirectorySourceContainerDialog_0=Directory Selection CompilationDirectorySourceContainerDialog_1=Choose directory to add: CompilationDirectorySourceContainerDialog_2=Compilation directory diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java index 8069eb40b06..2817285afca 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/sourcelookup/DsfSourceDisplayAdapter.java @@ -21,6 +21,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.atomic.AtomicBoolean; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.CCorePreferenceConstants; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.debug.internal.core.sourcelookup.CSourceNotFoundElement; import org.eclipse.cdt.debug.internal.ui.sourcelookup.CSourceNotFoundEditorInput; @@ -53,6 +55,7 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; @@ -416,15 +419,19 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl if (!page.getWorkbenchWindow().getWorkbench().isClosing()) { try { if (input instanceof CSourceNotFoundEditorInput) { - /* - * Don't open additional source not found - * editors if there is one to reuse. - */ - editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); - if (editor[0] instanceof IReusableEditor) { - IReusableEditor re = (IReusableEditor) editor[0]; - if (!input.equals(re.getEditorInput())) { - re.setInput(input); + if (Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, + CCorePreferenceConstants.SHOW_SOURCE_NOT_FOUND_EDITOR, true, null)) { + editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); + /* + * Don't open additional source not found + * editors if there is one to reuse. + */ + editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID); + if (editor[0] instanceof IReusableEditor) { + IReusableEditor re = (IReusableEditor) editor[0]; + if (!input.equals(re.getEditorInput())) { + re.setInput(input); + } } } } else {