diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index d9b48c58f2e..9a0b56e71de 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.ICBreakpoint; import org.eclipse.cdt.debug.core.ICLineBreakpoint; import org.eclipse.cdt.debug.core.ICSourceLocator; +import org.eclipse.cdt.debug.core.ICWatchpoint; import org.eclipse.cdt.debug.core.IFormattedMemoryBlock; import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval; import org.eclipse.cdt.debug.core.IRestart; @@ -44,6 +45,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIBreakpoint; 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.ICDIThread; +import org.eclipse.cdt.debug.core.cdi.model.ICDIWatchpoint; import org.eclipse.cdt.debug.internal.core.CSourceLocator; import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint; import org.eclipse.core.resources.IMarkerDelta; @@ -545,6 +547,10 @@ public class CDebugTarget extends CDebugElement { setLineBreakpoint( (ICLineBreakpoint)breakpoint ); } + else if ( breakpoint instanceof ICWatchpoint ) + { + setWatchpoint( (ICWatchpoint)breakpoint ); + } } catch( DebugException e ) { @@ -1485,6 +1491,33 @@ public class CDebugTarget extends CDebugElement } } + private void setWatchpoint( ICWatchpoint watchpoint ) throws DebugException + { + ICDIBreakpointManager bm = getCDISession().getBreakpointManager(); + try + { + ICDICondition condition = bm.createCondition( watchpoint.getIgnoreCount(), watchpoint.getCondition() ); + int accessType = 0; + accessType |= ( watchpoint.isWriteType() ) ? ICDIWatchpoint.WRITE : 0; + accessType |= ( watchpoint.isReadType() ) ? ICDIWatchpoint.READ : 0; + String expression = watchpoint.getExpression(); + ICDIWatchpoint cdiWatchpoint = bm.setWatchpoint( ICDIBreakpoint.REGULAR, accessType, expression, condition ); + if ( !getBreakpoints().containsKey( watchpoint ) ) + { + getBreakpoints().put( watchpoint, cdiWatchpoint ); + ((CBreakpoint)watchpoint).incrementInstallCount(); + } + } + catch( CoreException ce ) + { + requestFailed( "Operation failed. Reason: ", ce ); + } + catch( CDIException e ) + { + requestFailed( "Operation failed. Reason: ", e ); + } + } + private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint ) { return (ICDIBreakpoint)getBreakpoints().get( breakpoint ); diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java index 1218c6eda0a..ed3f5384bf4 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/cdi/BreakpointManager.java @@ -344,9 +344,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa */ public ICDIWatchpoint setWatchpoint( int type, int watchType, String expression, ICDICondition condition) throws CDIException { - boolean access = (type == ICDIWatchpoint.WRITE); - boolean read = (type == ICDIWatchpoint.READ); - + boolean access = ( (watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE && + (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); + boolean read = ( !((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE) && + (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ ); boolean state = suspendInferior(); CSession s = getCSession(); CommandFactory factory = s.getMISession().getCommandFactory();