| author | Scott Tepavich | 2012-06-28 01:24:23 (EDT) |
|---|---|---|
| committer | Eugene Tarassov | 2012-07-05 20:27:10 (EDT) |
| commit | b3a57f9f6fbf0cbfe82b4b1d617e1822726ee65b (patch) (side-by-side diff) | |
| tree | 8edb05804553e3e59b7ca55e15b625ac19284e38 | |
| parent | e8723af22f8f4c6749d4af807b5d6281748e7136 (diff) | |
| download | org.eclipse.tcf-b3a57f9f6fbf0cbfe82b4b1d617e1822726ee65b.zip org.eclipse.tcf-b3a57f9f6fbf0cbfe82b4b1d617e1822726ee65b.tar.gz org.eclipse.tcf-b3a57f9f6fbf0cbfe82b4b1d617e1822726ee65b.tar.bz2 | |
Bug [383041] Add hardware flag for breakpoints. Added missing copyright headers.
4 files changed, 391 insertions, 1 deletions
diff --git a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml index c3d8fdf..ca29bfd 100644 --- a/plugins/org.eclipse.tcf.cdt.ui/plugin.xml +++ b/plugins/org.eclipse.tcf.cdt.ui/plugin.xml @@ -479,4 +479,17 @@ </detailFactories> </extension> + <extension + point="org.eclipse.cdt.debug.ui.breakpointContribution"> + <breakpointEditors + debugModelId="org.eclipse.tcf.debug" markerType="org.eclipse.cdt.debug.core.cLineBreakpointMarker">> + <attribute + fieldEditorFactory="org.eclipse.tcf.internal.cdt.ui.breakpoints.HardwareFieldEditorFactory" + label="Hardware" + name="org.eclipse.tcf.cdt.Hardware" + type="string"> + </attribute> + </breakpointEditors> + </extension> + </plugin> diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java new file mode 100644 index 0000000..40b8c05 --- a/dev/null +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditor.java @@ -0,0 +1,307 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.internal.cdt.ui.breakpoints; + +import java.util.Map; + +import org.eclipse.cdt.debug.core.model.ICBreakpointType; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.debug.ui.DebugUITools; +import org.eclipse.debug.ui.contexts.IDebugContextProvider; +import org.eclipse.jface.dialogs.DialogPage; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.tcf.debug.ui.ITCFObject; +import org.eclipse.tcf.protocol.IChannel; +import org.eclipse.tcf.protocol.IToken; +import org.eclipse.tcf.services.IBreakpoints; +import org.eclipse.tcf.util.TCFTask; +import org.eclipse.ui.IWorkbenchPropertyPage; + +public class HardwareFieldEditor extends FieldEditor { + + private Composite fParent; + + /** + * The previously selected, or "before", value. + */ + private boolean wasSelected; + + /** + * The checkbox control, or <code>null</code> if none. + */ + private Button checkBox; + + public HardwareFieldEditor(Composite parent) { + super(ICBreakpointType.TYPE, "Hardware", parent); + fParent = parent; + } + + @Override + public void setPage(DialogPage dialogPage) { + super.setPage(dialogPage); + updateEnablement(); + } + + @Override + public void dispose() { + fParent = null; + super.dispose(); + } + + protected void updateEnablement() { + + // enable/disable this feature according to TCF agent capabilities. + final IChannel channel = getActiveChannel(); + Boolean enabled; + + if ((channel == null) || (channel.getState() != IChannel.STATE_OPEN)) { + enabled = Boolean.FALSE; + } + else { + // determine if "Physical Address" capability is supported and + // populate the cache. + + enabled = checkChannelCapabilities(channel); + } + setEnabled(enabled, fParent); + } + + /** + * determine if the channel is able to manage "Physical Address" capability + * + * @param channel + * the channel to check + * @return TRUE if "Physical Address" is supported by the channel, else + * false + */ + protected Boolean checkChannelCapabilities(final IChannel channel) { + Boolean result = Boolean.FALSE; + + result = new TCFTask<Boolean>() { + public void run() { + IBreakpoints service = channel.getRemoteService(IBreakpoints.class); + service.getCapabilities(null, new IBreakpoints.DoneGetCapabilities() { + public void doneGetCapabilities(IToken token, Exception error, Map<String, Object> capabilities) { + done( Boolean.TRUE.equals(capabilities.get(IBreakpoints.CAPABILITY_BREAKPOINT_TYPE)) ); + } + }); + } + }.getE(); + + return result; + } + + protected IChannel getActiveChannel() { + Object debugContext = getDebugContext(); + if (debugContext instanceof ITCFObject) { + return ((ITCFObject)debugContext).getChannel(); + } + return null; + } + + protected Object getDebugContext() { + IWorkbenchPropertyPage page = (IWorkbenchPropertyPage)getPage(); + if (page != null) { + IAdaptable element = page.getElement(); + IDebugContextProvider provider = (IDebugContextProvider)element.getAdapter(IDebugContextProvider.class); + if (provider != null) { + ISelection selection = provider.getActiveContext(); + if (selection instanceof IStructuredSelection) { + return ((IStructuredSelection) selection).getFirstElement(); + } + return null; + } + return DebugUITools.getDebugContext(); + } + return null; + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + protected void adjustForNumColumns(int numColumns) { + ((GridData)checkBox.getLayoutData()).horizontalSpan = numColumns - 1; + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + protected void doFillIntoGrid(Composite parent, int numColumns) { + getLabelControl(parent); + numColumns--; + checkBox = getChangeControl(parent); + GridData gd = new GridData(); + gd.horizontalSpan = numColumns; + checkBox.setLayoutData(gd); + } + + /** + * Returns the control responsible for displaying this field editor's label. + * This method can be used to set a tooltip for a + * <code>BooleanFieldEditor</code>. Note that the normal pattern of + * <code>getLabelControl(parent).setToolTipText(tooltipText)</code> does not + * work for boolean field editors, as it can lead to duplicate text (see bug + * 259952). + * + * @param parent + * the parent composite + * @return the control responsible for displaying the label + * + * @since 3.5 + */ + public Control getDescriptionControl(Composite parent) { + return getLabelControl(parent); + } + + /* + * (non-Javadoc) Method declared on FieldEditor. Loads the value from the + * preference store and sets it to the check box. + */ + protected void doLoad() { + if (checkBox != null) { + int type = getPreferenceStore().getInt(getPreferenceName()); + boolean value = (type & ICBreakpointType.HARDWARE) != 0; + checkBox.setSelection(value); + wasSelected = value; + } + } + + /* + * (non-Javadoc) Method declared on FieldEditor. Loads the default value + * from the preference store and sets it to the check box. + */ + protected void doLoadDefault() { + if (checkBox != null) { + int type = getPreferenceStore().getDefaultInt(getPreferenceName()); + boolean value = (type & ICBreakpointType.HARDWARE) != 0; + checkBox.setSelection(value); + wasSelected = value; + } + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + protected void doStore() { + int type = getPreferenceStore().getInt(getPreferenceName()); + boolean selection = checkBox.getSelection(); + if (selection) { + type = type | ICBreakpointType.HARDWARE; + } else { + type = type & ~ICBreakpointType.HARDWARE; + } + getPreferenceStore().setValue(getPreferenceName(), type); + } + + /** + * Returns this field editor's current value. + * + * @return the value + */ + public boolean getBooleanValue() { + return checkBox.getSelection(); + } + + /** + * Returns the change button for this field editor. + * + * @param parent + * The Composite to create the receiver in. + * + * @return the change button + */ + protected Button getChangeControl(Composite parent) { + if (checkBox == null) { + checkBox = new Button(parent, SWT.CHECK | SWT.LEFT); + checkBox.setFont(parent.getFont()); + checkBox.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + boolean isSelected = checkBox.getSelection(); + valueChanged(wasSelected, isSelected); + wasSelected = isSelected; + } + }); + checkBox.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + checkBox = null; + } + }); + } + else { + checkParent(checkBox, parent); + } + return checkBox; + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + public int getNumberOfControls() { + return 2; + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + public void setFocus() { + if (checkBox != null) { + checkBox.setFocus(); + } + } + + /* + * (non-Javadoc) Method declared on FieldEditor. + */ + public void setLabelText(String text) { + super.setLabelText(text); + Label label = getLabelControl(); + if (label == null && checkBox != null) { + checkBox.setText(text); + } + } + + /** + * Informs this field editor's listener, if it has one, about a change to + * the value (<code>VALUE</code> property) provided that the old and new + * values are different. + * + * @param oldValue + * the old value + * @param newValue + * the new value + */ + protected void valueChanged(boolean oldValue, boolean newValue) { + setPresentsDefaultValue(false); + if (oldValue != newValue) { + fireStateChanged(VALUE, oldValue, newValue); + } + } + + /* + * @see FieldEditor.setEnabled + */ + public void setEnabled(boolean enabled, Composite parent) { + super.setEnabled(enabled, parent); + getChangeControl(parent).setEnabled(enabled); + } +} diff --git a/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java new file mode 100644 index 0000000..b5ef95a --- a/dev/null +++ b/plugins/org.eclipse.tcf.cdt.ui/src/org/eclipse/tcf/internal/cdt/ui/breakpoints/HardwareFieldEditorFactory.java @@ -0,0 +1,28 @@ +/******************************************************************************* + * Copyright (c) 2012 Wind River Systems 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.internal.cdt.ui.breakpoints; + +import org.eclipse.cdt.debug.ui.breakpoints.IFieldEditorFactory; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.widgets.Composite; + + +/** + * HardwareFieldEditorFactory - Create the field editor for hardware breakpoint support. + */ +public class HardwareFieldEditorFactory implements IFieldEditorFactory { + + public FieldEditor createFieldEditor(String name, String labelText, Composite parent) { + return new HardwareFieldEditor (parent); + } + + +}
\ No newline at end of file diff --git a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java index 834f86d..ff36688 100644 --- a/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java +++ b/plugins/org.eclipse.tcf.debug/src/org/eclipse/tcf/internal/debug/model/TCFBreakpointsModel.java @@ -78,7 +78,14 @@ public class TCFBreakpointsModel { ATTR_STOP_GROUP = ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_STOP_GROUP, ATTR_CONTEXT_QUERY = ITCFConstants.ID_TCF_DEBUG_MODEL + '.' + IBreakpoints.PROP_CONTEXT_QUERY, ATTR_EVENT_TYPE = "org.eclipse.cdt.debug.core.eventbreakpoint_event_id", - ATTR_EVENT_ARGS = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg"; + ATTR_EVENT_ARGS = "org.eclipse.cdt.debug.core.eventbreakpoint_event_arg", + ATTR_TYPE = "org.eclipse.cdt.debug.core.breakpointType"; + + public static final int + ATTR_TYPE_TEMPORARY = 0x1, + ATTR_TYPE_REGULAR = 0x0 << 1, + ATTR_TYPE_HARDWARE = 0x1 << 1, + ATTR_TYPE_SOFTWARE = 0x2 << 1; private final IBreakpointManager bp_manager = DebugPlugin.getDefault().getBreakpointManager(); private final HashMap<IChannel,Map<String,Object>> channels = new HashMap<IChannel,Map<String,Object>>(); @@ -553,6 +560,26 @@ public class TCFBreakpointsModel { if (event_args != null && event_args.length() > 0) m.put(ATTR_EVENT_ARGS, event_args); Number ignore_count = (Number)p.get(IBreakpoints.PROP_IGNORE_COUNT); if (ignore_count != null) m.put(ATTR_IGNORE_COUNT, ignore_count); + Boolean temporary = (Boolean)p.get(IBreakpoints.PROP_TEMPORARY); + if (temporary != null && temporary.booleanValue()) { + Integer cdt_type = (Integer)m.get(ATTR_TYPE); + cdt_type = cdt_type != null ? cdt_type : 0; + cdt_type = cdt_type | ATTR_TYPE_TEMPORARY; + m.put(ATTR_TYPE, cdt_type); + } + Integer type = (Integer)p.get(IBreakpoints.PROP_TYPE); + if (type != null) { + Integer cdt_type = (Integer)m.get(ATTR_TYPE); + cdt_type = cdt_type != null ? cdt_type : 0; + if (IBreakpoints.TYPE_HARDWARE.equals(type)) { + cdt_type = cdt_type | ATTR_TYPE_HARDWARE; + } + else if (IBreakpoints.TYPE_SOFTWARE.equals(type)) { + cdt_type = cdt_type | ATTR_TYPE_SOFTWARE; + } + m.put(ATTR_TYPE, cdt_type); + } + return m; } @@ -664,6 +691,21 @@ public class TCFBreakpointsModel { if (event_args != null && event_args.length() > 0) m.put(IBreakpoints.PROP_EVENT_ARGS, event_args); Number ignore_count = (Number)p.get(ATTR_IGNORE_COUNT); if (ignore_count != null && ignore_count.intValue() > 0) m.put(IBreakpoints.PROP_IGNORE_COUNT, ignore_count); + Integer cdt_type = (Integer)p.get(ATTR_TYPE); + if (cdt_type != null) { + if ((cdt_type.intValue() & ATTR_TYPE_TEMPORARY) != 0) { + m.put(IBreakpoints.PROP_TEMPORARY, true); + } + if ((cdt_type.intValue() & ATTR_TYPE_HARDWARE) != 0) { + m.put(IBreakpoints.PROP_TYPE, IBreakpoints.TYPE_HARDWARE); + } + else if ((cdt_type.intValue() & ATTR_TYPE_SOFTWARE) != 0) { + m.put(IBreakpoints.PROP_TYPE, IBreakpoints.TYPE_SOFTWARE); + } + else { + m.put(IBreakpoints.PROP_TYPE, IBreakpoints.TYPE_AUTO); + } + } return m; } |

