Search in sources :

Example 16 with Breakpoint

use of nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint in project watchdog by TestRoots.

the class BreakpointCreatorTest method testCreateJavaBreakpointNoHitCount.

@Test
public void testCreateJavaBreakpointNoHitCount() throws CoreException {
    IJavaBreakpoint bp = mock(IJavaBreakpoint.class);
    when(bp.getHitCount()).thenReturn(-1);
    Breakpoint result = BreakpointCreator.createBreakpoint(bp);
    assertEquals(-1, result.getHitCount());
}
Also used : IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) Test(org.junit.Test)

Example 17 with Breakpoint

use of nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint in project watchdog by TestRoots.

the class BreakpointCreatorTest method testCreateJavaLineBreakpointConditionEnabled.

@Test
public void testCreateJavaLineBreakpointConditionEnabled() throws CoreException {
    IJavaLineBreakpoint bp = mock(IJavaLineBreakpoint.class);
    when(bp.isConditionEnabled()).thenReturn(true);
    Breakpoint result = BreakpointCreator.createBreakpoint(bp);
    assertTrue(result.isConditionEnabled());
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) Test(org.junit.Test)

Example 18 with Breakpoint

use of nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint in project watchdog by TestRoots.

the class BreakpointListener method breakpointRemoved.

@Override
public void breakpointRemoved(@NotNull XBreakpoint xBreakpoint) {
    Date timestamp = new Date();
    Breakpoint breakpoint = BreakpointCreator.createBreakpoint(xBreakpoint);
    breakpoints.remove(breakpoint.getHash());
    BreakpointRemoveEvent event = new BreakpointRemoveEvent(breakpoint.getHash(), breakpoint.getBreakpointType(), timestamp);
    trackingEventManager.addEvent(event);
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) BreakpointRemoveEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointRemoveEvent) Date(java.util.Date)

Example 19 with Breakpoint

use of nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint in project watchdog by TestRoots.

the class BreakpointCreator method createBreakpoint.

/**
 * Factory method that creates and returns a {@link Breakpoint} from a given
 * {@link XBreakpoint}.
 */
public static Breakpoint createBreakpoint(XBreakpoint breakpoint) {
    Breakpoint result = new Breakpoint(breakpoint.hashCode(), BreakpointClassifier.classify(breakpoint));
    // Initialize enabled and SuspendPolicy fields.
    result.setEnabled(breakpoint.isEnabled());
    result.setSuspendPolicy(breakpoint.getSuspendPolicy().ordinal());
    // Initialize hit count field.
    result.setHitCount(-1);
    if (breakpoint.getProperties() instanceof JavaBreakpointProperties) {
        JavaBreakpointProperties properties = (JavaBreakpointProperties) breakpoint.getProperties();
        if (properties.isCOUNT_FILTER_ENABLED()) {
            result.setHitCount(properties.getCOUNT_FILTER());
        }
    }
    // Initialize condition fields if available.
    XExpression condition = breakpoint.getConditionExpression();
    if (condition != null) {
        result.setCondition(condition.getExpression());
        result.setConditionEnabled(true);
    }
    return result;
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) JavaBreakpointProperties(org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties) XExpression(com.intellij.xdebugger.XExpression)

Example 20 with Breakpoint

use of nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint in project watchdog by TestRoots.

the class BreakpointListener method breakpointRemoved.

@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    Date timestamp = new Date();
    Breakpoint bp = BreakpointCreator.createBreakpoint(breakpoint);
    breakpoints.remove(bp.getHash());
    BreakpointRemoveEvent event = new BreakpointRemoveEvent(bp.getHash(), bp.getBreakpointType(), timestamp);
    TrackingEventManager.addEvent(event);
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) BreakpointRemoveEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointRemoveEvent) Date(java.util.Date)

Aggregations

Breakpoint (nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint)38 Test (org.junit.Test)30 BreakpointChangeType (nl.tudelft.watchdog.core.logic.breakpoint.BreakpointChangeType)20 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)16 IJavaBreakpoint (org.eclipse.jdt.debug.core.IJavaBreakpoint)13 IJavaLineBreakpoint (org.eclipse.jdt.debug.core.IJavaLineBreakpoint)13 Date (java.util.Date)6 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)4 BreakpointAddEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent)2 BreakpointChangeEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointChangeEvent)2 BreakpointRemoveEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointRemoveEvent)2 XExpression (com.intellij.xdebugger.XExpression)1 CoreException (org.eclipse.core.runtime.CoreException)1 JavaBreakpointProperties (org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties)1