/** * Resolve all deferred eventRequests waiting for 'refType'. * @return true if it completes successfully, false on error. */ boolean resolve(ClassPrepareEvent event) { boolean failure = false; synchronized(eventRequestSpecs) { for (EventRequestSpec spec : eventRequestSpecs) { if (!spec.isResolved()) { try { EventRequest eventRequest = spec.resolve(event); if (eventRequest != null) { MessageOutput.println("Set deferred", spec.toString()); } } catch (Exception e) { MessageOutput.println("Unable to set deferred", new Object [] {spec.toString(), spec.errorMessageFor(e)}); failure = true; } } } } return !failure; }
public void processClassPrepared(final ClassPrepareEvent event) { if (!myDebugProcess.isAttached()) { return; } final ReferenceType refType = event.referenceType(); if (refType instanceof ClassType || refType instanceof InterfaceType) { if (LOG.isDebugEnabled()) { LOG.debug("signature = " + refType.signature()); } ClassPrepareRequestor requestor = (ClassPrepareRequestor)event.request().getProperty(REQUESTOR); if (requestor != null) { if (LOG.isDebugEnabled()) { LOG.debug("requestor found " + refType.signature()); } requestor.processClassPrepare(myDebugProcess, refType); } } }
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); } }
/** * Resolve all deferred eventRequests waiting for 'refType'. * @return true if it completes successfully, false on error. */ boolean resolve(ClassPrepareEvent event) { boolean failure = false; synchronized(eventRequestSpecs) { for (EventRequestSpec spec : eventRequestSpecs) { if (!spec.isResolved()) { try { EventRequest eventRequest = spec.resolve(event); if (eventRequest != null) { env.messageOutput().println("Set deferred", spec.toString()); } } catch (Exception e) { env.messageOutput().println("Unable to set deferred", new Object [] {spec.toString(), spec.errorMessageFor(e)}); failure = true; } } } } return !failure; }
@Override public void jdiClassPrepare(final ClassPrepareEvent event) { if (!override && !owner.isStarted()) { return; } try { delegate.handleTypeLoad(event.referenceType(), event.thread()); } catch (final Throwable e) { JiveDebugPlugin.log(e); } }
@Override public boolean handleClassPrepareEvent(ClassPrepareEvent event, JDIDebugTarget target, boolean suspendVote) { //long startTime = System.currentTimeMillis(); //System.out.println("Prepare " + event.referenceType().name()); try { IType itype = project.findType(event.referenceType().name(), (IProgressMonitor)null); List<IField> fields = new ArrayList<IField>(); if (itype == null) { //System.out.println("Bad times on " + event.referenceType().name()); } else { String typeName = itype.getFullyQualifiedName(); if (isUsefulType(typeName)) for (IField field: itype.getFields()) if ((!Flags.isFinal(field.getFlags()) || field.getTypeSignature().contains("[")) && Flags.isStatic(field.getFlags()) && isUsefulField(typeName, field.getElementName(), typeName)) fields.add(field); List<MyJavaWatchpoint> newWatchpoints = getFieldWatchpoints(fields, null); addedWatchpoints.addAll(newWatchpoints); } //System.out.println("Prepared " + event.referenceType() + " in " + (System.currentTimeMillis()- startTime) + "ms."); } catch (JavaModelException e) { throw new RuntimeException(e); } return super.handleClassPrepareEvent(event, target, suspendVote); }
/** * @return If this EventRequestSpec matches the 'refType' * return the cooresponding EventRequest. Otherwise * return null. */ synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception { if ((resolved == null) && (prepareRequest != null) && prepareRequest.equals(event.request())) { resolved = resolveEventRequest(event.referenceType()); prepareRequest.disable(); Env.vm().eventRequestManager().deleteEventRequest(prepareRequest); prepareRequest = null; if (refSpec instanceof PatternReferenceTypeSpec) { PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec; if (! prs.isUnique()){ /* * Class pattern event requests are never * considered "resolved", since future class loads * might also match. * Create and enable a new ClassPrepareRequest to * keep trying to resolve. */ resolved = null; prepareRequest = refSpec.createPrepareRequest(); prepareRequest.enable(); } } } return resolved; }
/** * @return If this EventRequestSpec matches the 'refType' * return the cooresponding EventRequest. Otherwise * return null. */ synchronized EventRequest resolve(ClassPrepareEvent event) throws Exception { if ((resolved == null) && (prepareRequest != null) && prepareRequest.equals(event.request())) { resolved = resolveEventRequest(event.referenceType()); prepareRequest.disable(); env.vm().eventRequestManager().deleteEventRequest(prepareRequest); prepareRequest = null; if (refSpec instanceof PatternReferenceTypeSpec) { PatternReferenceTypeSpec prs = (PatternReferenceTypeSpec)refSpec; if (! prs.isUnique()){ /* * Class pattern event requests are never * considered "resolved", since future class loads * might also match. * Create and enable a new ClassPrepareRequest to * keep trying to resolve. */ resolved = null; prepareRequest = refSpec.createPrepareRequest(); prepareRequest.enable(); } } } return resolved; }
public ClassPrepareEvent resumeToPrepareOf(String className) { final ClassPrepareRequest request = eventRequestManager().createClassPrepareRequest(); request.addClassFilter(className); request.addCountFilter(1); request.enable(); return (ClassPrepareEvent)resumeToEvent(request); }
public void classPrepareEvent(ClassPrepareEvent evt) { synchronized (listeners) { for (EventNotifier en : listeners) { en.classPrepareEvent(evt); } } }
@Override public boolean handleEvent(final Event event, final JDIDebugTarget target, final boolean suspendVote, final EventSet eventSet) { classes.add(((ClassPrepareEvent) event).referenceType()); if (!owner.isActive()) { return true; } createFieldRequests(target, ((ClassPrepareEvent) event).referenceType()); owner.jdiHandler().jdiClassPrepare((ClassPrepareEvent) event); return true; }
/** * Notification of a class prepare in the target VM. See the JVM specification for a definition of * class preparation. Class prepare events are not generated for primitive classes (for example, * java.lang.Integer.TYPE). * * @param event * * @see <a href="">http://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/index.html</a> */ @Override public void jdiClassPrepare(final ClassPrepareEvent event) { // this.currentEvent = null; this.currentThread = event.thread(); // jdiTypeLoad(event.referenceType()); // // this.currentEvent = null; this.currentThread = null; }
public static void main(String[] args) throws IOException, InterruptedException { //VirtualMachine vm = launchTarget(sb.toString()); VirtualMachine vm = launchTarget(CLASS_NAME); System.out.println("Vm launched"); // process events EventQueue eventQueue = vm.eventQueue(); // resume the vm Process process = vm.process(); // Copy target's output and error to our output and error. Thread outThread = new StreamRedirectThread("out reader", process.getInputStream()); Thread errThread = new StreamRedirectThread("error reader", process.getErrorStream()); errThread.start(); outThread.start(); boolean connected = true; int watched = 0; while (connected) { EventSet eventSet = eventQueue.remove(); for (Event event : eventSet) { System.out.println("FieldMonitor-main receives: "+event); if (event instanceof VMStartEvent) { addClassWatch(vm); } else if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) { // exit connected = false; } else if (event instanceof ClassPrepareEvent) { // watch field on loaded class System.out.println("ClassPrepareEvent"); ClassPrepareEvent classPrepEvent = (ClassPrepareEvent) event; ReferenceType refType = classPrepEvent .referenceType(); addFieldWatch(vm, refType); } else if (event instanceof ModificationWatchpointEvent) { watched++; System.out.println("sleep for 500 ms"); Thread.sleep(500); ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event; System.out.println("old=" + modEvent.valueCurrent()); System.out.println("new=" + modEvent.valueToBe()); } } System.out.println("resume..."); eventSet.resume(); } // Shutdown begins when event thread terminates try { errThread.join(); // Make sure output is forwarded outThread.join(); } catch (InterruptedException exc) { // we don't interrupt } if (watched != 11) { // init + 10 modifications in TestPostFieldModification class throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched); } }
public F3ClassPrepareEvent(F3VirtualMachine f3vm, ClassPrepareEvent underlying) { super(f3vm, underlying); }
@Override protected ClassPrepareEvent underlying() { return (ClassPrepareEvent) super.underlying(); }