1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-01 21:35:40 +02:00

Bug 427898: Allow changing breakpoint type

Change-Id: Ia71395c15bb995edb25e7a910eb98b81a9a8c4f6
Signed-off-by: Teodor Madan <teodor.madan@freescale.com>
Reviewed-on: https://git.eclipse.org/r/21809
Tested-by: Hudson CI
Reviewed-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
IP-Clean: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
Tested-by: Mikhail Khodjaiants <mikhailkhod@googlemail.com>
This commit is contained in:
Teodor Madan 2014-02-11 15:26:24 +02:00
parent 4f2fe55e90
commit 710efe52ec
9 changed files with 192 additions and 4 deletions

View file

@ -1197,6 +1197,11 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
int oldLine = ( delta != null ) ? delta.getAttribute( IMarker.LINE_NUMBER, 0 ) : 0;
boolean basic = oldLine>0 && oldLine != line;
if (breakpoint instanceof ICBreakpointType) {
int oldType = ( delta != null ) ? delta.getAttribute( ICBreakpointType.TYPE, -1 ) : -1;
basic |= oldType != -1 && (oldType != ((ICBreakpointType) breakpoint).getType());
}
if (basic) {
final ICBreakpoint[] breakpoints = new ICBreakpoint[] {breakpoint};
breakpointsRemoved(breakpoints, null);

Binary file not shown.

After

Width:  |  Height:  |  Size: 864 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

View file

@ -1824,10 +1824,9 @@
</factory>
</extension>
<extension point="org.eclipse.cdt.debug.ui.breakpointContribution">
<breakpointLabels markerType="org.eclipse.cdt.debug.core.cBreakpointMarker"
debugModelId="org.eclipse.cdt.debug.core">
<breakpointLabels markerType="org.eclipse.cdt.debug.core.commonCLineBreakpointMarker">
<attribute name="org.eclipse.cdt.debug.core.breakpointType" label="%breapointType.label" type="integer"
fieldEditor="org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor"
fieldEditor="org.eclipse.cdt.debug.internal.ui.breakpoints.BreakpointComboFieldEditor"
>
<value value="0" label="%breapointType.regular.label"></value>
<value value="2" label="%breapointType.hardware.label"></value>

View file

@ -65,6 +65,8 @@ public class CDebugImages {
public static final String IMG_OVRS_GLOBAL = NAME_PREFIX + "global_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_ENABLED = NAME_PREFIX + "brkp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "brkpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_HWBREAKPOINT_ENABLED = NAME_PREFIX + "hwbrkp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_HWBREAKPOINT_DISABLED = NAME_PREFIX + "hwbrkpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_DISABLED = NAME_PREFIX + "addrbrkpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_FUNCTION_BREAKPOINT_ENABLED = NAME_PREFIX + "funbrkp_obj.gif"; //$NON-NLS-1$
@ -154,6 +156,8 @@ public class CDebugImages {
public static final ImageDescriptor DESC_OVRS_GLOBAL = createManaged(T_OVR, IMG_OVRS_GLOBAL);
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_ENABLED);
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED);
public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_HWBREAKPOINT_ENABLED);
public static final ImageDescriptor DESC_OBJS_HWBREAKPOINT_DISABLED = createManaged(T_OBJ, IMG_OBJS_HWBREAKPOINT_DISABLED);
public static final ImageDescriptor DESC_OBJS_TRACEPOINT_ENABLED = createManaged(T_ELCL, IMG_OBJS_TRACEPOINT_ENABLED);
public static final ImageDescriptor DESC_OBJS_TRACEPOINT_DISABLED = createManaged(T_DLCL, IMG_OBJS_TRACEPOINT_DISABLED);
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged(T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED);

View file

