Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2009-12-18 18:59:44 +0000
committerMarc Khouzam2009-12-18 18:59:44 +0000
commit721192f2665b2a885f5c848b7e847355f8538293 (patch)
treee30f8cbe1b197ee16092e4f9fa011bb897962d54
parent959296fdd1827680bb212b5be2be31dde05c16ae (diff)
downloadorg.eclipse.cdt-721192f2665b2a885f5c848b7e847355f8538293.tar.gz
org.eclipse.cdt-721192f2665b2a885f5c848b7e847355f8538293.tar.xz
org.eclipse.cdt-721192f2665b2a885f5c848b7e847355f8538293.zip
[284286] First phase of tracepoint support. Tracepoints can now be created/deleted/enabled/disabled, we can add conditions and passcount.
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.properties4
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.xml61
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java131
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java46
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java9
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java132
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.properties9
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java5
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java60
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java58
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java57
-rw-r--r--debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF1
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/dlcl16/trcpd_obj.gifbin0 -> 316 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/icons/elcl16/trcp_obj.gifbin0 -> 348 bytes
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.properties8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml86
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CBreakpointContext.java8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java17
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java32
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties2
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCTracepointsTargetFactory.java68
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleTracepointAdapter.java328
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java3
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties6
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml16
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java153
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java443
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java20
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java4
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java88
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/TracepointPreferenceStore.java47
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties24
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_0.java1128
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java3
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java61
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java6
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java35
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIPasscount.java30
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLITrace.java49
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakInsert.java73
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakPasscount.java35
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLITraceInfo.java62
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java86
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/bin/.cvsignore3
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc96
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java1042
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java1
47 files changed, 4541 insertions, 95 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.properties b/debug/org.eclipse.cdt.debug.core/plugin.properties
index fff2ac69084..e71bd234fc0 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.core/plugin.properties
@@ -12,6 +12,7 @@
# Ken Ryall (Nokia) - Added support for Breakpoint Actions ( 118308 )
# IBM Corporation
# Texas Instruments - added extension point for source container type (279473)
+# Ericsson - Added support for Tracepoints (284286)
###############################################################################
pluginName=C/C++ Development Tools Debug Model
providerName=Eclipse CDT
@@ -29,6 +30,9 @@ cAddressBreakpoints.name=C/C++ Address Breakpoints
cFunctionBreakpoints.name=C/C++ Function Breakpoints
cWatchpoints.name=C/C++ Watchpoints
cEventBreakpoints.name=C/C++ Event Breakpoints
+cLineTracepoints.name=C/C++ Line Tracepoints
+cAddressTracepoints.name=C/C++ Address Tracepoints
+cFunctionTracepoints.name=C/C++ Function Tracepoints
breakpointProblem.name=C/C++ Breakpoint Problem
containerName.mapping=Path Mapping
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml
index 7eddf760880..4c89ce0cc3c 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.core/plugin.xml
@@ -105,6 +105,49 @@
</persistent>
</extension>
<extension
+ id="cTracepointMarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.cdt.debug.core.cLineBreakpointMarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ <attribute
+ name="org.eclipse.cdt.debug.core.passCount">
+ </attribute>
+ </extension>
+ <extension
+ id="cLineTracepointMarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.cdt.debug.core.cTracepointMarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+ <extension
+ id="cAddressTracepointMarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.cdt.debug.core.cTracepointMarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+ <extension
+ id="cFunctionTracepointMarker"
+ point="org.eclipse.core.resources.markers">
+ <super
+ type="org.eclipse.cdt.debug.core.cTracepointMarker">
+ </super>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+ <extension
id="cWatchpointMarker"
point="org.eclipse.core.resources.markers">
<super
@@ -186,6 +229,24 @@
markerType="org.eclipse.cdt.debug.core.cWatchpointMarker"
id="cWatchpoint">
</breakpoint>
+ <breakpoint
+ class="org.eclipse.cdt.debug.internal.core.breakpoints.CLineTracepoint"
+ name="%cLineTracepoints.name"
+ markerType="org.eclipse.cdt.debug.core.cLineTracepointMarker"
+ id="cLineTracepoint">
+ </breakpoint>
+ <breakpoint
+ class="org.eclipse.cdt.debug.internal.core.breakpoints.CAddressTracepoint"
+ name="%cAddressTracepoints.name"
+ markerType="org.eclipse.cdt.debug.core.cAddressTracepointMarker"
+ id="cAddressTracepoint">
+ </breakpoint>
+ <breakpoint
+ class="org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionTracepoint"
+ name="%cFunctionTracepoints.name"
+ markerType="org.eclipse.cdt.debug.core.cFunctionTracepointMarker"
+ id="cFunctionTracepoint">
+ </breakpoint>
<breakpoint
class="org.eclipse.cdt.debug.internal.core.breakpoints.CEventBreakpoint"
name="%cEventBreakpoint.name"
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
index ba9adcc4de1..ea08b7ce6c8 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006-7 QNX Software Systems and others.
+ * Copyright (c) 2009 QNX Software 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
@@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
* QNX Software Systems - catchpoints - bug 226689
+ * Ericsson - tracepoints - bug 284286
*******************************************************************************/
package org.eclipse.cdt.debug.core;
@@ -34,9 +35,12 @@ import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
+import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressTracepoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CEventBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
+import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionTracepoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
+import org.eclipse.cdt.debug.internal.core.breakpoints.CLineTracepoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.core.resources.IFile;
@@ -231,7 +235,30 @@ public class CDIDebugModel {
* </ul>
*/
public static ICLineBreakpoint createLineBreakpoint( String sourceHandle, IResource resource, int type, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setLineBreakpointAttributes( attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition );
+ return new CLineBreakpoint( resource, attributes, register );
+ }
+
+ /**
+ * @since 6.1
+ */
+ public static ICLineBreakpoint createLineTracepoint( String sourceHandle, IResource resource, int type, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setLineBreakpointAttributes( attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition );
+ return new CLineTracepoint( resource, attributes, register );
+ }
+
+ /**
+ * Helper function for setting common line breakpoint attributes.
+ */
+ private static void setLineBreakpointAttributes( HashMap<String, Object> attributes,
+ String sourceHandle,
+ Integer type,
+ int lineNumber,
+ boolean enabled,
+ int ignoreCount,
+ String condition ) {
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( IBreakpoint.ENABLED, Boolean.valueOf( enabled ) );
@@ -239,7 +266,6 @@ public class CDIDebugModel {
attributes.put( ICBreakpoint.CONDITION, condition );
attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpointType.TYPE, type );
- return new CLineBreakpoint( resource, attributes, register );
}
/**
@@ -319,21 +345,39 @@ public class CDIDebugModel {
* </ul>
*/
public static ICAddressBreakpoint createAddressBreakpoint( String module, String sourceHandle, IResource resource, int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
- attributes.put( IBreakpoint.ID, getPluginIdentifier() );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setAddressBreakpointAttributes( attributes, module, sourceHandle, type, lineNumber, address, enabled, ignoreCount, condition );
+ return new CAddressBreakpoint( resource, attributes, register );
+ }
+
+ /**
+ * @since 6.1
+ */
+ public static ICAddressBreakpoint createAddressTracepoint( String module, String sourceHandle, IResource resource, int type, int lineNumber, IAddress address, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setAddressBreakpointAttributes( attributes, module, sourceHandle, type, lineNumber, address, enabled, ignoreCount, condition );
+ return new CAddressTracepoint( resource, attributes, register );
+ }
+
+ /**
+ * Helper function for setting common address breakpoint attributes.
+ */
+ private static void setAddressBreakpointAttributes( HashMap<String, Object> attributes,
+ String module,
+ String sourceHandle,
+ int type,
+ int lineNumber,
+ IAddress address,
+ boolean enabled,
+ int ignoreCount,
+ String condition ) {
+ setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition);
attributes.put( IMarker.CHAR_START, new Integer( -1 ) );
attributes.put( IMarker.CHAR_END, new Integer( -1 ) );
- attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICLineBreakpoint.ADDRESS, address.toHexAddressString() );
- attributes.put( IBreakpoint.ENABLED, Boolean.valueOf( enabled ) );
- attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
- attributes.put( ICBreakpoint.CONDITION, condition );
- attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
attributes.put( ICBreakpoint.MODULE, module );
- attributes.put( ICBreakpointType.TYPE, type );
- return new CAddressBreakpoint( resource, attributes, register );
}
-
+
/**
* Creates and returns a watchpoint for the source defined by the given
* source handle, at the given expression. The marker associated with the
@@ -357,8 +401,8 @@ public class CDIDebugModel {
* </ul>
*/
public static ICWatchpoint createWatchpoint( String sourceHandle, IResource resource, boolean writeAccess, boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
- setAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, "", BigInteger.ZERO, enabled, ignoreCount, condition, register );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setWatchPointAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, "", BigInteger.ZERO, enabled, ignoreCount, condition, register ); //$NON-NLS-1$
return new CWatchpoint( resource, attributes, register );
}
@@ -396,8 +440,8 @@ public class CDIDebugModel {
* </ul>
*/
public static ICWatchpoint createWatchpoint( String sourceHandle, IResource resource, int charStart, int charEnd, int lineNumber, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
- setAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, range, enabled, ignoreCount, condition, register );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setWatchPointAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, range, enabled, ignoreCount, condition, register );
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
@@ -430,15 +474,15 @@ public class CDIDebugModel {
* </ul>
*/
public static ICWatchpoint createWatchpoint( String sourceHandle, IResource resource, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
- setAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, range, enabled, ignoreCount, condition, register );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setWatchPointAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, memorySpace, range, enabled, ignoreCount, condition, register );
return new CWatchpoint( resource, attributes, register );
}
/**
- * Helper function for setting common attributes.
+ * Helper function for setting common watchpoint attributes.
*/
- private static void setAttributes( HashMap attributes, String sourceHandle, IResource resource, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register ) {
+ private static void setWatchPointAttributes( HashMap<String, Object> attributes, String sourceHandle, IResource resource, boolean writeAccess, boolean readAccess, String expression, String memorySpace, BigInteger range, boolean enabled, int ignoreCount, String condition, boolean register ) {
attributes.put( IBreakpoint.ID, getPluginIdentifier() );
attributes.put( IBreakpoint.ENABLED, Boolean.valueOf( enabled ) );
attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
@@ -517,20 +561,39 @@ public class CDIDebugModel {
* </ul>
*/
public static ICFunctionBreakpoint createFunctionBreakpoint( String sourceHandle, IResource resource, int type, String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
- HashMap attributes = new HashMap( 10 );
- attributes.put( IBreakpoint.ID, getPluginIdentifier() );
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setFunctionBreakpointAttributes( attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, enabled, ignoreCount, condition);
+ return new CFunctionBreakpoint( resource, attributes, register );
+ }
+
+ /**
+ * @since 6.1
+ */
+ public static ICFunctionBreakpoint createFunctionTracepoint( String sourceHandle, IResource resource, int type, String function, int charStart, int charEnd, int lineNumber, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
+ HashMap<String, Object> attributes = new HashMap<String, Object>( 10 );
+ setFunctionBreakpointAttributes( attributes, sourceHandle, type, function, charStart, charEnd, lineNumber, enabled, ignoreCount, condition);
+ return new CFunctionTracepoint( resource, attributes, register );
+ }
+
+ /**
+ * Helper function for setting common address breakpoint attributes.
+ */
+ private static void setFunctionBreakpointAttributes( HashMap<String, Object> attributes,
+ String sourceHandle,
+ int type,
+ String function,
+ int charStart,
+ int charEnd,
+ int lineNumber,
+ boolean enabled,
+ int ignoreCount,
+ String condition ) {
+ setLineBreakpointAttributes(attributes, sourceHandle, type, lineNumber, enabled, ignoreCount, condition);
attributes.put( IMarker.CHAR_START, new Integer( charStart ) );
attributes.put( IMarker.CHAR_END, new Integer( charEnd ) );
- attributes.put( IMarker.LINE_NUMBER, new Integer( lineNumber ) );
attributes.put( ICLineBreakpoint.FUNCTION, function );
- attributes.put( IBreakpoint.ENABLED, Boolean.valueOf( enabled ) );
- attributes.put( ICBreakpoint.IGNORE_COUNT, new Integer( ignoreCount ) );
- attributes.put( ICBreakpoint.CONDITION, condition );
- attributes.put( ICBreakpoint.SOURCE_HANDLE, sourceHandle );
- attributes.put( ICBreakpointType.TYPE, type );
- return new CFunctionBreakpoint( resource, attributes, register );
}
-
+
/**
* Returns the line breakpoint that is already registered with the
* breakpoint manager for a source with the given handle and the given
@@ -707,8 +770,8 @@ public class CDIDebugModel {
if (breakpoint.getEventType().equals(type)) {
String arg1 = breakpoint.getEventArgument();
if (arg1 == null)
- arg1 = "";
- String arg2 = arg == null ? "" : arg;
+ arg1 = ""; //$NON-NLS-1$
+ String arg2 = arg == null ? "" : arg; //$NON-NLS-1$
if (arg1.equals(arg2))
return breakpoint;
}
@@ -723,7 +786,7 @@ public class CDIDebugModel {
attributes.put(IBreakpoint.ID, CDIDebugModel.getPluginIdentifier());
attributes.put(IBreakpoint.ENABLED, true);
attributes.put(ICBreakpoint.IGNORE_COUNT, 0);
- attributes.put(ICBreakpoint.CONDITION, "");
+ attributes.put(ICBreakpoint.CONDITION, ""); //$NON-NLS-1$
attributes.put(ICEventBreakpoint.EVENT_TYPE_ID, type);
attributes.put(ICEventBreakpoint.EVENT_ARG, arg);
return new CEventBreakpoint(resource, attributes, register);
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java
new file mode 100644
index 00000000000..33c11f3dc14
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICTracepoint.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.debug.core.model;
+
+import org.eclipse.core.runtime.CoreException;
+
+
+/**
+ * A tracepoint specific to the C/C++ debug model.
+ *
+ * @since 6.1
+ */
+public interface ICTracepoint extends ICLineBreakpoint {
+ /**
+ * Tracepoint attribute storing a tracepoint's pass count value (value
+ * <code>"org.eclipse.cdt.debug.core.passCount"</code>). This attribute
+ * is an <code>int</code>.
+ */
+ public static final String PASS_COUNT = "org.eclipse.cdt.debug.core.passCount"; //$NON-NLS-1$
+
+ /**
+ * Returns the pass count used by this tracepoint.
+ *
+ * @return the pass count used by this breakpoint
+ * @exception CoreException if unable to access the property on this tracepoint's
+ * underlying marker
+ */
+ public int getPassCount() throws CoreException;
+
+ /**
+ * Sets the pass count attribute for this tracepoint.
+ *
+ * @param passCount the new pass count
+ * @exception CoreException if unable to access the property on this tracepoint's
+ * underlying marker
+ */
+ public void setPassCount(int passCount) throws CoreException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java
index 528d4eb171a..d3751d86b65 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java
@@ -71,6 +71,7 @@ import org.eclipse.cdt.debug.core.model.ICEventBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICThread;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
@@ -860,7 +861,13 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
if (icbreakpoint instanceof ICBreakpointType) {
breakpointType = ((ICBreakpointType) icbreakpoint).getType();
}
- if ( icbreakpoint instanceof ICFunctionBreakpoint ) {
+ if ( icbreakpoint instanceof ICTracepoint) {
+ ICTracepoint breakpoint = (ICTracepoint)icbreakpoint;
+ IMarker marker = BreakpointProblems.reportUnsupportedTracepoint(breakpoint, getDebugTarget().getName(), getDebugTarget().getInternalID());
+ if (marker != null)
+ fBreakpointProblems.add(marker);
+ }
+ else if ( icbreakpoint instanceof ICFunctionBreakpoint ) {
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)icbreakpoint;
String function = breakpoint.getFunction();
String fileName = breakpoint.getFileName();
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java
new file mode 100644
index 00000000000..c578e3c9d00
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/AbstractTracepoint.java
@@ -0,0 +1,132 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2006 QNX Software 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:
+ * QNX Software Systems - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.internal.core.breakpoints;
+
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.model.ICBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+
+/**
+ * Base class for different types of location tracepoints.
+ */
+public abstract class AbstractTracepoint extends CBreakpoint implements ICTracepoint {
+
+ /**
+ * Constructor for AbstractTracepoint.
+ */
+ public AbstractTracepoint() {
+ super();
+ }
+
+ /**
+ * Constructor for AbstractTracepoint.
+ *
+ * @param resource
+ * @param markerType
+ * @param attributes
+ * @param add
+ * @throws CoreException
+ */
+ public AbstractTracepoint( IResource resource, String markerType, Map<String, Object> attributes, boolean add ) throws CoreException {
+ super( resource, markerType, attributes, add );
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILineBreakpoint#getLineNumber()
+ */
+ public int getLineNumber() throws CoreException {
+ return ensureMarker().getAttribute( IMarker.LINE_NUMBER, -1 );
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharStart()
+ */
+ public int getCharStart() throws CoreException {
+ return ensureMarker().getAttribute( IMarker.CHAR_START, -1 );
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.debug.core.model.ILineBreakpoint#getCharEnd()
+ */
+ public int getCharEnd() throws CoreException {
+ return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getAddress()
+ */
+ public String getAddress() throws CoreException {
+ return ensureMarker().getAttribute( ICLineBreakpoint.ADDRESS, "" ); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFileName()
+ */
+ public String getFileName() throws CoreException {
+ String fileName = ensureMarker().getAttribute( ICBreakpoint.SOURCE_HANDLE, "" ); //$NON-NLS-1$
+ IPath path = new Path( fileName );
+ return ( path.isValidPath( fileName ) ) ? path.lastSegment() : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#getFunction()
+ */
+ public String getFunction() throws CoreException {
+ return ensureMarker().getAttribute( ICLineBreakpoint.FUNCTION, "" ); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.ICBreakpoint#isConditional()
+ */
+ @Override
+ public boolean isConditional() throws CoreException {
+ return (super.isConditional() || getPassCount() > 0);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setAddress(java.lang.String)
+ */
+ public void setAddress( String address ) throws CoreException {
+ setAttribute( ICLineBreakpoint.ADDRESS, address );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.model.ICLineBreakpoint#setFunction(java.lang.String)
+ */
+ public void setFunction( String function ) throws CoreException {
+ setAttribute( ICLineBreakpoint.FUNCTION, function );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.ICTracepoint#getPassCount()
+ */
+ public int getPassCount() throws CoreException {
+ return ensureMarker().getAttribute( PASS_COUNT, 0 );
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.ICTracepoint#setPassCount(int)
+ */
+ public void setPassCount( int passCount ) throws CoreException {
+ setAttribute( PASS_COUNT, passCount );
+ setAttribute( IMarker.MESSAGE, getMarkerMessage() );
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.properties
index 6f04161756f..34374b6cb06 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.properties
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointMessages.properties
@@ -7,19 +7,26 @@
#
# Contributors:
# QNX Software Systems - initial API and implementation
+# Erisson - Added support for tracepoints (284286)
###############################################################################
# The marker message of an address breakpoint.
CAddressBreakpoint.0=Address breakpoint: {0}
+# The marker message of an address tracepoint.
+CAddressTracepoint.0=Address tracepoint: {0}
CBreakpoint.1=\ [ignore count: {0}]
CBreakpoint.2=\ if {0}
# The marker message of a function breakpoint.
CFunctionBreakpoint.0=Function breakpoint: {0}
+# The marker message of a function tracepoint.
+CFunctionTracepoint.0=Function tracepoint: {0}
# The marker message of a line breakpoint.
CLineBreakpoint.0=Line breakpoint: {0}
+# The marker message of a line tracepoint.
+CLineTracepoint.0=Line tracepoint: {0}
# The marker message of a write watchpoint.
CWatchpoint.0=Write watchpoint: {0}
@@ -34,3 +41,5 @@ CWatchpoint.2=Access watchpoint: {0}
CWatchpoint.3=Watchpoint: {0}
BreakpointProblems_Moved=Breakpoint could not be set at line {0}, moved to line {1}
BreakpointProblems_Unresolved=Unresolved breakpoint
+
+BreakpointProblems_UnsupportedTracepoint=Tracepoints are not supported
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java
index 6ac1c081e0a..a2c9840b410 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/BreakpointProblems.java
@@ -48,6 +48,11 @@ public class BreakpointProblems {
return marker;
}
+ public static IMarker reportUnsupportedTracepoint(ICBreakpoint breakpoint, String contextName, String contextID) throws CoreException {
+ IMarker marker = BreakpointProblems.reportBreakpointProblem(breakpoint, BreakpointMessages.getString("BreakpointProblems_UnsupportedTracepoint"), IMarker.SEVERITY_WARNING, UNRESOLVED, true, false, contextName, contextID); //$NON-NLS-1$
+ return marker;
+ }
+
public static void removeProblemsForBreakpoint(ICBreakpoint breakpoint) throws CoreException {
IMarker marker = breakpoint.getMarker();
if (marker != null)
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java
new file mode 100644
index 00000000000..cdbbaf58ac6
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CAddressTracepoint.java
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.debug.internal.core.breakpoints;
+
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+import com.ibm.icu.text.MessageFormat;
+
+/**
+ * A tracepoint that collects data when a particular address is reached.
+ *
+ * @since 6.1
+ */
+public class CAddressTracepoint extends AbstractTracepoint implements ICAddressBreakpoint, ICTracepoint {
+
+ private static final String C_ADDRESS_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cAddressTracepointMarker"; //$NON-NLS-1$
+
+ /**
+ * Constructor for CAddressTracepoint.
+ */
+ public CAddressTracepoint() {
+ }
+
+ /**
+ * Constructor for CAddressTracepoint.
+ */
+ public CAddressTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
+ super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType() {
+ return C_ADDRESS_TRACEPOINT_MARKER;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
+ */
+ protected String getMarkerMessage() throws CoreException {
+ return MessageFormat.format( BreakpointMessages.getString( "CAddressTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java
new file mode 100644
index 00000000000..5b6d3a37aaf
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CFunctionTracepoint.java
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * 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.debug.internal.core.breakpoints;
+
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+import com.ibm.icu.text.MessageFormat;
+
+/**
+ * A tracepoint that collects data when a function is entered.
+ *
+ * @since 6.1
+ */
+public class CFunctionTracepoint extends AbstractTracepoint implements ICFunctionBreakpoint, ICTracepoint {
+
+ private static final String C_FUNCTION_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cFunctionTracepointMarker"; //$NON-NLS-1$
+
+ /**
+ * Constructor for CFunctionTracepoint.
+ */
+ public CFunctionTracepoint() {
+ }
+
+ /**
+ * Constructor for CFunctionTracepoint.
+ */
+ public CFunctionTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
+ super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType() {
+ return C_FUNCTION_TRACEPOINT_MARKER;
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
+ */
+ protected String getMarkerMessage() throws CoreException {
+ return MessageFormat.format( BreakpointMessages.getString( "CFunctionTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java
new file mode 100644
index 00000000000..eab231f66d7
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CLineTracepoint.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * 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.debug.internal.core.breakpoints;
+
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.CDebugUtils;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+
+import com.ibm.icu.text.MessageFormat;
+
+/**
+ * A tracepoint that collects data when a particular line of code is reached.
+ *
+ * @since 6.1
+ */
+public class CLineTracepoint extends AbstractTracepoint implements ICTracepoint {
+
+ private static final String C_LINE_TRACEPOINT_MARKER = "org.eclipse.cdt.debug.core.cLineTracepointMarker"; //$NON-NLS-1$
+
+ /**
+ * Constructor for CLineTracepoint.
+ */
+ public CLineTracepoint() {
+ }
+
+ /**
+ * Constructor for CLineTracepoint.
+ */
+ public CLineTracepoint( IResource resource, Map<String, Object> attributes, boolean add ) throws CoreException {
+ super( resource, getMarkerType(), attributes, add );
+ }
+
+ /**
+ * Returns the type of marker associated with this type of breakpoints
+ */
+ public static String getMarkerType() {
+ return C_LINE_TRACEPOINT_MARKER;
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint#getMarkerMessage()
+ */
+ protected String getMarkerMessage() throws CoreException {
+ return MessageFormat.format( BreakpointMessages.getString( "CLineTracepoint.0" ), new String[] { CDebugUtils.getBreakpointText( this, false ) } ); //$NON-NLS-1$
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
index 10664129a1a..0611e1b17dc 100644
--- a/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
+++ b/debug/org.eclipse.cdt.debug.ui/META-INF/MANIFEST.MF
@@ -25,6 +25,7 @@ Export-Package:
org.eclipse.cdt.debug.ui.disassembly,
org.eclipse.cdt.debug.ui.editors,
org.eclipse.cdt.debug.ui.importexecutable,
+ org.eclipse.cdt.debug.ui.preferences,
org.eclipse.cdt.debug.ui.sourcelookup
Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.2.0,4.0.0)",
org.eclipse.jface.text;bundle-version="[3.2.0,4.0.0)",
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/trcpd_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/trcpd_obj.gif
new file mode 100644
index 00000000000..76c65b6196f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/icons/dlcl16/trcpd_obj.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/icons/elcl16/trcp_obj.gif b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/trcp_obj.gif
new file mode 100644
index 00000000000..29ec606076f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/icons/elcl16/trcp_obj.gif
Binary files differ
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.properties b/debug/org.eclipse.cdt.debug.ui/plugin.properties
index bd147530149..4779c044db0 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.properties
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.properties
@@ -216,4 +216,10 @@ ReverseStepOver.description = Perform Reverse StepOver
ReverseStepOver.label = Reverse StepOver
Uncall.name = Uncall
Uncall.description = Perform Uncall
-Uncall.label = Uncall \ No newline at end of file
+Uncall.label = Uncall
+
+# Menu for selecting breakpoint toggle type
+BreakpointTypes.label=B&reakpoint Types
+
+# Tracepoints
+TracepointActionSet.label=Tracepoints
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index e313695e81e..ec258095b59 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -1247,9 +1247,14 @@
id="org.eclipse.cdt.debug.ui.propertypages.breakpoint.common"
name="%CommonBreakpointPage.label">
<enabledWhen>
- <adapt
- type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
- </adapt>
+ <and>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
+ </adapt>
+ <not>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint">
+ </adapt>
+ </not>
+ </and>
</enabledWhen>
</page>
<page
@@ -1257,9 +1262,14 @@
id="org.eclipse.cdt.debug.ui.breakpointactions.actions"
name="%BreakpointActionsPage.label">
<enabledWhen>
- <adapt
- type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
- </adapt>
+ <and>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
+ </adapt>
+ <not>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint">
+ </adapt>
+ </not>
+ </and>
</enabledWhen>
</page>
<page class="org.eclipse.cdt.debug.internal.ui.propertypages.CBreakpointFilteringPage"
@@ -1267,7 +1277,14 @@
name="%FilteringBreakpointPage.label">
<filter name="debugModelId" value="org.eclipse.cdt.debug.core"/>
<enabledWhen>
- <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint"/>
+ <and>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint">
+ </adapt>
+ <not>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint">
+ </adapt>
+ </not>
+ </and>
</enabledWhen>
</page>
<page
@@ -1907,6 +1924,34 @@
</or>
</enablement>
</toggleTargetFactory>
+ <toggleTargetFactory
+ id="org.eclipse.cdt.debug.ui.ToggleCTracepointsTargetFactory"
+ class="org.eclipse.cdt.debug.internal.ui.actions.ToggleCTracepointsTargetFactory">
+ <enablement>
+ <!-- Enable the breakpoint toggle for CDT's editors and model elements -->
+ <and>
+ <reference
+ definitionId="org.eclipse.cdt.debug.ui.testIsTracepointActionSetActive">
+ </reference>
+ <or>
+ <instanceof value="org.eclipse.cdt.internal.ui.editor.CEditor"/>
+ <instanceof value="org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor"/>
+ <instanceof value="org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView"/>
+ <instanceof value="org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditor"/>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <or>
+ <instanceof value="org.eclipse.cdt.core.model.IFunction"/>
+ <instanceof value="org.eclipse.cdt.core.model.IMethod"/>
+ <instanceof value="org.eclipse.cdt.core.model.IVariable"/>
+ </or>
+ </iterate>
+ </with>
+ </or>
+ </and>
+ </enablement>
+ </toggleTargetFactory>
</extension>
<extension
point="org.eclipse.ui.actionSets">
@@ -1915,6 +1960,11 @@
label="%ReverseActionSet.label"
visible="false">
</actionSet>
+ <actionSet
+ id="org.eclipse.cdt.debug.ui.tracepointActionSet"
+ label="%TracepointActionSet.label"
+ visible="false">
+ </actionSet>
</extension>
<extension
point="org.eclipse.ui.commands">
@@ -2013,6 +2063,14 @@
</or>
</and>
</definition>
+ <definition id="org.eclipse.cdt.debug.ui.testIsTracepointActionSetActive">
+ <with variable="activeContexts">
+ <iterate operator="or">
+ <equals value="org.eclipse.cdt.debug.ui.tracepointActionSet">
+ </equals>
+ </iterate>
+ </with>
+ </definition>
</extension>
<extension
point="org.eclipse.ui.bindings">
@@ -2269,4 +2327,18 @@
</command>
</menuContribution>
</extension>
+ <extension
+ point="org.eclipse.ui.popupMenus">
+ <viewerContribution
+ id="org.eclipse.cdt.debug.ui.breakpointTypeMenu"
+ targetID="#CEditorRulerContext">
+ <action
+ class="org.eclipse.debug.ui.actions.RulerBreakpointTypesActionDelegate"
+ id="org.eclipse.cdt.debug.ui.breakpointTypesAction"
+ label="%BreakpointTypes.label"
+ menubarPath="debug"
+ style="pulldown">
+ </action>
+ </viewerContribution>
+ </extension>
</plugin>
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CBreakpointContext.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CBreakpointContext.java
index 7a08e33ef03..265b74367a1 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CBreakpointContext.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CBreakpointContext.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems and others.
+ * Copyright (c) 2009 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
@@ -7,10 +7,12 @@
*
* Contributors:
* Wind River Systems - initial API and implementation
+ * Ericsson - Added tracepoint support (284286)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.core.runtime.Platform;
@@ -76,7 +78,7 @@ class CBreakpointContextActionFilter implements IActionFilter {
public boolean testAttribute(Object target, String name, String value) {
if (target instanceof CBreakpointContext) {
- if ("debugModelId".equals(name)) {
+ if ("debugModelId".equals(name)) { //$NON-NLS-1$
String[] targetModelIds = getDebugModelIds( (CBreakpointContext)target );
for (int i = 0; i < targetModelIds.length; i++) {
if (targetModelIds[i].equals(value)) {
@@ -113,7 +115,7 @@ class CBreakpointContextActionFilter implements IActionFilter {
class CBreakpointContextAdapterFactory implements IAdapterFactory {
private static final Class[] fgAdapterList = new Class[] {
- IBreakpoint.class, ICBreakpoint.class, IActionFilter.class
+ IBreakpoint.class, ICBreakpoint.class, ICTracepoint.class, IActionFilter.class
};
private static final IActionFilter fgActionFilter = new CBreakpointContextActionFilter();
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
index 40449f463da..b1e0a3fae0e 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugImages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 QNX Software Systems and others.
+ * Copyright (c) 2009 QNX Software 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
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Ericsson - Added tracepoint support (284286)
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui;
@@ -48,7 +49,7 @@ public class CDebugImages {
// The plugin registry
private static ImageRegistry fgImageRegistry = null;
- private static HashMap fgAvoidSWTErrorMap = null;
+ private static HashMap<String, ImageDescriptor> fgAvoidSWTErrorMap = null;
/*
* Available cached Images in the C/C++ debug plug-in image registry.
@@ -74,6 +75,8 @@ public class CDebugImages {
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$
public static final String IMG_OBJS_FUNCTION_BREAKPOINT_DISABLED = NAME_PREFIX + "funbrkpd_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TRACEPOINT_ENABLED = NAME_PREFIX + "trcp_obj.gif"; //$NON-NLS-1$
+ public static final String IMG_OBJS_TRACEPOINT_DISABLED = NAME_PREFIX + "trcpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_WATCHPOINT_ENABLED = NAME_PREFIX + "readwrite_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_WATCHPOINT_DISABLED = NAME_PREFIX + "readwrite_obj_disabled.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_READ_WATCHPOINT_ENABLED = NAME_PREFIX + "read_obj.gif"; //$NON-NLS-1$
@@ -154,6 +157,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_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 );
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_DISABLED );
public static final ImageDescriptor DESC_OBJS_READ_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_READ_WATCHPOINT_ENABLED );
@@ -236,10 +241,10 @@ public class CDebugImages {
if ( fgImageRegistry == null )
{
fgImageRegistry = new ImageRegistry();
- for ( Iterator iter = fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext(); )
+ for ( Iterator<String> iter = fgAvoidSWTErrorMap.keySet().iterator(); iter.hasNext(); )
{
- String key = (String)iter.next();
- fgImageRegistry.put( key, (ImageDescriptor)fgAvoidSWTErrorMap.get( key ) );
+ String key = iter.next();
+ fgImageRegistry.put( key, fgAvoidSWTErrorMap.get( key ) );
}
fgAvoidSWTErrorMap = null;
}
@@ -283,7 +288,7 @@ public class CDebugImages {
ImageDescriptor result = ImageDescriptor.createFromURL( makeIconFileURL( prefix, name.substring( NAME_PREFIX_LENGTH ) ) );
if ( fgAvoidSWTErrorMap == null )
{
- fgAvoidSWTErrorMap = new HashMap();
+ fgAvoidSWTErrorMap = new HashMap<String, ImageDescriptor>();
}
fgAvoidSWTErrorMap.put( name, result );
if ( fgImageRegistry != null )
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
index 1ff564509ef..ad3d25290f3 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugModelPresentation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2008 QNX Software Systems and others.
+ * Copyright (c) 2009 QNX Software 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
@@ -10,11 +10,11 @@
* Ken Ryall (Nokia) - Added support for CSourceNotFoundElement ( 167305 )
* ARM Limited - https://bugs.eclipse.org/bugs/show_bug.cgi?id=186981
* Ken Ryall (Nokia) - Bug 201165 don't toss images on dispose.
+ * Ericsson - Bug 284286 support for tracepoints
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui;
import java.io.File;
-import com.ibm.icu.text.MessageFormat;
import java.util.HashMap;
import org.eclipse.cdt.core.IAddress;
@@ -44,6 +44,7 @@ import org.eclipse.cdt.debug.core.model.ICModule;
import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICThread;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable;
@@ -97,6 +98,8 @@ import org.eclipse.ui.IEditorRegistry;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
+import com.ibm.icu.text.MessageFormat;
+
/**
* @see IDebugModelPresentation
*/
@@ -106,7 +109,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
private static final String DUMMY_STACKFRAME_LABEL = "..."; //$NON-NLS-1$
- protected HashMap fAttributes = new HashMap( 3 );
+ protected HashMap<String, Object> fAttributes = new HashMap<String, Object>( 3 );
protected CDebugImageDescriptorRegistry fDebugImageRegistry = CDebugUIPlugin.getImageDescriptorRegistry();
@@ -318,6 +321,10 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
if (image!=null) return image;
}
try {
+ // Check for ICTracepoint first because they are also ICLineBreakpoint
+ if ( breakpoint instanceof ICTracepoint ) {
+ return getTracepointImage( (ICTracepoint)breakpoint );
+ }
if ( breakpoint instanceof ICLineBreakpoint ) {
return getLineBreakpointImage( (ICLineBreakpoint)breakpoint );
}
@@ -330,6 +337,17 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return null;
}
+ protected Image getTracepointImage( ICTracepoint tracepoint ) throws CoreException {
+ ImageDescriptor descriptor = null;
+ if ( tracepoint.isEnabled() ) {
+ descriptor = CDebugImages.DESC_OBJS_TRACEPOINT_ENABLED;
+ }
+ else {
+ descriptor = CDebugImages.DESC_OBJS_TRACEPOINT_DISABLED;
+ }
+ return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( tracepoint ) ) );
+ }
+
protected Image getLineBreakpointImage( ICLineBreakpoint breakpoint ) throws CoreException {
ImageDescriptor descriptor = null;
if ( breakpoint.isEnabled() ) {
@@ -338,7 +356,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
else {
descriptor = CDebugImages.DESC_OBJS_BREAKPOINT_DISABLED;
}
- return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( breakpoint ) ) );
+ return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( breakpoint ) ) );
}
protected Image getWatchpointImage( ICWatchpoint watchpoint ) throws CoreException {
@@ -359,7 +377,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
else
descriptor = CDebugImages.DESC_OBJS_WATCHPOINT_DISABLED;
}
- return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeBreakpointOverlays( watchpoint ) ) );
+ return getImageCache().getImageFor( new OverlayImageDescriptor( fDebugImageRegistry.get( descriptor ), computeOverlays( watchpoint ) ) );
}
@Override
@@ -478,7 +496,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return showQualified.booleanValue();
}
- private HashMap getAttributes() {
+ private HashMap<String, Object> getAttributes() {
return this.fAttributes;
}
@@ -494,7 +512,7 @@ public class CDebugModelPresentation extends LabelProvider implements IDebugMode
return DebugPlugin.getDefault().getBreakpointManager().getBreakpoint( marker );
}
- private ImageDescriptor[] computeBreakpointOverlays( ICBreakpoint breakpoint ) {
+ private ImageDescriptor[] computeOverlays( ICBreakpoint breakpoint ) {
ImageDescriptor[] overlays = new ImageDescriptor[]{ null, null, null, null };
try {
if ( CDebugCorePlugin.getDefault().getBreakpointActionManager().breakpointHasActions(breakpoint) ) {
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 ea66c7cf616..ee7cc57b849 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
@@ -127,3 +127,5 @@ AddEventBreakpointActionDelegate.0=Error adding Event Breakpoint
AddEventBreakpointActionDelegate.2=Action is not supported by installed debuggers
ToggleCBreakpointsTargetFactory.CBreakpointDescription=Standard C/C++ breakpoint type.
ToggleCBreakpointsTargetFactory.CBreakpointName=C/C++ Breakpoints
+ToggleCBreakpointsTargetFactory.CTracepointDescription=Standard C/C++ tracepoint type.
+ToggleCBreakpointsTargetFactory.CTracepointName=C/C++ Tracepoints
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCTracepointsTargetFactory.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCTracepointsTargetFactory.java
new file mode 100644
index 00000000000..9e5822c157a
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleCTracepointsTargetFactory.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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.debug.internal.ui.actions;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Toggle tracepoints target factory for the CEditor.
+ * We use a separate factory so that we can control it through an action set.
+ *
+ * @since 6.1
+ */
+public class ToggleCTracepointsTargetFactory implements IToggleBreakpointsTargetFactory {
+
+ public static String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.getUniqueIdentifier() + ".toggleCTracepointTarget"; //$NON-NLS-1$
+
+ private static Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1);
+ static {
+ TOGGLE_TARGET_IDS.add(TOGGLE_C_TRACEPOINT_TARGET_ID);
+ }
+
+ private ToggleTracepointAdapter fCToggleTracepointTarget = new ToggleTracepointAdapter();
+
+ public IToggleBreakpointsTarget createToggleTarget(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return fCToggleTracepointTarget;
+ }
+ return null;
+ }
+
+ public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
+ return null;
+ }
+
+ public String getToggleTargetDescription(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointDescription"); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ public String getToggleTargetName(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return ActionMessages.getString("ToggleCBreakpointsTargetFactory.CTracepointName"); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set getToggleTargets(IWorkbenchPart part, ISelection selection) {
+ return TOGGLE_TARGET_IDS;
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleTracepointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleTracepointAdapter.java
new file mode 100644
index 00000000000..7b331596eab
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleTracepointAdapter.java
@@ -0,0 +1,328 @@
+/*******************************************************************************
+ * 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.debug.internal.ui.actions;
+
+import org.eclipse.cdt.core.model.CModelException;
+import org.eclipse.cdt.core.model.CoreModel;
+import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.IDeclaration;
+import org.eclipse.cdt.core.model.IFunction;
+import org.eclipse.cdt.core.model.IFunctionDeclaration;
+import org.eclipse.cdt.core.model.IMethod;
+import org.eclipse.cdt.core.model.ISourceRange;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.model.ICBreakpointType;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.internal.ui.CDebugUIUtils;
+import org.eclipse.cdt.debug.internal.ui.IInternalCDebugUIConstants;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
+import org.eclipse.cdt.ui.CDTUITools;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * Toggles a tracepoint in a C/C++ editor.
+ */
+public class ToggleTracepointAdapter implements IToggleBreakpointsTarget {
+
+ /**
+ * Toggle a line tracepoint
+ */
+ public void toggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
+ String errorMessage = null;
+ if ( part instanceof ITextEditor ) {
+ ITextEditor textEditor = (ITextEditor)part;
+ IEditorInput input = textEditor.getEditorInput();
+ if ( input == null ) {
+ errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Empty_editor_1" ); //$NON-NLS-1$
+ }
+ else {
+ IDocument document = textEditor.getDocumentProvider().getDocument( input );
+ if ( document == null ) {
+ errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_document_1" ); //$NON-NLS-1$
+ }
+ else {
+ IResource resource = getResource( textEditor );
+ if ( resource == null ) {
+ errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Missing_resource_1" ); //$NON-NLS-1$
+ }
+ else {
+ BreakpointLocationVerifier bv = new BreakpointLocationVerifier();
+ int lineNumber = bv.getValidLineBreakpointLocation( document, ((ITextSelection)selection).getStartLine() );
+ if ( lineNumber == -1 ) {
+ errorMessage = ActionMessages.getString( "ToggleBreakpointAdapter.Invalid_line_1" ); //$NON-NLS-1$
+ }
+ else {
+ String sourceHandle = getSourceHandle( input );
+ // the method lineBreakpointExists also works for tracepoints
+ ICLineBreakpoint breakpoint = CDIDebugModel.lineBreakpointExists( sourceHandle, resource, lineNumber );
+ if ( breakpoint != null ) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
+ }
+ else {
+ CDIDebugModel.createLineTracepoint( sourceHandle,
+ resource,
+ ICBreakpointType.REGULAR,
+ lineNumber,
+ true,
+ 0,
+ "", //$NON-NLS-1$
+ true );
+ }
+ return;
+ }
+ }
+ }
+ }
+ }
+ else {
+ errorMessage = ActionMessages.getString( "RunToLineAdapter.Operation_is_not_supported_1" ); //$NON-NLS-1$
+ }
+ throw new CoreException( new Status( IStatus.ERROR, CDebugUIPlugin.getUniqueIdentifier(), IInternalCDebugUIConstants.INTERNAL_ERROR, errorMessage, null ) );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleLineBreakpoints( IWorkbenchPart part, ISelection selection ) {
+ return ( selection instanceof ITextSelection );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
+ ICElement element = getCElementFromSelection( part, selection );
+ if ( element instanceof IFunction || element instanceof IMethod ) {
+ toggleMethodBreakpoints0( (IDeclaration)element );
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleMethodBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleMethodBreakpoints( IWorkbenchPart part, ISelection selection ) {
+ ICElement element = getCElementFromSelection( part, selection );
+ return ( element instanceof IFunction || element instanceof IMethod );
+ }
+
+ protected ICElement getCElementFromSelection( IWorkbenchPart part, ISelection selection ) {
+ if ( selection instanceof ITextSelection ) {
+ ITextSelection textSelection = (ITextSelection)selection;
+ String text = textSelection.getText();
+ if ( text != null ) {
+ if (part instanceof ITextEditor) {
+ ICElement editorElement = CDTUITools.getEditorInputCElement(((ITextEditor) part).getEditorInput());
+ if (editorElement instanceof ITranslationUnit) {
+ ITranslationUnit tu = (ITranslationUnit) editorElement;
+ try {
+ if (tu.isStructureKnown() && tu.isConsistent()) {
+ return tu.getElementAtOffset( textSelection.getOffset() );
+ }
+ } catch (CModelException exc) {
+ // ignored on purpose
+ }
+ }
+ } else {
+ IResource resource = getResource( part );
+ if ( resource instanceof IFile ) {
+ ITranslationUnit tu = getTranslationUnit( (IFile)resource );
+ if ( tu != null ) {
+ try {
+ ICElement element = tu.getElement( text.trim() );
+ if ( element == null ) {
+ element = tu.getElementAtLine( textSelection.getStartLine() );
+ }
+ return element;
+ }
+ catch( CModelException e ) {
+ }
+ }
+ }
+ }
+ }
+ }
+ else if ( selection instanceof IStructuredSelection ) {
+ IStructuredSelection ss = (IStructuredSelection)selection;
+ if ( ss.size() == 1 ) {
+ Object object = ss.getFirstElement();
+ if ( object instanceof ICElement ) {
+ return (ICElement)object;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleWatchpoints( IWorkbenchPart part, ISelection selection ) throws CoreException {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#canToggleWatchpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleWatchpoints( IWorkbenchPart part, ISelection selection ) {
+ return false;
+ }
+
+ protected static IResource getResource( IWorkbenchPart part ) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if ( part instanceof IEditorPart ) {
+ IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
+ IResource resource = null;
+ if ( editorInput instanceof IFileEditorInput ) {
+ resource = ((IFileEditorInput)editorInput).getFile();
+ } else if (editorInput instanceof ExternalEditorInput) {
+ resource = ((ExternalEditorInput)editorInput).getMarkerResource();
+ }
+ if (resource != null)
+ return resource;
+ /* This file is not in a project, let default case handle it */
+ ILocationProvider provider = (ILocationProvider)editorInput.getAdapter( ILocationProvider.class );
+ if ( provider != null ) {
+ IPath location = provider.getPath( editorInput );
+ if ( location != null ) {
+ IFile[] files = root.findFilesForLocation( location );
+ if ( files.length > 0 )
+ return files[0];
+ }
+ }
+ }
+ return root;
+ }
+
+ private String getSourceHandle( IEditorInput input ) throws CoreException {
+ return CDebugUIUtils.getEditorFilePath(input);
+ }
+
+ private String getSourceHandle( IDeclaration declaration ) {
+ ITranslationUnit tu = declaration.getTranslationUnit();
+ if ( tu != null ) {
+ IPath location = tu.getLocation();
+ if (location != null) {
+ return location.toOSString();
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ private IResource getElementResource( IDeclaration declaration ) {
+ return declaration.getUnderlyingResource();
+ }
+
+ private String getFunctionName( IFunction function ) {
+ String functionName = function.getElementName();
+ StringBuffer name = new StringBuffer( functionName );
+ ITranslationUnit tu = function.getTranslationUnit();
+ if ( tu != null && tu.isCXXLanguage() ) {
+ appendParameters( name, function );
+ }
+ return name.toString();
+ }
+
+ private String getMethodName( IMethod method ) {
+ StringBuffer name = new StringBuffer();
+ String methodName = method.getElementName();
+ ICElement parent = method.getParent();
+ while ( parent != null && ( parent.getElementType() == ICElement.C_NAMESPACE || parent.getElementType() == ICElement.C_CLASS
+ || parent.getElementType() == ICElement.C_STRUCT || parent.getElementType() == ICElement.C_UNION ) ) {
+ name.append( parent.getElementName() ).append( "::" ); //$NON-NLS-1$
+ parent = parent.getParent();
+ }
+ name.append( methodName );
+ appendParameters( name, method );
+ return name.toString();
+ }
+
+ private void appendParameters( StringBuffer sb, IFunctionDeclaration fd ) {
+ String[] params = fd.getParameterTypes();
+ sb.append( '(' );
+ for( int i = 0; i < params.length; ++i ) {
+ sb.append( params[i] );
+ if ( i != params.length - 1 )
+ sb.append( ',' );
+ }
+ sb.append( ')' );
+ }
+
+ private ITranslationUnit getTranslationUnit( IFile file ) {
+ Object element = CoreModel.getDefault().create( file );
+ if ( element instanceof ITranslationUnit ) {
+ return (ITranslationUnit)element;
+ }
+ return null;
+ }
+
+ private void toggleMethodBreakpoints0( IDeclaration declaration ) throws CoreException {
+ String sourceHandle = getSourceHandle( declaration );
+ IResource resource = getElementResource( declaration );
+ String functionName = ( declaration instanceof IFunction ) ? getFunctionName( (IFunction)declaration ) : getMethodName( (IMethod)declaration );
+ // The method functionBreakpointExists also works for tracepoints
+ ICFunctionBreakpoint breakpoint = CDIDebugModel.functionBreakpointExists( sourceHandle, resource, functionName );
+ if ( breakpoint != null ) {
+ DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( breakpoint, true );
+ }
+ else {
+ int lineNumber = -1;
+ int charStart = -1;
+ int charEnd = -1;
+ try {
+ ISourceRange sourceRange = declaration.getSourceRange();
+ if ( sourceRange != null ) {
+ charStart = sourceRange.getStartPos();
+ charEnd = charStart + sourceRange.getLength();
+ if ( charEnd <= 0 ) {
+ charStart = -1;
+ charEnd = -1;
+ }
+ lineNumber = sourceRange.getStartLine();
+ }
+ }
+ catch( CModelException e ) {
+ DebugPlugin.log( e );
+ }
+ CDIDebugModel.createFunctionTracepoint( sourceHandle,
+ resource,
+ ICBreakpointType.REGULAR,
+ functionName,
+ charStart,
+ charEnd,
+ lineNumber,
+ true,
+ 0,
+ "", //$NON-NLS-1$
+ true );
+ }
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java
index d0e104b3c6b..3f0fc19a55c 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java
@@ -20,6 +20,9 @@ import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
+/**
+ * @since 6.1
+ */
public class ReadOnlyFieldEditor extends FieldEditor implements ICBreakpointsUIContributionUser {
protected Label textField;
protected ICBreakpointsUIContribution contribution;
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties
index 3ba2603d009..3b671d0714c 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.properties
@@ -24,4 +24,8 @@ launchTab.sourceLookup.name=Source
launchTab.common.name=Common
editorTextHover.label=GDB Debugger
-editorTextHover.description=Shows formatted value in debugger hover \ No newline at end of file
+editorTextHover.description=Shows formatted value in debugger hover
+
+breakpoints.property.filter=Filter
+tracepoints.property.common=Common
+tracepoints.property.actions=Actions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
index b6145902b6b..bc4821f5cbd 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/plugin.xml
@@ -183,10 +183,22 @@
<extension point="org.eclipse.ui.propertyPages">
<page class="org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints.CBreakpointGdbThreadFilterPage"
id="org.eclipse.cdt.dsf.gdb.breakpoint.filtering"
- name="Filter">
+ name="%breakpoints.property.filter">
<filter name="debugModelId" value="org.eclipse.cdt.dsf.gdb"/>
<enabledWhen>
- <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint"/>
+ <and>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint"/>
+ <not>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
+ </not>
+ </and>
+ </enabledWhen>
+ </page>
+ <page class="org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints.GDBTracepointPropertyPage"
+ id="org.eclipse.cdt.dsf.gdb.tracepoint.common"
+ name="%tracepoints.property.common">
+ <enabledWhen>
+ <adapt type="org.eclipse.cdt.debug.core.model.ICTracepoint"/>
</enabledWhen>
</page>
</extension>
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java
new file mode 100644
index 00000000000..99e4f2809ec
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/DisassemblyToggleTracepointsTarget.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
+
+import java.math.BigInteger;
+import java.net.URI;
+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.ICBreakpointType;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblySelection;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblySelection;
+import org.eclipse.cdt.utils.Addr64;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
+
+/**
+ * Toggle tracepoint target implementation for the disassembly part.
+ */
+public class DisassemblyToggleTracepointsTarget implements IToggleBreakpointsTargetExtension {
+
+ public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ assert part instanceof IDisassemblyPart && selection instanceof ITextSelection;
+
+ if (!(selection instanceof IDisassemblySelection)) {
+ selection = new DisassemblySelection((ITextSelection) selection, (IDisassemblyPart) part);
+ }
+ IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
+ int line = disassemblySelection.getStartLine();
+ IBreakpoint[] bp = getBreakpointsAtLine((IDisassemblyPart) part, line);
+ if (bp == null || bp.length == 0) {
+ insertBreakpoint(disassemblySelection);
+ } else {
+ for (int i = 0; i < bp.length; i++) {
+ bp[i].delete();
+ }
+ }
+ }
+
+ public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return part instanceof IDisassemblyPart && selection instanceof ITextSelection;
+ }
+
+ public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ }
+
+ public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return false;
+ }
+
+ public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ }
+
+ public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
+ return false;
+ }
+ /*
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#canToggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public boolean canToggleBreakpoints(IWorkbenchPart part, ISelection selection) {
+ return canToggleLineBreakpoints(part, selection);
+ }
+ /*
+ * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTargetExtension#toggleBreakpoints(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void toggleBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+ toggleLineBreakpoints(part, selection);
+ }
+
+ private IBreakpoint[] getBreakpointsAtLine(IDisassemblyPart part, int line) {
+ List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>();
+ IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel();
+ IDocument document = part.getTextViewer().getDocument();
+ if (annotationModel != null) {
+ Iterator<?> iterator = annotationModel.getAnnotationIterator();
+ while (iterator.hasNext()) {
+ Object object = iterator.next();
+ if (object instanceof SimpleMarkerAnnotation) {
+ SimpleMarkerAnnotation markerAnnotation = (SimpleMarkerAnnotation) object;
+ IMarker marker = markerAnnotation.getMarker();
+ try {
+ if (marker.isSubtypeOf(IBreakpoint.BREAKPOINT_MARKER)) {
+ Position position = annotationModel.getPosition(markerAnnotation);
+ int bpLine = document.getLineOfOffset(position.getOffset());
+ if (line == bpLine) {
+ IBreakpoint breakpoint = DebugPlugin.getDefault().getBreakpointManager().getBreakpoint(marker);
+ if (breakpoint != null) {
+ breakpoints.add(breakpoint);
+ }
+ }
+ }
+ } catch (CoreException e) {
+ } catch (BadLocationException e) {
+ }
+ }
+ }
+ }
+ IBreakpoint[] breakpointsArray = new IBreakpoint[breakpoints.size()];
+ return breakpoints.toArray(breakpointsArray );
+ }
+ private void insertBreakpoint(IDisassemblySelection selection) throws CoreException {
+ BigInteger address = selection.getStartAddress();
+ if (address == null) {
+ return;
+ }
+ URI fileUri = selection.getSourceLocationURI();
+ if (fileUri != null) {
+ String filePath = null;
+ IResource resource = selection.getSourceFile();
+ if (resource != null) {
+ final IPath location= resource.getLocation();
+ if (location == null) {
+ return;
+ }
+ filePath = location.toOSString();
+ } else {
+ resource = ResourcesPlugin.getWorkspace().getRoot();
+ filePath = URIUtil.toPath(fileUri).toOSString();
+ }
+ int srcLine = selection.getSourceLine();
+ CDIDebugModel.createLineTracepoint(filePath, resource, ICBreakpointType.REGULAR, srcLine + 1, true, 0, "", true); //$NON-NLS-1$
+ } else {
+ IResource resource = ResourcesPlugin.getWorkspace().getRoot();
+ CDIDebugModel.createAddressTracepoint(null, null, resource, ICBreakpointType.REGULAR, -1, new Addr64(address), true, 0, "", true); //$NON-NLS-1$
+ }
+ }
+} \ No newline at end of file
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java
new file mode 100644
index 00000000000..3c166416bbd
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java
@@ -0,0 +1,443 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
+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.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+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.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbenchPropertyPage;
+
+/**
+ * The preference page used to present the properties of a GDB tracepoint as preferences.
+ * A TracepointPreferenceStore is used to interface between this page and the tracepoint.
+ */
+public class GDBTracepointPropertyPage extends FieldEditorPreferencePage implements IWorkbenchPropertyPage {
+
+ class TracepointIntegerFieldEditor extends IntegerFieldEditor {
+
+ public TracepointIntegerFieldEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ setErrorMessage(Messages.TracepointPropertyPage_integer_negative);
+ }
+
+ /**
+ * @see IntegerFieldEditor#checkState()
+ */
+ @Override
+ protected boolean checkState() {
+ Text control = getTextControl();
+ if (!control.isEnabled()) {
+ clearErrorMessage();
+ return true;
+ }
+ return super.checkState();
+ }
+
+ /**
+ * Only store if the text control is enabled
+ *
+ * @see FieldEditor#doStore()
+ */
+ @Override
+ protected void doStore() {
+ Text text = getTextControl();
+ if (text.isEnabled()) {
+ super.doStore();
+ }
+ }
+
+ /**
+ * Clears the error message from the message line if the error message is the error message from this field editor.
+ */
+ @Override
+ protected void clearErrorMessage() {
+ if (getPage() != null) {
+ String message = getPage().getErrorMessage();
+ if ( message != null ) {
+ if (getErrorMessage().equals(message)) {
+ super.clearErrorMessage();
+ }
+ }
+ else {
+ super.clearErrorMessage();
+ }
+ }
+ }
+ }
+
+ class TracepointStringFieldEditor extends StringFieldEditor {
+
+ public TracepointStringFieldEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ }
+
+ /**
+ * @see StringFieldEditor#checkState()
+ */
+ @Override
+ protected boolean checkState() {
+ Text control = getTextControl();
+ if (!control.isEnabled()) {
+ clearErrorMessage();
+ return true;
+ }
+ return super.checkState();
+ }
+
+ @Override
+ protected void doStore() {
+ Text text = getTextControl();
+ if (text.isEnabled()) {
+ super.doStore();
+ }
+ }
+
+ /**
+ * Clears the error message from the message line if the error message is the error message from this field editor.
+ */
+ @Override
+ protected void clearErrorMessage() {
+ if (getPage() != null) {
+ String message = getPage().getErrorMessage();
+ if ( message != null ) {
+ if (getErrorMessage().equals(message)) {
+ super.clearErrorMessage();
+ }
+ }
+ else {
+ super.clearErrorMessage();
+ }
+ }
+ }
+ }
+
+ class LabelFieldEditor extends ReadOnlyFieldEditor {
+ private String fValue;
+
+ public LabelFieldEditor(Composite parent, String title, String value) {
+ super(title, title, parent);
+ fValue = value;
+ }
+
+ @Override
+ protected void doLoad() {
+ if (textField != null) {
+ textField.setText(fValue);
+ }
+ }
+ @Override
+ protected void doLoadDefault() {
+ // nothing
+ }
+
+ }
+
+ private BooleanFieldEditor fEnabled;
+
+ private TracepointStringFieldEditor fCondition;
+
+ private Text fIgnoreCountTextControl;
+ private TracepointIntegerFieldEditor fIgnoreCount;
+
+ private Text fPassCountTextControl;
+ private TracepointIntegerFieldEditor fPassCount;
+
+ private IAdaptable fElement;
+
+ /**
+ * The "fake" preference store used to interface between
+ * the tracepoint and the tracepoint preference page.
+ */
+ private TracepointPreferenceStore fTracepointPreferenceStore;
+
+ /**
+ * Constructor for GDBTracepointPropertyPage.
+ *
+ */
+ public GDBTracepointPropertyPage() {
+ super( GRID );
+ noDefaultAndApplyButton();
+ fTracepointPreferenceStore = new TracepointPreferenceStore();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
+ */
+ @Override
+ protected void createFieldEditors() {
+ ICTracepoint tracepoint = getTracepoint();
+ 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);
+ }
+ }
+
+ private void createMainLabel(ICTracepoint tracepoint) {
+ addField(createLabelEditor(getFieldEditorParent(),
+ Messages.TracepointPropertyPage_Class,
+ 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));
+ }
+ }
+ 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));
+ }
+ }
+ else { // LineTracepoint
+ String fileName = null;
+ try {
+ fileName = tracepoint.getSourceHandle();
+ }
+ catch(CoreException e) {
+ GdbUIPlugin.log(e);
+ }
+ 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);
+ }
+
+ 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;
+ }
+
+ protected void createLineNumberEditor(Composite parent) {
+ String title = Messages.TracepointPropertyPage_LineNumber;
+ TracepointIntegerFieldEditor labelFieldEditor = new TracepointIntegerFieldEditor(TracepointPreferenceStore.LINE ,title, parent);
+ labelFieldEditor.setValidRange(1, Integer.MAX_VALUE);
+ addField(labelFieldEditor);
+ }
+
+ protected void createEnabledField(Composite parent) {
+ fEnabled = new BooleanFieldEditor(TracepointPreferenceStore.ENABLED, Messages.TracepointPropertyPage_Enabled, parent);
+ addField(fEnabled);
+ }
+
+ protected void createConditionEditor( Composite parent ) {
+ fCondition = new TracepointStringFieldEditor(TracepointPreferenceStore.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.setValidRange(0, Integer.MAX_VALUE);
+ fIgnoreCountTextControl = fIgnoreCount.getTextControl(parent);
+ try {
+ fIgnoreCountTextControl.setEnabled(getTracepoint().getIgnoreCount() >= 0);
+ }
+ catch(CoreException ce) {
+ GdbUIPlugin.log(ce);
+ }
+ addField(fIgnoreCount);
+ }
+
+ protected void createPassCountEditor(Composite parent) {
+ fPassCount = new TracepointIntegerFieldEditor(TracepointPreferenceStore.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);
+ }
+ addField(fPassCount);
+ }
+
+ protected FieldEditor createLabelEditor(Composite parent, String title, String value) {
+ return new LabelFieldEditor(parent, title, value);
+ }
+
+ protected ICTracepoint getTracepoint() {
+ IAdaptable element = getElement();
+ return (element instanceof ICTracepoint) ? (ICTracepoint)element : (ICTracepoint)element.getAdapter(ICTracepoint.class);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement()
+ */
+ public IAdaptable getElement() {
+ return fElement;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable)
+ */
+ public void setElement(IAdaptable element) {
+ 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)
+ */
+ 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() {
+
+ 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;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java
index 82de3a8d337..980f6da5d36 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/Messages.java
@@ -17,7 +17,25 @@ public class Messages extends NLS {
public static String ToggleBreakpointsTargetFactory_description;
public static String ToggleBreakpointsTargetFactory_name;
-
+ public static String ToggleTracepointsTargetFactory_description;
+ public static String ToggleTracepointsTargetFactory_name;
+ 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;
+ public static String TracepointPropertyPage_InvalidCondition;
+ public static String TracepointPropertyPage_IgnoreCount;
+ public static String TracepointPropertyPage_PassCount;
+ public static String TracepointPropertyPage_Class;
+ public static String TracepointPropertyPage_Enabled;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java
index 2c791ea6803..a4b6862dc58 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleBreakpointsTargetFactory.java
@@ -41,12 +41,10 @@ public class ToggleBreakpointsTargetFactory implements IToggleBreakpointsTargetF
* for the editor.
*/
public static final String TOGGLE_C_BREAKPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCBreakpointTarget"; //$NON-NLS-1$
-// public static final String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCTracepointTarget"; //$NON-NLS-1$
- private static final Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(2);
+ private static final Set<String> TOGGLE_TARGET_IDS = new HashSet<String>(1);
static {
TOGGLE_TARGET_IDS.add(TOGGLE_C_BREAKPOINT_TARGET_ID);
-// TOGGLE_TARGET_IDS.add(TOGGLE_C_TRACEPOINT_TARGET_ID);
}
private static final IToggleBreakpointsTarget fgDisassemblyToggleBreakpointsTarget = new DisassemblyToggleBreakpointsTarget();
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java
new file mode 100644
index 00000000000..3032a3e0aab
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Ericsson - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.gdb.internal.ui.breakpoints;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTargetFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * Toggle tracepoints target factory for disassembly parts.
+ * We use a separate factory so that we can control it through an action set.
+ *
+ * @since 2.1
+ */
+public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetFactory {
+
+ /**
+ * Toggle tracepoint target-id for normal C tracepointspoints.
+ * Note: The id must be the same as in <code>ToggleCBreakpointsTargetFactory</code>
+ * which is used for the editor. We need the id to be the same so that when
+ * the user goes from editor to DSF disassembly view, the choice of breakpoint
+ * targets looks the same and is remembered.
+ * To use the same id though, we must be careful not to have the two factories
+ * return the same id for the same part, or else it may confuse things.
+ * This is why this factory only returns this id for the DSF disassembly part,
+ * leaving <code>ToggleCBreakpointsTargetFactory</code> to return the same id
+ * for the editor.
+ */
+ public static final String TOGGLE_C_TRACEPOINT_TARGET_ID = CDebugUIPlugin.PLUGIN_ID + ".toggleCTracepointTarget"; //$NON-NLS-1$
+
+ private static final Set<String> TOGGLE_TARGET_IDS_ALL = new HashSet<String>(1);
+ static {
+ TOGGLE_TARGET_IDS_ALL.add(TOGGLE_C_TRACEPOINT_TARGET_ID);
+ }
+
+ private static final IToggleBreakpointsTarget fgDisassemblyToggleTracepointsTarget = new DisassemblyToggleTracepointsTarget();
+
+ public ToggleTracepointsTargetFactory() {
+ }
+
+ public IToggleBreakpointsTarget createToggleTarget(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return fgDisassemblyToggleTracepointsTarget;
+ }
+ return null;
+ }
+
+ public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) {
+ return null;
+ }
+
+ public String getToggleTargetDescription(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return Messages.ToggleTracepointsTargetFactory_description;
+ }
+ return null;
+ }
+
+ public String getToggleTargetName(String targetID) {
+ if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) {
+ return Messages.ToggleTracepointsTargetFactory_name;
+ }
+ return null;
+ }
+
+ public Set<String> getToggleTargets(IWorkbenchPart part, ISelection selection) {
+ if (part instanceof IDisassemblyPart) {
+ return TOGGLE_TARGET_IDS_ALL;
+ }
+ return Collections.emptySet();
+ }
+
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/TracepointPreferenceStore.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/TracepointPreferenceStore.java
new file mode 100644
index 00000000000..7d5bacec548
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/TracepointPreferenceStore.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * 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;
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties
index ef5a5d5c38b..652e78a4dac 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/messages.properties
@@ -7,7 +7,27 @@
#
# Contributors:
# Wind River Systems - initial API and implementation
+# Ericsson - added Tracepoint support
###############################################################################
-ToggleBreakpointsTargetFactory_description=Standard C/C++ Breakpoint Type
-ToggleBreakpointsTargetFactory_name=C/C++ Breakpoint
+ToggleBreakpointsTargetFactory_description=Standard C/C++ breakpoint type.
+ToggleBreakpointsTargetFactory_name=C/C++ Breakpoints
+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:
+TracepointPropertyPage_InvalidCondition=Invalid condition.
+TracepointPropertyPage_IgnoreCount=&Ignore count:
+TracepointPropertyPage_PassCount=&Pass count:
+TracepointPropertyPage_Class=Class:
+TracepointPropertyPage_Enabled=Enabled
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_0.java
new file mode 100644
index 00000000000..f4b59cb8574
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBreakpoints_7_0.java
@@ -0,0 +1,1128 @@
+/*******************************************************************************
+ * 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.service;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.Immutable;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
+import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent;
+import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandControl;
+import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin;
+import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
+import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
+import org.eclipse.cdt.dsf.mi.service.command.commands.CLIPasscount;
+import org.eclipse.cdt.dsf.mi.service.command.commands.CLITrace;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakAfter;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakCondition;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDelete;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakDisable;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakEnable;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakList;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakWatch;
+import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakListInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakpoint;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+import org.eclipse.cdt.dsf.service.AbstractDsfService;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.osgi.framework.BundleContext;
+
+/**
+ * Initial breakpoint service implementation.
+ * Implements the IBreakpoints interface.
+ * @since 2.1
+ */
+public class GDBBreakpoints_7_0 extends AbstractDsfService implements IBreakpoints
+{
+ // Services
+ ICommandControl fConnection;
+
+ // Service breakpoints tracking
+ // The breakpoints are stored per context and keyed on the back-end breakpoint reference
+ private Map<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>> fBreakpoints =
+ new HashMap<IBreakpointsTargetDMContext, Map<Integer, MIBreakpointDMData>>();
+
+ // Error messages
+ final String NULL_STRING = ""; //$NON-NLS-1$
+ final String UNKNOWN_EXECUTION_CONTEXT = "Unknown execution context"; //$NON-NLS-1$
+ final String UNKNOWN_BREAKPOINT_CONTEXT = "Unknown breakpoint context"; //$NON-NLS-1$
+ final String UNKNOWN_BREAKPOINT_TYPE = "Unknown breakpoint type"; //$NON-NLS-1$
+ final String UNKNOWN_BREAKPOINT = "Unknown breakpoint"; //$NON-NLS-1$
+ final String BREAKPOINT_INSERTION_FAILURE = "Breakpoint insertion failure"; //$NON-NLS-1$
+ final String WATCHPOINT_INSERTION_FAILURE = "Watchpoint insertion failure"; //$NON-NLS-1$
+ final String TRACEPOINT_INSERTION_FAILURE = "Tracepoint insertion failure"; //$NON-NLS-1$
+ final String INVALID_CONDITION = "Invalid condition"; //$NON-NLS-1$
+ final String INVALID_BREAKPOINT_TYPE = "Invalid breakpoint type"; //$NON-NLS-1$
+
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Breakpoint Events
+ ///////////////////////////////////////////////////////////////////////////
+
+ static private class BreakpointsChangedEvent extends AbstractDMEvent<IBreakpointsTargetDMContext> implements IBreakpointsChangedEvent {
+ private IBreakpointDMContext[] fEventBreakpoints;
+
+ public BreakpointsChangedEvent(IBreakpointDMContext bp) {
+ super(DMContexts.getAncestorOfType(bp, IBreakpointsTargetDMContext.class));
+ fEventBreakpoints = new IBreakpointDMContext[] { bp };
+ }
+ public IBreakpointDMContext[] getBreakpoints() {
+ return fEventBreakpoints;
+ }
+ }
+
+ static private class BreakpointAddedEvent extends BreakpointsChangedEvent implements IBreakpointsAddedEvent {
+ public BreakpointAddedEvent(IBreakpointDMContext context) {
+ super(context);
+ }
+ }
+
+ static private class BreakpointUpdatedEvent extends BreakpointsChangedEvent implements IBreakpointsUpdatedEvent {
+ public BreakpointUpdatedEvent(IBreakpointDMContext context) {
+ super(context);
+ }
+ }
+
+ static private class BreakpointRemovedEvent extends BreakpointsChangedEvent implements IBreakpointsRemovedEvent {
+ public BreakpointRemovedEvent(IBreakpointDMContext context) {
+ super(context);
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // IBreakpointDMContext
+ // Used to hold the back-end breakpoint references. The reference can then
+ // be used to get the actual DsfMIBreakpoint.
+ ///////////////////////////////////////////////////////////////////////////
+ @Immutable
+ private static final class MIBreakpointDMContext extends AbstractDMContext implements IBreakpointDMContext {
+
+ // The breakpoint reference
+ private final int fReference;
+
+ /**
+ * @param session the DsfSession for this service
+ * @param parents the parent contexts
+ * @param reference the DsfMIBreakpoint reference
+ */
+ public MIBreakpointDMContext(DsfSession session, IDMContext[] parents, int reference) {
+ super(session.getId(), parents);
+ fReference = reference;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints.IDsfBreakpointDMContext#getReference()
+ */
+ public int getReference() {
+ return fReference;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.datamodel.AbstractDMContext#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ return baseEquals(obj) && (fReference == ((MIBreakpointDMContext) obj).fReference);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.datamodel.AbstractDMContext#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return baseHashCode() + fReference;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ return baseToString() + ".reference(" + fReference + ")"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AbstractDsfService
+ ///////////////////////////////////////////////////////////////////////////
+
+ /**
+ * The service constructor
+ *
+ * @param session The debugging session
+ */
+ public GDBBreakpoints_7_0(DsfSession session) {
+ super(session);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.service.AbstractDsfService#initialize(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
+ */
+ @Override
+ public void initialize(final RequestMonitor rm) {
+ super.initialize(new RequestMonitor(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ doInitialize(rm);
+ }
+ });
+ }
+
+ /*
+ * Asynchronous service initialization
+ */
+ private void doInitialize(final RequestMonitor rm) {
+
+ // Get the services references
+ fConnection = getServicesTracker().getService(ICommandControl.class);
+
+ // Register this service
+ register(new String[] { IBreakpoints.class.getName(),
+ GDBBreakpoints_7_0.class.getName() },
+ new Hashtable<String, String>());
+
+ rm.done();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.service.AbstractDsfService#shutdown(org.eclipse.cdt.dsf.concurrent.RequestMonitor)
+ */
+ @Override
+ public void shutdown(final RequestMonitor rm) {
+ unregister();
+ rm.done();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.service.AbstractDsfService#getBundleContext()
+ */
+ @Override
+ protected BundleContext getBundleContext() {
+ return GdbPlugin.getBundleContext();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpoints(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
+ */
+ public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor<IBreakpointDMContext[]> drm)
+ {
+ // Validate the context
+ if (context == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Select the breakpoints context map
+ // If it doesn't exist then no breakpoint was ever inserted for this breakpoint space.
+ // In that case, return an empty list.
+ final Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
+ if (breakpointContext == null) {
+ drm.setData(new IBreakpointDMContext[0]);
+ drm.done();
+ return;
+ }
+
+ // Execute the command
+ fConnection.queueCommand(new MIBreakList(context),
+ new DataRequestMonitor<MIBreakListInfo>(getExecutor(), drm) {
+ @Override
+ protected void handleSuccess() {
+ // Refresh the breakpoints map and format the result
+ breakpointContext.clear();
+ MIBreakpoint[] breakpoints = getData().getMIBreakpoints();
+ IBreakpointDMContext[] result = new IBreakpointDMContext[breakpoints.length];
+ for (int i = 0; i < breakpoints.length; i++) {
+ MIBreakpointDMData breakpoint = new MIBreakpointDMData(breakpoints[i]);
+ int reference = breakpoint.getReference();
+ result[i] = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
+ breakpointContext.put(reference, breakpoint);
+ }
+ drm.setData(result);
+ drm.done();
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpointDMData(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IDsfBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
+ */
+ public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor<IBreakpointDMData> drm)
+ {
+ // Validate the breakpoint context
+ if (dmc == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Validate the breakpoint type
+ MIBreakpointDMContext breakpoint;
+ if (dmc instanceof MIBreakpointDMContext) {
+ breakpoint = (MIBreakpointDMContext) dmc;
+ }
+ else {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
+ drm.done();
+ return;
+ }
+
+ // Validate the target context
+ IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(breakpoint, IBreakpointsTargetDMContext.class);
+ if (context == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Select the breakpoints context map
+ Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ drm.done();
+ return;
+ }
+
+ // No need to go to the back-end for this one
+ IBreakpointDMData breakpointCopy = new MIBreakpointDMData(contextBreakpoints.get(breakpoint.getReference()));
+ drm.setData(breakpointCopy);
+ drm.done();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#insertBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor)
+ */
+ public void insertBreakpoint(IBreakpointsTargetDMContext context, Map<String, Object> attributes, DataRequestMonitor<IBreakpointDMContext> drm) {
+
+ // Validate the context
+ if (context == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Select the breakpoints context map. If it doesn't exist, create it.
+ Map<Integer, MIBreakpointDMData> breakpointContext = fBreakpoints.get(context);
+ if (breakpointContext == null) {
+ breakpointContext = new HashMap<Integer, MIBreakpointDMData>();
+ fBreakpoints.put(context, breakpointContext);
+ }
+
+ // Validate the breakpoint type
+ String type = (String) attributes.get(MIBreakpoints.BREAKPOINT_TYPE);
+ if (type == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
+ drm.done();
+ return;
+ }
+
+ // And go...
+ if (type.equals(MIBreakpoints.BREAKPOINT)) {
+ addBreakpoint(context, attributes, drm);
+ }
+ else if (type.equals(MIBreakpoints.WATCHPOINT)) {
+ addWatchpoint(context, attributes, drm);
+ }
+ else if (type.equals(MIBreakpoints.TRACEPOINT)) {
+ addTracepoint(context, attributes, drm);
+ }
+ else {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
+ drm.done();
+ }
+ }
+
+ /**
+ * @param map
+ * @param key
+ * @param defaultValue
+ * @return
+ */
+ public Object getProperty(Map<String, Object> map, String key, Object defaultValue) {
+ Object value = map.get(key);
+ return (value != null) ? value : defaultValue;
+ }
+
+ /**
+ * @param attributes
+ * @return
+ */
+ private String formatLocation(Map<String, Object> attributes) {
+
+ // Unlikely default location
+ String location = (String) getProperty(attributes, MIBreakpoints.ADDRESS, NULL_STRING);
+
+ // Get the relevant parameters
+ String fileName = (String) getProperty(attributes, MIBreakpoints.FILE_NAME, NULL_STRING);
+ Integer lineNumber = (Integer) getProperty(attributes, MIBreakpoints.LINE_NUMBER, -1);
+ String function = (String) getProperty(attributes, MIBreakpoints.FUNCTION, NULL_STRING);
+
+ // Fix for Bug264721
+ if (fileName.contains(" ")) { //$NON-NLS-1$
+ fileName = "\"" + fileName + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ if (!fileName.equals(NULL_STRING)) {
+ if (lineNumber != -1) {
+ location = fileName + ":" + lineNumber; //$NON-NLS-1$
+ } else {
+ location = fileName + ":" + function; //$NON-NLS-1$
+ }
+ } else if (!function.equals(NULL_STRING)) {
+ // function location without source
+ location = function;
+ } else if (location.length() > 0) {
+ // address location
+ if (Character.isDigit(location.charAt(0))) {
+ // numeric address needs '*' prefix
+ location = '*' + location;
+ }
+ }
+
+ return location;
+ }
+
+ /**
+ * Add a breakpoint of type BREAKPOINT
+ *
+ * @param context
+ * @param breakpoint
+ * @param drm
+ */
+ private void addBreakpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
+ {
+ // Select the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Extract the relevant parameters (providing default values to avoid potential NPEs)
+ String location = formatLocation(attributes);
+ if (location.equals(NULL_STRING)) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ Boolean enabled = (Boolean) getProperty(attributes, MIBreakpoints.IS_ENABLED, true);
+ Boolean isTemporary = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_TEMPORARY, false);
+ Boolean isHardware = (Boolean) getProperty(attributes, MIBreakpointDMData.IS_HARDWARE, false);
+ String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING);
+ Integer ignoreCount = (Integer) getProperty(attributes, MIBreakpoints.IGNORE_COUNT, 0);
+ String threadId = (String) getProperty(attributes, MIBreakpointDMData.THREAD_ID, "0"); //$NON-NLS-1$
+ int tid = Integer.parseInt(threadId);
+
+ // The DataRequestMonitor for the add request
+ DataRequestMonitor<MIBreakInsertInfo> addBreakpointDRM =
+ new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), drm) {
+ @Override
+ protected void handleSuccess() {
+
+ // With MI, an invalid location won't generate an error
+ if (getData().getMIBreakpoints().length == 0) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ return;
+ }
+
+ // Create a breakpoint object and store it in the map
+ final MIBreakpointDMData newBreakpoint = new MIBreakpointDMData(getData().getMIBreakpoints()[0]);
+ int reference = newBreakpoint.getNumber();
+ if (reference == -1) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ return;
+ }
+ contextBreakpoints.put(reference, newBreakpoint);
+
+ // Format the return value
+ MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
+ drm.setData(dmc);
+
+ // Flag the event
+ getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
+
+ drm.done();
+ }
+
+ @Override
+ protected void handleError() {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ }
+ };
+
+ // Execute the command
+ fConnection.queueCommand(
+ new MIBreakInsert(context, isTemporary, isHardware, condition, ignoreCount, location, tid, !enabled, false), addBreakpointDRM);
+ }
+
+ /**
+ * Add a tracepoint
+ *
+ * @param context
+ * @param breakpoint
+ * @param drm
+ */
+ private void addTracepoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
+ {
+ // Select the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Extract the relevant parameters (providing default values to avoid potential NPEs)
+ final String location = formatLocation(attributes);
+ if (location.equals(NULL_STRING)) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ final String condition = (String) getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING);
+
+ fConnection.queueCommand(
+ new CLITrace(context, location, condition),
+ new DataRequestMonitor<CLITraceInfo>(getExecutor(), drm) {
+ @Override
+ protected void handleSuccess() {
+ // The simplest way to convert from the CLITraceInfo to a MIBreakInsertInfo
+ // is to list the breakpoints and take the proper output
+ final int tpReference = getData().getTraceReference();
+ fConnection.queueCommand(
+ new MIBreakList(context),
+ new DataRequestMonitor<MIBreakListInfo>(getExecutor(), drm) {
+ @Override
+ protected void handleSuccess() {
+ MIBreakpoint[] breakpoints = getData().getMIBreakpoints();
+ for (MIBreakpoint bp : breakpoints) {
+ if (bp.getNumber() == tpReference) {
+
+ // Create a breakpoint object and store it in the map
+ final MIBreakpointDMData newBreakpoint = new MIBreakpointDMData(bp);
+ int reference = newBreakpoint.getNumber();
+ contextBreakpoints.put(reference, newBreakpoint);
+
+ // Format the return value
+ MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
+ drm.setData(dmc);
+
+ // Flag the event
+ getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
+
+ // By default the tracepoint is enabled at creation
+ // If it wasn't supposed to be, then disable it right away
+ // Also, tracepoints are created with no passcount.
+ // We have to set the passcount manually now.
+ Map<String,Object> delta = new HashMap<String,Object>();
+ delta.put(MIBreakpoints.IS_ENABLED, getProperty(attributes, MIBreakpoints.IS_ENABLED, true));
+ delta.put(MIBreakpoints.PASS_COUNT, getProperty(attributes, MIBreakpoints.PASS_COUNT, 0));
+ modifyBreakpoint(dmc, delta, drm, false);
+ return;
+ }
+ }
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, BREAKPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ }
+ });
+ }
+ });
+ }
+
+ /**
+ * Add a breakpoint of type WATCHPOINT
+ *
+ * @param context
+ * @param watchpoint
+ * @param drm
+ */
+ private void addWatchpoint(final IBreakpointsTargetDMContext context, final Map<String, Object> attributes, final DataRequestMonitor<IBreakpointDMContext> drm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ drm.done();
+ return;
+ }
+
+ // Extract the relevant parameters (providing default values to avoid potential NPEs)
+ String expression = (String) getProperty(attributes, MIBreakpoints.EXPRESSION, NULL_STRING);
+ boolean isRead = (Boolean) getProperty(attributes, MIBreakpoints.READ, false);
+ boolean isWrite = (Boolean) getProperty(attributes, MIBreakpoints.WRITE, false);
+
+ // The DataRequestMonitor for the add request
+ DataRequestMonitor<MIBreakInsertInfo> addWatchpointDRM =
+ new DataRequestMonitor<MIBreakInsertInfo>(getExecutor(), drm) {
+ @Override
+ protected void handleSuccess() {
+
+ // With MI, an invalid location won't generate an error
+ if (getData().getMIBreakpoints().length == 0) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ return;
+ }
+
+ // Create a breakpoint object and store it in the map
+ final MIBreakpointDMData newBreakpoint = new MIBreakpointDMData(getData().getMIBreakpoints()[0]);
+ int reference = newBreakpoint.getNumber();
+ if (reference == -1) {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ return;
+ }
+ contextBreakpoints.put(reference, newBreakpoint);
+
+ // Format the return value
+ MIBreakpointDMContext dmc = new MIBreakpointDMContext(getSession(), new IDMContext[] { context }, reference);
+ drm.setData(dmc);
+
+ // Flag the event
+ getSession().dispatchEvent(new BreakpointAddedEvent(dmc), getProperties());
+
+ // Condition, ignore count and state can not be specified at watchpoint creation time.
+ // Therefore, we have to update the watchpoint if any of these is present
+ Map<String,Object> delta = new HashMap<String,Object>();
+ delta.put(MIBreakpoints.CONDITION, getProperty(attributes, MIBreakpoints.CONDITION, NULL_STRING));
+ delta.put(MIBreakpoints.IGNORE_COUNT, getProperty(attributes, MIBreakpoints.IGNORE_COUNT, 0 ));
+ delta.put(MIBreakpoints.IS_ENABLED, getProperty(attributes, MIBreakpoints.IS_ENABLED, true));
+ modifyBreakpoint(dmc, delta, drm, false);
+ }
+
+ @Override
+ protected void handleError() {
+ drm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, WATCHPOINT_INSERTION_FAILURE, null));
+ drm.done();
+ }
+ };
+
+ // Execute the command
+ fConnection.queueCommand(new MIBreakWatch(context, isRead, isWrite, expression), addWatchpointDRM);
+ }
+
+ //-------------------------------------------------------------------------
+ // removeBreakpoint
+ //-------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#removeBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.RequestMonitor)
+ */
+ public void removeBreakpoint(final IBreakpointDMContext dmc, final RequestMonitor rm) {
+
+ // Validate the breakpoint context
+ if (dmc == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the breakpoint type
+ MIBreakpointDMContext breakpointCtx;
+ if (dmc instanceof MIBreakpointDMContext) {
+ breakpointCtx = (MIBreakpointDMContext) dmc;
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the target context
+ IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class);
+ if (context == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Pick the context breakpoints map
+ final Map<Integer,MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the breakpoint
+ final int reference = breakpointCtx.getReference();
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new MIBreakDelete(context, new int[] { reference }),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ getSession().dispatchEvent(new BreakpointRemovedEvent(dmc), getProperties());
+ contextBreakpoints.remove(reference);
+ rm.done();
+ }
+ });
+ }
+
+ // -------------------------------------------------------------------------
+ // updateBreakpoint
+ //-------------------------------------------------------------------------
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#updateBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.RequestMonitor)
+ */
+ public void updateBreakpoint(IBreakpointDMContext dmc, Map<String, Object> properties, RequestMonitor rm)
+ {
+ // Validate the breakpoint context
+ if (dmc == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the breakpoint type
+ MIBreakpointDMContext breakpointCtx;
+ if (dmc instanceof MIBreakpointDMContext) {
+ breakpointCtx = (MIBreakpointDMContext) dmc;
+ }
+ else {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_TYPE, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the context
+ IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(dmc, IBreakpointsTargetDMContext.class);
+ if (context == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_EXECUTION_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+
+ // Validate the breakpoint
+ final int reference = breakpointCtx.getReference();
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+
+ modifyBreakpoint(breakpointCtx, properties, rm, true);
+ }
+
+ /**
+ * @param dmc
+ * @param properties
+ * @param rm
+ * @param generateUpdateEvent
+ */
+ private void modifyBreakpoint(final MIBreakpointDMContext breakpointCtx, Map<String, Object> attributes,
+ final RequestMonitor rm, final boolean generateUpdateEvent)
+ {
+ // Use a working copy of the attributes since we are going to tamper happily with them
+ Map<String, Object> properties = new HashMap<String, Object>(attributes);
+
+ // Retrieve the breakpoint parameters
+ // At this point, we know their are OK so there is no need to re-validate
+ IBreakpointsTargetDMContext context = DMContexts.getAncestorOfType(breakpointCtx, IBreakpointsTargetDMContext.class);
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ final int reference = breakpointCtx.getReference();
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+
+ // Track the number of change requests
+ int numberOfChanges = 0;
+ final CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ if (generateUpdateEvent)
+ getSession().dispatchEvent(new BreakpointUpdatedEvent(breakpointCtx), getProperties());
+ rm.done();
+ }
+ };
+
+ // Determine if the breakpoint condition changed
+ String conditionAttribute = MIBreakpoints.CONDITION;
+ if (properties.containsKey(conditionAttribute)) {
+ String oldValue = breakpoint.getCondition();
+ String newValue = (String) properties.get(conditionAttribute);
+ if (newValue == null) newValue = NULL_STRING;
+ if (!oldValue.equals(newValue)) {
+ changeCondition(context, reference, newValue, countingRm);
+ numberOfChanges++;
+ }
+ properties.remove(conditionAttribute);
+ }
+
+ // Determine if the breakpoint ignore count changed
+ String ignoreCountAttribute = MIBreakpoints.IGNORE_COUNT;
+ if (properties.containsKey(ignoreCountAttribute)) {
+ Integer oldValue = breakpoint.getIgnoreCount();
+ Integer newValue = (Integer) properties.get(ignoreCountAttribute);
+ if (newValue == null) newValue = 0;
+ if (!oldValue.equals(newValue)) {
+ changeIgnoreCount(context, reference, newValue, countingRm);
+ numberOfChanges++;
+ }
+ properties.remove(ignoreCountAttribute);
+ }
+
+ // Determine if the tracepoint pass count changed
+ String passCountAttribute = MIBreakpoints.PASS_COUNT;
+ if (properties.containsKey(passCountAttribute)) {
+ Integer oldValue = breakpoint.getPassCount();
+ Integer newValue = (Integer) properties.get(passCountAttribute);
+ if (newValue == null) newValue = 0;
+ if (!oldValue.equals(newValue)) {
+ changePassCount(context, reference, newValue, countingRm);
+ numberOfChanges++;
+ }
+ properties.remove(passCountAttribute);
+ }
+
+ // Determine if the breakpoint state changed
+ String enableAttribute = MIBreakpoints.IS_ENABLED;
+ if (properties.containsKey(enableAttribute)) {
+ Boolean oldValue = breakpoint.isEnabled();
+ Boolean newValue = (Boolean) properties.get(enableAttribute);
+ if (newValue == null) newValue = false;
+ if (!oldValue.equals(newValue)) {
+ numberOfChanges++;
+ if (newValue)
+ enableBreakpoint(context, reference, countingRm);
+ else
+ disableBreakpoint(context, reference, countingRm);
+ }
+ properties.remove(enableAttribute);
+ }
+
+// // Determine if the breakpoint state changed
+// String commandsAttribute = MIBreakpoints.COMMANDS;
+// if (properties.containsKey(commandsAttribute)) {
+// String oldValue = "khouzam"; //TODO
+// String newValue = (String) properties.get(commandsAttribute);
+// if (newValue == null) newValue = NULL_STRING;
+// if (!oldValue.equals(newValue)) {
+// IBreakpointAction[] actions = generateGdbActions(newValue);
+// numberOfChanges++;
+// changeActions(context, reference, actions, countingRm);
+// }
+// properties.remove(commandsAttribute);
+// }
+
+ // Set the number of completions required
+ countingRm.setDoneCount(numberOfChanges);
+ }
+
+// private IBreakpointAction[] generateGdbActions(String actionStr) {
+// String[] actionNames = actionStr.split(",");
+// IBreakpointAction[] actions = new IBreakpointAction[actionNames.length];
+//
+// for (int i = 0; i < actionNames.length; i++) {
+// BreakpointActionManager actionManager = CDebugCorePlugin.getDefault().getBreakpointActionManager();
+// actions[i] = actionManager.findTracepointAction(actionNames[i]);
+// }
+// return actions;
+// }
+ /**
+ * Update the breakpoint condition
+ *
+ * @param context
+ * @param dmc
+ * @param condition
+ * @param rm
+ */
+ private void changeCondition(final IBreakpointsTargetDMContext context,
+ final int reference, final String condition, final RequestMonitor rm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new MIBreakCondition(context, reference, condition),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ breakpoint.setCondition(condition);
+ rm.done();
+ }
+
+ // In case of error (new condition could not be installed for whatever reason),
+ // GDB "offers" different behaviours depending on its version: it can either keep
+ // the original condition (the right thing to do) or keep the invalid condition.
+ // Our sole option is to remove the condition in case of error and rely on the
+ // upper layer to re-install the right condition.
+ @Override
+ protected void handleError() {
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ // Remove invalid condition from the back-end breakpoint
+ breakpoint.setCondition(NULL_STRING);
+ fConnection.queueCommand(
+ new MIBreakCondition(context, reference, NULL_STRING),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ // The report the initial problem
+ protected void handleCompleted() {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_CONDITION, null));
+ rm.done();
+ }
+ });
+ }
+ });
+ }
+
+// private void changeActions(final IBreakpointsTargetDMContext context,
+// final int reference, final IBreakpointAction[] actions, final RequestMonitor rm)
+// {
+// // Pick the context breakpoints map
+// final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+// if (contextBreakpoints == null) {
+// rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+// rm.done();
+// return;
+// }
+//
+// // We only do this for tracepoints
+//
+// ArrayList<String> actionStrings = new ArrayList<String>();
+// for (int i = 0; i< actions.length; i++) {
+// IBreakpointAction action = actions[i];
+// if (action != null) {
+// actionStrings.add(action.toString());
+// }
+// }
+// // Queue the command
+// //TODO should we use a cache?
+// fConnection.queueCommand(
+// new MIBreakCommands(context, reference, actionStrings.toArray(new String[0])),
+// new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+// @Override
+// protected void handleSuccess() {
+//// MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+//// if (breakpoint == null) {
+//// rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+//// rm.done();
+//// return;
+//// }
+//// breakpoint.setCondition(condition);
+// rm.done();
+// }
+// });
+// }
+
+
+ /**
+ * Update the breakpoint ignoreCount
+ *
+ * @param context
+ * @param reference
+ * @param ignoreCount
+ * @param rm
+ */
+ private void changeIgnoreCount(IBreakpointsTargetDMContext context,
+ final int reference, final int ignoreCount, final RequestMonitor rm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ final MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT)) {
+ // Ingorecount is not supported for tracepoints
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_BREAKPOINT_TYPE, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new MIBreakAfter(context, reference, ignoreCount),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ breakpoint.setIgnoreCount(ignoreCount);
+ rm.done();
+ }
+ });
+ }
+
+ /**
+ * Update the tracepoint passCount
+ *
+ * @param context
+ * @param reference
+ * @param ignoreCount
+ * @param rm
+ */
+ private void changePassCount(IBreakpointsTargetDMContext context,
+ final int reference, final int ignoreCount, final RequestMonitor rm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ final MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint.getBreakpointType().equals(MIBreakpoints.TRACEPOINT) == false) {
+ // Passcount is just for tracepoints
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, INVALID_BREAKPOINT_TYPE, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new CLIPasscount(context, reference, ignoreCount),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ breakpoint.setPassCount(ignoreCount);
+ rm.done();
+ }
+ });
+ }
+
+ /**
+ * Enable the breakpoint
+ *
+ * @param context
+ * @param reference
+ * @param rm
+ */
+ private void enableBreakpoint(IBreakpointsTargetDMContext context,
+ final int reference, final RequestMonitor rm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new MIBreakEnable(context, new int[] { reference }),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ breakpoint.setEnabled(true);
+ rm.done();
+ }
+ });
+ }
+
+ /**
+ * Disable the breakpoint
+ *
+ * @param context
+ * @param dmc
+ * @param rm
+ */
+ private void disableBreakpoint(IBreakpointsTargetDMContext context,
+ final int reference, final RequestMonitor rm)
+ {
+ // Pick the context breakpoints map
+ final Map<Integer, MIBreakpointDMData> contextBreakpoints = fBreakpoints.get(context);
+ if (contextBreakpoints == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT_CONTEXT, null));
+ rm.done();
+ return;
+ }
+
+ // Queue the command
+ fConnection.queueCommand(
+ new MIBreakDisable(context, new int[] { reference }),
+ new DataRequestMonitor<MIInfo>(getExecutor(), rm) {
+ @Override
+ protected void handleSuccess() {
+ MIBreakpointDMData breakpoint = contextBreakpoints.get(reference);
+ if (breakpoint == null) {
+ rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, REQUEST_FAILED, UNKNOWN_BREAKPOINT, null));
+ rm.done();
+ return;
+ }
+ breakpoint.setEnabled(false);
+ rm.done();
+ }
+ });
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
index 222ee32fe32..b55c3aa77d5 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java
@@ -83,6 +83,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory {
@Override
protected IBreakpoints createBreakpointService(DsfSession session) {
+ if (GDB_7_0_VERSION.compareTo(fVersion) <= 0) {
+ return new GDBBreakpoints_7_0(session);
+ }
return new MIBreakpoints(session);
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
index 4a2c5e4e6a9..53db39a2cfa 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java
@@ -39,7 +39,8 @@ public class MIBreakpointDMData implements IBreakpointDMData {
private final Map<String, Object> fProperties;
// Breakpoint types
- public static enum MIBreakpointNature { UNKNOWN, BREAKPOINT, WATCHPOINT, CATCHPOINT };
+ public static enum MIBreakpointNature { UNKNOWN, BREAKPOINT, WATCHPOINT, CATCHPOINT,
+ /** @since 2.1*/ TRACEPOINT };
private final MIBreakpointNature fNature;
@@ -66,9 +67,15 @@ public class MIBreakpointDMData implements IBreakpointDMData {
*/
public MIBreakpointDMData(MIBreakpoint dsfMIBreakpoint) {
- // We only support breakpoint and watchpoint (so far)
+ // No support for catchpoints yet
fBreakpoint = dsfMIBreakpoint;
- fNature = dsfMIBreakpoint.isWatchpoint() ? MIBreakpointNature.WATCHPOINT : MIBreakpointNature.BREAKPOINT;
+ if (dsfMIBreakpoint.isTracepoint()) {
+ fNature = MIBreakpointNature.TRACEPOINT;
+ } else if (dsfMIBreakpoint.isWatchpoint()) {
+ fNature = MIBreakpointNature.WATCHPOINT;
+ } else {
+ fNature = MIBreakpointNature.BREAKPOINT;
+ }
fProperties = new HashMap<String,Object>();
switch (fNature) {
@@ -109,7 +116,31 @@ public class MIBreakpointDMData implements IBreakpointDMData {
fProperties.put(NUMBER, dsfMIBreakpoint.getNumber());
break;
}
-
+
+ case TRACEPOINT:
+ {
+ // Generic breakpoint attributes
+ fProperties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ fProperties.put(MIBreakpoints.FILE_NAME, dsfMIBreakpoint.getFile());
+ fProperties.put(MIBreakpoints.LINE_NUMBER, dsfMIBreakpoint.getLine());
+ fProperties.put(MIBreakpoints.FUNCTION, dsfMIBreakpoint.getFunction());
+ fProperties.put(MIBreakpoints.ADDRESS, dsfMIBreakpoint.getAddress());
+ fProperties.put(MIBreakpoints.CONDITION, dsfMIBreakpoint.getCondition());
+ fProperties.put(MIBreakpoints.IGNORE_COUNT, dsfMIBreakpoint.getPassCount());
+ fProperties.put(MIBreakpoints.IS_ENABLED, new Boolean(dsfMIBreakpoint.isEnabled()));
+
+ // MI-specific breakpoint attributes
+ fProperties.put(NUMBER, dsfMIBreakpoint.getNumber());
+ fProperties.put(TYPE, dsfMIBreakpoint.getType());
+ fProperties.put(THREAD_ID, dsfMIBreakpoint.getThreadId());
+ fProperties.put(FULL_NAME, dsfMIBreakpoint.getFullName());
+ fProperties.put(HITS, dsfMIBreakpoint.getTimes());
+ fProperties.put(IS_TEMPORARY, new Boolean(dsfMIBreakpoint.isTemporary()));
+ fProperties.put(IS_HARDWARE, new Boolean(dsfMIBreakpoint.isHardware()));
+ fProperties.put(LOCATION, formatLocation());
+ break;
+ }
+
// Not reachable
default:
{
@@ -201,6 +232,20 @@ public class MIBreakpointDMData implements IBreakpointDMData {
return fBreakpoint.isEnabled();
}
+ /**
+ * @since 2.1
+ */
+ public int getPassCount() {
+ return fBreakpoint.getPassCount();
+ }
+
+ /**
+ * @since 2.1
+ */
+ public String getCommands() {
+ return fBreakpoint.getCommands();
+ }
+
///////////////////////////////////////////////////////////////////////////
// MIBreakpointDMData
///////////////////////////////////////////////////////////////////////////
@@ -251,6 +296,14 @@ public class MIBreakpointDMData implements IBreakpointDMData {
fBreakpoint.setEnabled(isEnabled);
fProperties.put(MIBreakpoints.IS_ENABLED, isEnabled);
}
+
+ /**
+ * @since 2.1
+ */
+ public void setPassCount(int count) {
+ fBreakpoint.setPassCount(count);
+ fProperties.put(MIBreakpoints.IGNORE_COUNT, count);
+ }
public boolean isReadWatchpoint() {
return fBreakpoint.isReadWatchpoint();
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
index 83ecf232d62..4bca623aad6 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java
@@ -66,6 +66,8 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
public static final String BREAKPOINT = "breakpoint"; //$NON-NLS-1$
public static final String WATCHPOINT = "watchpoint"; //$NON-NLS-1$
public static final String CATCHPOINT = "catchpoint"; //$NON-NLS-1$
+ /** @since 2.1 */
+ public static final String TRACEPOINT = "tracepoint"; //$NON-NLS-1$
// Basic set of breakpoint attribute markers
public static final String FILE_NAME = PREFIX + ".fileName"; //$NON-NLS-1$
@@ -74,7 +76,11 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints
public static final String ADDRESS = PREFIX + ".address"; //$NON-NLS-1$
public static final String CONDITION = PREFIX + ".condition"; //$NON-NLS-1$
public static final String IGNORE_COUNT = PREFIX + ".ignoreCount"; //$NON-NLS-1$
+ /** @since 2.1 */
+ public static final String PASS_COUNT = PREFIX + ".passCount"; //$NON-NLS-1$
public static final String IS_ENABLED = PREFIX + ".isEnabled"; //$NON-NLS-1$
+ /** @since 2.1 */
+ public static final String COMMANDS = PREFIX + ".commands"; //$NON-NLS-1$
// Basic set of watchpoint attribute markers
public static final String EXPRESSION = PREFIX + ".expression"; //$NON-NLS-1$
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java
index 31a2dddc25e..cd5f2e1c620 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java
@@ -31,6 +31,7 @@ import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpointExtension;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICTracepoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.BreakpointProblems;
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
@@ -416,7 +417,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
@Override
protected void handleSuccess() {
// Install only if the breakpoint is enabled at startup (Bug261082)
- boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && fBreakpointManager.isEnabled();
+ // Note that Tracepoints are not affected by "skip-all"
+ boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
+ (breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled());
if (bpEnabled)
installBreakpoint(dmc, breakpoint, attributes, countingRm);
else
@@ -784,7 +787,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// some attribute might have changed which will make the install succeed.
if (!breakpointIDs.containsKey(breakpoint) && !targetBPs.containsValue(breakpoint)) {
// Install only if the breakpoint is enabled
- boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) && fBreakpointManager.isEnabled();
+ // Note that Tracepoints are not affected by "skip-all"
+ boolean bpEnabled = attributes.get(ICBreakpoint.ENABLED).equals(true) &&
+ (breakpoint instanceof ICTracepoint || fBreakpointManager.isEnabled());
if (bpEnabled) {
attributes.put(ATTR_DEBUGGER_PATH, NULL_STRING);
attributes.put(ATTR_THREAD_FILTER, extractThreads(dmc, breakpoint));
@@ -967,7 +972,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Convert the breakpoint attributes for the back-end
// Refresh the set of attributes at each iteration just in case...
Map<String,Object> attrs = convertToTargetBreakpoint(breakpoint, attributes);
- if (!fBreakpointManager.isEnabled()) {
+ // Tracepoints are not affected by "skip-all"
+ if (!(breakpoint instanceof ICTracepoint) && !fBreakpointManager.isEnabled()) {
attrs.put(MIBreakpoints.IS_ENABLED, false);
}
// Add the secret ingredient..
@@ -1010,7 +1016,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
for (IBreakpointsTargetDMContext context : fBreakpointIDs.keySet()) {
for (ICBreakpoint breakpoint : fBreakpointIDs.get(context).keySet()) {
try {
- if (breakpoint.isEnabled()) {
+ // Note that Tracepoints are not affected by "skip-all"
+ if (!(breakpoint instanceof ICTracepoint) && breakpoint.isEnabled()) {
for (IBreakpointDMContext ref : fBreakpointIDs.get(context).get(breakpoint)) {
Map<String,Object> delta = new HashMap<String,Object>();
delta.put(MIBreakpoints.IS_ENABLED, enabled);
@@ -1090,7 +1097,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Retrieve the breakpoint attributes
@SuppressWarnings("unchecked")
final Map<String, Object> attrs = breakpoint.getMarker().getAttributes();
- if (!fBreakpointManager.isEnabled()) {
+ // Tracepoints are not affected by "skip-all"
+ if (!(breakpoint instanceof ICTracepoint) && !fBreakpointManager.isEnabled()) {
attrs.put(ICBreakpoint.ENABLED, false);
}
@@ -1136,7 +1144,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
new RequestMonitor(getExecutor(), countingRm) {
@Override
protected void handleSuccess() {
- modifyBreakpoint(dmc, (ICBreakpoint) breakpoint, attrs, delta, new RequestMonitor(getExecutor(), countingRm));
+ modifyBreakpoint(dmc, (ICBreakpoint) breakpoint, attrs, delta, countingRm);
}
});
}
@@ -1499,6 +1507,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
if (cdt_attributes.containsKey(IMarker.LINE_NUMBER))
result.put(MIBreakpoints.LINE_NUMBER, cdt_attributes.get(IMarker.LINE_NUMBER));
+ if (cdt_attributes.containsKey(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE))
+ result.put(MIBreakpoints.COMMANDS, cdt_attributes.get(BreakpointActionManager.BREAKPOINT_ACTION_ATTRIBUTE));
+
// ICLineBreakpoint attributes
if (cdt_attributes.containsKey(ICLineBreakpoint.FUNCTION))
result.put(MIBreakpoints.FUNCTION, cdt_attributes.get(ICLineBreakpoint.FUNCTION));
@@ -1513,6 +1524,9 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
if (cdt_attributes.containsKey(ICBreakpoint.IGNORE_COUNT))
result.put(MIBreakpoints.IGNORE_COUNT, cdt_attributes.get(ICBreakpoint.IGNORE_COUNT));
+ if (cdt_attributes.containsKey(ICTracepoint.PASS_COUNT))
+ result.put(MIBreakpoints.PASS_COUNT, cdt_attributes.get(ICTracepoint.PASS_COUNT));
+
if (cdt_attributes.containsKey(ICBreakpoint.ENABLED))
result.put(MIBreakpoints.IS_ENABLED, cdt_attributes.get(ICBreakpoint.ENABLED));
@@ -1633,6 +1647,12 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
properties.put(MIBreakpoints.LINE_NUMBER, attributes.get(IMarker.LINE_NUMBER));
properties.put(MIBreakpoints.FUNCTION, attributes.get(ICLineBreakpoint.FUNCTION));
properties.put(MIBreakpoints.ADDRESS, attributes.get(ICLineBreakpoint.ADDRESS));
+
+ if (breakpoint instanceof ICTracepoint) {
+ // A tracepoint is a LineBreakpoint, but needs its own type
+ properties.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ properties.put(MIBreakpoints.PASS_COUNT, attributes.get(ICTracepoint.PASS_COUNT));
+ }
} else {
// catchpoint?
}
@@ -1644,7 +1664,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
properties.put(MIBreakpointDMData.THREAD_ID, attributes.get(ATTR_THREAD_ID));
// Adjust for "skip-all"
- if (!fBreakpointManager.isEnabled()) {
+ // Tracepoints are not affected by "skip-all"
+ if (!(breakpoint instanceof ICTracepoint ) && !fBreakpointManager.isEnabled()) {
properties.put(MIBreakpoints.IS_ENABLED, false);
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIPasscount.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIPasscount.java
new file mode 100644
index 00000000000..7a4d4712db8
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLIPasscount.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.mi.service.command.commands;
+
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+
+/**
+ * Set the passcount of a tracepoint. The passcount is a way to automatically stop a trace experiment.
+ * If a tracepoint's passcount is N, then the trace experiment will be automatically stopped on the N'th
+ * time that tracepoint is hit. If no passcount is given, the trace experiment will run until stopped
+ * explicitly by the user.
+
+ * @since 2.1
+ */
+public class CLIPasscount extends CLICommand<MIInfo> {
+ public CLIPasscount(IBreakpointsTargetDMContext ctx, int breakpoint, int passcount) {
+ super(ctx, "passcount"); //$NON-NLS-1$
+ setParameters(new String[] { Integer.toString(passcount), Integer.toString(breakpoint) });
+ }
+}
+
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLITrace.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLITrace.java
new file mode 100644
index 00000000000..8c038652544
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/CLITrace.java
@@ -0,0 +1,49 @@
+/*******************************************************************************
+ * 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.mi.service.command.commands;
+
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
+import org.eclipse.cdt.dsf.mi.service.command.output.CLITraceInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
+
+/**
+ * This command creates a tracepoint.
+ * @since 2.1
+ */
+public class CLITrace extends CLICommand<CLITraceInfo> {
+ public CLITrace(IBreakpointsTargetDMContext ctx, String location) {
+ this(ctx, location, null);
+ }
+
+ // In this particular case, because of a GDB peculiarity, setParameters() is
+ // not used and the whole command is formatted on the parent's constructor.
+ // See bug 213076 for more information.
+ public CLITrace(IBreakpointsTargetDMContext ctx, String location, String condition) {
+ super(ctx, "trace " + location + //$NON-NLS-1$
+ ((condition != null && condition.trim().length() > 0) ? " if " + condition : "")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ @Override
+ public CLITraceInfo getResult(MIOutput output) {
+ return (CLITraceInfo)getMIInfo(output);
+ }
+
+ public MIInfo getMIInfo(MIOutput out) {
+ MIInfo info = null;
+ if (out != null) {
+ info = new CLITraceInfo(out);
+ }
+ return info;
+ }
+}
+
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakInsert.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakInsert.java
index e2dfb494a63..28c75f725c1 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakInsert.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakInsert.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 QNX Software Systems and others.
+ * Copyright (c) 2009 QNX Software 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
@@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Modified for new DSF Reference Implementation
* Ericsson - Modified for bug 219920
+ * Ericsson - Modified for tracepoints (284286)
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.commands;
@@ -18,11 +19,11 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIBreakInsertInfo;
import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
/**
- * -break-insert [ -t ] [ -h ] [ -r ]
+ * -break-insert [ -t ] [ -h ] [ -f ] [ -d ] [ -a ]
* [ -c CONDITION ] [ -i IGNORE-COUNT ]
- * [ -p THREAD ] [ LINE | ADDR ]
+ * [ -p THREAD ] [ LOCATION ]
*
- * If specified, LINE, can be one of:
+ * If specified, LOCATION, can be one of:
* * function
* * filename:linenum
* * filename:function
@@ -35,20 +36,31 @@ import org.eclipse.cdt.dsf.mi.service.command.output.MIOutput;
*
* '-h'
* Insert a hardware breakpoint.
- *
- * '-r'
- * Insert a regular breakpoint in all the functions whose names match
- * the given regular expression. Other flags are not applicable to
- * regular expression.
+ * When inserting a tracepoint (-a), this option indicates a fast tracepoint
*
* '-c CONDITION'
- * Make the breakpoint conditional on CONDITION.
+ * Make the breakpoint conditional on CONDITION.
*
* '-i IGNORE-COUNT'
- * Initialize the IGNORE-COUNT (number of breakpoint hits before breaking).
+ * Initialize the IGNORE-COUNT (number of breakpoint hits before breaking).
+ *
+ * '-f'
+ * If location cannot be parsed (for example if it refers to unknown files or
+ * functions), create a pending breakpoint. Without this flag, if a location
+ * cannot be parsed, the breakpoint will not be created and an error will be
+ * reported.
+ * Only available starting GDB 6.8
*
+ * '-d'
+ * Create a disabled breakpoint.
+ * Only available starting GDB 7.0
+ *
+ * '-a'
+ * Insert a tracepoint instead of a breakpoint
+ * Only available starting GDB 7.1
+ *
* '-p THREAD'
- * THREAD on which to apply the breakpoint
+ * THREAD on which to apply the breakpoint
*/
public class MIBreakInsert extends MICommand<MIBreakInsertInfo>
{
@@ -58,8 +70,30 @@ public class MIBreakInsert extends MICommand<MIBreakInsertInfo>
public MIBreakInsert(IBreakpointsTargetDMContext ctx, boolean isTemporary, boolean isHardware,
String condition, int ignoreCount, String line, int tid) {
+ this(ctx, isTemporary, isHardware, condition, ignoreCount, line, tid, false, false);
+ }
+
+ /**
+ * This constructor allows to specify if the breakpoint should actually be
+ * a tracepoint (this will only work starting with GDB 7.1)
+ * It also includes if a breakpoint should be created disabled (starting GDB 7.0)
+ * @since 2.1
+ */
+ public MIBreakInsert(IBreakpointsTargetDMContext ctx, boolean isTemporary, boolean isHardware,
+ String condition, int ignoreCount, String line, int tid, boolean disabled, boolean isTracepoint) {
super(ctx, "-break-insert"); //$NON-NLS-1$
+ // For a tracepoint, force certain parameters to what is allowed
+ if (isTracepoint) {
+ // A tracepoint cannot be temporary
+ isTemporary = false;
+ // GDB 7.1 does not support ignore-counts for tracepoints
+ // and passcounts cannot be set by a -break-insert
+ ignoreCount = 0;
+ // GDB 7.1 only supports tracepoints that apply to all threads
+ tid = 0;
+ }
+
// Determine the number of optional parameters that are present
// and allocate a corresponding string array
int i = 0;
@@ -78,6 +112,12 @@ public class MIBreakInsert extends MICommand<MIBreakInsertInfo>
if (tid > 0) {
i += 2;
}
+ if (disabled) {
+ i++;
+ }
+ if (isTracepoint) {
+ i ++;
+ }
String[] opts = new String[i];
// Fill in the optional parameters
@@ -87,6 +127,7 @@ public class MIBreakInsert extends MICommand<MIBreakInsertInfo>
i++;
}
if (isHardware) {
+ // For tracepoints, this will request a fast tracepoint
opts[i] = "-h"; //$NON-NLS-1$
i++;
}
@@ -107,6 +148,14 @@ public class MIBreakInsert extends MICommand<MIBreakInsertInfo>
i++;
opts[i] = Integer.toString(tid);
}
+ if (disabled) {
+ opts[i] = "-d"; //$NON-NLS-1$
+ i ++;
+ }
+ if (isTracepoint) {
+ opts[i] = "-a"; //$NON-NLS-1$
+ i ++;
+ }
if (opts.length > 0) {
setOptions(opts);
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakPasscount.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakPasscount.java
new file mode 100644
index 00000000000..e24c1bf0954
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakPasscount.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.mi.service.command.commands;
+
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+
+/**
+ *
+ * -break-passcount TRACEPOINT-NUMBER PASSCOUNT
+ *
+ * Set the passcount for tracepoint TRACEPOINT_NUMBER to PASSCOUNT. If the breakpoint
+ * referred to by TRACEPOINT_NUMBER is not a tracepoint, an error is emitted. This
+ * corresponds to the CLI command 'passcount'.
+ *
+ * Available starting with GDB 7.1
+ *
+ * @since 2.1
+ */
+
+public class MIBreakPasscount extends MICommand<MIInfo>
+{
+ public MIBreakPasscount(IBreakpointsTargetDMContext ctx, int tracepoint, int passCount) {
+ super(ctx, "-break-passcount", null, new String[] { Integer.toString(tracepoint), Integer.toString(passCount) }); //$NON-NLS-1$
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLITraceInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLITraceInfo.java
new file mode 100644
index 00000000000..2695a72098d
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/CLITraceInfo.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.mi.service.command.output;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * GDB/MI trace command output parsing.
+ *
+ * ~"Tracepoint 2 at 0x4035a9: file /scratch/marc/test/src/main.cxx, line 109"
+ *
+ * @since 2.1
+ */
+public class CLITraceInfo extends MIInfo {
+
+ public CLITraceInfo(MIOutput out) {
+ super(out);
+ parse();
+ }
+
+ Integer fReference = null;
+
+ public Integer getTraceReference(){
+ return fReference;
+ }
+
+ protected void parse() {
+ if (isDone()) {
+ MIOutput out = getMIOutput();
+ MIOOBRecord[] oobs = out.getMIOOBRecords();
+ for (int i = 0; i < oobs.length; i++) {
+ if (oobs[i] instanceof MIConsoleStreamOutput) {
+ MIStreamRecord cons = (MIStreamRecord) oobs[i];
+ String str = cons.getString();
+ str.trim();
+ if(str.length() > 0 ){
+ Pattern pattern = Pattern.compile("^Tracepoint\\s(\\d+)", Pattern.MULTILINE); //$NON-NLS-1$
+ Matcher matcher = pattern.matcher(str);
+ if (matcher.find()) {
+ String id = matcher.group(1);
+ try {
+ fReference = Integer.parseInt(id);
+ } catch (NumberFormatException e) {
+ fReference = null;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
index aaddbb5ecdd..1d490123892 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIBreakpoint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 QNX Software Systems and others.
+ * Copyright (c) 2009 QNX Software 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
@@ -9,6 +9,7 @@
* QNX Software Systems - Initial API and implementation
* Wind River Systems - Modified for new DSF Reference Implementation
* Ericsson - Modified for the breakpoint service
+ * Ericsson - Added Tracepoint support (284286)
*******************************************************************************/
package org.eclipse.cdt.dsf.mi.service.command.output;
@@ -41,7 +42,12 @@ package org.eclipse.cdt.dsf.mi.service.command.output;
* -break-watch p
* ^done,wpt={number="6",exp="p"}
* (gdb)
- */
+ *
+ * Tracepoints:
+ * bkpt={number="5",type="tracepoint",disp="keep",enabled="y",addr="0x0804846b",func="main",file="hello.c",line="4",thread="0",thread="0",times="0"}
+ * bkpt={number="1",type="tracepoint",disp="keep",enabled="y",addr="0x0041bca0",func="main",file="hello.c",line="4",times="0",pass="4",original-location="hello.c:4"},
+ * bkpt={number="5",type="fast tracepoint",disp="keep",enabled="y",addr="0x0804852d",func="testTracepoints()",file="TracepointTestApp.cc",fullname="/local/src/TracepointTestApp.cc",line="84",times="0",original-location="TracepointTestApp.cc:84"}
+ * */
public class MIBreakpoint {
int number = -1;
@@ -58,6 +64,10 @@ public class MIBreakpoint {
String exp = ""; //$NON-NLS-1$
String threadId = "0"; //$NON-NLS-1$
int ignore = 0;
+ String commands = ""; //$NON-NLS-1$
+
+ // For tracepoints
+ int passcount = 0;
boolean isWpt = false;
boolean isAWpt = false;
@@ -65,6 +75,10 @@ public class MIBreakpoint {
boolean isWWpt = false;
boolean isHdw = false;
+ // Indicate if we are dealing with a tracepoint.
+ // (if its a fast or slow tracepoint can be known through the 'type' field)
+ boolean isTpt = false;
+
public MIBreakpoint() {
}
@@ -73,7 +87,6 @@ public class MIBreakpoint {
type = new String(other.type);
disp = new String(other.disp);
enabled = other.enabled;
- type = new String(other.type);
address = new String(other.address);
func = new String(other.func);
fullName = new String(other.fullName);
@@ -84,11 +97,14 @@ public class MIBreakpoint {
exp = new String(other.exp);
threadId = new String(other.threadId);
ignore = other.ignore;
+ commands = other.commands;
+ passcount= other.passcount;
isWpt = other.isWpt;
isAWpt = other.isAWpt;
isRWpt = other.isRWpt;
isWWpt = other.isWWpt;
isHdw = other.isHdw;
+ isTpt = other.isTpt;
}
public MIBreakpoint(MITuple tuple) {
@@ -171,6 +187,11 @@ public class MIBreakpoint {
return getDisposition().equals("del"); //$NON-NLS-1$
}
+ /**
+ * Will return true if we are dealing with a hardware breakpoint.
+ * Note that this method will return false for tracepoint, even
+ * if it is a fast tracepoint.
+ */
public boolean isHardware() {
return isHdw;
}
@@ -215,6 +236,56 @@ public class MIBreakpoint {
isWWpt = b;
}
+ /**
+ * Return whether this breakpoint is actually a tracepoint.
+ * This method will return true for both fast and slow tracepoints.
+ * To know of fast vs slow tracepoint use {@link getType()} and look
+ * for "tracepoint" or "fast tracepoint"
+ *
+ * @since 2.1
+ */
+ public boolean isTracepoint() {
+ return isTpt;
+ }
+
+ /**
+ * Returns the passcount of a tracepoint. Will return 0 if this
+ * breakpoint is not a tracepoint.
+ *
+ * @since 2.1
+ */
+ public int getPassCount() {
+ return passcount;
+ }
+
+ /**
+ * Set the passcount of a tracepoint. Will not do anything if
+ * this breakpoint is not a tracepoint.
+ * @since 2.1
+ */
+ public void setPassCount(int count) {
+ if (isTpt == false) return;
+ passcount = count;
+ }
+
+ /**
+ * Return the commands associated with this breakpoint (or tracepoint)
+ *
+ * @since 2.1
+ */
+ public String getCommands() {
+ return commands;
+ }
+
+ /**
+ * Sets the commands associated with this breakpoint (or tracepoint)
+ *
+ * @since 2.1
+ */
+ public void setCommands(String cmds) {
+ commands = cmds;
+ }
+
// Parse the result string
void parse(MITuple tuple) {
MIResult[] results = tuple.getMIResults();
@@ -249,6 +320,10 @@ public class MIBreakpoint {
isRWpt = true;
isWpt = true;
}
+ if (type.startsWith("tracepoint") || //$NON-NLS-1$
+ type.startsWith("fast tracepoint")) { //$NON-NLS-1$
+ isTpt = true;
+ }
// type="breakpoint"
// default ok.
} else if (var.equals("disp")) { //$NON-NLS-1$
@@ -285,6 +360,11 @@ public class MIBreakpoint {
ignore = Integer.parseInt(str.trim());
} catch (NumberFormatException e) {
}
+ } else if (var.equals("pass")) { //$NON-NLS-1$
+ try {
+ passcount = Integer.parseInt(str.trim());
+ } catch (NumberFormatException e) {
+ }
} else if (var.equals("cond")) { //$NON-NLS-1$
cond = str;
}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/bin/.cvsignore b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/bin/.cvsignore
index eb4f59ec793..1931d8e9352 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/bin/.cvsignore
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/bin/.cvsignore
@@ -3,4 +3,5 @@ SpecialTestApp.exe
GDBMIGenericTestApp.exe
MemoryTestApp.exe
ExpressionTestApp.exe
-MultiThread.exe \ No newline at end of file
+MultiThread.exe
+TracepointTestApp.exe \ No newline at end of file
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc
new file mode 100644
index 00000000000..1c6802d73f7
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/data/launch/src/TracepointTestApp.cc
@@ -0,0 +1,96 @@
+#include <stdio.h>
+
+int gIntVar = 543;
+double gDoubleVar = 543.543;
+char gCharVar = 'g';
+bool gBoolVar = false;
+
+int gIntArray[2] = {987, 654};
+double gDoubleArray[2] = {987.654, 654.321};
+char gCharArray[2] = {'g', 'd'};
+bool gBoolArray[2] = {true, false};
+
+int *gIntPtr = &gIntVar;
+double *gDoublePtr = &gDoubleVar;
+char *gCharPtr = &gCharVar;
+bool *gBoolPtr = &gBoolVar;
+
+int *gIntPtr2 = (int*)0x8;
+double *gDoublePtr2 = (double*)0x5432;
+char *gCharPtr2 = (char*)0x4321;
+bool *gBoolPtr2 = (bool*)0x12ABCDEF;
+
+class bar {
+public:
+ int d;
+private:
+ int e[2];
+};
+
+class bar2 {
+public:
+ int f;
+private:
+ int g[2];
+};
+
+class foo: public bar, bar2 {
+public:
+ int a[2];
+ bar b;
+private:
+ int c;
+};
+
+struct Z {
+public:
+ int x;
+ int y;
+};
+struct childStruct {
+public:
+ Z z;
+};
+
+void testTracepoints() {
+ printf("Running TracepointTest App\n");
+
+ int lIntVar = 12345;
+ double lDoubleVar = 12345.12345;
+ char lCharVar = 'm';
+ bool lBoolVar = false;
+
+ int lIntArray[2] = {6789, 12345};
+ double lDoubleArray[2] = {456.789, 12345.12345};
+ char lCharArray[2] = {'i', 'm'};
+ bool lBoolArray[2] = {true, false};
+
+ int *lIntPtr = &lIntVar;
+ double *lDoublePtr = &lDoubleVar;
+ char *lCharPtr = &lCharVar;
+ bool *lBoolPtr = &gBoolVar;
+
+ int *lIntPtr2 = (int*)0x1;
+ double *lDoublePtr2 = (double*)0x2345;
+ char *lCharPtr2 = (char*)0x1234;
+ bool *lBoolPtr2 = (bool*)0x123ABCDE;
+
+ int counter = 0;
+ // Small loop
+ for (counter=0; counter<10;) {
+ counter++;
+ }
+
+ counter = 185;
+
+ // Large loop
+ for (counter=0; counter<10000;) {
+ counter++;
+ }
+}
+
+int main() {
+ testTracepoints();
+ return 0;
+}
+
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java
new file mode 100644
index 00000000000..359c2738f53
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/GDBRemoteTracepointsTest_7_0.java
@@ -0,0 +1,1042 @@
+/*******************************************************************************
+ * 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 implementation of Test cases
+ *******************************************************************************/
+package org.eclipse.cdt.tests.dsf.gdb.tests.tests_7_0;
+
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
+import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
+import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMData;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsAddedEvent;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsRemovedEvent;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext;
+import org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsUpdatedEvent;
+import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
+import org.eclipse.cdt.dsf.gdb.IGDBLaunchConfigurationConstants;
+import org.eclipse.cdt.dsf.mi.service.MIBreakpointDMData;
+import org.eclipse.cdt.dsf.mi.service.MIBreakpoints;
+import org.eclipse.cdt.dsf.service.DsfServiceEventHandler;
+import org.eclipse.cdt.dsf.service.DsfServicesTracker;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.tests.dsf.gdb.framework.AsyncCompletionWaitor;
+import org.eclipse.cdt.tests.dsf.gdb.framework.BackgroundRunner;
+import org.eclipse.cdt.tests.dsf.gdb.framework.BaseTestCase;
+import org.eclipse.cdt.tests.dsf.gdb.launching.TestsPlugin;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(BackgroundRunner.class)
+public class GDBRemoteTracepointsTest_7_0 extends BaseTestCase {
+ @BeforeClass
+ public static void beforeClassMethod_7_0() {
+ setLaunchAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, "gdb.7.0");
+ setLaunchAttribute(ATTR_DEBUG_SERVER_NAME, "gdbserver.7.0");
+ setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "data/launch/bin/TracepointTestApp.exe");
+
+ // GDB tracepoints are only supported on a remote target (e.g., using gdbserver)
+ setLaunchAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_START_MODE,
+ IGDBLaunchConfigurationConstants.DEBUGGER_MODE_REMOTE);
+ }
+
+ private DsfSession fSession;
+ private DsfServicesTracker fServicesTracker;
+ private IBreakpoints fBreakpointService;
+// private ITraceControl fTraceService;
+ private IBreakpointsTargetDMContext fBreakpointsDmc;
+// private ITraceTargetDMContext fTraceTargetDmc;
+
+// private int fTotalTracingBufferSize = 0;
+
+ private final static int[] PASS_COUNTS = {12, 2, 32, 6, 128, 0, 0, 0, 0, 0, 0, 0};
+
+// private static CollectAction COLLECT_ACTION_1;
+// private static CollectAction COLLECT_ACTION_2;
+// private static CollectAction COLLECT_ACTION_3;
+// private static EvalAction EVAL_ACTION_1;
+// private static EvalAction EVAL_ACTION_2;
+// private static EvalAction EVAL_ACTION_3;
+// private static WhileSteppingAction STEPPING_ACTION_1;
+// private static WhileSteppingAction STEPPING_ACTION_2;
+// private static WhileSteppingAction STEPPING_ACTION_3;
+
+
+// static {
+// BreakpointActionManager breakpointActionMgr = CDebugCorePlugin.getDefault().getBreakpointActionManager();
+//
+// COLLECT_ACTION_1 = new CollectAction();
+// COLLECT_ACTION_1.setCollectString("$locals, counter");
+// COLLECT_ACTION_1.setName("CollectAction1");
+// breakpointActionMgr.addAction(COLLECT_ACTION_1);
+//
+// COLLECT_ACTION_2 = new CollectAction();
+// COLLECT_ACTION_2.setCollectString("$reg");
+// COLLECT_ACTION_2.setName("CollectAction2");
+// breakpointActionMgr.addAction(COLLECT_ACTION_2);
+//
+// COLLECT_ACTION_3 = new CollectAction();
+// COLLECT_ACTION_3.setCollectString("$myTraceVariable");
+// COLLECT_ACTION_3.setName("CollectAction3");
+// breakpointActionMgr.addAction(COLLECT_ACTION_3);
+//
+//
+// EVAL_ACTION_1 = new EvalAction();
+// EVAL_ACTION_1.setEvalString("$count=$count+1");
+// EVAL_ACTION_1.setName("EvalAction1");
+// breakpointActionMgr.addAction(EVAL_ACTION_1);
+//
+// EVAL_ACTION_2 = new EvalAction();
+// EVAL_ACTION_2.setEvalString("$count2=$count2+2");
+// EVAL_ACTION_2.setName("EvalAction2");
+// breakpointActionMgr.addAction(EVAL_ACTION_2);
+//
+// EVAL_ACTION_3 = new EvalAction();
+// EVAL_ACTION_3.setEvalString("$count3=$count3+3");
+// EVAL_ACTION_3.setName("EvalAction3");
+// breakpointActionMgr.addAction(EVAL_ACTION_3);
+//
+// //TODO do while stepping actions
+//
+// }
+
+ @Before
+ public void initialTest() throws Throwable {
+ fSession = getGDBLaunch().getSession();
+ fServicesTracker = new DsfServicesTracker(TestsPlugin.getBundleContext(), fSession.getId());
+
+ ICommandControlService commandControl = fServicesTracker.getService(ICommandControlService.class);
+ fBreakpointsDmc = (IBreakpointsTargetDMContext)commandControl.getContext();
+ assert(fBreakpointsDmc != null);
+
+// fTraceTargetDmc = (ITraceTargetDMContext)commandControl.getContext();
+
+ fBreakpointService = fServicesTracker.getService(IBreakpoints.class);
+// fTraceService = fServicesTracker.getService(ITraceControl.class);
+ fSession.addServiceEventListener(this, null);
+
+ // Create a large array to make sure we don't run out
+ fTracepoints = new IBreakpointDMContext[100];
+
+ // Run an initial test to check that everything is ok with GDB
+ checkTraceInitialStatus();
+ }
+
+ @After
+ public void shutdown() {
+ fSession.removeServiceEventListener(this);
+ fBreakpointService = null;
+ fServicesTracker.dispose();
+ }
+
+
+ // *********************************************************************
+ // Below are utility methods.
+ // *********************************************************************
+ private static Boolean lock = true;
+ enum Events {BP_ADDED, BP_UPDATED, BP_REMOVED, BP_HIT}
+ final int BP_ADDED = Events.BP_ADDED.ordinal();
+ final int BP_UPDATED = Events.BP_UPDATED.ordinal();
+ final int BP_REMOVED = Events.BP_REMOVED.ordinal();
+ final int BP_HIT = Events.BP_HIT.ordinal();
+ private int[] fBreakpointEvents = new int[Events.values().length];
+ private boolean fBreakpointEvent;
+ private int fBreakpointEventCount;
+
+ @DsfServiceEventHandler
+ public void eventDispatched(IBreakpointsAddedEvent e) {
+ synchronized (lock) {
+ fBreakpointEvents[BP_ADDED]++;
+ fBreakpointEventCount++;
+ fBreakpointEvent = true;
+ lock.notifyAll();
+ }
+ }
+
+ @DsfServiceEventHandler
+ public void eventDispatched(IBreakpointsUpdatedEvent e) {
+ synchronized (lock) {
+ fBreakpointEvents[BP_UPDATED]++;
+ fBreakpointEventCount++;
+ fBreakpointEvent = true;
+ lock.notifyAll();
+ }
+ }
+
+ @DsfServiceEventHandler
+ public void eventDispatched(IBreakpointsRemovedEvent e) {
+ synchronized (lock) {
+ fBreakpointEvents[BP_REMOVED]++;
+ fBreakpointEventCount++;
+ fBreakpointEvent = true;
+ lock.notifyAll();
+ }
+ }
+
+ // Clears the counters
+ private void clearEventCounters() {
+ synchronized (lock) {
+ for (int i = 0; i < fBreakpointEvents.length; i++) {
+ fBreakpointEvents[i] = 0;
+ }
+ fBreakpointEvent = false;
+ fBreakpointEventCount = 0;
+ }
+ }
+
+ // Get the breakpoint hit count
+ private int getBreakpointEventCount(int event) {
+ int count = 0;
+ synchronized (lock) {
+ count = fBreakpointEvents[event];
+ }
+ return count;
+ }
+
+ // Suspends the thread until an event is flagged
+ // NOTE: too simple for real life but good enough for this test suite
+ private void waitForBreakpointEvent() {
+ synchronized (lock) {
+ while (!fBreakpointEvent) {
+ try {
+ lock.wait();
+ } catch (InterruptedException ex) {
+ }
+ }
+ fBreakpointEvent = false;
+ }
+ }
+
+ // *********************************************************************
+ // Breakpoint service methods (to use with tracepoints).
+ // *********************************************************************
+
+ private IBreakpointDMContext insertBreakpoint(final IBreakpointsTargetDMContext context,
+ final Map<String,Object> attributes) throws InterruptedException
+ {
+ final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+
+ fBreakpointService.getExecutor().submit(new Runnable() {
+ public void run() {
+ fBreakpointService.insertBreakpoint(context, attributes,
+ new DataRequestMonitor<IBreakpointDMContext>(fBreakpointService.getExecutor(), null) {
+ @Override
+ protected void handleCompleted() {
+ wait.setReturnInfo(getData());
+ wait.waitFinished(getStatus());
+ }
+ });
+ }
+ });
+
+ // Wait for the result and return the breakpoint id
+ wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+ assertTrue(wait.getMessage(), wait.isOK());
+
+ return (IBreakpointDMContext)wait.getReturnInfo();
+ }
+
+ private void removeBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
+ {
+ final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+
+ fBreakpointService.getExecutor().submit(new Runnable() {
+ public void run() {
+ fBreakpointService.removeBreakpoint(breakpoint,
+ new RequestMonitor(fBreakpointService.getExecutor(), null) {
+ @Override
+ protected void handleCompleted() {
+ wait.waitFinished(getStatus());
+ }
+ });
+ }
+ });
+
+ wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+ assertTrue(wait.getMessage(), wait.isOK());
+ }
+
+ private void updateBreakpoint(final IBreakpointDMContext breakpoint,
+ final Map<String, Object> delta) throws InterruptedException
+ {
+ final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+
+ fBreakpointService.getExecutor().submit(new Runnable() {
+ public void run() {
+ fBreakpointService.updateBreakpoint(breakpoint, delta,
+ new RequestMonitor(fBreakpointService.getExecutor(), null) {
+ @Override
+ protected void handleCompleted() {
+ wait.waitFinished(getStatus());
+ }
+ });
+ }
+ });
+
+ wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+ assertTrue(wait.getMessage(), wait.isOK());
+ }
+
+ private IBreakpointDMData getBreakpoint(final IBreakpointDMContext breakpoint) throws InterruptedException
+ {
+ final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+
+ fBreakpointService.getExecutor().submit(new Runnable() {
+ public void run() {
+ fBreakpointService.getBreakpointDMData(breakpoint,
+ new DataRequestMonitor<IBreakpointDMData>(fBreakpointService.getExecutor(), null) {
+ @Override
+ protected void handleCompleted() {
+ wait.setReturnInfo(getData());
+ wait.waitFinished(getStatus());
+ }
+ });
+ }
+ });
+
+ wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+ assertTrue(wait.getMessage(), wait.isOK());
+
+ return (IBreakpointDMData)wait.getReturnInfo();
+ }
+
+ private IBreakpointDMContext[] getBreakpoints(final IBreakpointsTargetDMContext context) throws InterruptedException
+ {
+ final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+
+ fBreakpointService.getExecutor().submit(new Runnable() {
+ public void run() {
+ fBreakpointService.getBreakpoints(context, new DataRequestMonitor<IBreakpointDMContext[]>(fBreakpointService.getExecutor(), null) {
+ @Override
+ protected void handleCompleted() {
+ wait.setReturnInfo(getData());
+ wait.waitFinished(getStatus());
+ }
+ });
+ }
+ });
+
+ wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+ assertTrue(wait.getMessage(), wait.isOK());
+
+ return (IBreakpointDMContext[])wait.getReturnInfo();
+ }
+
+ // *********************************************************************
+ // TraceControl service methods.
+ // *********************************************************************
+
+// private void startTracing() throws InterruptedException
+// {
+// startTracing(null);
+// }
+//
+// private void startTracing(String errorMessage) throws InterruptedException
+// {
+// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.canStartTracing(fTraceTargetDmc,
+// new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.setReturnInfo(getData());
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// assertTrue(wait.getMessage(), wait.isOK());
+// assertTrue("Not allowed to start tracing!", (Boolean)wait.getReturnInfo());
+//
+// wait.waitReset();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.startTracing(fTraceTargetDmc,
+// new RequestMonitor(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// if (errorMessage == null) {
+// assertTrue(wait.getMessage(), wait.isOK());
+// } else {
+// assertTrue(wait.getMessage(), !wait.isOK());
+// assertTrue("Message " + wait.getMessage() + " does not contain \"" + errorMessage +"\"",
+// wait.getMessage().indexOf(errorMessage) != -1);
+// }
+// }
+//
+// private void stopTracing() throws InterruptedException
+// {
+// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.canStopTracing(fTraceTargetDmc,
+// new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.setReturnInfo(getData());
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// assertTrue(wait.getMessage(), wait.isOK());
+// assertTrue("Not allowed to stop tracing!", (Boolean)wait.getReturnInfo());
+//
+// wait.waitReset();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.stopTracing(fTraceTargetDmc,
+// new RequestMonitor(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// assertTrue(wait.getMessage(), wait.isOK());
+// }
+//
+// private boolean isTracing() throws InterruptedException
+// {
+// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.isTracing(fTraceTargetDmc,
+// new DataRequestMonitor<Boolean>(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.setReturnInfo(getData());
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// assertTrue(wait.getMessage(), wait.isOK());
+//
+// return (Boolean)wait.getReturnInfo();
+// }
+//
+// private ITraceStatusDMData getTraceStatus() throws InterruptedException
+// {
+// final AsyncCompletionWaitor wait = new AsyncCompletionWaitor();
+//
+// fTraceService.getExecutor().submit(new Runnable() {
+// public void run() {
+// fTraceService.getTraceStatus(fTraceTargetDmc,
+// new DataRequestMonitor<ITraceStatusDMData>(fTraceService.getExecutor(), null) {
+// @Override
+// protected void handleCompleted() {
+// wait.setReturnInfo(getData());
+// wait.waitFinished(getStatus());
+// }
+// });
+// }
+// });
+//
+// wait.waitUntilDone(AsyncCompletionWaitor.WAIT_FOREVER);
+// assertTrue(wait.getMessage(), wait.isOK());
+//
+// return (ITraceStatusDMData)wait.getReturnInfo();
+// }
+
+ // *********************************************************************
+ // Below are the tests for the control of tracepoints.
+ // *********************************************************************
+
+ private static final String SOURCE_FILE = "TracepointTestApp.cc";
+ private static final String METHOD_NAME = "testTracepoints";
+ private static final int LINE_NUMBER_1 = 84;
+ private static final int LINE_NUMBER_2 = 55;
+ private static final int LINE_NUMBER_3 = 56;
+ private static final int LINE_LOOP_1 = 81;
+ private static final int LINE_LOOP_2 = 88;
+ private static final String NO_CONDITION = "";
+// private static final int LAST_LINE_NUMBER = 94;
+//
+// private static final int TOTAL_FRAMES_TO_BE_COLLECTED = 1 + 1 + 10 + 1 + 10000;
+
+
+ private IBreakpointDMContext[] fTracepoints = null;
+
+// private void checkTraceStatus(boolean supported, boolean active, int frames,
+// STOP_REASON_ENUM reason, Integer stoppingTracepoint) throws Throwable {
+// ITraceStatusDMData status = getTraceStatus();
+// assertTrue("Error tracing supported should be " + supported + " but was " + status.isTracingSupported(),
+// status.isTracingSupported() == supported);
+// assertTrue("Error tracing active should be " + active + " but was " + status.isTracingActive(),
+// status.isTracingActive() == active);
+// boolean isTracing = isTracing();
+// assertTrue("Error, tracing active is " + status.isTracingActive() + " but the tracepoint service thinks it is " + isTracing,
+// status.isTracingActive() == isTracing);
+//
+// assertTrue("Wrong number of collected frames. Expected " + frames + " but got " +
+// status.getNumberOfCollectedFrame(),
+// status.getNumberOfCollectedFrame() == frames);
+// assertTrue("Total buffer size should be positive but is " +
+// status.getTotalBufferSize(),
+// status.getTotalBufferSize() > 0);
+//
+// if (fTotalTracingBufferSize == 0) {
+// // Initialize buffer
+// fTotalTracingBufferSize = status.getTotalBufferSize();
+// } else {
+// assertTrue("Total buffer size changed! Should be " + fTotalTracingBufferSize +
+// " but got " + status.getTotalBufferSize(),
+// status.getTotalBufferSize() == fTotalTracingBufferSize);
+// }
+//
+// assertTrue("Expected stopping reason " + reason + " but got " + status.getStopReason(),
+// status.getStopReason() == reason);
+// assertTrue("Expected stopping bp " + stoppingTracepoint + " but got " + status.getStoppingTracepoint(),
+// status.getStoppingTracepoint() == stoppingTracepoint);
+// }
+//
+// private void checkTraceStatus(boolean supported, boolean active, int frames) throws Throwable {
+// checkTraceStatus(supported, active, frames, null, null);
+// }
+
+ // GDB 7.0 does not support fast tracepoints, but GDB 7.1 will
+ protected boolean fastTracepointsSupported() { return false; }
+
+ private class TracepointData {
+ String sourceFile;
+ int lineNumber;
+ String condition;
+ int passcount;
+ boolean enabled;
+ String actions;
+ boolean isFastTp;
+
+ public TracepointData(String file, int line, String cond, int pass, boolean isEnabled, String acts, boolean fast) {
+ sourceFile = file;
+ lineNumber = line;
+ condition = cond;
+ passcount = pass;
+ enabled = isEnabled;
+ actions = acts;
+ if (fastTracepointsSupported()) {
+ isFastTp = fast;
+ } else {
+ isFastTp = false;
+ }
+ }
+ }
+
+ private void checkTracepoints(TracepointData[] dataArray) throws Throwable {
+ int numTracepoints = dataArray.length;
+
+ // Fetch the tp list from the backend
+ IBreakpointDMContext[] tracepoints = getBreakpoints(fBreakpointsDmc);
+ assertTrue("expected " + numTracepoints + " breakpoint(s), received "
+ + tracepoints.length, tracepoints.length == numTracepoints);
+
+ for (int i=0; i<numTracepoints; i++) {
+ TracepointData data = dataArray[i];
+
+ // Ensure that the tracepoints were correctly installed
+ MIBreakpointDMData tp = (MIBreakpointDMData) getBreakpoint(fTracepoints[i]);
+ assertTrue("tracepoint "+i+" is not a tracepoint but a " + tp.getBreakpointType(),
+ tp.getBreakpointType().equals(MIBreakpoints.TRACEPOINT));
+ assertTrue("tracepoint "+i+" should be a " + (data.isFastTp?"fast":"slow")+" tracepoint but is not",
+ tp.getType().equals("fast tracepoint") == data.isFastTp);
+ assertTrue("tracepoint "+i+" mismatch (wrong file name) got " + tp.getFileName(),
+ tp.getFileName().equals(data.sourceFile));
+ assertTrue("tracepoint "+i+" mismatch (wrong line number) got " + tp.getLineNumber(),
+ tp.getLineNumber() == data.lineNumber);
+ assertTrue("tracepoint "+i+" mismatch (wrong condition) got " + tp.getCondition(),
+ tp.getCondition().equals(data.condition));
+ assertTrue("tracepoint "+i+" mismatch (wrong pass count) got " + tp.getPassCount(),
+ tp.getPassCount() == data.passcount);
+ assertTrue("tracepoint "+i+" mismatch (wrong state) got " + tp.isEnabled(),
+ tp.isEnabled() == data.enabled);
+ assertTrue("tracepoint mismatch (wrong actions) got " + tp.getCommands(),
+ tp.getCommands().equals(data.actions));
+
+ assertTrue("tracepoint "+i+" mismatch",
+ tp.equals((MIBreakpointDMData)getBreakpoint(tracepoints[i])));
+ }
+ }
+
+ /**
+ * This test makes sure that the tracing status is correct when we start.
+ * It also stores the total buffer size to be used by other tests.
+ * This test is being run before every other test by being called
+ * by the @Before method; this allows to verify every launch of GDB.
+ */
+ @Test
+ public void checkTraceInitialStatus() throws Throwable {
+// checkTraceStatus(true, false, 0);
+ }
+
+ /**
+ * This test sets different tracepoints in the program:
+ * - using a method address
+ * - using a method name
+ * - using a filename and line number
+ *
+ * It also set a fast tracepoint by
+ */
+ @Test
+ public void testCreateTracepoints() throws Throwable {
+
+ Map<String, Object> attributes = null;
+ int index = 0;
+
+ // First tracepoint (will be a slow tracepoint)
+ attributes = new HashMap<String, Object>();
+ attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ attributes.put(MIBreakpoints.FUNCTION, "*"+METHOD_NAME);
+ fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
+
+ waitForBreakpointEvent();
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ + fBreakpointEventCount, fBreakpointEventCount == 1);
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
+ clearEventCounters();
+
+ // Second tracepoint (will be a fast tracepoint)
+ attributes = new HashMap<String, Object>();
+ attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
+ attributes.put(MIBreakpoints.FUNCTION, METHOD_NAME);
+ fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
+
+ waitForBreakpointEvent();
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ + fBreakpointEventCount, fBreakpointEventCount == 1);
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
+ clearEventCounters();
+
+ // Third tracepoint (will be a slow tracepoint)
+ attributes = new HashMap<String, Object>();
+ attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
+ attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_1);
+ fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
+
+ waitForBreakpointEvent();
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ + fBreakpointEventCount, fBreakpointEventCount == 1);
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
+ clearEventCounters();
+
+ // Forth tracepoint (will be a fast tracepoint)
+ attributes = new HashMap<String, Object>();
+ attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
+ attributes.put(MIBreakpoints.LINE_NUMBER, LINE_NUMBER_1);
+ fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
+
+ waitForBreakpointEvent();
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ + fBreakpointEventCount, fBreakpointEventCount == 1);
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
+ clearEventCounters();
+
+ // Fifth tracepoint (will be a slow tracepoint)
+ attributes = new HashMap<String, Object>();
+ attributes.put(MIBreakpoints.BREAKPOINT_TYPE, MIBreakpoints.TRACEPOINT);
+ attributes.put(MIBreakpoints.FILE_NAME, SOURCE_FILE);
+ attributes.put(MIBreakpoints.LINE_NUMBER, LINE_LOOP_2);
+ fTracepoints[index++] = insertBreakpoint(fBreakpointsDmc, attributes);
+
+ waitForBreakpointEvent();
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT event(s), received "
+ + fBreakpointEventCount, fBreakpointEventCount == 1);
+ assertTrue("BreakpointEvent problem: expected " + 1 + " BREAKPOINT_ADDED event(s), received "
+ + getBreakpointEventCount(BP_ADDED), getBreakpointEventCount(BP_ADDED) == 1);
+ clearEventCounters();
+
+ ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false));
+
+ checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
+ }
+
+ /**
+ * This test sets the different types of tracepoints and then deletes them
+ */
+ @Test
+ public void testDeleteTracepoints() throws Throwable {
+ testCreateTracepoints();
+ // Delete all tracepoints
+ for (IBreakpointDMContext tp : fTracepoints) {
+ if (tp == null) break;
+ removeBreakpoint(tp);
+ }
+
+ // Fetch the bp list from the backend
+ IBreakpointDMContext[] breakpoints = getBreakpoints(fBreakpointsDmc);
+ assertTrue("BreakpointService problem: expected " + 0 + " breakpoints, received "
+ + breakpoints.length, breakpoints.length == 0);
+ }
+
+ /**
+ * This test sets the different types of tracepoints and then disables them
+ */
+ @Test
+ public void testDisableTracepoints() throws Throwable {
+ testCreateTracepoints();
+
+ Map<String, Object> delta = new HashMap<String, Object>();
+ delta.put(MIBreakpoints.IS_ENABLED, false);
+ // Disable all tracepoints
+ for (IBreakpointDMContext tp : fTracepoints) {
+ if (tp == null) break;
+ updateBreakpoint(tp, delta);
+ }
+
+ ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, false, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, false, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, false, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, false, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, false, "", false));
+
+ checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
+ }
+
+ /**
+ * This test sets, disables the different types of tracepoints and then enables them
+ */
+ @Test
+ public void testEnableTracepoints() throws Throwable {
+ testDisableTracepoints();
+
+ Map<String, Object> delta = new HashMap<String, Object>();
+ delta.put(MIBreakpoints.IS_ENABLED, true);
+ // Enable all tracepoints
+ for (IBreakpointDMContext tp : fTracepoints) {
+ if (tp == null) break;
+ updateBreakpoint(tp, delta);
+ }
+
+ ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, 0, true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, 0, true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, 0, true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, 0, true, "", false));
+
+ checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
+ }
+
+ /**
+ * This test sets the different types of tracepoints and then sets their passcount
+ */
+ @Test
+ public void testTracepointPasscount() throws Throwable {
+ testCreateTracepoints();
+
+ Map<String, Object> delta = new HashMap<String, Object>();
+ // Set passcount for all tracepoints
+ for (int i=0; i<fTracepoints.length; i++) {
+ if (fTracepoints[i] == null) break;
+ if (PASS_COUNTS[i] == 0) continue;
+ delta.put(MIBreakpoints.PASS_COUNT, PASS_COUNTS[i]);
+ updateBreakpoint(fTracepoints[i], delta);
+ }
+
+ ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_2, NO_CONDITION, PASS_COUNTS[0], true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_3, NO_CONDITION, PASS_COUNTS[1], true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_1, NO_CONDITION, PASS_COUNTS[2], true, "", false));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, PASS_COUNTS[3], true, "", true));
+ dataArray.add(new TracepointData(SOURCE_FILE, LINE_LOOP_2, NO_CONDITION, PASS_COUNTS[4], true, "", false));
+
+ checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
+ }
+
+ /**
+ * This test sets a tracepoint and then gives it a condition
+ */
+ //@Test
+ public void testTracepointCondition() throws Throwable {
+ // Use trace state variables and stuff
+ }
+
+
+// private void testActions(String[] actions) throws Throwable {
+// Map<String, Object> delta = new HashMap<String, Object>();
+// ArrayList<TracepointData> dataArray = new ArrayList<TracepointData>();
+//
+// for (int i=0; i<actions.length; i++) {
+// delta.put(MIBreakpoints.COMMANDS, actions[i]);
+// updateBreakpoint(fTracepoints[i], delta);
+// dataArray.add(new TracepointData(SOURCE_FILE, LINE_NUMBER_1, NO_CONDITION, 0, true, actions[i], false));
+// }
+//
+// checkTracepoints(dataArray.toArray(new TracepointData[dataArray.size()]));
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some collect actions
+// */
+// @Test
+// public void testCollectActions() throws Throwable {
+// final String ACTIONS1 = COLLECT_ACTION_1.getName()+","+COLLECT_ACTION_2.getName()+","+COLLECT_ACTION_3.getName();
+// final String ACTIONS2 = COLLECT_ACTION_1.getName()+","+COLLECT_ACTION_3.getName();
+// final String ACTIONS3 = COLLECT_ACTION_3.getName();
+//
+// testCreateTracepoints();
+// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some eval actions
+// */
+// @Test
+// public void testEvalActions() throws Throwable {
+// final String ACTIONS1 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_2.getName()+","+EVAL_ACTION_3.getName();
+// final String ACTIONS2 = EVAL_ACTION_1.getName()+","+EVAL_ACTION_3.getName();
+// final String ACTIONS3 = EVAL_ACTION_3.getName();
+//
+// testCreateTracepoints();
+// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some while-stepping actions
+// */
+// //@Test
+// public void testSteppingActions() throws Throwable {
+//// final String ACTIONS1 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_2.getName()+","+STEPPING_ACTION_3.getName();
+//// final String ACTIONS2 = STEPPING_ACTION_1.getName()+","+STEPPING_ACTION_3.getName();
+//// final String ACTIONS3 = STEPPING_ACTION_3.getName();
+////
+//// testCreateTracepoints();
+//// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets a mix of different
+// * tracepoint actions
+// */
+// //@Test
+// public void testMixedActions() throws Throwable {
+//// final String ACTIONS1 = COLLECT_ACTION_1.getName() + "," +
+//// EVAL_ACTION_2.getName() + "," +
+//// STEPPING_ACTION_3.getName();
+//// final String ACTIONS2 = STEPPING_ACTION_1.getName() + "," +
+//// COLLECT_ACTION_2.getName() + "," +
+//// EVAL_ACTION_1.getName() + "," +
+//// COLLECT_ACTION_3.getName() + "," +
+//// EVAL_ACTION_2.getName() + "," +
+//// EVAL_ACTION_3.getName();
+//// final String ACTIONS3 = EVAL_ACTION_3.getName() + "," +
+//// COLLECT_ACTION_1.getName() + "," +
+//// EVAL_ACTION_2.getName() + "," +
+//// STEPPING_ACTION_3.getName();
+////
+//// testCreateTracepoints();
+//// testActions(new String[] {ACTIONS1, ACTIONS2, ACTIONS3, ""});
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some default collect actions
+// */
+// //@Test
+// public void testDefaultCollectAction() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+// // *********************************************************************
+// // Below are the tests for the control of tracing
+// // *********************************************************************
+//
+// /**
+// * This test sets different tracepoints in the program:
+// * - using a filename and line number
+// * - using a method name
+// * - using a method address
+// *
+// * and confirms they are installed when tracing starts
+// */
+// @Test
+// public void testCreateAndRunTracepoints() throws Throwable {
+// testCreateTracepoints();
+// startTracing();
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+// checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED);
+// stopTracing();
+// checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED);
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then deletes them
+// * and confirms they are not installed when tracing starts
+// */
+// @Test
+// public void testDeleteAndRunTracepoints() throws Throwable {
+// testDeleteTracepoints();
+// startTracing("No tracepoints available to download");
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+// checkTraceStatus(true, false, 0);
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then disables them
+// * and confirms they are not hit when tracing starts
+// */
+// @Test
+// public void testDisableAndRunTracepoints() throws Throwable {
+// testDisableTracepoints();
+// startTracing("None of the downloadable tracepoints enabled");
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+// checkTraceStatus(true, false, 0);
+// }
+//
+// /**
+// * This test sets, disables the different types of tracepoints and then enables them
+// * and confirms they are hit when tracing starts
+// */
+// @Test
+// public void testEnableAndRunTracepoints() throws Throwable {
+// testEnableTracepoints();
+// startTracing();
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+// checkTraceStatus(true, true, TOTAL_FRAMES_TO_BE_COLLECTED);
+// stopTracing();
+// checkTraceStatus(true, false, TOTAL_FRAMES_TO_BE_COLLECTED);
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets their passcount
+// * and confirms the passcount is respected
+// */
+// @Test
+// public void testTracepointPasscountAndRun1() throws Throwable {
+// testTracepointPasscount();
+// startTracing();
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+//
+// checkTraceStatus(true, false,
+// 1 + 1 + 10 + 1 + PASS_COUNTS[4],
+// STOP_REASON_ENUM.PASSCOUNT, 6);
+// }
+//
+// /**
+// * This test sets the passcount of the a tracepoint that is hit before some
+// * other tracepoints are hit, to confirm tracing really stops.
+// */
+// @Test
+// public void testTracepointPasscountAndRun2() throws Throwable {
+// testTracepointPasscount();
+//
+// // Set the passcount of the forth tp to make it stop the tracing
+// Map<String, Object> delta = new HashMap<String, Object>();
+// delta.put(MIBreakpoints.IGNORE_COUNT, 1);
+// updateBreakpoint(fTracepoints[3], delta);
+//
+// startTracing();
+// SyncUtil.SyncRunToLocation(Integer.toString(LAST_LINE_NUMBER));
+//
+// checkTraceStatus(true, false,
+// 1 + 1 + 10 + 1,
+// STOP_REASON_ENUM.PASSCOUNT, 5);
+// }
+//
+// /**
+// * This test sets a tracepoint and then gives it a condition
+// * and confirms the condition is respected
+// */
+// //@Test
+// public void testTracepointConditionAndRun() throws Throwable {
+// // Use trace state variables and stuff
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some collect actions
+// * and confirms the proper information is collected
+// */
+// //@Test
+// public void testCollectActionsAndRun() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some eval actions
+// * and confirms the trace variables are properly updated
+// */
+// //@Test
+// public void testEvalActionsAndRun() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some while-stepping actions
+// * and confirms the proper information is collected
+// */
+// //@Test
+// public void testSteppingActionsAndRun() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets a mix of different
+// * tracepoint actions and confirms the proper information is collected
+// */
+// //@Test
+// public void testMixedActionsAndRun() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+// /**
+// * This test sets the different types of tracepoints and then sets some default collect actions
+// * and confirms the proper information is collected
+// */
+// //@Test
+// public void testDefaultCollectActionAndRun() throws Throwable {
+// testCreateTracepoints();
+// }
+//
+
+
+}
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
index ab4e6e7366e..64922459907 100644
--- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/tests/tests_7_0/Suite_Remote_7_0.java
@@ -29,6 +29,7 @@ import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
// We need specific name for the tests of this suite, because of bug https://bugs.eclipse.org/172256
+ GDBRemoteTracepointsTest_7_0.class,
MIRegistersTest_7_0.class,
MIRunControlTest_7_0.class,
MIExpressionsTest_7_0.class,

Back to the top