1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Implementation of watchpoints.

This commit is contained in:
Mikhail Khodjaiants 2002-09-05 22:45:38 +00:00
parent 0ab86c77d5
commit fe4c884ab4
2 changed files with 37 additions and 3 deletions

View file

@ -16,6 +16,7 @@ import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.ICBreakpoint; import org.eclipse.cdt.debug.core.ICBreakpoint;
import org.eclipse.cdt.debug.core.ICLineBreakpoint; import org.eclipse.cdt.debug.core.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.ICSourceLocator; 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.IFormattedMemoryBlock;
import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval; import org.eclipse.cdt.debug.core.IFormattedMemoryRetrieval;
import org.eclipse.cdt.debug.core.IRestart; 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.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget; 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.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.CSourceLocator;
import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CBreakpoint;
import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.core.resources.IMarkerDelta;
@ -545,6 +547,10 @@ public class CDebugTarget extends CDebugElement
{ {
setLineBreakpoint( (ICLineBreakpoint)breakpoint ); setLineBreakpoint( (ICLineBreakpoint)breakpoint );
} }
else if ( breakpoint instanceof ICWatchpoint )
{
setWatchpoint( (ICWatchpoint)breakpoint );
}
} }
catch( DebugException e ) 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 ) private ICDIBreakpoint findCDIBreakpoint( IBreakpoint breakpoint )
{ {
return (ICDIBreakpoint)getBreakpoints().get( breakpoint ); return (ICDIBreakpoint)getBreakpoints().get( breakpoint );

View file

@ -344,9 +344,10 @@ public class BreakpointManager extends SessionObject implements ICDIBreakpointMa
*/ */
public ICDIWatchpoint setWatchpoint( int type, int watchType, String expression, public ICDIWatchpoint setWatchpoint( int type, int watchType, String expression,
ICDICondition condition) throws CDIException { ICDICondition condition) throws CDIException {
boolean access = (type == ICDIWatchpoint.WRITE); boolean access = ( (watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE &&
boolean read = (type == ICDIWatchpoint.READ); (watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ );
boolean read = ( !((watchType & ICDIWatchpoint.WRITE) == ICDIWatchpoint.WRITE) &&
(watchType & ICDIWatchpoint.READ) == ICDIWatchpoint.READ );
boolean state = suspendInferior(); boolean state = suspendInferior();
CSession s = getCSession(); CSession s = getCSession();
CommandFactory factory = s.getMISession().getCommandFactory(); CommandFactory factory = s.getMISession().getCommandFactory();