@ -35,6 +35,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.core.model.CDebugElementState;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
@ -356,6 +357,13 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return getTracepointImage( (ICTracepoint)breakpoint );
}
if ( breakpoint instanceof ICLineBreakpoint ) {
// checks if the breakpoint type is a hardware breakpoint,
// if so, return the hardware breakpoint image
if( breakpoint instanceof ICBreakpointType) {
ICBreakpointType breakpointType = (ICBreakpointType) breakpoint;
if( (breakpointType.getType() & ICBreakpointType.HARDWARE) != 0)
return getHWBreakpointImage( (ICLineBreakpoint) breakpoint);
}
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
}
if ( breakpoint instanceof ICWatchpoint ) {
@ -371,6 +379,17 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return null;
}
protected Image getHWBreakpointImage(ICLineBreakpoint breakpoint) throws CoreException {
ImageDescriptor descriptor = null;
if ( breakpoint.isEnabled() ) {
descriptor = CDebugImages.DESC_OBJS_HWBREAKPOINT_ENABLED;
}
else {
descriptor = CDebugImages.DESC_OBJS_HWBREAKPOINT_DISABLED;
}
return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( breakpoint ) ) );
}
protected Image getTracepointImage( ICTracepoint tracepoint ) throws CoreException {
ImageDescriptor descriptor = null;
if ( tracepoint.isEnabled() ) {

View file

@ -0,0 +1,128 @@
/*******************************************************************************
* Copyright (c) 2014 Freescale 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:
* Freescale - initial API and implementation (Bug 427898)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.breakpoints;
import org.eclipse.cdt.debug.internal.ui.preferences.ComboFieldEditor;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution;
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContributionUser;
import org.eclipse.swt.widgets.Composite;
/**
* Extends combo field editor to load combo values from {@extensionPoint org.eclipse.cdt.debug.ui.breakpointContribution} extension
*/
public class BreakpointComboFieldEditor extends ComboFieldEditor implements
ICBreakpointsUIContributionUser {
private ICBreakpointsUIContribution fContribution;
/**
* Create combo field editor that would load choice values from {@link ICBreakpointsUIContribution}
* @param name - property name, must be the same as breakpoint attribute
* @param labelText - text in front of field
* @param parent
*/
public BreakpointComboFieldEditor(String name, String labelText, Composite parent) {
super(name, labelText, new String[0][0], parent);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContributionUser#setContribution(org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution)
*/
@Override
public void setContribution(ICBreakpointsUIContribution contribution) {
fContribution = contribution;
//load values from contribution
String[] possibleValues = fContribution.getPossibleValues();
String[][] entryNamesAndValues = new String[possibleValues.length][2];
for (int i=0; i<possibleValues.length; ++i) {
entryNamesAndValues[i][0] = fContribution.getLabelForValue(possibleValues[i]);
entryNamesAndValues[i][1] = possibleValues[i];
}
setEntries(entryNamesAndValues);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContributionUser#getContribution()
*/
@Override
public ICBreakpointsUIContribution getContribution() {
return fContribution;
}
/**
* @see FieldEditor#doLoad()
*/
@Override
protected void doLoad() {
updateComboForValue(storeToComboValue());
}
/**
* @see FieldEditor#doStore()
*/
@Override
protected void doStore() {
if (fValue == null) {
getPreferenceStore().setToDefault(getPreferenceName());
return;
}
comboValueToStore(fValue);
}
/**
* load field value from preference store and return as combo widget value
* @return - "String" value of the attribute
*/
protected String storeToComboValue() {
String value = getPreferenceStore().getString(getPreferenceName());
if (fContribution!=null) {
if ("integer".equals (fContribution.getType())) { //$NON-NLS-1$
value = Integer.toString( getPreferenceStore().getInt(getPreferenceName()) );
} else if ("boolean".equals (fContribution.getType()) ) {//$NON-NLS-1$
value = Boolean.toString( getPreferenceStore().getBoolean(getPreferenceName()) );
} else if ("float".equals (fContribution.getType()) ) {//$NON-NLS-1$
value = Float.toString( getPreferenceStore().getFloat(getPreferenceName()) );
} else if ("double".equals (fContribution.getType()) ) {//$NON-NLS-1$
value = Double.toString( getPreferenceStore().getDouble(getPreferenceName()) );
}
}
return value;
}
/**
* Save to preference store the selected combo value
* @param val - value to be stored.
*/
protected void comboValueToStore(String val) {
if (fContribution!=null) {
if ("integer".equals (fContribution.getType())) { //$NON-NLS-1$
getPreferenceStore().setValue(getPreferenceName(), Integer.parseInt(val)) ;
} else if ("boolean".equals (fContribution.getType()) ) {//$NON-NLS-1$
getPreferenceStore().setValue(getPreferenceName(), Boolean.parseBoolean(val)) ;
} else if ("float".equals (fContribution.getType()) ) {//$NON-NLS-1$
getPreferenceStore().setValue(getPreferenceName(), Float.parseFloat(val)) ;
} else if ("double".equals (fContribution.getType()) ) {//$NON-NLS-1$
getPreferenceStore().setValue(getPreferenceName(), Double.parseDouble(val)) ;
} else {
// handle "String" attribute type
getPreferenceStore().setValue(getPreferenceName(), val);
}
} else {
getPreferenceStore().setValue(getPreferenceName(), val);
}
}
}

View file

@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
* Freescale - allow setting combo values after creating FieldEditor object (Bug 427898)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.preferences;
@ -42,6 +43,14 @@ public class ComboFieldEditor extends FieldEditor {
*/
private String[][] fEntryNamesAndValues;
/**
* Create combo field editor with all choice values.
* @param name - property name, must be the same as breakpoint attribute
* @param labelText - text in front of field
* @param entryNamesAndValues - The names (labels) and underlying values to populate the combo widget.
* These should be arranged as: { {name1, value1}, {name2, value2}, ...}
* @param parent the parent control
*/
public ComboFieldEditor(String name, String labelText, String[][] entryNamesAndValues, Composite parent) {
init(name, labelText);
Assert.isTrue(checkArray(entryNamesAndValues));
@ -210,4 +219,24 @@ public class ComboFieldEditor extends FieldEditor {
{
super.setPresentsDefaultValue( b );
}
/**
* Load new values in combo selection.
* @param namesAndValues: new values for combo widget. Cannot be null.
* <p> See {@link ComboFieldEditor#ComboFieldEditor(String, String, String[][], Composite)} for names and values format
*/
protected void setEntries(String[][] entryNamesAndValues) {
fEntryNamesAndValues = entryNamesAndValues;
Combo combo = getComboBoxControl();
// dispose old items.
if (combo.getItemCount() > 0) {
combo.removeAll();
}
//load values from contribution
for (int i=0; i<fEntryNamesAndValues.length; ++i) {
combo.add(fEntryNamesAndValues[i][0], i);
}
fCombo.select(0);
}
}

View file

@ -1713,6 +1713,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
if (cdt_attributes.containsKey(ICBreakpoint.ENABLED))
result.put(MIBreakpoints.IS_ENABLED, cdt_attributes.get(ICBreakpoint.ENABLED));
if (cdt_attributes.containsKey(ICBreakpointType.TYPE))
result.put(MIBreakpoints.BREAKPOINT_TYPE, cdt_attributes.get(ICBreakpointType.TYPE));
// ICWatchpoint attributes
if (cdt_attributes.containsKey(ICWatchpoint.EXPRESSION))
result.put(MIBreakpoints.EXPRESSION, cdt_attributes.get(ICWatchpoint.EXPRESSION));
@ -1893,6 +1896,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Check the "critical" attributes
if (delta.containsKey(ATTR_DEBUGGER_PATH) // File name
|| delta.containsKey(MIBreakpoints.LINE_NUMBER) // Line number
|| delta.containsKey(MIBreakpoints.BREAKPOINT_TYPE) // breakpoint type
|| delta.containsKey(MIBreakpoints.FUNCTION) // Function name
|| delta.containsKey(MIBreakpoints.ADDRESS) // Absolute address
|| delta.containsKey(ATTR_THREAD_FILTER) // Thread ID