Java 类com.sun.jdi.event.WatchpointEvent 实例源码

项目:form-follows-function    文件:F3Event.java   
public static F3Event wrap(F3VirtualMachine f3vm, Event evt) {
    if (evt == null) {
        return null;
    }
    if (evt instanceof AccessWatchpointEvent) {
        return new F3AccessWatchpointEvent(f3vm, (AccessWatchpointEvent)evt);
    } else if (evt instanceof BreakpointEvent) {
        return new F3BreakpointEvent(f3vm, (BreakpointEvent)evt);
    } else if (evt instanceof ClassPrepareEvent) {
        return new F3ClassPrepareEvent(f3vm, (ClassPrepareEvent)evt);
    } else if (evt instanceof ClassUnloadEvent) {
        return new F3ClassUnloadEvent(f3vm, (ClassUnloadEvent)evt);
    } else if (evt instanceof ExceptionEvent) {
        return new F3ExceptionEvent(f3vm, (ExceptionEvent)evt);
    } else if (evt instanceof MethodEntryEvent) {
        return new F3MethodEntryEvent(f3vm, (MethodEntryEvent)evt);
    } else if (evt instanceof MethodExitEvent) {
        return new F3MethodExitEvent(f3vm, (MethodExitEvent)evt);
    } else if (evt instanceof ModificationWatchpointEvent) {
        return new F3ModificationWatchpointEvent(f3vm, (ModificationWatchpointEvent)evt);
    } else if (evt instanceof MonitorContendedEnterEvent) {
        return new F3MonitorContendedEnterEvent(f3vm, (MonitorContendedEnterEvent)evt);
    } else if (evt instanceof MonitorContendedEnteredEvent) {
        return new F3MonitorContendedEnteredEvent(f3vm, (MonitorContendedEnteredEvent)evt);
    } else if (evt instanceof MonitorWaitEvent) {
        return new F3MonitorWaitEvent(f3vm, (MonitorWaitEvent)evt);
    } else if (evt instanceof MonitorWaitedEvent) {
        return new F3MonitorWaitedEvent(f3vm, (MonitorWaitedEvent)evt);
    } else if (evt instanceof StepEvent) {
        return new F3StepEvent(f3vm, (StepEvent)evt);
    } else if (evt instanceof ThreadDeathEvent) {
        return new F3ThreadDeathEvent(f3vm, (ThreadDeathEvent)evt);
    } else if (evt instanceof ThreadStartEvent) {
        return new F3ThreadStartEvent(f3vm, (ThreadStartEvent)evt);
    } else if (evt instanceof VMDeathEvent) {
        return new F3VMDeathEvent(f3vm, (VMDeathEvent)evt);
    } else if (evt instanceof VMDisconnectEvent) {
        return new F3VMDisconnectEvent(f3vm, (VMDisconnectEvent)evt);
    } else if (evt instanceof VMStartEvent) {
        return new F3VMStartEvent(f3vm, (VMStartEvent)evt);
    } else if (evt instanceof WatchpointEvent) {
        return new F3WatchpointEvent(f3vm, (WatchpointEvent)evt);
    } else if (evt instanceof LocatableEvent) {
        return new F3LocatableEvent(f3vm, (LocatableEvent)evt);
    } else {
        return new F3Event(f3vm, evt);
    }
}
项目:EclipseTracer    文件:BreakpointsManager.java   
/**
 * Processes modification event for the given watch point by storing the new
 * values and caller information, and then by registered listeners
 * 
 * @param event
 *            the modification event. It provides information about the
 *            current / new values and the affected instance, as well as the
 *            caller (thread, method, etc.).
 * @param watchPoint
 *            the watch point to which the event belongs.
 * @param target
 *            the debug target in which the event occurred
 */
public void processWatchEvent(WatchpointEvent event, AbstractBreakpoint watchPoint,
        IJavaDebugTarget target) {
    if (!watchPoint.isTrackingActive()) {
        return;
    }
    long currTime = System.currentTimeMillis();
    ObjectReference instance = event.object();
    VariableHistory history = (VariableHistory)getHistory(instance, watchPoint, target);        
    boolean notifyInstanceAdded = history.getAllValues().size() == 0;
    boolean eventModificationEvent = event instanceof ModificationWatchpointEvent;
    Value value = eventModificationEvent ? ((ModificationWatchpointEvent) event)
            .valueToBe() : ((WatchpointEvent)event).valueCurrent();
    history.addValue(value, currTime, event.thread(),
            eventModificationEvent);
    for (IBreakpointListener listener : listeners) {
        if (notifyInstanceAdded) {
            listener.notifyInstanceAdded(watchPoint, instance, target);
        }
        listener.notifyBreakpointHit(watchPoint, instance, target);
    }

}
项目:form-follows-function    文件:Debugger.java   
public WatchpointEvent resumeToWatchpoint() {
    return (WatchpointEvent) resumeToEvent(new EventFilter() {
        public boolean match(Event evt) {
            return (evt instanceof WatchpointEvent);
        }
    });
}
项目:form-follows-function    文件:Debugger.java   
public void fieldWatchEvent(WatchpointEvent evt) {
    synchronized (listeners) {
        for (EventNotifier en : listeners) {
            en.fieldWatchEvent(evt);
        }
    }
}
项目:form-follows-function    文件:WatchAccessModificationTest.java   
/**
* Checks the type of WatchpointEvent and validates type of field-being-watched
* @param wpEvent
*/
   private void checkWatchPointEvent(WatchpointEvent wpEvent) {
       if (wpEvent instanceof AccessWatchpointEvent) {
           Assert.assertTrue(((AccessWatchpointEvent)wpEvent).valueCurrent().type().name().equals("float"));
           Assert.assertTrue(wpEvent.getClass().toString().equals("class org.f3.jdi.event.F3AccessWatchpointEvent"));
       } else if (wpEvent instanceof ModificationWatchpointEvent) {
           Assert.assertTrue(((ModificationWatchpointEvent)wpEvent).valueCurrent().type().name().equals("float"));
           Assert.assertTrue(wpEvent.getClass().toString().equals("class org.f3.jdi.event.F3ModificationWatchpointEvent"));
       }
   }
