Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Ryall2007-11-05 03:38:19 +0000
committerKen Ryall2007-11-05 03:38:19 +0000
commitbbea3fa250e6265a795f8bfeb1a7eae05dfde939 (patch)
tree4ce391beca4cf0db61c654509762a49d8e73fb2e
parent1df511765aecfe173d262313cf5681da5f46d18d (diff)
downloadorg.eclipse.cdt-bbea3fa250e6265a795f8bfeb1a7eae05dfde939.tar.gz
org.eclipse.cdt-bbea3fa250e6265a795f8bfeb1a7eae05dfde939.tar.xz
org.eclipse.cdt-bbea3fa250e6265a795f8bfeb1a7eae05dfde939.zip
Bug 118299.
-rw-r--r--debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement2.java20
-rw-r--r--debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIWatchpoint2.java41
-rw-r--r--debug/org.eclipse.cdt.debug.core/plugin.xml6
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java62
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java23
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties3
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java48
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CBreakpointManager.java71
-rw-r--r--debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java22
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java49
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java46
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java71
-rw-r--r--debug/org.eclipse.cdt.debug.ui/plugin.xml22
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ActionMessages.properties5
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java50
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java412
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnMemoryActionDelegate.java113
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java84
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java8
-rw-r--r--debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICMemorySelection.java38
20 files changed, 1018 insertions, 176 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement2.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement2.java
index e12e252f566..424ce84c056 100644
--- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement2.java
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIBreakpointManagement2.java
@@ -7,17 +7,20 @@
*
* Contributors:
* Nokia - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.core.cdi.model;
+import java.math.BigInteger;
+
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIAddressLocation;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.ICDIFunctionLocation;
import org.eclipse.cdt.debug.core.cdi.ICDILineLocation;
-public interface ICDIBreakpointManagement2 {
+public interface ICDIBreakpointManagement2 extends ICDIBreakpointManagement {
/**
* Set a line breakpoint.
@@ -76,6 +79,21 @@ public interface ICDIBreakpointManagement2 {
ICDICondition condition, boolean enabled) throws CDIException;
/**
+ * Set a watchpoint.
+ *
+ * @param type
+ * @param watchType
+ * @param expression
+ * @param memorySpace set to "" for default memorySpace
+ * @param range set to "" for default range
+ * @param condition
+ * @return
+ * @throws CDIException
+ */
+ ICDIWatchpoint setWatchpoint(int type, int watchType, String expression, String memorySpace, BigInteger range,
+ ICDICondition condition, boolean enabled) throws CDIException;
+
+ /**
* Set an exception point.
*
* @param clazz
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIWatchpoint2.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIWatchpoint2.java
new file mode 100644
index 00000000000..c3f9f946c48
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIWatchpoint2.java
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Freescale Semiconductor and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Freescale Semiconductor - Initial API and implementation, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
+ *******************************************************************************/
+
+package org.eclipse.cdt.debug.core.cdi.model;
+
+import java.math.BigInteger;
+import org.eclipse.cdt.debug.core.cdi.CDIException;
+
+/**
+ *
+ * Represents a watchpoint.
+ *
+ */
+public interface ICDIWatchpoint2 extends ICDIWatchpoint {
+
+ /**
+ * Returns the memory space associated with this
+ * watchpoint's start address, or null if there is no memory space.
+ *
+ * @return the memory space Id associated with the address of
+ * this watchpoint
+ * @throws CDIException if this method fails. Reasons include:
+ */
+ String getMemorySpace() throws CDIException;
+
+ /**
+ * Returns the range for this watchpoint in addressable units.
+ *
+ * @return the range of the watchpoint.
+ * @throws CDIException if this method fails. Reasons include:
+ */
+ BigInteger getRange() throws CDIException;
+}
diff --git a/debug/org.eclipse.cdt.debug.core/plugin.xml b/debug/org.eclipse.cdt.debug.core/plugin.xml
index 92a842e1c1e..c81340d9808 100644
--- a/debug/org.eclipse.cdt.debug.core/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.core/plugin.xml
@@ -92,6 +92,12 @@
name="org.eclipse.cdt.debug.core.expression">
</attribute>
<attribute
+ name="org.eclipse.cdt.debug.core.memoryspace">
+ </attribute>
+ <attribute
+ name="org.eclipse.cdt.debug.core.range">
+ </attribute>
+ <attribute
name="org.eclipse.cdt.debug.core.write">
</attribute>
<attribute
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 60c8113fbf7..e3bda5fcb80 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 QNX Software Systems and others.
+ * Copyright (c) 2004, 2006-7 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,10 +7,12 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.core;
import java.io.IOException;
+import java.math.BigInteger;
import java.util.HashMap;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IAddress;
@@ -24,6 +26,7 @@ import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
@@ -284,14 +287,7 @@ public class CDIDebugModel {
*/
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 );
- attributes.put( IBreakpoint.ID, getPluginIdentifier() );
- 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( ICWatchpoint.EXPRESSION, expression );
- attributes.put( ICWatchpoint.READ, Boolean.valueOf( readAccess ) );
- attributes.put( ICWatchpoint.WRITE, Boolean.valueOf( writeAccess ) );
+ setAttributes( attributes, sourceHandle, resource, writeAccess, readAccess, expression, "", BigInteger.ZERO, enabled, ignoreCount, condition, register );
return new CWatchpoint( resource, attributes, register );
}
@@ -314,6 +310,8 @@ public class CDIDebugModel {
* @param writeAccess whether this is write watchpoint
* @param readAccess whether this is read watchpoint
* @param expression the expression on which the watchpoint is set
+ * @param memorySpace the memory space in which the watchpoint is set
+ * @param range the range of the watchpoint in addressable units
* @param enabled whether to enable or disable this breakpoint
* @param ignoreCount the number of times this breakpoint will be ignored
* @param condition the breakpoint condition
@@ -326,20 +324,60 @@ public class CDIDebugModel {
* failure.</li>
* </ul>
*/
- public static ICWatchpoint createWatchpoint( String sourceHandle, IResource resource, int charStart, int charEnd, int lineNumber, boolean writeAccess, boolean readAccess, String expression, boolean enabled, int ignoreCount, String condition, boolean register ) throws CoreException {
+ 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 );
- attributes.put( IBreakpoint.ID, getPluginIdentifier() );
+ setAttributes( 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 ) );
+ return new CWatchpoint( resource, attributes, register );
+ }
+
+ /**
+ * Creates and returns a watchpoint for the source defined by the given
+ * source handle, at the given expression and over the given range.
+ * The marker associated with the watchpoint will be created on the
+ * specified resource.
+ *
+ * @param sourceHandle the handle to the watchpoint source
+ * @param resource the resource on which to create the associated watchpoint marker
+ * @param writeAccess whether this is write watchpoint
+ * @param readAccess whether this is read watchpoint
+ * @param expression the expression on which the watchpoint is set
+ * @param memorySpace the memory space in which the watchpoint is set
+ * @param range the range of the watchpoint in addressable units
+ * @param enabled whether to enable or disable this breakpoint
+ * @param ignoreCount the number of times this breakpoint will be ignored
+ * @param condition the breakpoint condition
+ * @param register whether to add this breakpoint to the breakpoint manager
+ * @return the watchpoint that was created
+ * @throws CoreException if this method fails. Reasons include:
+ * <ul>
+ * <li>Failure creating underlying marker. The exception's
+ * status contains the underlying exception responsible for the
+ * failure.</li>
+ * </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 );
+ return new CWatchpoint( resource, attributes, register );
+ }
+
+ /**
+ * Helper function for setting common 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 ) {
+ attributes.put( IBreakpoint.ID, getPluginIdentifier() );
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( ICWatchpoint.EXPRESSION, expression );
+ attributes.put( ICWatchpoint2.MEMORYSPACE, memorySpace );
+ attributes.put( ICWatchpoint2.RANGE, range.toString() );
attributes.put( ICWatchpoint.READ, Boolean.valueOf( readAccess ) );
attributes.put( ICWatchpoint.WRITE, Boolean.valueOf( writeAccess ) );
- return new CWatchpoint( resource, attributes, register );
}
/**
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java
index 45239286eb6..19840592824 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugUtils.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.core;
@@ -30,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.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CFloatingPointValue;
@@ -327,6 +329,11 @@ public class CDebugUtils {
StringBuffer label = new StringBuffer();
appendSourceName( watchpoint, label, qualified );
appendWatchExpression( watchpoint, label );
+ if ( watchpoint instanceof ICWatchpoint2 ) {
+ ICWatchpoint2 wp2 = (ICWatchpoint2)watchpoint;
+ appendWatchMemorySpace( wp2, label );
+ appendWatchRange( wp2, label );
+ }
appendIgnoreCount( watchpoint, label );
appendCondition( watchpoint, label );
return label.toString();
@@ -414,6 +421,22 @@ public class CDebugUtils {
}
}
+ private static void appendWatchMemorySpace( ICWatchpoint2 watchpoint, StringBuffer label ) throws CoreException {
+ String memorySpace = watchpoint.getMemorySpace();
+ if ( memorySpace != null && memorySpace.length() > 0 ) {
+ label.append( ' ' );
+ label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.6" ), new String[] { memorySpace } ) ); //$NON-NLS-1$
+ }
+ }
+
+ private static void appendWatchRange( ICWatchpoint2 watchpoint, StringBuffer label ) throws CoreException {
+ String range = watchpoint.getRange().toString();
+ if ( range.length() > 0 && !range.equals( "0" ) ) {
+ label.append( ' ' );
+ label.append( MessageFormat.format( DebugCoreMessages.getString( "CDebugUtils.7" ), new String[]{ range } ) ); //$NON-NLS-1$
+ }
+ }
+
private static boolean isEmpty( String string ) {
return ( string == null || string.trim().length() == 0 );
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties
index 9b61c116aa3..a8bd33a2672 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/DebugCoreMessages.properties
@@ -7,6 +7,7 @@
#
# Contributors:
# QNX Software Systems - initial API and implementation
+# Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
###############################################################################
CDebugCorePlugin.0=No such debugger
CDebugUtils.0=[line: {0}]
@@ -15,4 +16,6 @@ CDebugUtils.2=[function: {0}]
CDebugUtils.3=[ignore count: {0}]
CDebugUtils.4=[condition: {0}]
CDebugUtils.5=[expression: ''{0}'']
+CDebugUtils.6=[memory space: {0}]
+CDebugUtils.7=[units: {0}]
CDIDebugModel.0=Unable to parser binary information from file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java
new file mode 100644
index 00000000000..2bd9409daf4
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICWatchpoint2.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Freescale Semiconductor and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Freescale Semiconductor - Initial API, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
+ *******************************************************************************/
+package org.eclipse.cdt.debug.core.model;
+
+import java.math.BigInteger;
+
+import org.eclipse.core.runtime.CoreException;
+
+public interface ICWatchpoint2 extends ICWatchpoint {
+
+ /**
+ * Watchpoint attribute storing the memory space associated with this
+ * watchpoint (value <code>"org.eclipse.cdt.debug.core.memoryspace"</code>).
+ * This attribute is a <code>String</code>.
+ */
+ public static final String MEMORYSPACE = "org.eclipse.cdt.debug.core.memoryspace"; //$NON-NLS-1$
+
+ /**
+ * Watchpoint attribute storing the range associated with this
+ * watchpoint (value <code>"org.eclipse.cdt.debug.core.range"</code>).
+ * This attribute is an <code>int</code>.
+ */
+ public static final String RANGE = "org.eclipse.cdt.debug.core.range"; //$NON-NLS-1$
+
+ /**
+ * Returns the watchpoint's memory space.
+ *
+ * @return the memory space of this watchpoint
+ * @throws CDIException if this method fails. Reasons include:
+ */
+ String getMemorySpace() throws CoreException;
+
+ /**
+ * Returns the watchpoint's range.
+ *
+ * @return the range of this watchpoint
+ * @throws CDIException if this method fails. Reasons include:
+ */
+ BigInteger getRange() 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 872c1a9cd0f..32887939202 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
@@ -10,6 +10,7 @@
* Matthias Spycher (matthias@coware.com) - patch for bug #112008
* Ken Ryall (Nokia) - bugs 170027, 105196
* Ling Wang (Nokia) - bug 176081
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core;
@@ -47,6 +48,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIFunctionBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDILocationBreakpoint;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint2;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDITargetConfiguration;
@@ -57,6 +59,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
@@ -223,6 +226,14 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
if ( breakpoint instanceof ICWatchpoint && cdiBreakpoint instanceof ICDIWatchpoint ) {
try {
ICWatchpoint watchpoint = (ICWatchpoint)breakpoint;
+ if ( watchpoint instanceof ICWatchpoint2 && cdiBreakpoint instanceof ICDIWatchpoint2 ) {
+ ICWatchpoint2 wp2 = (ICWatchpoint2)breakpoint;
+ ICDIWatchpoint2 cdiwp2 = (ICDIWatchpoint2)cdiBreakpoint;
+ if ( !wp2.getMemorySpace().equals( cdiwp2.getMemorySpace() )
+ || !wp2.getRange().equals( cdiwp2.getRange() ) ) {
+ return false;
+ }
+ }
ICDIWatchpoint cdiWatchpoint = (ICDIWatchpoint)cdiBreakpoint;
return ( watchpoint.getExpression().compareTo( cdiWatchpoint.getWatchExpression() ) == 0 &&
watchpoint.isReadType() == cdiWatchpoint.isReadType() &&
@@ -725,10 +736,17 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
accessType |= (watchpoint.isReadType()) ? ICDIWatchpoint.READ : 0;
String expression = watchpoint.getExpression();
ICDICondition condition = createCondition( watchpoint );
- if (bpManager2 != null)
- b = bpManager2.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, condition, breakpoints[i].isEnabled() );
- else
+ if ( bpManager2 != null ) {
+ if ( breakpoints[i] instanceof ICWatchpoint2 ) {
+ ICWatchpoint2 wp2 = (ICWatchpoint2)watchpoint;
+ b = bpManager2.setWatchpoint(ICDIBreakpoint.REGULAR, accessType, expression, wp2.getMemorySpace(),
+ wp2.getRange(), condition, breakpoints[i].isEnabled() );
+ } else {
+ b = bpManager2.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, condition, breakpoints[i].isEnabled() );
+ }
+ } else {
b = cdiTarget.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, condition );
+ }
}
if ( b != null ) {
Object obj = getBreakpointMap().get( breakpoints[i] );
@@ -861,15 +879,30 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
private ICWatchpoint createWatchpoint( ICDIWatchpoint cdiWatchpoint ) throws CDIException, CoreException {
IPath execFile = getExecFilePath();
String sourceHandle = execFile.toOSString();
- ICWatchpoint watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
- getProject(),
- cdiWatchpoint.isWriteType(),
- cdiWatchpoint.isReadType(),
- cdiWatchpoint.getWatchExpression(),
- cdiWatchpoint.isEnabled(),
- cdiWatchpoint.getCondition().getIgnoreCount(),
- cdiWatchpoint.getCondition().getExpression(),
- false );
+ ICWatchpoint watchpoint = null;
+ if ( cdiWatchpoint instanceof ICDIWatchpoint2 ){
+ watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
+ getProject(),
+ cdiWatchpoint.isWriteType(),
+ cdiWatchpoint.isReadType(),
+ cdiWatchpoint.getWatchExpression(),
+ ( (ICDIWatchpoint2)cdiWatchpoint ).getMemorySpace(),
+ ( (ICDIWatchpoint2)cdiWatchpoint ).getRange(),
+ cdiWatchpoint.isEnabled(),
+ cdiWatchpoint.getCondition().getIgnoreCount(),
+ cdiWatchpoint.getCondition().getExpression(),
+ false);
+ } else {
+ watchpoint = CDIDebugModel.createWatchpoint( sourceHandle,
+ getProject(),
+ cdiWatchpoint.isWriteType(),
+ cdiWatchpoint.isReadType(),
+ cdiWatchpoint.getWatchExpression(),
+ cdiWatchpoint.isEnabled(),
+ cdiWatchpoint.getCondition().getIgnoreCount(),
+ cdiWatchpoint.getCondition().getExpression(),
+ false );
+ }
return watchpoint;
}
@@ -1031,15 +1064,21 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
}
catch( CoreException e ) {
}
- if ( module != null )
+ if ( module != null && getExecFilePath() != null )
return getExecFilePath().toOSString().equals( module );
+
// supporting old breakpoints (> 3.0)
+ String sourceHandle = null;
try {
- return getExecFilePath().toOSString().equals( breakpoint.getSourceHandle() );
+ sourceHandle = breakpoint.getSourceHandle();
}
catch( CoreException e ) {
}
- return false;
+ if ( sourceHandle != null && getExecFilePath() != null )
+ return getExecFilePath().toOSString().equals( sourceHandle );
+
+ return module != null && module.length() == 0 &&
+ sourceHandle != null && sourceHandle.length() == 0;
}
public void skipBreakpoints( boolean enabled ) {
@@ -1092,6 +1131,8 @@ public class CBreakpointManager implements IBreakpointsListener, IBreakpointMana
}
private IPath getExecFilePath() {
+ if (getDebugTarget() == null || getDebugTarget().getExecFile() == null)
+ return null;
return getDebugTarget().getExecFile().getPath();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java
index 1ea608de837..8e87a3be1c9 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/breakpoints/CWatchpoint.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 2006-7 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,13 +7,15 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.breakpoints;
+import java.math.BigInteger;
import java.text.MessageFormat;
import java.util.Map;
import org.eclipse.cdt.debug.core.CDebugUtils;
-import org.eclipse.cdt.debug.core.model.ICWatchpoint;
+import org.eclipse.cdt.debug.core.model.ICWatchpoint2;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -21,7 +23,7 @@ import org.eclipse.core.runtime.CoreException;
/**
* A watchpoint specific to the C/C++ debug model.
*/
-public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
+public class CWatchpoint extends CBreakpoint implements ICWatchpoint2 {
private static final String C_WATCHPOINT = "org.eclipse.cdt.debug.core.cWatchpointMarker"; //$NON-NLS-1$
@@ -38,6 +40,10 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
super( resource, getMarkerType(), attributes, add );
}
+ protected CWatchpoint( IResource resource, String marker, Map attributes, boolean add ) throws CoreException {
+ super( resource, marker, attributes, add );
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICWatchpoint#isWriteType()
*/
@@ -100,4 +106,14 @@ public class CWatchpoint extends CBreakpoint implements ICWatchpoint {
public int getCharEnd() throws CoreException {
return ensureMarker().getAttribute( IMarker.CHAR_END, -1 );
}
+
+ public String getMemorySpace() throws CoreException {
+ return ensureMarker().getAttribute( MEMORYSPACE, "" );
+ }
+
+ public BigInteger getRange() throws CoreException {
+ String attr = ensureMarker().getAttribute( RANGE, "0" );
+ return new BigInteger( attr.length() > 0 ? attr : "0" );
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
index e4f95240eb2..e7bb474e22f 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java
@@ -350,7 +350,7 @@ public class BreakpointManager extends Manager {
if (breakpoint instanceof LocationBreakpoint) {
setLocationBreakpoint((LocationBreakpoint)breakpoint);
} else if (breakpoint instanceof Watchpoint) {
- setWatchpoint((Watchpoint)breakpoint);
+ setWatchpoint((Watchpoint)breakpoint, false);
} else {
throw new CDIException(CdiResources.getString("cdi.BreakpointManager.Not_a_CDT_breakpoint")); //$NON-NLS-1$
}
@@ -361,7 +361,7 @@ public class BreakpointManager extends Manager {
if (breakpoint instanceof LocationBreakpoint) {
setLocationBreakpoint((LocationBreakpoint)breakpoint);
} else if (breakpoint instanceof Watchpoint) {
- setWatchpoint((Watchpoint)breakpoint);
+ setWatchpoint((Watchpoint)breakpoint, false);
}
}
}
@@ -675,32 +675,6 @@ public class BreakpointManager extends Manager {
}
}
- public ICDIWatchpoint setWatchpoint(Target target, int type, int watchType, String expression,
- ICDICondition condition, boolean enabled) throws CDIException {
-
- // HACK: for the IDE,
- try {
- // Check if this an address watchpoint, and add a '*'
- Integer.decode(expression);
- expression = '*' + expression;
- } catch (NumberFormatException e) {
- //
- }
- Watchpoint bkpt = new Watchpoint(target, expression, type, watchType, condition, enabled);
-
- setWatchpoint(bkpt);
- List bList = getBreakpointsList(target);
- bList.add(bkpt);
-
- // Fire a created Event.
- MIBreakpoint[] miBreakpoints = bkpt.getMIBreakpoints();
- if (miBreakpoints != null && miBreakpoints.length > 0) {
- MISession miSession = target.getMISession();
- miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, miBreakpoints[0].getNumber()));
- }
- return bkpt;
- }
-
public void setLocationBreakpoint (LocationBreakpoint bkpt) throws CDIException {
Target target = (Target)bkpt.getTarget();
MISession miSession = target.getMISession();
@@ -766,11 +740,15 @@ public class BreakpointManager extends Manager {
bkpt.setMIBreakpoints(allPoints);
}
- public void setWatchpoint(Watchpoint watchpoint) throws CDIException {
+ public void setWatchpoint(Watchpoint bkpt) throws CDIException {
+ setWatchpoint(bkpt, true);
+ }
+
+ private void setWatchpoint(Watchpoint watchpoint, boolean isNew) throws CDIException {
Target target = (Target)watchpoint.getTarget();
boolean access = watchpoint.isReadType() && watchpoint.isWriteType();
boolean read = ! watchpoint.isWriteType() && watchpoint.isReadType();
- String expression = watchpoint.getWatchExpression();
+ String expression = watchpoint.getDerivedExpression();
MISession miSession = target.getMISession();
CommandFactory factory = miSession.getCommandFactory();
@@ -824,6 +802,17 @@ public class BreakpointManager extends Manager {
resumeInferior(target, restart);
}
watchpoint.setMIBreakpoints(points);
+
+ if (isNew) {
+ List bList = getBreakpointsList(target);
+ bList.add(watchpoint);
+
+ // Fire a created Event.
+ MIBreakpoint[] miBreakpoints = watchpoint.getMIBreakpoints();
+ if (miBreakpoints != null && miBreakpoints.length > 0) {
+ miSession.fireEvent(new MIBreakpointCreatedEvent(miSession, miBreakpoints[0].getNumber()));
+ }
+ }
}
Breakpoint[] exceptionBps = new Breakpoint[2];
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
index 74d1ec16d3a..463fd8a9785 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Target.java
@@ -36,6 +36,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIGlobalVariableDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.ICDIInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDILineBreakpoint;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMemoryBlock;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
import org.eclipse.cdt.debug.core.cdi.model.ICDIMixedInstruction;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterDescriptor;
@@ -95,7 +96,7 @@ import org.eclipse.cdt.debug.mi.core.output.MIThreadSelectInfo;
/**
*/
-public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement2, ICDIAddressToSource {
+public class Target extends SessionObject implements ICDITarget, ICDIBreakpointManagement2, ICDIAddressToSource, ICDIMemorySpaceManagement {
public class Lock {
@@ -145,6 +146,9 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
boolean suspended = true;
boolean deferBreakpoints = true;
Lock lock = new Lock();
+
+ final static String CODE_MEMORY_SPACE = "code"; //$NON-NLS-1$
+ final static String DATA_MEMORY_SPACE = "data"; //$NON-NLS-1$
public Target(Session s, MISession mi) {
super(s);
@@ -913,6 +917,28 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
}
/* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2#setWatchpoint(int, int, java.lang.String, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean)
+ */
+ public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression,
+ ICDICondition condition, boolean enabled) throws CDIException {
+ BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager();
+ Watchpoint bkpt = new Watchpoint(this, expression, type, watchType, condition, enabled);
+ bMgr.setWatchpoint(bkpt);
+ return bkpt;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement2#setWatchpoint(int, int, java.lang.String, java.math.BigInteger, org.eclipse.cdt.debug.core.cdi.ICDICondition, boolean)
+ */
+ public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression,
+ String memorySpace, BigInteger range, ICDICondition condition, boolean enabled) throws CDIException {
+ BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager();
+ Watchpoint bkpt = new Watchpoint(this, expression, memorySpace, range, type, watchType, condition, enabled);
+ bMgr.setWatchpoint(bkpt);
+ return bkpt;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpointManagement#setExceptionBreakpoint(java.lang.String, boolean, boolean)
*/
public ICDIExceptionpoint setExceptionBreakpoint(String clazz, boolean stopOnThrow, boolean stopOnCatch)
@@ -1229,11 +1255,6 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
return bMgr.setLineBreakpoint(this, type, location, condition, deferred, enabled);
}
- public ICDIWatchpoint setWatchpoint(int type, int watchType, String expression, ICDICondition condition, boolean enabled) throws CDIException {
- BreakpointManager bMgr = ((Session)getSession()).getBreakpointManager();
- return bMgr.setWatchpoint(this, type, watchType, expression, condition, enabled);
- }
-
public IMappedSourceLocation getSourceForAddress(IAddress address) throws CDIException {
// Ask gdb for info for this address, use the module list
// to determine the executable.
@@ -1256,4 +1277,17 @@ public class Target extends SessionObject implements ICDITarget, ICDIBreakpointM
throw new MI2CDIException(e);
}
}
+
+ public String addressToString(BigInteger address, String memorySpaceID) {
+ return null; // use CDT's built-in encoding/decoding <memspace>:<addr-hex>
+ }
+
+ public BigInteger stringToAddress(String str, StringBuffer memorySpaceID_out)
+ throws CDIException {
+ return null; // use CDT's built-in encoding/decoding <memspace>:<addr-hex>
+ }
+
+ public String[] getMemorySpaces() {
+ return new String[] { CODE_MEMORY_SPACE, DATA_MEMORY_SPACE };
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java
index 2720aac533f..da23fa2b2bf 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/cdi/org/eclipse/cdt/debug/mi/core/cdi/model/Watchpoint.java
@@ -10,35 +10,81 @@
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core.cdi.model;
+import java.math.BigInteger;
+
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDICondition;
import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint2;
import org.eclipse.cdt.debug.mi.core.output.MIBreakpoint;
/**
*/
-public class Watchpoint extends Breakpoint implements ICDIWatchpoint {
+public class Watchpoint extends Breakpoint implements ICDIWatchpoint2 {
int watchType;
- String what;
+ String expression;
+ String memorySpace;
+ BigInteger range;
+ String derivedExpression;
+
+ public Watchpoint(Target target, String expression, int type,
+ int watchType, ICDICondition condition, boolean enabled) {
+ this(target, expression, "", BigInteger.ZERO, type, watchType, condition, enabled);
+ }
- public Watchpoint(Target target, String expression, int type, int wType, ICDICondition cond, boolean enabled) {
+ public Watchpoint(Target target, String expression, String memorySpace,
+ BigInteger range, int type, int watchType, ICDICondition cond,
+ boolean enabled) {
super(target, type, cond, enabled);
- watchType = wType;
- what = expression;
+ this.watchType = watchType;
+ this.expression = expression;
+ this.memorySpace = memorySpace;
+ this.range = range;
+
+ // If the range and/or memory space are specified, cast the expression, e.g.,
+ // (@data char[4])(*0x402000)
+ derivedExpression = "";
+ boolean doSpecifyMemorySpace = memorySpace.length() > 0;
+ boolean doSpecifyRange = range.compareTo(BigInteger.ZERO) > 0;
+ boolean doSpecify = doSpecifyMemorySpace || doSpecifyRange;
+ if ( doSpecify ) {
+ derivedExpression += "(";
+ if ( doSpecifyMemorySpace ) {
+ derivedExpression += "@" + memorySpace;
+ if ( doSpecifyRange ) {
+ derivedExpression += " ";
+ }
+ }
+ if ( doSpecifyRange ) {
+ derivedExpression += "char[" + range.toString() + "]";
+ }
+ derivedExpression += ")(";
+ }
+
+ try {
+ // Check if this an address watchpoint, and add a '*'
+ Integer.decode(expression);
+ derivedExpression += '*';
+ } catch (NumberFormatException e) {
+ }
+ derivedExpression += expression;
+ if ( doSpecify ) {
+ derivedExpression += ")";
+ }
}
/**
* @see org.eclipse.cdt.debug.core.cdi.ICDIWatchpoint#getWatchExpression()
*/
public String getWatchExpression() throws CDIException {
- if (what == null) {
+ if (expression == null) {
MIBreakpoint[] miPoints = getMIBreakpoints();
if (miPoints != null && miPoints.length > 0) {
return miPoints[0].getWhat();
}
}
- return what;
+ return expression;
}
/**
@@ -63,4 +109,15 @@ public class Watchpoint extends Breakpoint implements ICDIWatchpoint {
// return ((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE);
}
+ public String getMemorySpace() throws CDIException {
+ return memorySpace;
+ }
+
+ public BigInteger getRange() throws CDIException {
+ return range;
+ }
+
+ public String getDerivedExpression() {
+ return derivedExpression;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/plugin.xml b/debug/org.eclipse.cdt.debug.ui/plugin.xml
index cbc05cb2ab5..5e8f9dff651 100644
--- a/debug/org.eclipse.cdt.debug.ui/plugin.xml
+++ b/debug/org.eclipse.cdt.debug.ui/plugin.xml
@@ -619,6 +619,15 @@
class="org.eclipse.cdt.debug.core.model.ICVariable">
</selection>
</action>
+ <action
+ class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
+ enablesFor="1"
+ icon="icons/elcl16/watchpoint_co.gif"
+ id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnVariableActionDelegate"
+ label="%AddWatchpoint.label"
+ menubarPath="additions"
+ tooltip="%AddWatchpoint.tooltip">
+ </action>
</viewerContribution>
<viewerContribution
targetID="org.eclipse.debug.ui.RegisterView"
@@ -773,6 +782,19 @@
menubarPath="additions"
tooltip="%EditRegisterGroupAction.tooltip"/>
</objectContribution>
+ <viewerContribution
+ id="org.eclipse.debug.ui.MemoryView.RenderingViewPane.popupMenu"
+ targetID="org.eclipse.debug.ui.MemoryView.RenderingViewPane.1">
+ <action
+ class="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnMemoryActionDelegate"
+ enablesFor="1"
+ icon="icons/elcl16/watchpoint_co.gif"
+ id="org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointOnMemoryActionDelegate"
+ label="%AddWatchpoint.label"
+ menubarPath="additions"
+ tooltip="%AddWatchpoint.tooltip">
+ </action>
+ </viewerContribution>
</extension>
<extension
point="org.eclipse.ui.viewActions">
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 fb9f7aa62f4..caf66468eac 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2003, 2006 QNX Software Systems and others.
+# Copyright (c) 2003, 2006-7 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
+# Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
###############################################################################
LoadSymbolsActionDelegate.Unable_to_load_symbols_of_shared_library_1=Unable to load symbols of shared library.
@@ -94,6 +95,8 @@ AddWatchpointDialog.1=Expression to watch:
AddWatchpointDialog.2=Access
AddWatchpointDialog.3=Write
AddWatchpointDialog.4=Read
+AddWatchpointDialog.5=Memory space:
+AddWatchpointDialog.6=Units:
ResumeAtLineAdapter.0=Empty editor
ResumeAtLineAdapter.1=Missing document
ResumeAtLineAdapter.2=Empty editor
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
index 04b17511b42..18726e426ba 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointActionDelegate.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 2006-7 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,14 +7,22 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
- *******************************************************************************/
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
+*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
+import java.math.BigInteger;
+
import org.eclipse.cdt.debug.core.CDIDebugModel;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
+import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
+import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IViewActionDelegate;
@@ -26,28 +34,38 @@ import org.eclipse.ui.actions.ActionDelegate;
*/
public class AddWatchpointActionDelegate extends ActionDelegate implements IViewActionDelegate {
+ private IViewPart fView;
+
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
- // TODO Auto-generated method stub
+ setView( view );
+ }
+
+ private void setView(IViewPart view) {
+ fView = view;
}
+ protected IViewPart getView() {
+ return fView;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
- AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), true, false, "", true ); //$NON-NLS-1$
+ AddWatchpointDialog dlg = new AddWatchpointDialog( CDebugUIPlugin.getActiveWorkbenchShell(), getMemorySpaceManagement() );
if ( dlg.open() == Window.OK ) {
- addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression() );
+ addWatchpoint( dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange() );
}
}
- private void addWatchpoint( boolean write, boolean read, String expression ) {
+ protected void addWatchpoint(boolean write, boolean read, String expression, String memorySpace, BigInteger range) {
if ( getResource() == null )
return;
try {
- CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, true, 0, "", true ); //$NON-NLS-1$
+ CDIDebugModel.createWatchpoint( getSourceHandle(), getResource(), write, read, expression, memorySpace, range, true, 0, "", true ); //$NON-NLS-1$
}
catch( CoreException ce ) {
CDebugUIPlugin.errorDialog( ActionMessages.getString( "AddWatchpointActionDelegate1.0" ), ce ); //$NON-NLS-1$
@@ -61,4 +79,22 @@ public class AddWatchpointActionDelegate extends ActionDelegate implements IView
private String getSourceHandle() {
return ""; //$NON-NLS-1$
}
+
+ static ICDIMemorySpaceManagement getMemorySpaceManagement(){
+ IAdaptable debugViewElement = DebugUITools.getDebugContext();
+ ICDIMemorySpaceManagement memMgr = null;
+
+ if ( debugViewElement != null ) {
+ ICDebugTarget debugTarget = (ICDebugTarget)debugViewElement.getAdapter(ICDebugTarget.class);
+
+ if ( debugTarget != null ){
+ ICDITarget target = (ICDITarget)debugTarget.getAdapter(ICDITarget.class);
+
+ if (target instanceof ICDIMemorySpaceManagement)
+ memMgr = (ICDIMemorySpaceManagement)target;
+ }
+ }
+
+ return memMgr;
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java
index 03d27fcd048..f1d5ca96b97 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 QNX Software Systems and others.
+ * Copyright (c) 2004-5, 2007 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,20 +7,30 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
-import org.eclipse.cdt.debug.internal.ui.CDebugImages;
+import java.math.BigInteger;
+import java.util.ArrayList;
+
+import org.eclipse.cdt.debug.core.cdi.model.ICDIMemorySpaceManagement;
+import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.events.VerifyEvent;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Group;
@@ -31,151 +41,369 @@ import org.eclipse.swt.widgets.Text;
/**
* The "Add Watchpoint" dialog of the "Toggle watchpoint" action.
*/
-public class AddWatchpointDialog extends Dialog {
+public class AddWatchpointDialog extends Dialog implements ModifyListener, SelectionListener {
- private Button fBtnOk = null;
+ private Combo fExpressionInput;
+ private String fExpression;
+ private static ArrayList sExpressionHistory = new ArrayList();
- private Text fTextExpression;
+ private boolean fHasMemorySpaceControls;
+ private Button fMemorySpaceEnableButton;
+ private Combo fMemorySpaceInput;
+ private String fMemorySpace;
+ private boolean fRangeInitialEnable;
+ private Button fRangeEnableButton;
+ private Text fRangeField;
+ private String fRange = new String();
+
private Button fChkBtnWrite;
-
private Button fChkBtnRead;
-
- private boolean fWrite = true;
-
- private boolean fRead = false;
-
- private String fExpression = ""; //$NON-NLS-1$
-
- private boolean fEditable = true;
+ private boolean fRead;
+ private boolean fWrite;
+
+ private ICDIMemorySpaceManagement fMemManagement;
+
/**
* Constructor for AddWatchpointDialog.
*
* @param parentShell
*/
- public AddWatchpointDialog( Shell parentShell, boolean write, boolean read, String expression, boolean editable ) {
+ public AddWatchpointDialog( Shell parentShell, ICDIMemorySpaceManagement memMgmt ) {
super( parentShell );
- fWrite = write;
- fRead = read;
- if ( expression != null )
- fExpression = expression;
- fEditable = editable;
+ setShellStyle( getShellStyle() | SWT.RESIZE );
+ fMemManagement = memMgmt;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createDialogArea( Composite parent ) {
+ // The button bar will work better if we make the parent composite
+ // a single column grid layout. For the widgets we add, we want a
+ // a two-column grid, so we just create a sub composite for that.
+ GridLayout gridLayout = new GridLayout();
+ parent.setLayout( gridLayout );
+ GridData gridData = new GridData( GridData.FILL_BOTH );
+ parent.setLayoutData( gridData );
+ Composite composite = new Composite( parent, SWT.None );
+ gridLayout = new GridLayout();
+ gridLayout.numColumns = 2;
+ composite.setLayout( gridLayout );
+ parent = composite;
- protected void configureShell( Shell shell ) {
- super.configureShell( shell );
- shell.setText( ActionMessages.getString( "AddWatchpointDialog.0" ) ); //$NON-NLS-1$
- shell.setImage( CDebugImages.get( CDebugImages.IMG_OBJS_WATCHPOINT_ENABLED ) );
+ // Create the controls
+ createExpressionControl( parent );
+ boolean hasDebugContext = DebugUITools.getDebugContext() != null;
+ boolean hasMemorySpaces = hasDebugContext && fMemManagement != null && fMemManagement.getMemorySpaces() != null && fMemManagement.getMemorySpaces().length > 0;
+ fHasMemorySpaceControls = !hasDebugContext || hasMemorySpaces;
+ if ( fHasMemorySpaceControls ) {
+ createMemorySpaceControl( parent, hasMemorySpaces );
+ }
+ createCountField( parent );
+ createAccessWidgets( parent );
+
+ // Initialize the inter-control state
+ if ( fExpression != null && fExpression.length() > 0 ) {
+ fExpressionInput.add( fExpression, 0 );
+ fExpressionInput.select( 0 );
+ }
+ fExpressionInput.setFocus();
+ if ( fHasMemorySpaceControls ) {
+ fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getEnabled() );
+ }
+ fRangeField.setEnabled( fRangeEnableButton.getEnabled() );
+ updateUI();
+ return parent;
}
+
+ private void createExpressionControl(Composite parent ) {
- protected Control createContents( Composite parent ) {
- Control control = super.createContents( parent );
- setOkButtonState();
- return control;
- }
+ Label l = new Label( parent, GridData.FILL_HORIZONTAL );
+ l.setText( ActionMessages.getString( "AddWatchpointDialog.1" ) ); //$NON-NLS-1$
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 2;
+ l.setLayoutData( gridData );
- protected Control createDialogArea( Composite parent ) {
- Composite composite = new Composite( parent, SWT.NONE );
- composite.setLayout( new GridLayout() );
- ((GridLayout)composite.getLayout()).marginWidth = 10;
- composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
- createDataWidgets( composite );
- initializeDataWidgets();
- return composite;
+ fExpressionInput = new Combo( parent, SWT.BORDER );
+ gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 2;
+ fExpressionInput.setLayoutData( gridData );
+ fExpressionInput.addModifyListener( this );
+ String[] history = getHistory( sExpressionHistory );
+ for ( int i = 0; i < history.length; i++ )
+ fExpressionInput.add( history[i] );
}
+
+ private void createMemorySpaceControl( Composite parent, boolean hasMemorySpaces ) {
+ fMemorySpaceEnableButton = new Button( parent, SWT.CHECK );
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 1;
+ fMemorySpaceEnableButton.setLayoutData( gridData );
+ fMemorySpaceEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.5" ) ); //$NON-NLS-1$
+ fMemorySpaceEnableButton.setSelection( false );
+ fMemorySpaceEnableButton.addSelectionListener( this );
- protected void createButtonsForButtonBar( Composite parent ) {
- fBtnOk = createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true );
- createButton( parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false );
+ if ( hasMemorySpaces ) {
+ fMemorySpaceInput = new Combo( parent, SWT.BORDER | SWT.READ_ONLY );
+ } else {
+ fMemorySpaceInput = new Combo( parent, SWT.BORDER );
+ }
+ gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 1;
+ fMemorySpaceInput.setLayoutData( gridData );
+ fMemorySpaceInput.addSelectionListener( this );
+ if ( fMemManagement != null ) {
+ String [] memorySpaces = fMemManagement.getMemorySpaces();
+ for ( int i = 0; i < memorySpaces.length; i++ ) {
+ fMemorySpaceInput.add( memorySpaces[i] );
+ }
+ }
+ if ( fMemorySpace != null && fMemorySpace.length() > 0 ) {
+ int i = fMemorySpaceInput.indexOf( fMemorySpace );
+ if ( i >= 0 ) {
+ fMemorySpaceInput.select( i );
+ fMemorySpaceEnableButton.setSelection( true );
+ } else {
+ fMemorySpaceInput.add( fMemorySpace );
+ }
+ }
+ fMemorySpaceInput.addModifyListener( this );
}
- private void createDataWidgets( Composite parent ) {
- fTextExpression = createExpressionText( parent );
- createAccessWidgets( parent );
+ /**
+ * @param text
+ * @param c
+ * @return true if the concatenation of text + c results
+ * in a valid string representation of an integer
+ * @see verifyIntegerText()
+ */
+ private static boolean verifyIntegerTextAddition( String text, char c ) {
+
+ // pass through all control characters
+ if ( Character.isISOControl( c ) ) {
+ return true;
+ }
+
+ // case-insensitive
+ c = Character.toLowerCase( c );
+ text = text.toLowerCase();
+
+ // first character has to be 0-9
+ if ( text.length() == 0 ) {
+ return Character.isDigit( c );
+ }
+
+ // second character must be x if preceded by a 0, otherwise 0-9 will do
+ if ( text.length() == 1 ) {
+ if ( text.equals( "0" ) ) {
+ return c == 'x';
+ }
+ return Character.isDigit( c );
+ }
+
+ // all subsequent characters must be 0-9 or a-f if started with 0x
+ return Character.isDigit( c )
+ || text.startsWith( "0x" ) && 'a' <= c && c <= 'f';
}
-
- private void initializeDataWidgets() {
- fTextExpression.setText( fExpression );
- fChkBtnRead.setSelection( fRead );
- fChkBtnWrite.setSelection( fWrite );
- setOkButtonState();
+
+ /**
+ * @param text integer string built up using verifyIntegerTextAddition()
+ * @return true if text represents a valid string representation of
+ * an integer
+ */
+ private static boolean verifyIntegerText( String text ) {
+ if ( text.length() == 0 ) {
+ return false;
+ }
+ if ( text.length() == 1 ) {
+ return true;
+ }
+ if ( text.length() == 2 ) {
+ return !text.equals("0x");
+ }
+ return true;
}
- private Text createExpressionText( Composite parent ) {
- Label label = new Label( parent, SWT.RIGHT );
- label.setText( ActionMessages.getString( "AddWatchpointDialog.1" ) ); //$NON-NLS-1$
- final Text text = new Text( parent, SWT.BORDER );
+ private void createCountField( Composite parent ) {
+ fRangeEnableButton = new Button( parent, SWT.CHECK );
GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
- gridData.widthHint = 300;
- text.setLayoutData( gridData );
- text.setEnabled( fEditable );
- addModifyListener( text );
- return text;
- }
+ gridData.horizontalSpan = 1;
+ fRangeEnableButton.setLayoutData( gridData );
+ fRangeEnableButton.setText( ActionMessages.getString( "AddWatchpointDialog.6" ) ); //$NON-NLS-1$
+ fRangeEnableButton.setSelection( fRangeInitialEnable && fRange.length() > 0 );
+ fRangeEnableButton.addSelectionListener( this );
+ fRangeField = new Text( parent, SWT.BORDER );
+ gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 1;
+ GC gc = new GC( fRangeField );
+ FontMetrics fm = gc.getFontMetrics();
+ gridData.minimumWidth = 8 * fm.getAverageCharWidth();
+ fRangeField.setLayoutData( gridData );
+ fRangeField.setText( fRange );
+ fRangeField.addVerifyListener( new VerifyListener() {
+ public void verifyText( VerifyEvent e ) {
+ e.doit = verifyIntegerTextAddition( fRangeField.getText(), e.character );
+ }
+ });
+ fRangeField.addModifyListener( this );
+ }
+
private void createAccessWidgets( Composite parent ) {
+ GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+ gridData.horizontalSpan = 3;
+
Group group = new Group( parent, SWT.NONE );
group.setLayout( new GridLayout() );
- group.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+ group.setLayoutData( gridData );
group.setText( ActionMessages.getString( "AddWatchpointDialog.2" ) ); //$NON-NLS-1$
fChkBtnWrite = new Button( group, SWT.CHECK );
fChkBtnWrite.setText( ActionMessages.getString( "AddWatchpointDialog.3" ) ); //$NON-NLS-1$
- addSelectionListener( fChkBtnWrite );
+ fChkBtnWrite.setSelection( true );
+ fChkBtnWrite.addSelectionListener( this );
fChkBtnRead = new Button( group, SWT.CHECK );
fChkBtnRead.setText( ActionMessages.getString( "AddWatchpointDialog.4" ) ); //$NON-NLS-1$
- addSelectionListener( fChkBtnRead );
+ fChkBtnRead.setSelection( false );
+ fChkBtnRead.addSelectionListener( this );
}
- private void addSelectionListener( Button button ) {
- button.addSelectionListener( new SelectionAdapter() {
-
- public void widgetSelected( SelectionEvent e ) {
- setOkButtonState();
- }
- } );
- }
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ protected void configureShell( Shell newShell ) {
+ super.configureShell( newShell );
- protected void setOkButtonState() {
- if ( fBtnOk == null )
- return;
- fBtnOk.setEnabled( (fChkBtnRead.getSelection() || fChkBtnWrite.getSelection()) && fTextExpression.getText().trim().length() > 0 );
+ // use the same title used by the platform dialog
+ newShell.setText( ActionMessages.getString( "AddWatchpointDialog.0" ) ); //$NON-NLS-1$
}
- private void storeData() {
- fExpression = fTextExpression.getText().trim();
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ protected void okPressed() {
+ fExpression = fExpressionInput.getText().trim();
+ if ( fExpression.length() > 0 ) {
+ addHistory( sExpressionHistory, fExpression );
+ }
+ if ( fHasMemorySpaceControls ) {
+ fMemorySpace = fMemorySpaceEnableButton.getSelection() ? fMemorySpaceInput.getText().trim() : "";
+ }
+ fRange = fRangeEnableButton.getSelection() ? fRangeField.getText().trim() : "0";
fRead = fChkBtnRead.getSelection();
fWrite = fChkBtnWrite.getSelection();
+ super.okPressed();
}
- private void addModifyListener( Text text ) {
- text.addModifyListener( new ModifyListener() {
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ public void modifyText( ModifyEvent e ) {
+ updateUI();
+ }
- public void modifyText( ModifyEvent e ) {
- setOkButtonState();
- }
- } );
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
+ */
+ protected Control createButtonBar( Composite parent ) {
+ return super.createButtonBar( parent );
}
public String getExpression() {
return fExpression;
}
+ public String getMemorySpace() {
+ return fMemorySpace;
+ }
+
+ private static void addHistory( ArrayList list, String item ) {
+ if ( !list.contains( item ) )
+ list.add( 0, item );
+
+ if ( list.size() > 5 )
+ list.remove( list.size() - 1 );
+ }
+
+ private static String[] getHistory( ArrayList list ) {
+ return (String[])list.toArray( new String[list.size()] );
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetDefaultSelected( SelectionEvent e ) {
+ // ignore
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ public void widgetSelected( SelectionEvent e ) {
+ updateUI();
+ }
+
+ private void updateUI() {
+ if ( fHasMemorySpaceControls ) {
+ fMemorySpaceInput.setEnabled( fMemorySpaceEnableButton.getSelection() );
+ }
+ fRangeField.setEnabled( fRangeEnableButton.getSelection() );
+ Button b = getButton( IDialogConstants.OK_ID );
+ if ( b == null ) {
+ return;
+ }
+ b.setEnabled( okayEnabled() );
+ }
+
+ private boolean okayEnabled() {
+ if ( !fChkBtnRead.getSelection() && !fChkBtnWrite.getSelection() ) {
+ return false ;
+ }
+ if ( fExpressionInput.getText().length() == 0 ) {
+ return false;
+ }
+ if ( fHasMemorySpaceControls && fMemorySpaceInput.getEnabled() && fMemorySpaceInput.getText().length() == 0 ) {
+ return false;
+ }
+ if ( fRangeField.getEnabled()
+ && ( fRangeField.getText().length() == 0 || !verifyIntegerText( fRangeField.getText() ) ) ) {
+ return false;
+ }
+ return true;
+ }
+
public boolean getWriteAccess() {
return fWrite;
}
-
+
public boolean getReadAccess() {
return fRead;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- storeData();
- super.okPressed();
+ public void setExpression(String expressionString ) {
+ fExpression = expressionString;
+ }
+
+ public BigInteger getRange() {
+ return new BigInteger( fRange );
+ }
+
+ public void initializeRange( boolean enable, String range ) {
+ fRangeInitialEnable = enable;
+ fRange = range;
}
+
+ public void initializeMemorySpace( String memorySpace ) {
+ fMemorySpace = memorySpace;
+ }
+
+ protected void createButtonsForButtonBar(Composite parent) {
+ // override so we can change the initial okay enabled state
+ createButton( parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL,
+ true ).setEnabled( okayEnabled() );
+ createButton( parent, IDialogConstants.CANCEL_ID,
+ IDialogConstants.CANCEL_LABEL, false );
+ }
+
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnMemoryActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnMemoryActionDelegate.java
new file mode 100644
index 00000000000..a3b8579f4ca
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnMemoryActionDelegate.java
@@ -0,0 +1,113 @@
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+
+import java.math.BigInteger;
+
+import org.eclipse.cdt.debug.internal.core.model.CMemoryBlockExtension;
+import org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointDialog;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.cdt.debug.ui.ICMemorySelection;
+import org.eclipse.debug.core.model.IMemoryBlock;
+import org.eclipse.debug.core.model.MemoryByte;
+import org.eclipse.debug.internal.ui.memory.provisional.AbstractAsyncTableRendering;
+import org.eclipse.debug.ui.memory.AbstractMemoryRendering;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class AddWatchpointOnMemoryActionDelegate extends AddWatchpointActionDelegate {
+
+ /**
+ * Constructor for Action1.
+ */
+ public AddWatchpointOnMemoryActionDelegate() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ IStructuredSelection selection = getSelection();
+
+ if (selection == null || selection.isEmpty()) {
+ return;
+ }
+
+ Object obj = selection.getFirstElement();
+ if (obj != null) {
+ String memorySpace = null;
+ String address = ""; //$NON-NLS-1$
+ String range = "1"; //$NON-NLS-1$
+
+ if (obj instanceof AbstractAsyncTableRendering) {
+ AbstractAsyncTableRendering r = (AbstractAsyncTableRendering) obj;
+ memorySpace = getMemorySpace(r.getMemoryBlock(), memorySpace);
+ address = getSelectedAddress(r.getSelectedAddress(), address);
+ range = getRange(r.getSelectedAsBytes(), range);
+ } else if (obj instanceof ICMemorySelection) {
+ ICMemorySelection sel = (ICMemorySelection) obj;
+ memorySpace = getMemorySpace(sel.getContainingBlock(), memorySpace);
+ address = getSelectedAddress(sel.getAddress(), address);
+ range = sel.getUnits().toString();
+ } else if (obj instanceof AbstractMemoryRendering) {
+ AbstractMemoryRendering r = (AbstractMemoryRendering) obj;
+ address = getSelectedAddress(BigInteger.valueOf(r.getMemoryBlock().getStartAddress()), address);
+ }
+
+ AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(),
+ getMemorySpaceManagement());
+ dlg.initializeMemorySpace(memorySpace);
+ dlg.setExpression(address);
+ dlg.initializeRange(true, range);
+
+ if (dlg.open() == Window.OK) {
+ addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
+ }
+ }
+ }
+
+ private String getMemorySpace(IMemoryBlock memBlock, String def) {
+ if (memBlock != null && memBlock instanceof CMemoryBlockExtension) {
+ return ((CMemoryBlockExtension)memBlock).getMemorySpaceID();
+ }
+ return def;
+ }
+
+ private String getSelectedAddress(BigInteger selectedAddress, String def) {
+ if (selectedAddress != null) {
+ return "0x" + selectedAddress.toString(16); //$NON-NLS-1$
+ }
+ return def;
+ }
+
+ private String getRange(MemoryByte[] selectedBytes, String def) {
+ if (selectedBytes != null && selectedBytes.length > 0) {
+ return Integer.toString(selectedBytes.length);
+ }
+ return def;
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {}
+
+ private IStructuredSelection getSelection() {
+ return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
+ }
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java
new file mode 100644
index 00000000000..086f95cffa3
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/AddWatchpointOnVariableActionDelegate.java
@@ -0,0 +1,84 @@
+package org.eclipse.cdt.debug.internal.ui.actions;
+
+
+import org.eclipse.cdt.debug.internal.core.model.CVariable;
+import org.eclipse.cdt.debug.internal.ui.actions.AddWatchpointDialog;
+import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IActionDelegate;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+
+public class AddWatchpointOnVariableActionDelegate extends AddWatchpointActionDelegate {
+
+ /**
+ * Constructor for Action1.
+ */
+ public AddWatchpointOnVariableActionDelegate() {
+ super();
+ }
+
+ /**
+ * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
+ */
+ public void setActivePart(IAction action, IWorkbenchPart targetPart) {}
+
+ /**
+ * @see IActionDelegate#run(IAction)
+ */
+ public void run(IAction action) {
+ IStructuredSelection selection = getSelection();
+
+ if (selection == null || selection.isEmpty()) {
+ return;
+ }
+
+ Object obj = ((TreeSelection)selection).getFirstElement();
+ if (obj != null && obj instanceof CVariable) {
+ CVariable var = (CVariable)obj;
+
+ String expr = "";
+
+ try {
+ expr = var.getExpressionString();
+ } catch (DebugException e) {}
+
+ AddWatchpointDialog dlg = new AddWatchpointDialog(CDebugUIPlugin.getActiveWorkbenchShell(),
+ getMemorySpaceManagement()); //$NON-NLS-1$
+ dlg.setExpression(expr);
+ dlg.initializeRange(false, Integer.toString(var.sizeof()));
+ if (dlg.open() == Window.OK) {
+ addWatchpoint(dlg.getWriteAccess(), dlg.getReadAccess(), dlg.getExpression(), dlg.getMemorySpace(), dlg.getRange());
+ }
+ }
+ }
+
+ /**
+ * @see IActionDelegate#selectionChanged(IAction, ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ if (selection == null || selection.isEmpty()) {
+ action.setEnabled(false);
+ return;
+ }
+ if (selection instanceof TreeSelection) {
+ Object obj = ((TreeSelection)selection).getFirstElement();
+ if (obj != null && obj instanceof CVariable) {
+ action.setEnabled(true);
+ } else {
+ action.setEnabled(false);
+ }
+ }
+ }
+
+ private IStructuredSelection getSelection() {
+ return (IStructuredSelection)getView().getViewSite().getSelectionProvider().getSelection();
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java
index ac03bcf05b3..65aa5effa1c 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/actions/ToggleBreakpointAdapter.java
@@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Freescale Semiconductor - Address watchpoints, https://bugs.eclipse.org/bugs/show_bug.cgi?id=118299
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
@@ -336,7 +337,8 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
DebugPlugin.getDefault().getBreakpointManager().removeBreakpoint( watchpoint, true );
}
else {
- AddWatchpointDialog dlg = new AddWatchpointDialog( part.getSite().getShell(), true, false, expression, false );
+ AddWatchpointDialog dlg = new AddWatchpointDialog( part.getSite().getShell(), AddWatchpointActionDelegate.getMemorySpaceManagement() );
+ dlg.setExpression( expression );
if ( dlg.open() != Window.OK )
return;
expression = dlg.getExpression();
@@ -365,7 +367,9 @@ public class ToggleBreakpointAdapter implements IToggleBreakpointsTarget {
lineNumber,
dlg.getWriteAccess(),
dlg.getReadAccess(),
- expression,
+ expression,
+ dlg.getMemorySpace(),
+ dlg.getRange(),
true,
0,
"", //$NON-NLS-1$
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICMemorySelection.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICMemorySelection.java
new file mode 100644
index 00000000000..8415a80c89f
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/ICMemorySelection.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Freescale Semiconductor and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Freescale Semiconductor - Initial API and implementation
+ *******************************************************************************/
+package org.eclipse.cdt.debug.ui;
+
+import java.math.BigInteger;
+
+import org.eclipse.debug.core.model.IMemoryBlockExtension;
+
+/**
+ * Defines an interface that allows the implementor to specify the currently
+ * selected memory block.
+ */
+public interface ICMemorySelection {
+
+ /**
+ * @return the block of memory that contains the selection
+ */
+ IMemoryBlockExtension getContainingBlock();
+
+ /**
+ * @return the beginning address of the selection
+ */
+ BigInteger getAddress();
+
+ /**
+ * @return the length in units of the selection
+ */
+ BigInteger getUnits();
+
+}

Back to the top