From e58a3323c8d086bc699ece9de857c6335bc76af3 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Thu, 13 Dec 2012 10:17:57 -0500 Subject: [PATCH 1/7] bug 396411: JUnit failure, correction of expected results for Unix --- .../core/tests/ManagedBuildCoreTests20.java | 42 ++++++++++++++----- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index 805d83df23d..73c4d90863a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -51,9 +51,11 @@ import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; /* @@ -232,21 +234,39 @@ public class ManagedBuildCoreTests20 extends TestCase { } //These are the expected path settings - final String[] expectedPaths = { - toOSString("/usr/include"), - toOSString("/opt/gnome/include"), - toOSString("C:\\home\\tester/include"), - // relative path makes 2 entries - project.getLocation().append("includes").toOSString(), - "includes", - "/usr/gnu/include", // This one set to ICSettingEntry.RESOLVED - }; + IPath buildCWD = project.getLocation().append("Sub Config"); + + final String[] expectedPaths; + if (new Path("C:\\home\\tester/include").isAbsolute()) { + // Windows + expectedPaths = new String[] { + toOSString("/usr/include"), + toOSString("/opt/gnome/include"), + toOSString("C:\\home\\tester/include"), + // relative paths make 2 entries + project.getLocation().append("includes").toOSString(), + "includes", // FIXME this is incorrect, the original entry set via extension point is "../includes" + "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } else { + // Unix + expectedPaths = new String[] { + toOSString("/usr/include"), + toOSString("/opt/gnome/include"), + // relative paths make 2 entries + buildCWD.append("C:\\home\\tester/include").toOSString(), + "C:\\home\\tester/include", + project.getLocation().append("includes").toOSString(), + "includes", // FIXME this is incorrect, the original entry set via extension point is "../includes" + "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED + }; + } // Create a new managed project based on the sub project type IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.sub"); assertNotNull(projType); - // Create the managed-project (.cdtbuild) for our project + // Create the managed-project for our project IManagedProject newProject = null; try { newProject = ManagedBuildManager.createManagedProject(project, projType); @@ -527,7 +547,7 @@ public class ManagedBuildCoreTests20 extends TestCase { IProjectType projType = ManagedBuildManager.getExtensionProjectType("test.root"); assertNotNull(projType); - // Create the managed-project (.cdtbuild) for our project that builds a dummy executable + // Create the managed-project for our project that builds a dummy executable IManagedProject newProject = ManagedBuildManager.createManagedProject(project, projType); assertEquals(newProject.getName(), projType.getName()); assertFalse(newProject.equals(projType)); From c2605537bc1c5046d539829aba24c8ac14fa5777 Mon Sep 17 00:00:00 2001 From: Marc Dumais Date: Thu, 13 Dec 2012 13:21:13 -0500 Subject: [PATCH 2/7] Bug 365776 - [breakpoints] Add breakpoint action to toggle reverse debugging. Change-Id: I065297685fefba76df7ad40c578a0ce5d0c40fba Reviewed-on: https://git.eclipse.org/r/8982 IP-Clean: Marc Khouzam Tested-by: Marc Khouzam Reviewed-by: Marc Khouzam --- .../IReverseDebugEnabler.java | 37 ++++ .../plugin.properties | 2 + debug/org.eclipse.cdt.debug.ui/plugin.xml | 16 ++ .../breakpointactions/ReverseDebugAction.java | 193 ++++++++++++++++++ .../ReverseDebugActionComposite.java | 58 ++++++ .../ReverseDebugActionPage.java | 42 ++++ .../ui/breakpointactions/messages.properties | 12 +- .../actions/BreakpointActionAdapter.java | 7 +- .../actions/MIReverseDebugEnabler.java | 89 ++++++++ 9 files changed, 454 insertions(+), 2 deletions(-) create mode 100644 debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugAction.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionComposite.java create mode 100644 debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/breakpointactions/ReverseDebugActionPage.java create mode 100644 dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MIReverseDebugEnabler.java diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java new file mode 100644 index 00000000000..0388be9291b --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/breakpointactions/IReverseDebugEnabler.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2007, 2012 Nokia 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc Dumais (Ericsson) - initial implementation + *******************************************************************************/ + +package org.eclipse.cdt.debug.core.breakpointactions; + +/** + * @since 7.3 + */ +public interface IReverseDebugEnabler { + + /** + * Toggles the state of the reverse debugging mode. + * @throws Exception + */ + void toggle() throws Exception; + + /** + * Enables the reverse debugging mode. No effect if already enabled. + * @throws Exception + */ + void enable() throws Exception; + + /** + * Disables the reverse debugging mode. No effect if it's not enabled. + * @throws Exception + */ + void disable() throws Exception; + +} diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index a68c817bb15..f2df720999c 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -11,6 +11,7 @@ # Patrick Chuong (Texas Instruments) - Pin and Clone Supports (Bug 331781) # Dobrin Alexiev (Texas Instruments) - initial API and implementation (bug 336876) # Marc Khouzam (Ericsson) - Added support for connect command (Bug 365601) +# Marc Dumais (Ericsson) - Added support for reverse debug action (Bug 365776) ############################################################################### pluginName=C/C++ Development Tools Debugger UI @@ -157,6 +158,7 @@ SoundAction.name=Sound Action LogAction.name=Log Action ResumeAction.name=Resume Action ExternalToolAction.name=External Tool Action +ReverseDebugAction.name=Reverse Debug Action # Breakpoint Types breapointType.label=Type diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml index d1ae7a9b7c4..fa6769bbf67 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.xml +++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml @@ -1710,6 +1710,14 @@ class="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction" id="org.eclipse.cdt.debug.ui.breakpointactions.ExternalToolAction"/> + + + + + + + + (fExecutor, null) { + @Override + public void handleSuccess() { + Boolean enabled = getData(); + if ( (enabled.equals(false) && mode.equals(REVERSE_DEBUG_MODE.ENABLE) ) || + (enabled.equals(true) && mode.equals(REVERSE_DEBUG_MODE.DISABLE) ) || + (mode.equals(REVERSE_DEBUG_MODE.TOGGLE)) ) + { + runControl.enableReverseMode(fContext, !enabled, new RequestMonitor(fExecutor, null)); + } + } + }); + } + } + }); + } + +} From 7ef969fe79ba93b41e60ebf4e96ffbed57be3b3f Mon Sep 17 00:00:00 2001 From: Pawel Piech Date: Wed, 12 Dec 2012 21:13:52 -0800 Subject: [PATCH 3/7] Bug 396466 - [breakpoints] warnings in log related to toggle breakpoint actions --- .../org.eclipse.cdt.debug.ui/plugin.properties | 6 +++--- .../cdt/debug/internal/ui/CDebugUIUtils.java | 17 +++++++++++++++++ .../ui/actions/ActionMessages.properties | 9 +++++---- .../CAddBreakpointInteractiveRulerAction.java | 5 ++++- .../CBreakpointPropertiesRulerAction.java | 5 ++++- .../EnableDisableBreakpointRulerAction.java | 14 +++++++++++--- dsf/org.eclipse.cdt.dsf.ui/plugin.properties | 6 +++--- .../ui/disassembly/DisassemblyMessages.java | 4 +++- .../disassembly/DisassemblyMessages.properties | 9 +++++---- .../ui/disassembly/DisassemblyPart.java | 10 +++++++--- .../actions/AddBreakpointRulerAction.java | 5 ++++- .../BreakpointPropertiesRulerAction.java | 5 ++++- 12 files changed, 70 insertions(+), 25 deletions(-) diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties index f2df720999c..34cbb7d2d35 100644 --- a/debug/org.eclipse.cdt.debug.ui/plugin.properties +++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties @@ -38,10 +38,10 @@ ShowDebuggerConsoleAction.label=Show Debugger Console ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection AddBreakpoint.label=Toggle Brea&kpoint -AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+Double Click -EnableBreakpoint.label=&Toggle Breakpoint Enabled\tShift+Double Click +AddBreakpointInteractive.label=&Add Breakpoint... +EnableBreakpoint.label=&Toggle Breakpoint Enabled BreakpointProperties.label=Breakpoint P&roperties... -RulerBreakpointProperties.label=Breakpoint P&roperties...\tCtrl+Double Click +RulerBreakpointProperties.label=Breakpoint P&roperties... BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint ManageFunctionBreakpointAction.label=Toggle Breakpoint diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java index 473330f68a3..58f0ce164fd 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIUtils.java @@ -39,6 +39,7 @@ import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.contexts.IDebugContextListener; import org.eclipse.debug.ui.contexts.IDebugContextProvider; +import org.eclipse.jface.bindings.keys.KeyStroke; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; @@ -338,4 +339,20 @@ public class CDebugUIUtils { propertiesAction.run(); propertiesAction.dispose(); } + + /** + * Formats the given key stroke or click name and the modifier keys + * to a key binding string that can be used in action texts. + * + * @param modifierKeys the modifier keys + * @param keyOrClick a key stroke or click, e.g. "Double Click" + * @return the formatted keyboard shortcut string, e.g. "Shift+Double Click" + * + * @since 8.1 + */ + public static final String formatKeyBindingString(int modifierKeys, String keyOrClick) { + // this should actually all be delegated to KeyStroke class + return KeyStroke.getInstance(modifierKeys, KeyStroke.NO_KEY).format() + keyOrClick; + } + } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties index b805821863b..6be1401ba9e 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties @@ -37,14 +37,14 @@ ToggleBreakpointAdapter.Missing_document_2=Missing document ToggleBreakpointAdapter.Missing_resource_2=Missing resource ToggleBreakpointAdapter.Invalid_expression_1=Invalid expression: RunToLineAdapter.Operation_is_not_supported_1=Operation is not supported. -EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint\tShift+Double Click +EnableDisableBreakpointRulerAction.Enable_Breakpoint_1=&Enable Breakpoint EnableDisableBreakpointRulerAction.Enabling_disabling_breakpoints_1=Enabling/disabling breakpoints EnableDisableBreakpointRulerAction.Exceptions_occurred_enabling_or_disabling_breakpoint_1=Exceptions occurred enabling or disabling the breakpoint -EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint\tShift+Double Click +EnableDisableBreakpointRulerAction.Disable_Breakpoint_1=&Disable Breakpoint ToggleWatchpointActionDelegate.Operation_failed_1=Operation failed. ToggleBreakpointRulerAction.Error_1=Error ToggleBreakpointRulerAction.Operation_failed_1=Operation failed -CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties...\tCtrl+Double Click +CBreakpointPropertiesRulerAction.Breakpoint_Properties=Breakpoint &Properties... CBreakpointPropertiesRulerAction.Error=Unable to edit breakpoint properties. ResumeAtLineActionDelegate.Error_1=Error ResumeAtLineActionDelegate.1=Error @@ -129,7 +129,8 @@ RetargetAction.0=Error RetargetAction.1=Operation failed RetargetMoveToLineAction.0=The operation is unavailable on the current selection. Please place the cursor on valid line to run to. RetargetResumeAtLineAction.0=The operation is unavailable on the current selection. Please place the cursor on valid line to run to. -CAddBreakpointInteractiveRulerAction_label=&Add Breakpoint...\tCtrl+Double Click +CAddBreakpointInteractiveRulerAction_label=&Add Breakpoint... CAddBreakpointInteractiveRulerAction_error_title=Error CAddBreakpointInteractiveRulerAction_error_message=Unable to create breakpoint CRulerToggleBreakpointActionDelegate_label=Toggle Brea&kpoint +CRulerToggleBreakpointAction_accelerator=Double Click diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java index a7923b204cc..672d73ece3c 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CAddBreakpointInteractiveRulerAction.java @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension; @@ -30,6 +31,7 @@ import org.eclipse.jface.text.TextSelection; import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; @@ -68,7 +70,8 @@ public class CAddBreakpointInteractiveRulerAction extends Action implements IUpd * @param rulerInfo specifies location the user has double-clicked */ public CAddBreakpointInteractiveRulerAction(IWorkbenchPart part, IDocument document, IVerticalRulerInfo rulerInfo) { - super(ActionMessages.getString("CAddBreakpointInteractiveRulerAction_label")); //$NON-NLS-1$ + super(ActionMessages.getString("CAddBreakpointInteractiveRulerAction_label") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ fPart = part; fDocument = document; fRulerInfo = rulerInfo; diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java index 49f5b40c95e..38a0efb84cc 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/CBreakpointPropertiesRulerAction.java @@ -12,6 +12,7 @@ package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; @@ -25,6 +26,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; /** @@ -40,7 +42,8 @@ public class CBreakpointPropertiesRulerAction extends AbstractBreakpointRulerAct */ public CBreakpointPropertiesRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) { super( part, info ); - setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) ); //$NON-NLS-1$ + setText( ActionMessages.getString( "CBreakpointPropertiesRulerAction.Breakpoint_Properties" ) + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.BREAKPOINT_PROPERTIES_ACTION ); setId( IInternalCDebugUIConstants.ACTION_BREAKPOINT_PROPERTIES ); } diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java index 586020c4fae..ac94116652f 100644 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/breakpoints/EnableDisableBreakpointRulerAction.java @@ -11,6 +11,7 @@ *******************************************************************************/ package org.eclipse.cdt.debug.internal.ui.actions.breakpoints; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.ICDebugHelpContextIds; import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; @@ -19,6 +20,7 @@ import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerAction { @@ -30,7 +32,8 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA */ public EnableDisableBreakpointRulerAction( IWorkbenchPart part, IVerticalRulerInfo info ) { super( part, info ); - setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$ + setText( ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ part.getSite().getWorkbenchWindow().getWorkbench().getHelpSystem().setHelp( this, ICDebugHelpContextIds.ENABLE_DISABLE_BREAKPOINT_ACTION ); setId( IInternalCDebugUIConstants.ACTION_ENABLE_DISABLE_BREAKPOINT ); } @@ -61,8 +64,13 @@ public class EnableDisableBreakpointRulerAction extends AbstractBreakpointRulerA setEnabled( fBreakpoint != null ); if ( isEnabled() ) { try { - boolean enabled = getBreakpoint().isEnabled(); - setText( enabled ? ActionMessages.getString( "EnableDisableBreakpointRulerAction.Disable_Breakpoint_1" ) : ActionMessages.getString( "EnableDisableBreakpointRulerAction.Enable_Breakpoint_1" ) ); //$NON-NLS-1$ //$NON-NLS-2$ + if (getBreakpoint().isEnabled()) { + setText( ActionMessages.getString("EnableDisableBreakpointRulerAction.Disable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ + } else { + setText( ActionMessages.getString("EnableDisableBreakpointRulerAction.Enable_Breakpoint_1") + "\t" + //$NON-NLS-1$ //$NON-NLS-2$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, ActionMessages.getString("CRulerToggleBreakpointAction_accelerator")) ); //$NON-NLS-1$ + } } catch( CoreException e ) { DebugPlugin.log( e ); diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties index beddd33412d..8882a84afe0 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties @@ -31,9 +31,9 @@ commandContext.name= In Disassembly commandContext.description= When debugging in assembly mode # actions -action.breakpointProperties.label = Breakpoint Properties...\Ctrl+Double Click -action.toggleBreakpoint.label = Toggle Breakpoint\tDouble Click -action.addBreakpoint.label = Add Breakpoint...\tCtrl+Double Click +action.breakpointProperties.label = Breakpoint Properties... +action.toggleBreakpoint.label = Toggle Breakpoint +action.addBreakpoint.label = Add Breakpoint... menu.updatePolicy = Update Policy menu.threadsUpdatePolicy = Threads Update Policy diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java index cb73691e57e..7a5d3431e77 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java @@ -83,9 +83,11 @@ public final class DisassemblyMessages extends NLS { public static String Disassembly_Error_Dialog_title; public static String Disassembly_Error_Dialog_ok_button; public static String DisassemblyBackendDsf_error_UnableToRetrieveData; - public static String Disassembly_action_AddBreakpoint_label; + public static String Disassembly_action_AddBreakpoint_label; public static String Disassembly_action_AddBreakpoint_errorTitle; public static String Disassembly_action_AddBreakpoint_errorMessage; + public static String Disassembly_action_ToggleBreakpoint_accelerator; + static { NLS.initializeMessages(DisassemblyMessages.class.getName(), DisassemblyMessages.class); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties index fbe8b0b165f..b295a6056f6 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties @@ -18,14 +18,15 @@ Disassembly_action_GotoPC_tooltip=Go to Current Program Counter Disassembly_action_GotoAddress_label=Go to Address... Disassembly_action_Copy_label=&Copy Disassembly_action_SelectAll_label=Select &All -Disassembly_action_BreakpointProperties_label=Breakpoint Properties...\tCtrl+Double Click -Disassembly_action_DisableBreakpoint_label=Disable Breakpoint\tShift+Double Click -Disassembly_action_EnableBreakpoint_label=Enable Breakpoint\tShift+Double Click +Disassembly_action_BreakpointProperties_label=Breakpoint Properties... +Disassembly_action_ToggleBreakpoint_accelerator=Double Click +Disassembly_action_EnableBreakpoint_label=Enable Breakpoint +Disassembly_action_DisableBreakpoint_label=Disable Breakpoint Disassembly_action_RefreshView_label=Re&fresh View Disassembly_action_OpenPreferences_label=&Preferences... Disassembly_action_Sync_label=Link with Active Debug Context Disassembly_action_TrackExpression_label=Track Expression -Disassembly_action_AddBreakpoint_label=Add Breakpoint...\tCtrl+Double Click +Disassembly_action_AddBreakpoint_label=Add Breakpoint... Disassembly_action_AddBreakpoint_errorTitle=Error Disassembly_action_AddBreakpoint_errorMessage=Unable to create breakpoint diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index 4b1187a6a07..dbf601e331c 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -31,6 +31,7 @@ import java.util.Map; import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AbstractDisassemblyBackend; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition; @@ -414,7 +415,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private IBreakpoint fBreakpoint; public ActionToggleBreakpointEnablement() { super(DisassemblyPart.this); - setText(DisassemblyMessages.Disassembly_action_EnableBreakpoint_label); + setText(DisassemblyMessages.Disassembly_action_EnableBreakpoint_label + "\t" + //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, DisassemblyMessages.Disassembly_action_ToggleBreakpoint_accelerator)); } @Override public void run() { @@ -436,9 +438,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fBreakpoint = bps[0]; try { if (fBreakpoint.isEnabled()) { - setText(DisassemblyMessages.Disassembly_action_DisableBreakpoint_label); + setText(DisassemblyMessages.Disassembly_action_DisableBreakpoint_label + "\t" + //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, DisassemblyMessages.Disassembly_action_ToggleBreakpoint_accelerator)); } else { - setText(DisassemblyMessages.Disassembly_action_EnableBreakpoint_label); + setText(DisassemblyMessages.Disassembly_action_EnableBreakpoint_label + "\t" + //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD2, DisassemblyMessages.Disassembly_action_ToggleBreakpoint_accelerator)); } } catch (CoreException e) { setEnabled(false); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java index 7e4df04046d..2ebc6375eec 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/AddBreakpointRulerAction.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages; import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.breakpoints.IToggleBreakpointsTargetCExtension; @@ -31,6 +32,7 @@ import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; /** @@ -41,7 +43,8 @@ public class AddBreakpointRulerAction extends AbstractDisassemblyBreakpointRuler protected AddBreakpointRulerAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { super(disassemblyPart, rulerInfo); - setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label); + setText(DisassemblyMessages.Disassembly_action_AddBreakpoint_label + "\t" + //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, DisassemblyMessages.Disassembly_action_ToggleBreakpoint_accelerator)); } /* diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java index fd3010d83a9..f1acbd206a2 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/actions/BreakpointPropertiesRulerAction.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions; import org.eclipse.cdt.debug.core.model.ICBreakpoint; +import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils; import org.eclipse.cdt.debug.ui.breakpoints.CBreakpointPropertyDialogAction; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.DisassemblyMessages; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; @@ -23,6 +24,7 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.ISelectionProvider; import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.SWT; import org.eclipse.ui.IWorkbenchPart; /** @@ -35,7 +37,8 @@ public class BreakpointPropertiesRulerAction extends AbstractDisassemblyBreakpoi protected BreakpointPropertiesRulerAction(IDisassemblyPart disassemblyPart, IVerticalRulerInfo rulerInfo) { super(disassemblyPart, rulerInfo); - setText(DisassemblyMessages.Disassembly_action_BreakpointProperties_label); + setText(DisassemblyMessages.Disassembly_action_BreakpointProperties_label + "\t" + //$NON-NLS-1$ + CDebugUIUtils.formatKeyBindingString(SWT.MOD1, DisassemblyMessages.Disassembly_action_ToggleBreakpoint_accelerator)); } /* From 963f1bf26e40f7156d51d5fd34067e87c370c8b9 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Fri, 14 Dec 2012 14:28:19 -0500 Subject: [PATCH 4/7] Cosmetics --- .../dsf/gdb/service/GDBBreakpoints_7_2.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java index 0f2a9314ce0..1571e1a635a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_2.java @@ -225,20 +225,20 @@ public class GDBBreakpoints_7_2 extends GDBBreakpoints_7_0 contextBreakpoints.put(reference, newBreakpoint); // Format the return value - MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference); - drm.setData(dmc); + MIBreakpointDMContext dmc = new MIBreakpointDMContext(GDBBreakpoints_7_2.this, new IDMContext[] { context }, reference); + drm.setData(dmc); - // Flag the event - getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); + // Flag the event + getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties()); - // Tracepoints are created with no passcount (passcount are not - // the same thing as ignore-count, which is not supported by - // tracepoints). We have to set the passcount manually now. - // Same for commands. - Map delta = new HashMap(); - delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0)); - delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$ - modifyBreakpoint(dmc, delta, drm, false); + // Tracepoints are created with no passcount (passcount are not + // the same thing as ignore-count, which is not supported by + // tracepoints). We have to set the passcount manually now. + // Same for commands. + Map delta = new HashMap(); + delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0)); + delta.put(MIBreakpoints.COMMANDS, getProperty(attributes, MIBreakpoints.COMMANDS, "")); //$NON-NLS-1$ + modifyBreakpoint(dmc, delta, drm, false); } @Override From 0a4170fed0f50ba5c04bc4380458fd4feb93c9db Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 16 Dec 2012 07:17:43 -0500 Subject: [PATCH 5/7] bug 396411: JUnit failure: cdt.managedbuilder.core.tests.ManagedBuildCoreTests20.testScannerInfoInterface --- .../core/tests/ManagedBuildCoreTests20.java | 33 +++++++++------ .../managedbuilder/internal/core/Builder.java | 7 ++-- .../LanguageSettingsScannerInfoProvider.java | 41 ++++++++++++------- 3 files changed, 49 insertions(+), 32 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index 73c4d90863a..1aab71b5996 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -204,7 +204,7 @@ public class ManagedBuildCoreTests20 extends TestCase { /** * Convert path to OS specific representation */ - private String toOSString(String path) { + private String toOSLocation(String path) { File file = new File(path); try { path = file.getCanonicalPath(); @@ -213,7 +213,14 @@ public class ManagedBuildCoreTests20 extends TestCase { return path; } - + + /** + * Convert path to OS specific representation + */ + private String toOSString(String path) { + return new Path(path).toOSString(); + } + /** * The purpose of this test is to exercise the build path info interface. * To get to that point, a new project/config has to be created in the test @@ -240,24 +247,24 @@ public class ManagedBuildCoreTests20 extends TestCase { if (new Path("C:\\home\\tester/include").isAbsolute()) { // Windows expectedPaths = new String[] { - toOSString("/usr/include"), - toOSString("/opt/gnome/include"), - toOSString("C:\\home\\tester/include"), + toOSLocation("/usr/include"), + toOSLocation("/opt/gnome/include"), + toOSLocation("C:\\home\\tester/include"), // relative paths make 2 entries - project.getLocation().append("includes").toOSString(), - "includes", // FIXME this is incorrect, the original entry set via extension point is "../includes" + buildCWD.append("../includes").toOSString(), + toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED }; } else { // Unix expectedPaths = new String[] { - toOSString("/usr/include"), - toOSString("/opt/gnome/include"), + toOSLocation("/usr/include"), + toOSLocation("/opt/gnome/include"), + buildCWD.append("C:\\home\\tester/include").toOSString(), // added on Unix being relative path + toOSLocation("C:\\home\\tester/include"), // relative paths make 2 entries - buildCWD.append("C:\\home\\tester/include").toOSString(), - "C:\\home\\tester/include", - project.getLocation().append("includes").toOSString(), - "includes", // FIXME this is incorrect, the original entry set via extension point is "../includes" + buildCWD.append("../includes").toOSString(), + toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED }; } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java index 9378bdf1988..3f6b3818677 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Builder.java @@ -1841,11 +1841,10 @@ public class Builder extends HoldsOptions implements IBuilder, IMatchKeyProvider // } if(!buildPath.isAbsolute()){ - buildPath = project.getFullPath().append(buildPath); IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); - - result = buildPath.toString(); - result = mngr.generateVariableExpression("workspace_loc", result); //$NON-NLS-1$ + // build dir may not exist yet and non-existent paths will resolve to empty string by VariablesPlugin + // so append relative part outside of expression, i.e. ${workspace_loc:/Project}/BuildDir + result = mngr.generateVariableExpression("workspace_loc", project.getFullPath().toString()) + Path.SEPARATOR + buildPath.toString(); //$NON-NLS-1$ } else { result = buildPath.toString(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java index b00b3b639b0..302ec73ecd0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java @@ -148,7 +148,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider */ private static IPath getBuildCWD(ICConfigurationDescription cfgDescription) { IPath buildCWD = cfgDescription.getBuildSetting().getBuilderCWD(); - if (buildCWD==null) { + if (buildCWD == null) { IProject project = cfgDescription.getProjectDescription().getProject(); buildCWD = project.getLocation(); } else { @@ -178,7 +178,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider * Resolve location to file system location in a configuration context. * Resolving includes replacing build/environment variables with values, making relative path absolute etc. * - * @param location - location to resolve. If relative, it is taken to be rooted in build working directory. + * @param location - location to resolve. If relative, it is taken to be rooted in project directory. * @param cfgDescription - the configuration context. * @return resolved file system location. */ @@ -192,24 +192,35 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider CCorePlugin.log(e); } // use OS file separators (i.e. '\' on Windows) - if (java.io.File.separatorChar != '/') { - location = location.replace('/', java.io.File.separatorChar); + if (java.io.File.separatorChar != IPath.SEPARATOR) { + location = location.replace(IPath.SEPARATOR, java.io.File.separatorChar); } - // note that we avoid using org.eclipse.core.runtime.Path for manipulations being careful - // to preserve "../" segments and not let collapsing them which is not correct for symbolic links. - Path locPath = new Path(location); - if (locPath.isAbsolute() && locPath.getDevice()==null) { + IPath locPath = new Path(location); + if (locPath.isAbsolute() && locPath.getDevice() == null) { + IPath buildCWD = getBuildCWD(cfgDescription); // prepend device (C:) for Windows - IPath buildCWD = getBuildCWD(cfgDescription); String device = buildCWD.getDevice(); - if (device!=null) + if (device != null) { + // note that we avoid using org.eclipse.core.runtime.Path for manipulations being careful + // to preserve "../" segments and not let collapsing them which is not correct for symbolic links. location = device + location; + } } + if (!locPath.isAbsolute()) { - // consider relative path to be from build working directory - IPath buildCWD = getBuildCWD(cfgDescription); - location = buildCWD.toOSString() + locPath; + ICProjectDescription projectDescription = cfgDescription.getProjectDescription(); + if (projectDescription != null) { + IProject project = projectDescription.getProject(); + if (project != null) { + IPath projectLocation = project.getLocation(); + if (projectLocation != null) { + // again, we avoid using org.eclipse.core.runtime.Path for manipulations being careful + // to preserve "../" segments and not let collapsing them which is not correct for symbolic links. + location = projectLocation.addTrailingSeparator().toOSString() + locPath.toOSString(); + } + } + } } return location; } @@ -222,7 +233,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider * @param cfgDescription - configuration description for resolving entries. * @return array of the locations. */ - private String[] convertToLocations(LinkedHashSet entriesPath, ICConfigurationDescription cfgDescription){ + private String[] convertToLocations(LinkedHashSet entriesPath, ICConfigurationDescription cfgDescription) { List locations = new ArrayList(entriesPath.size()); for (ICLanguageSettingEntry entry : entriesPath) { ACPathEntry entryPath = (ACPathEntry)entry; @@ -261,7 +272,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider IPath unresolvedPath = entryPath.getLocation(); if (!unresolvedPath.isAbsolute()) { IPath expandedPath = expandVariables(unresolvedPath, cfgDescription); - if (!expandedPath.isAbsolute()) { + if (!expandedPath.isEmpty() && !expandedPath.isAbsolute()) { locations.add(expandedPath.toOSString()); } } From 7e38f66a54adc64011f6bc28eb62992481627a33 Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 16 Dec 2012 11:24:06 -0500 Subject: [PATCH 6/7] bug 396411: JUnit failure: cdt.managedbuilder.core.tests.ManagedBuildCoreTests20.testScannerInfoInterface --- .../cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index 1aab71b5996..db1e40dd63d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -261,7 +261,7 @@ public class ManagedBuildCoreTests20 extends TestCase { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), buildCWD.append("C:\\home\\tester/include").toOSString(), // added on Unix being relative path - toOSLocation("C:\\home\\tester/include"), + toOSString("Sub Config/C:\\home\\tester/include"), // relative paths make 2 entries buildCWD.append("../includes").toOSString(), toOSString("includes"), From 7c92e3e070fe96238cb24cc6bc6b4f453d33bdda Mon Sep 17 00:00:00 2001 From: Andrew Gvozdev Date: Sun, 16 Dec 2012 23:52:16 -0500 Subject: [PATCH 7/7] bug 396411: JUnit failure: cdt.managedbuilder.core.tests.ManagedBuildCoreTests20.testScannerInfoInterface --- .../core/tests/ManagedBuildCoreTests20.java | 15 ++-- .../MBSLanguageSettingsProvider.java | 19 +++++ .../LanguageSettingsScannerInfoProvider.java | 74 ++++++++++--------- 3 files changed, 68 insertions(+), 40 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java index db1e40dd63d..1df00d08f76 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests20.java @@ -250,8 +250,9 @@ public class ManagedBuildCoreTests20 extends TestCase { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), toOSLocation("C:\\home\\tester/include"), - // relative paths make 2 entries - buildCWD.append("../includes").toOSString(), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), + buildCWD.append("includes").toOSString(), toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED }; @@ -260,10 +261,14 @@ public class ManagedBuildCoreTests20 extends TestCase { expectedPaths = new String[] { toOSLocation("/usr/include"), toOSLocation("/opt/gnome/include"), - buildCWD.append("C:\\home\\tester/include").toOSString(), // added on Unix being relative path + // on unix "C:\\home\\tester/include" is relative path + // looks like nonsense but has to be this way as MBS converts entry to keep "Sub Config/C:\\home\\tester/include" in its storage + project.getLocation().append("Sub Config/C:\\home\\tester/include").toOSString(), + buildCWD.append("Sub Config/C:\\home\\tester/include").toOSString(), toOSString("Sub Config/C:\\home\\tester/include"), - // relative paths make 2 entries - buildCWD.append("../includes").toOSString(), + // relative paths from MBS will make 3 entries + project.getLocation().append("includes").toOSString(), + buildCWD.append("includes").toOSString(), toOSString("includes"), "/usr/gnu/include", // Not converted to OS string due to being flagged as ICSettingEntry.RESOLVED }; diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java index 24616f8eeb7..e529345df1d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/language/settings/providers/MBSLanguageSettingsProvider.java @@ -22,11 +22,16 @@ import org.eclipse.cdt.core.settings.model.ICFileDescription; import org.eclipse.cdt.core.settings.model.ICFolderDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; +import org.eclipse.cdt.core.settings.model.ICPathEntry; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; /** * Implementation of language settings provider for CDT Managed Build System. @@ -62,6 +67,20 @@ public class MBSLanguageSettingsProvider extends AbstractExecutableExtensionBase if ((kindsBits & kind) != 0) { List additions = langSetting.getSettingEntriesList(kind); for (ICLanguageSettingEntry entry : additions) { + if (entry instanceof ICPathEntry) { + // have to use getName() rather than getLocation() and not use IPath operations to avoid collapsing ".." + String pathStr = ((ICPathEntry) entry).getName(); + if (!new Path(pathStr).isAbsolute()) { + // We need to add project-rooted entry for relative path as MBS counts it this way in some UI + // The relative entry below also should be added for indexer to resolve from source file locations + IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager(); + String projectRootedPath = mngr.generateVariableExpression("workspace_loc", rc.getProject().getName()) + Path.SEPARATOR + pathStr; //$NON-NLS-1$ + ICLanguageSettingEntry projectRootedEntry = (ICLanguageSettingEntry) CDataUtil.createEntry(kind, projectRootedPath, projectRootedPath, null, entry.getFlags()); + if (! list.contains(projectRootedEntry)) { + list.add(projectRootedEntry); + } + } + } if (! list.contains(entry)) { list.add(entry); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java index 302ec73ecd0..86748454c45 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/settings/providers/LanguageSettingsScannerInfoProvider.java @@ -30,10 +30,10 @@ import org.eclipse.cdt.core.parser.ExtendedScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.parser.IScannerInfoChangeListener; import org.eclipse.cdt.core.parser.IScannerInfoProvider; -import org.eclipse.cdt.core.settings.model.ACPathEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICMacroEntry; +import org.eclipse.cdt.core.settings.model.ICPathEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; @@ -129,17 +129,15 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider return new ExtendedScannerInfo(definedMacros, includePaths, macroFiles, includeFiles, includePathsLocal); } - private IPath expandVariables(IPath path, ICConfigurationDescription cfgDescription) { - ICdtVariableManager varManager = CCorePlugin.getDefault().getCdtVariableManager(); - String pathStr = path.toString(); + private String expandVariables(String pathStr, ICConfigurationDescription cfgDescription) { try { + ICdtVariableManager varManager = CCorePlugin.getDefault().getCdtVariableManager(); pathStr = varManager.resolveValue(pathStr, "", null, cfgDescription); //$NON-NLS-1$ - } catch (CdtVariableException e) { + } catch (Exception e) { // Swallow exceptions but also log them CCorePlugin.log(e); } - IPath resolvedLoc = new Path(pathStr); - return resolvedLoc; + return pathStr; } /** @@ -178,7 +176,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider * Resolve location to file system location in a configuration context. * Resolving includes replacing build/environment variables with values, making relative path absolute etc. * - * @param location - location to resolve. If relative, it is taken to be rooted in project directory. + * @param location - location to resolve. If relative, it is taken to be rooted in build working directory. * @param cfgDescription - the configuration context. * @return resolved file system location. */ @@ -209,22 +207,27 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } if (!locPath.isAbsolute()) { - ICProjectDescription projectDescription = cfgDescription.getProjectDescription(); - if (projectDescription != null) { - IProject project = projectDescription.getProject(); - if (project != null) { - IPath projectLocation = project.getLocation(); - if (projectLocation != null) { - // again, we avoid using org.eclipse.core.runtime.Path for manipulations being careful - // to preserve "../" segments and not let collapsing them which is not correct for symbolic links. - location = projectLocation.addTrailingSeparator().toOSString() + locPath.toOSString(); - } - } - } + // consider relative path to be from build working directory + IPath buildCWD = getBuildCWD(cfgDescription); + // again, we avoid using org.eclipse.core.runtime.Path for manipulations being careful + // to preserve "../" segments and not let collapsing them which is not correct for symbolic links. + location = buildCWD.addTrailingSeparator().toOSString() + location; } return location; } + /** + * Convert path delimiters to OS representation avoiding using org.eclipse.core.runtime.Path + * being careful to preserve "../" segments and not let collapsing them which is not correct for symbolic links. + */ + private String toOSString(String loc) { + // use OS file separators (i.e. '\' on Windows) + if (java.io.File.separatorChar != IPath.SEPARATOR) { + loc = loc.replace(IPath.SEPARATOR, java.io.File.separatorChar); + } + return loc; + } + /** * Convert the path entries to absolute file system locations represented as String array. * Resolve the entries which are not resolved. @@ -236,7 +239,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider private String[] convertToLocations(LinkedHashSet entriesPath, ICConfigurationDescription cfgDescription) { List locations = new ArrayList(entriesPath.size()); for (ICLanguageSettingEntry entry : entriesPath) { - ACPathEntry entryPath = (ACPathEntry)entry; + ICPathEntry entryPath = (ICPathEntry)entry; if (entryPath.isValueWorkspacePath()) { ICLanguageSettingEntry[] entries = new ICLanguageSettingEntry[] {entry}; if (!entry.isResolved()) { @@ -244,7 +247,7 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } for (ICLanguageSettingEntry resolved : entries) { - IPath loc = ((ACPathEntry) resolved).getLocation(); + IPath loc = ((ICPathEntry) resolved).getLocation(); if (loc != null) { if (checkBit(resolved.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) { // handle frameworks, see IScannerInfo.getIncludePaths() @@ -256,24 +259,25 @@ public class LanguageSettingsScannerInfoProvider implements IScannerInfoProvider } } } else { - String locStr = entryPath.getName(); + // have to use getName() rather than getLocation() to avoid collapsing ".." + String loc = entryPath.getName(); if (entryPath.isResolved()) { - locations.add(locStr); + locations.add(loc); } else { - locStr = resolveEntry(locStr, cfgDescription); - if (locStr!=null) { + loc = resolveEntry(loc, cfgDescription); + if (loc != null) { if (checkBit(entryPath.getFlags(), ICSettingEntry.FRAMEWORKS_MAC)) { // handle frameworks, see IScannerInfo.getIncludePaths() - locations.add(locStr+FRAMEWORK_HEADERS_INCLUDE); - locations.add(locStr+FRAMEWORK_PRIVATE_HEADERS_INCLUDE); + locations.add(toOSString(loc + FRAMEWORK_HEADERS_INCLUDE)); + locations.add(toOSString(loc + FRAMEWORK_PRIVATE_HEADERS_INCLUDE)); } else { - locations.add(locStr); - // add relative paths again for indexer to resolve from source file location - IPath unresolvedPath = entryPath.getLocation(); - if (!unresolvedPath.isAbsolute()) { - IPath expandedPath = expandVariables(unresolvedPath, cfgDescription); - if (!expandedPath.isEmpty() && !expandedPath.isAbsolute()) { - locations.add(expandedPath.toOSString()); + locations.add(toOSString(loc)); + String unresolvedPath = entryPath.getName(); + if (!new Path(unresolvedPath).isAbsolute()) { + // add relative paths again for indexer to resolve from source file location + String expandedPath = expandVariables(unresolvedPath, cfgDescription); + if (!expandedPath.isEmpty() && !new Path(expandedPath).isAbsolute()) { + locations.add(toOSString(expandedPath)); } } }