项目:form-follows-function    文件:WatchAccessModificationTest.java   
/**
* Watch all means
* 1) watch access
* 2) watch modification of a field
*/
   @Test(timeout=5000)
   public void testWatchAll() {
       try {
           //resetOutputs();//Uncomment this if you want to see the output on console
           compile("WatchAll.f3");
           stop("in WatchAll.f3$run$");
           WatchpointRequest watchpointReq = watch("all WatchAll.$numVar");//watch access (checks for access only, and not modifications)
           f3run();
           WatchpointEvent wpEvent = resumeToWatchpoint();
           checkWatchPointEvent(wpEvent);

           list();
           step();
           list();
           wpEvent = resumeToWatchpoint();
           checkWatchPointEvent(wpEvent);
           step();
           list();
           wpEvent = resumeToWatchpoint();
           checkWatchPointEvent(wpEvent);
           resumeToVMDeath();
           quit();
       } catch (Exception exp) {
           exp.printStackTrace();
           Assert.fail(exp.getMessage());
       }
   }
项目:EclipseTracer    文件:Watchpoint.java   
@Override
public boolean handleEvent(Event event, JDIDebugTarget target,
        boolean suspendVote, EventSet eventSet) {
    if (event instanceof WatchpointEvent) {
        wpMgr.processWatchEvent((WatchpointEvent)event, this, target);
    }
    return true;
}
项目:form-follows-function    文件:F3AccessWatchpointEvent.java   
@Override
protected WatchpointEvent underlying() {
    return (WatchpointEvent) super.underlying();
}
项目:form-follows-function    文件:F3WatchpointEvent.java   
public F3WatchpointEvent(F3VirtualMachine f3vm, WatchpointEvent underlying) {
    super(f3vm, underlying);
}
项目:form-follows-function    文件:F3WatchpointEvent.java   
@Override
protected WatchpointEvent underlying() {
    return (WatchpointEvent) super.underlying();
}
项目:form-follows-function    文件:EventNotifierAdapter.java   
public void fieldWatchEvent(WatchpointEvent e) {
}
项目:jdivisitor    文件:VisitableWatchpointEvent.java   
public VisitableWatchpointEvent(WatchpointEvent event) {
    this.event = event;
}
项目:jdivisitor    文件:EmptyEventVisitor.java   
@Override
public void visit(WatchpointEvent event) {
}
项目:codehint    文件:SideEffectHandler.java   
@Override
public boolean handleEvent(Event event, JDIDebugTarget target, boolean suspendVote, EventSet eventSet) {
    /*if (event instanceof WatchpointEvent)
        System.out.println(event + " on " + FieldLVal.makeFieldLVal(((WatchpointEvent)event).object(), ((WatchpointEvent)event).field()).toString());
    else if (event instanceof com.sun.jdi.event.ClassPrepareEvent)
        System.out.println("Prep " + ((com.sun.jdi.event.ClassPrepareEvent)event).referenceType().name());
    else
        System.out.println(event);*/
    synchronized (SideEffectHandler.this) {
        if (effectsMap == null)  // We're not currently tracking side effects.
            return true;
        if (event instanceof WatchpointEvent) {
            WatchpointEvent watchEvent = (WatchpointEvent)event;
            //System.out.println(event + " on " + FieldLVal.makeFieldLVal(watchEvent.object(), watchEvent.field()).toString());
            ObjectReference obj = watchEvent.object();
            if (obj != null && obj.uniqueID() > maxID) {
                //System.out.println("Ignoring new object " + obj.toString());
                return true;
            }
            if (watchEvent instanceof ModificationWatchpointEvent) {
                ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent)watchEvent;
                if (!modEvent.location().method().isStaticInitializer())  // If the field is modified in a static initializer, it must be the initialization of a static field of a newly-loaded class, which we don't want to revert.
                    recordEffect(FieldLVal.makeFieldLVal(obj, modEvent.field()), modEvent.valueCurrent(), modEvent.valueToBe());
                return true;
            } else if (watchEvent instanceof AccessWatchpointEvent) {
                AccessWatchpointEvent readEvent = (AccessWatchpointEvent)watchEvent;
                Value oldVal = readEvent.valueCurrent();
                if (oldVal instanceof ArrayReference) {
                    FieldLVal lval = FieldLVal.makeFieldLVal(obj, readEvent.field());
                    backupArray(lval, oldVal);
                    if (canDisable && !changedFields.contains(lval) && Utils.incrementMap(accessCounts, this) >= 10) {  // Disabling is slow, so we only do it for frequently-accessed fields.
                        try {
                            disabledWatchpoints.add(this);
                            setEnabled(false);
                        } catch (CoreException e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
                /*else
                System.out.println("Ignoring read on non-array Object");*/
                return true;
            }
        }
        return super.handleEvent(event, target, suspendVote, eventSet);
    }
}
项目:jdivisitor    文件:EventVisitor.java   
/**
 * Visit a {@code WatchpointEvent}.
 *
 * @param event Event to visit
 */
void visit(WatchpointEvent event);