mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 17:35:35 +02:00
Bug 376116 - Use new "Add breakpoint..." with tracepoints
Change-Id: I35ccb2d089683ce760405358d45fff2477036659 Reviewed-on: https://git.eclipse.org/r/11033 Reviewed-by: Pawel Piech <pawel.1.piech@gmail.com> Tested-by: Pawel Piech <pawel.1.piech@gmail.com> Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
parent
b09a3880fd
commit
11171b06ad
10 changed files with 229 additions and 249 deletions
|
@ -10,7 +10,7 @@ Export-Package:
|
|||
org.eclipse.cdt.debug.internal.ui;x-internal:x-friends:="org.eclipse.cdt.dsf.ui";x-friends:="org.eclipse.cdt.dsf.ui",
|
||||
org.eclipse.cdt.debug.internal.ui.actions;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.debug.ui.memory.memorybrowser",
|
||||
org.eclipse.cdt.debug.internal.ui.actions.breakpoints;x-internal:=true,
|
||||
org.eclipse.cdt.debug.internal.ui.breakpoints;x-friends:="org.eclipse.cdt.dsf.ui",
|
||||
org.eclipse.cdt.debug.internal.ui.breakpoints;x-friends:="org.eclipse.cdt.dsf.ui,org.eclipse.cdt.dsf.gdb.ui",
|
||||
org.eclipse.cdt.debug.internal.ui.commands;x-internal:=true,
|
||||
org.eclipse.cdt.debug.internal.ui.dialogfields;x-friends:="org.eclipse.cdt.dsf.gdb.ui",
|
||||
org.eclipse.cdt.debug.internal.ui.dialogs;x-internal:=true,
|
||||
|
|
|
@ -41,3 +41,7 @@ CBreakpointPropertyPage.enabled_label=Enabled
|
|||
CBreakpointPropertyPage.eventType_label=Event Type
|
||||
|
||||
ThreadFilterEditor.0=&Restrict to Selected Targets and Threads:
|
||||
|
||||
TracepointPropertyPage.tracepointType_function_label=C/C++ Function Tracepoint
|
||||
TracepointPropertyPage.tracepointType_address_label=C/C++ Address Tracepoint
|
||||
TracepointPropertyPage.tracepointType_line_label=C/C++ Line Tracepoint
|
||||
|
|
|
@ -177,11 +177,23 @@ class CBreakpointContextWorkbenchAdapter implements IWorkbenchAdapter {
|
|||
|
||||
private String getBreakpointMainLabel(ICBreakpoint breakpoint) {
|
||||
if (breakpoint instanceof ICFunctionBreakpoint) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICTracepoint) {
|
||||
return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_function_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_function_label"); //$NON-NLS-1$
|
||||
}
|
||||
} else if (breakpoint instanceof ICAddressBreakpoint) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICTracepoint) {
|
||||
return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_address_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_address_label"); //$NON-NLS-1$
|
||||
}
|
||||
} else if (breakpoint instanceof ICLineBreakpoint) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$
|
||||
if (breakpoint instanceof ICTracepoint) {
|
||||
return BreakpointsMessages.getString("TracepointPropertyPage.tracepointType_line_label"); //$NON-NLS-1$
|
||||
} else {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_line_label"); //$NON-NLS-1$
|
||||
}
|
||||
} else if (breakpoint instanceof ICEventBreakpoint) {
|
||||
return BreakpointsMessages.getString("CBreakpointPropertyPage.breakpointType_event_label"); //$NON-NLS-1$
|
||||
} else if (breakpoint instanceof ICWatchpoint) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* QNX Software Systems - Refactored to use platform implementation
|
||||
* Marc Khouzam (Ericsson) - Added support for Tracepoints (bug 376116)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.internal.ui.breakpoints;
|
||||
|
||||
|
@ -23,6 +24,7 @@ import java.util.Set;
|
|||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint2;
|
||||
import org.eclipse.cdt.debug.core.model.ICTracepoint;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
|
@ -36,7 +38,8 @@ import org.eclipse.jface.util.IPropertyChangeListener;
|
|||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
|
||||
/**
|
||||
* A preference store that presents the state of the properties of a C/C++ breakpoint.
|
||||
* A preference store that presents the state of the properties of a C/C++ breakpoint
|
||||
* or Tracepoint.
|
||||
*/
|
||||
public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
|
||||
|
||||
|
@ -131,6 +134,9 @@ public class CBreakpointPreferenceStore implements IPersistentPreferenceStore {
|
|||
else if ( property.equals( ICBreakpoint.IGNORE_COUNT ) ) {
|
||||
breakpoint.setIgnoreCount( getInt( ICBreakpoint.IGNORE_COUNT ) );
|
||||
}
|
||||
else if ( breakpoint instanceof ICTracepoint && property.equals( ICTracepoint.PASS_COUNT ) ) {
|
||||
((ICTracepoint)breakpoint).setPassCount( getInt( ICTracepoint.PASS_COUNT ) );
|
||||
}
|
||||
else if ( property.equals( ICBreakpoint.CONDITION ) ) {
|
||||
breakpoint.setCondition( getString( ICBreakpoint.CONDITION ) );
|
||||
}
|
||||
|
|
|
@ -191,7 +191,13 @@
|
|||
id="org.eclipse.cdt.dsf.gdb.tracepoint.common"
|
||||
name="%tracepoints.property.common">
|
||||
<enabledWhen>
|
||||
<adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
|
||||
<or>
|
||||
<adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
|
||||
<and>
|
||||
<instanceof value="org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext"/>
|
||||
<test property="org.eclipse.cdt.debug.ui.createBreakpointAdapt" value="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
|
||||
</and>
|
||||
</or>
|
||||
</enabledWhen>
|
||||
</page>
|
||||
</extension>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2010 Ericsson, Inc. and others.
|
||||
* Copyright (c) 2009, 2013 Ericsson, Inc. 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
|
||||
|
@ -7,15 +7,22 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ericsson - initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Updated to allow updating properties
|
||||
* before creating the tracepoint (Bug 376116)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.IAddress;
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpointType;
|
||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.dsf.debug.ui.actions.AbstractDisassemblyBreakpointsTarget;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
/**
|
||||
* Toggle tracepoint target implementation for the disassembly part.
|
||||
|
@ -26,18 +33,40 @@ public class DisassemblyToggleTracepointsTarget extends AbstractDisassemblyBreak
|
|||
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createLineBreakpoint(java.lang.String, org.eclipse.core.resources.IResource, int)
|
||||
*/
|
||||
@Override
|
||||
protected void createLineBreakpoint( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
|
||||
CDIDebugModel.createLineTracepoint( sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true ); //$NON-NLS-1$
|
||||
protected void createLineBreakpoint(String sourceHandle, IResource resource, int lineNumber) throws CoreException {
|
||||
CDIDebugModel.createLineTracepoint(sourceHandle, resource, getBreakpointType(), lineNumber, true, 0, "", true); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void createLineBreakpointInteractive(IWorkbenchPart part, String sourceHandle, IResource resource, int lineNumber)
|
||||
throws CoreException
|
||||
{
|
||||
ICLineBreakpoint lineBp = CDIDebugModel.createBlankLineTracepoint();
|
||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
CDIDebugModel.setLineBreakpointAttributes(
|
||||
attributes, sourceHandle, getBreakpointType(), lineNumber, true, 0, "" ); //$NON-NLS-1$
|
||||
openBreakpointPropertiesDialog(lineBp, part, resource, attributes);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.AbstractDisassemblyBreakpointsTarget#createAddressBreakpoint(org.eclipse.core.resources.IResource, org.eclipse.cdt.core.IAddress)
|
||||
*/
|
||||
@Override
|
||||
protected void createAddressBreakpoint( IResource resource, IAddress address ) throws CoreException {
|
||||
CDIDebugModel.createAddressTracepoint( null, null, resource, getBreakpointType(), -1, address, true, 0, "", true ); //$NON-NLS-1$
|
||||
protected void createAddressBreakpoint(IResource resource, IAddress address) throws CoreException {
|
||||
CDIDebugModel.createAddressTracepoint(null, null, resource, getBreakpointType(), -1, address, true, 0, "", true); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void createAddressBreakpointInteractive(IWorkbenchPart part, IResource resource, IAddress address)
|
||||
throws CoreException
|
||||
{
|
||||
ICLineBreakpoint lineBp = CDIDebugModel.createBlankAddressTracepoint();
|
||||
Map<String, Object> attributes = new HashMap<String, Object>();
|
||||
CDIDebugModel.setAddressBreakpointAttributes(
|
||||
attributes, null, null, getBreakpointType(), -1, address, true, 0, "" ); //$NON-NLS-1$
|
||||
openBreakpointPropertiesDialog(lineBp, part, resource, attributes);
|
||||
}
|
||||
|
||||
protected int getBreakpointType() {
|
||||
return ICBreakpointType.REGULAR;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Ericsson and others.
|
||||
* Copyright (c) 2009, 2013 Ericsson 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
|
||||
|
@ -7,36 +7,41 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Ericsson - Initial API and implementation
|
||||
* Marc Khouzam (Ericsson) - Updated to allow updating properties
|
||||
* before creating the tracepoint (Bug 376116)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICTracepoint;
|
||||
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
|
||||
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointPreferenceStore;
|
||||
import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointContext;
|
||||
import org.eclipse.cdt.debug.ui.preferences.ReadOnlyFieldEditor;
|
||||
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.debug.core.model.ILineBreakpoint;
|
||||
import org.eclipse.debug.core.DebugPlugin;
|
||||
import org.eclipse.debug.core.model.IDebugElement;
|
||||
import org.eclipse.debug.core.model.IDebugModelProvider;
|
||||
import org.eclipse.debug.ui.DebugUITools;
|
||||
import org.eclipse.debug.ui.contexts.IDebugContextProvider;
|
||||
import org.eclipse.jface.preference.BooleanFieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditor;
|
||||
import org.eclipse.jface.preference.FieldEditorPreferencePage;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.IntegerFieldEditor;
|
||||
import org.eclipse.jface.preference.StringFieldEditor;
|
||||
import org.eclipse.jface.util.IPropertyChangeListener;
|
||||
import org.eclipse.jface.util.PropertyChangeEvent;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Text;
|
||||
import org.eclipse.ui.IWorkbenchPropertyPage;
|
||||
import org.eclipse.ui.model.IWorkbenchAdapter;
|
||||
|
||||
/**
|
||||
* The preference page used to present the properties of a GDB tracepoint as preferences.
|
||||
|
@ -122,6 +127,12 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
super.doStore();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doLoad() {
|
||||
String value = getPreferenceStore().getString(getPreferenceName());
|
||||
setStringValue(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the error message from the message line if the error message is the error message from this field editor.
|
||||
|
@ -176,19 +187,21 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
private IAdaptable fElement;
|
||||
|
||||
/**
|
||||
* The "fake" preference store used to interface between
|
||||
* the tracepoint and the tracepoint preference page.
|
||||
* The preference store used to interface between the tracepoint and the
|
||||
* tracepoint preference page. This preference store is initialized only
|
||||
* when the preference store cannot be retrieved from the preference
|
||||
* dialog's element.
|
||||
* @see #getPreferenceStore()
|
||||
*/
|
||||
private TracepointPreferenceStore fTracepointPreferenceStore;
|
||||
private CBreakpointPreferenceStore fTracepointPreferenceStore;
|
||||
|
||||
/**
|
||||
* Constructor for GDBTracepointPropertyPage.
|
||||
*
|
||||
*/
|
||||
public GDBTracepointPropertyPage() {
|
||||
super( GRID );
|
||||
super(GRID);
|
||||
noDefaultAndApplyButton();
|
||||
fTracepointPreferenceStore = new TracepointPreferenceStore();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -202,26 +215,10 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
createMainLabel(tracepoint);
|
||||
createTypeSpecificLabelFieldEditors(tracepoint);
|
||||
createEnabledField(getFieldEditorParent());
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
try {
|
||||
String condition = tracepoint.getCondition();
|
||||
if ( condition == null ) {
|
||||
condition = ""; //$NON-NLS-1$
|
||||
}
|
||||
store.setValue(TracepointPreferenceStore.CONDITION, condition);
|
||||
createConditionEditor(getFieldEditorParent());
|
||||
store.setValue(TracepointPreferenceStore.ENABLED, tracepoint.isEnabled());
|
||||
// GDB does not support ignore count right now
|
||||
// int ignoreCount = tracepoint.getIgnoreCount();
|
||||
// store.setValue(TracepointPreferenceStore.IGNORE_COUNT, (ignoreCount >= 0) ? ignoreCount : 0);
|
||||
// createIgnoreCountEditor(getFieldEditorParent());
|
||||
int passCount = tracepoint.getPassCount();
|
||||
store.setValue(TracepointPreferenceStore.PASS_COUNT, (passCount >= 0) ? passCount : 0);
|
||||
createPassCountEditor(getFieldEditorParent());
|
||||
}
|
||||
catch( CoreException ce ) {
|
||||
GdbUIPlugin.log(ce);
|
||||
}
|
||||
createConditionEditor(getFieldEditorParent());
|
||||
// GDB does not support ignore count right now
|
||||
//createIgnoreCountEditor(getFieldEditorParent());
|
||||
createPassCountEditor(getFieldEditorParent());
|
||||
}
|
||||
|
||||
private void createMainLabel(ICTracepoint tracepoint) {
|
||||
|
@ -230,117 +227,86 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
getTracepointMainLabel(tracepoint)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method createTypeSpecificLabelFieldEditors.
|
||||
*
|
||||
* @param tracepoint
|
||||
*/
|
||||
private void createTypeSpecificLabelFieldEditors(ICTracepoint tracepoint) {
|
||||
|
||||
if (tracepoint instanceof ICFunctionBreakpoint) {
|
||||
ICFunctionBreakpoint ftrpt = (ICFunctionBreakpoint)tracepoint;
|
||||
String function = Messages.TracepointPropertyPage_NotAvailable;
|
||||
try {
|
||||
function = ftrpt.getFunction();
|
||||
}
|
||||
catch(CoreException e) {
|
||||
GdbUIPlugin.log(e);
|
||||
}
|
||||
if (function != null) {
|
||||
addField(createLabelEditor(getFieldEditorParent(), Messages.TracepointPropertyPage_FunctionName, function));
|
||||
}
|
||||
createFunctionEditor(getFieldEditorParent());
|
||||
}
|
||||
else if (tracepoint instanceof ICAddressBreakpoint) {
|
||||
ICAddressBreakpoint atrpt = (ICAddressBreakpoint)tracepoint;
|
||||
String address = Messages.TracepointPropertyPage_NotAvailable;
|
||||
try {
|
||||
address = atrpt.getAddress();
|
||||
}
|
||||
catch(CoreException e) {
|
||||
GdbUIPlugin.log(e);
|
||||
}
|
||||
if (address != null) {
|
||||
addField(createLabelEditor(getFieldEditorParent(), Messages.TracepointPropertyPage_Address, address));
|
||||
String address = getPreferenceStore().getString(ICLineBreakpoint.ADDRESS);
|
||||
if (address == null || address.trim().length() == 0) {
|
||||
address = Messages.TracepointPropertyPage_NotAvailable;
|
||||
}
|
||||
addField(createLabelEditor(getFieldEditorParent(), Messages.TracepointPropertyPage_Address, address));
|
||||
}
|
||||
else { // LineTracepoint
|
||||
String fileName = null;
|
||||
try {
|
||||
fileName = tracepoint.getSourceHandle();
|
||||
}
|
||||
catch(CoreException e) {
|
||||
GdbUIPlugin.log(e);
|
||||
}
|
||||
String fileName = getPreferenceStore().getString(ICBreakpoint.SOURCE_HANDLE);
|
||||
if (fileName != null) {
|
||||
addField(createLabelEditor(getFieldEditorParent(), Messages.TracepointPropertyPage_File, fileName));
|
||||
}
|
||||
ILineBreakpoint ltrpt = tracepoint;
|
||||
|
||||
int lNumber = 0;
|
||||
try {
|
||||
lNumber = ltrpt.getLineNumber();
|
||||
} catch (CoreException e) {
|
||||
GdbUIPlugin.log(e);
|
||||
}
|
||||
|
||||
int lNumber = getPreferenceStore().getInt(IMarker.LINE_NUMBER);
|
||||
if (lNumber > 0) {
|
||||
getPreferenceStore().setValue(TracepointPreferenceStore.LINE, lNumber);
|
||||
createLineNumberEditor(getFieldEditorParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String getTracepointMainLabel(ICTracepoint tracepoint) {
|
||||
if (tracepoint instanceof ICFunctionBreakpoint)
|
||||
return Messages.TracepointPropertyPage_FunctionTracepoint;
|
||||
if (tracepoint instanceof ICAddressBreakpoint)
|
||||
return Messages.TracepointPropertyPage_AddressTracepoint;
|
||||
|
||||
return Messages.TracepointPropertyPage_LineTracepoint;
|
||||
IWorkbenchAdapter labelProvider = (IWorkbenchAdapter)getElement().getAdapter(IWorkbenchAdapter.class);
|
||||
if (labelProvider != null) {
|
||||
return labelProvider.getLabel(getElement());
|
||||
}
|
||||
// default main label is the label of marker type for the tracepoint
|
||||
return CDIDebugModel.calculateMarkerType(tracepoint);
|
||||
}
|
||||
|
||||
protected void createFunctionEditor(Composite parent) {
|
||||
ICTracepoint tracepoint = getTracepoint();
|
||||
if (tracepoint == null || tracepoint.getMarker() == null) {
|
||||
TracepointStringFieldEditor expressionEditor = new TracepointStringFieldEditor(
|
||||
ICLineBreakpoint.FUNCTION, Messages.TracepointPropertyPage_FunctionName, parent);
|
||||
expressionEditor.setErrorMessage(Messages.TracepointPropertyPage_function_value_errorMessage);
|
||||
expressionEditor.setEmptyStringAllowed(false);
|
||||
addField(expressionEditor);
|
||||
} else {
|
||||
String function = getPreferenceStore().getString(ICLineBreakpoint.FUNCTION);
|
||||
if (function == null) {
|
||||
function = Messages.TracepointPropertyPage_NotAvailable;
|
||||
}
|
||||
addField(createLabelEditor(getFieldEditorParent(), Messages.TracepointPropertyPage_FunctionName, function));
|
||||
}
|
||||
}
|
||||
protected void createLineNumberEditor(Composite parent) {
|
||||
String title = Messages.TracepointPropertyPage_LineNumber;
|
||||
TracepointIntegerFieldEditor labelFieldEditor = new TracepointIntegerFieldEditor(TracepointPreferenceStore.LINE ,title, parent);
|
||||
TracepointIntegerFieldEditor labelFieldEditor = new TracepointIntegerFieldEditor(IMarker.LINE_NUMBER, title, parent);
|
||||
labelFieldEditor.setValidRange(1, Integer.MAX_VALUE);
|
||||
addField(labelFieldEditor);
|
||||
}
|
||||
|
||||
|
||||
protected void createEnabledField(Composite parent) {
|
||||
fEnabled = new BooleanFieldEditor(TracepointPreferenceStore.ENABLED, Messages.TracepointPropertyPage_Enabled, parent);
|
||||
fEnabled = new BooleanFieldEditor(ICBreakpoint.ENABLED, Messages.TracepointPropertyPage_Enabled, parent);
|
||||
addField(fEnabled);
|
||||
}
|
||||
|
||||
protected void createConditionEditor( Composite parent ) {
|
||||
fCondition = new TracepointStringFieldEditor(TracepointPreferenceStore.CONDITION, Messages.TracepointPropertyPage_Condition, parent);
|
||||
protected void createConditionEditor(Composite parent) {
|
||||
fCondition = new TracepointStringFieldEditor(ICBreakpoint.CONDITION, Messages.TracepointPropertyPage_Condition, parent);
|
||||
fCondition.setEmptyStringAllowed(true);
|
||||
fCondition.setErrorMessage(Messages.TracepointPropertyPage_InvalidCondition);
|
||||
addField(fCondition);
|
||||
}
|
||||
|
||||
protected void createIgnoreCountEditor(Composite parent) {
|
||||
fIgnoreCount = new TracepointIntegerFieldEditor(TracepointPreferenceStore.IGNORE_COUNT, Messages.TracepointPropertyPage_IgnoreCount, parent);
|
||||
fIgnoreCount = new TracepointIntegerFieldEditor(ICBreakpoint.IGNORE_COUNT, Messages.TracepointPropertyPage_IgnoreCount, parent);
|
||||
fIgnoreCount.setValidRange(0, Integer.MAX_VALUE);
|
||||
fIgnoreCountTextControl = fIgnoreCount.getTextControl(parent);
|
||||
try {
|
||||
fIgnoreCountTextControl.setEnabled(getTracepoint().getIgnoreCount() >= 0);
|
||||
}
|
||||
catch(CoreException ce) {
|
||||
GdbUIPlugin.log(ce);
|
||||
}
|
||||
fIgnoreCountTextControl.setEnabled( getPreferenceStore().getInt(ICBreakpoint.IGNORE_COUNT) >= 0 );
|
||||
addField(fIgnoreCount);
|
||||
}
|
||||
|
||||
protected void createPassCountEditor(Composite parent) {
|
||||
fPassCount = new TracepointIntegerFieldEditor(TracepointPreferenceStore.PASS_COUNT, Messages.TracepointPropertyPage_PassCount, parent);
|
||||
fPassCount = new TracepointIntegerFieldEditor(ICTracepoint.PASS_COUNT, Messages.TracepointPropertyPage_PassCount, parent);
|
||||
fPassCount.setValidRange(0, Integer.MAX_VALUE);
|
||||
fPassCountTextControl = fPassCount.getTextControl(parent);
|
||||
try {
|
||||
fPassCountTextControl.setEnabled(getTracepoint().getPassCount() >= 0);
|
||||
}
|
||||
catch(CoreException ce) {
|
||||
GdbUIPlugin.log(ce);
|
||||
}
|
||||
fPassCountTextControl.setEnabled(getPreferenceStore().getInt(ICTracepoint.PASS_COUNT) >= 0);
|
||||
addField(fPassCount);
|
||||
}
|
||||
|
||||
|
@ -350,9 +316,80 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
|
||||
protected ICTracepoint getTracepoint() {
|
||||
IAdaptable element = getElement();
|
||||
return (element instanceof ICTracepoint) ? (ICTracepoint)element : (ICTracepoint)element.getAdapter(ICTracepoint.class);
|
||||
if (element instanceof ICTracepoint) {
|
||||
return (ICTracepoint)element;
|
||||
}
|
||||
|
||||
if (element instanceof ICBreakpointContext) {
|
||||
ICBreakpoint breakpoint =((ICBreakpointContext)element).getBreakpoint();
|
||||
if (breakpoint instanceof ICTracepoint) {
|
||||
return (ICTracepoint)breakpoint;
|
||||
}
|
||||
assert false : "Should always have a tracepoint"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
return (ICTracepoint)element.getAdapter(ICTracepoint.class);
|
||||
}
|
||||
|
||||
protected Object getDebugContext() {
|
||||
IDebugContextProvider provider = (IDebugContextProvider)getElement().getAdapter(IDebugContextProvider.class);
|
||||
if (provider != null) {
|
||||
ISelection selection = provider.getActiveContext();
|
||||
if (selection instanceof IStructuredSelection) {
|
||||
return ((IStructuredSelection) selection).getFirstElement();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return DebugUITools.getDebugContext();
|
||||
}
|
||||
|
||||
|
||||
protected IResource getResource() {
|
||||
IAdaptable element = getElement();
|
||||
if (element instanceof ICTracepoint) {
|
||||
IMarker marker = ((ICTracepoint)element).getMarker();
|
||||
if (marker != null) {
|
||||
return marker.getResource();
|
||||
}
|
||||
} else if (element instanceof ICBreakpointContext) {
|
||||
return ((ICBreakpointContext)element).getResource();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPreferenceStore getPreferenceStore() {
|
||||
IAdaptable element = getElement();
|
||||
if (element instanceof ICBreakpointContext) {
|
||||
return ((ICBreakpointContext)element).getPreferenceStore();
|
||||
}
|
||||
|
||||
if (fTracepointPreferenceStore == null) {
|
||||
CBreakpointContext bpContext = element instanceof CBreakpointContext ?
|
||||
(CBreakpointContext)element : null;
|
||||
fTracepointPreferenceStore = new CBreakpointPreferenceStore(bpContext, null);
|
||||
}
|
||||
return fTracepointPreferenceStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCancel() {
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
if (store instanceof CBreakpointPreferenceStore) {
|
||||
((CBreakpointPreferenceStore)store).setCanceled(true);
|
||||
}
|
||||
return super.performCancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
if (store instanceof CBreakpointPreferenceStore) {
|
||||
((CBreakpointPreferenceStore)store).setCanceled(false);
|
||||
}
|
||||
return super.performOk();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
|
||||
*/
|
||||
|
@ -369,79 +406,16 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme
|
|||
fElement = element;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPreferenceStore getPreferenceStore() {
|
||||
return fTracepointPreferenceStore;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performOk() {
|
||||
final List<String> changedProperties = new ArrayList<String>(5);
|
||||
getPreferenceStore().addPropertyChangeListener( new IPropertyChangeListener() {
|
||||
|
||||
/**
|
||||
* @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
|
||||
*/
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent event) {
|
||||
changedProperties.add(event.getProperty());
|
||||
}
|
||||
} );
|
||||
boolean result = super.performOk();
|
||||
setBreakpointProperties(changedProperties);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void setBreakpointProperties(final List<String> changedProperties) {
|
||||
IWorkspaceRunnable wr = new IWorkspaceRunnable() {
|
||||
|
||||
@Override
|
||||
public void run( IProgressMonitor monitor ) throws CoreException {
|
||||
ICTracepoint tracepoint = getTracepoint();
|
||||
Iterator<String> changed = changedProperties.iterator();
|
||||
while(changed.hasNext()) {
|
||||
String property = changed.next();
|
||||
if (property.equals(TracepointPreferenceStore.ENABLED)) {
|
||||
tracepoint.setEnabled(getPreferenceStore().getBoolean(TracepointPreferenceStore.ENABLED));
|
||||
}
|
||||
else if (property.equals(TracepointPreferenceStore.IGNORE_COUNT)) {
|
||||
tracepoint.setIgnoreCount(getPreferenceStore().getInt(TracepointPreferenceStore.IGNORE_COUNT));
|
||||
}
|
||||
else if (property.equals(TracepointPreferenceStore.PASS_COUNT)) {
|
||||
tracepoint.setPassCount(getPreferenceStore().getInt(TracepointPreferenceStore.PASS_COUNT));
|
||||
}
|
||||
else if (property.equals(TracepointPreferenceStore.CONDITION)) {
|
||||
tracepoint.setCondition(getPreferenceStore().getString(TracepointPreferenceStore.CONDITION));
|
||||
}
|
||||
else if (property.equals(TracepointPreferenceStore.LINE)) {
|
||||
// already workspace runnable, setting markers are safe
|
||||
tracepoint.getMarker().setAttribute(IMarker.LINE_NUMBER, getPreferenceStore().getInt(TracepointPreferenceStore.LINE));
|
||||
} else {
|
||||
// this allow set attributes contributed by other plugins
|
||||
String value = getPropertyAsString(property);
|
||||
tracepoint.getMarker().setAttribute(property, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
try {
|
||||
ResourcesPlugin.getWorkspace().run(wr, null);
|
||||
}
|
||||
catch(CoreException ce) {
|
||||
GdbUIPlugin.log(ce);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return string value of given property or null.
|
||||
*/
|
||||
protected String getPropertyAsString(String property) {
|
||||
// currently only supports String and Integer
|
||||
IPreferenceStore store = getPreferenceStore();
|
||||
|
||||
if (store.contains(property)) {
|
||||
String value = store.getString(property);
|
||||
return value;
|
||||
} else return null;
|
||||
protected String[] getDebugModelIds() {
|
||||
String[] debugModelIds = null;
|
||||
Object debugContext = getDebugContext();
|
||||
IDebugModelProvider debugModelProvider = (IDebugModelProvider)
|
||||
DebugPlugin.getAdapter(debugContext, IDebugModelProvider.class);
|
||||
if (debugModelProvider != null) {
|
||||
debugModelIds = debugModelProvider.getModelIdentifiers();
|
||||
} else if (debugContext instanceof IDebugElement) {
|
||||
debugModelIds = new String[] { ((IDebugElement)debugContext).getModelIdentifier() };
|
||||
}
|
||||
return debugModelIds;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,11 +18,8 @@ public class Messages extends NLS {
|
|||
public static String TracepointPropertyPage_integer_negative;
|
||||
public static String TracepointPropertyPage_NotAvailable;
|
||||
public static String TracepointPropertyPage_FunctionName;
|
||||
public static String TracepointPropertyPage_FunctionTracepoint;
|
||||
public static String TracepointPropertyPage_Address;
|
||||
public static String TracepointPropertyPage_AddressTracepoint;
|
||||
public static String TracepointPropertyPage_File;
|
||||
public static String TracepointPropertyPage_LineTracepoint;
|
||||
public static String TracepointPropertyPage_LineNumber;
|
||||
public static String TracepointPropertyPage_Project;
|
||||
public static String TracepointPropertyPage_Condition;
|
||||
|
@ -31,7 +28,8 @@ public class Messages extends NLS {
|
|||
public static String TracepointPropertyPage_PassCount;
|
||||
public static String TracepointPropertyPage_Class;
|
||||
public static String TracepointPropertyPage_Enabled;
|
||||
|
||||
public static String TracepointPropertyPage_function_value_errorMessage;
|
||||
|
||||
public static String GdbThreadFilterEditor_Thread;
|
||||
public static String GdbThreadFilterEditor_RestrictToSelected;
|
||||
|
||||
|
|
|
@ -10,17 +10,14 @@
|
|||
# Ericsson - added Tracepoint support
|
||||
###############################################################################
|
||||
|
||||
ToggleTracepointsTargetFactory_description=Standard C/C++ tracepoint type.
|
||||
ToggleTracepointsTargetFactory_description=Standard C/C++ Tracepoint type.
|
||||
ToggleTracepointsTargetFactory_name=C/C++ Tracepoints
|
||||
|
||||
TracepointPropertyPage_integer_negative=Count must be a nonnegative integer
|
||||
TracepointPropertyPage_NotAvailable=Not available
|
||||
TracepointPropertyPage_FunctionName=Function name:
|
||||
TracepointPropertyPage_FunctionTracepoint=C/C++ function tracepoint
|
||||
TracepointPropertyPage_Address=Address:
|
||||
TracepointPropertyPage_AddressTracepoint=C/C++ address tracepoint
|
||||
TracepointPropertyPage_File=File:
|
||||
TracepointPropertyPage_LineTracepoint=C/C++ line tracepoint
|
||||
TracepointPropertyPage_LineNumber=Line number:
|
||||
TracepointPropertyPage_Project=Project:
|
||||
TracepointPropertyPage_Condition=&Condition:
|
||||
|
@ -29,6 +26,7 @@ TracepointPropertyPage_IgnoreCount=&Ignore count:
|
|||
TracepointPropertyPage_PassCount=&Pass count:
|
||||
TracepointPropertyPage_Class=Class:
|
||||
TracepointPropertyPage_Enabled=Enabled
|
||||
TracepointPropertyPage_function_value_errorMessage=Enter a function expression:
|
||||
|
||||
GdbThreadFilterEditor_Thread=Thread
|
||||
GdbThreadFilterEditor_RestrictToSelected=&Restrict to Selected Processes and Threads:
|
|
@ -1,47 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009 Ericsson 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:
|
||||
* Ericsson - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
|
||||
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
import org.eclipse.jface.preference.PreferenceStore;
|
||||
|
||||
/**
|
||||
* A preference store that presents the state of the properties of a C/C++ Tracepoint.
|
||||
*/
|
||||
public class TracepointPreferenceStore extends PreferenceStore implements IPreferenceStore {
|
||||
|
||||
protected final static String ENABLED = "ENABLED"; //$NON-NLS-1$
|
||||
|
||||
protected final static String CONDITION = "CONDITION"; //$NON-NLS-1$
|
||||
|
||||
protected final static String IGNORE_COUNT = "IGNORE_COUNT"; //$NON-NLS-1$
|
||||
|
||||
protected final static String PASS_COUNT = "PASS_COUNT"; //$NON-NLS-1$
|
||||
|
||||
protected final static String LINE = "LINE"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Constructor for TracepointPreferenceStore.
|
||||
*/
|
||||
public TracepointPreferenceStore() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to not save.
|
||||
* This store used for temporary tracepoint setting in dialogs
|
||||
* and does not require permanent storage.
|
||||
*/
|
||||
@Override
|
||||
public boolean needsSaving() {
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue