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); } }
@Override public synchronized void jdiMethodExit(final MethodExitEvent event) { if (!override && !owner.isStarted()) { return; } try { delegate.handleMethodExit(event, manager().generateLocalEvents()); // if (manager().generateLockEvents()) { // inspectThreads(); // } } catch (final Throwable e) { JiveDebugPlugin.log(e); } }
private IValue resolveReturnValue(final MethodExitEvent event) { if (event.method().returnTypeName().equalsIgnoreCase(EventFactoryAdapter.VOID_TYPE_NAME)) { return null; } // Java SE 6 or later supports method return values if (event.virtualMachine().canGetMethodReturnValues()) { return resolveValue(event.thread(), event.returnValue(), event.method().returnTypeName()); } // Support for J2SE 1.5 else { return valueFactory().createUninitializedValue(); } }
IJiveEvent createMethodExitEvent(final MethodExitEvent event) { final IThreadValue threadId = resolveThread(event); ILineValue line = executionState().currentLine(threadId); final String methodKey = executionState().methodKey(event.location().method()); if (methodKey.contains(".access$") && event.location().method().isSynthetic()) { // System.err.println("SYNTHETIC_ACCESSOR_METHOD_EXIT[" + methodKey + "]"); // retrieve the source location at the origin of the synthetic accessor call line = executionState().removeSyntheticAccessor(methodKey); } final IMethodTerminatorEvent terminator = (IMethodTerminatorEvent) eventFactory() .createMethodExitEvent(threadId, line); executionState().methodReturnedPending(event.thread().uniqueID(), terminator); executionState().framePop(event.thread().uniqueID()); return terminator; }
/** * Notification of a method return in the target VM. This event is generated after all code in the * method has executed, but the location of this event is the last executed location in the * method. Method exit events are generated for both native and non-native methods. Method exit * events are not generated if the method terminates with a thrown exception. * * @param event * * @see <a href="">http://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/index.html</a> */ @Override public void jdiMethodExit(final MethodExitEvent event) { if (event.method().isSynthetic() || event.method().isBridge() || event.method().name().contains("$")) { return; } // this.currentEvent = event; this.currentThread = event.thread(); // final long thId = registry.getThreadId(event.thread()); // final long[] eventId = registry.encode(EventHandlerLite.KIND_METHOD_EXITING); // final long nfrId = registry.methodExiting(thId); // System.out.format(EventHandlerLite.ENCODED_METHOD_EXITING, eventId[0], eventId[1], nfrId); // System.out.println(registry.decode(eventId)); // this.currentEvent = null; this.currentThread = null; }
/** * Dispatch incoming events */ private void handleEvent(Event event) { if (event instanceof ExceptionEvent) { if (!enableProfiling) exceptionManager.exceptionEvent((ExceptionEvent)event); } else if (event instanceof MethodEntryEvent) { methodEntryEvent((MethodEntryEvent)event); } else if (event instanceof MethodExitEvent) { methodExitEvent((MethodExitEvent)event); } else if (event instanceof ThreadDeathEvent) { threadeath.threadDeathEvent((ThreadDeathEvent)event); } else if (event instanceof VMDeathEvent) { vmDeathEvent((VMDeathEvent)event); } else if (event instanceof VMDisconnectEvent) { connected = disconnect.vmDisconnectEvent((VMDisconnectEvent)event); } }
@Override public void exit(MethodExitEvent event) { MethodEntity entity = new MethodEntity(); com.sun.jdi.Method method = event.method(); entity.setClassName(method.declaringType().signature()); entity.setMethodName(method.name()); entity.setDescription(method.signature()); simplify.addtask(simplify.getTracerMap().get(entity), entity); simplify.getTracerMap().remove(entity); if (simplify.getTracerMap().size() == 0) { simplify.close(); ctx.close(); } }
public boolean methodExitEvent(MethodExitEvent evt) { boolean result = false; synchronized (listeners) { for (EventNotifier en : listeners) { result |= en.methodExitEvent(evt); } } return result; }
/** * Convenient method that compares the method name (extracted from event) with the given set of names. * @param event * @param methodName1 * @param methodName2 */ private void checkEntryExit(Event event, String methodName1, String methodName2) { if (event instanceof MethodEntryEvent) { System.out.println("Starting method = " + ((MethodEntryEvent)event).method().toString()); Assert.assertTrue(((MethodEntryEvent)event).method().toString().equals(methodName1) || ((MethodEntryEvent)event).method().toString().equals(methodName2)); }else if (event instanceof MethodExitEvent) { System.out.println("Exiting method = " + ((MethodExitEvent)event).method().toString()); Assert.assertTrue(((MethodExitEvent)event).method().toString().equals(methodName1) || ((MethodExitEvent)event).method().toString().equals(methodName2)); } }
@Override public boolean handleEvent(final Event event, final JDIDebugTarget target, final boolean suspendVote, final EventSet eventSet) { if (owner.isActive()) { owner.jdiHandler().jdiMethodExit((MethodExitEvent) event); } return true; }
IJiveEvent createMethodResultEvent(final MethodExitEvent event) { final IThreadValue threadId = resolveThread(event); final StackFrame activation = executionState().framePeek(event.thread().uniqueID()); final IMethodContour method = executionState().lookupContour(activation); final IValue value = resolveReturnValue(event); final IContourMember instance = method.lookupResultMember(); // defensively record the location-- no harm done if the location hasn't changed executionState().nextLine(threadId, resolveLine(event.location())); final ILineValue line = executionState().currentLine(threadId); return eventFactory().createVarAssignEvent(threadId, line, value, instance); }
/** * Filtered method calls/returns are captured lazily by determineStackFrame(event). */ void handleMethodExit(final MethodExitEvent event, final boolean generateLocals) throws IncompatibleThreadStateException, AbsentInformationException { if (!eventFilter().acceptsMethod(event.method(), event.thread())) { return; } final StackFrame frame = determineStackFrame(event); // local variable writes on the return line could be missed without this if (generateLocals) { handleLocals(null, frame, event.location()); } // handle a pending returned event if necessary handlePendingReturned(event.location(), frame, event.thread()); if (!event.method().returnTypeName().equalsIgnoreCase(JDIEventHandlerDelegate.VOID_TYPE_NAME)) { final Value result = event.returnValue(); if (manager().generateArrayEvents() && result instanceof ArrayReference) { // dispatch a new array event and the respective cell assignments handleNewArray((ArrayReference) result, event.location(), frame); } // dispatch a result event dispatcher().dispatchMethodResultEvent(event); } // unregister this contour's local variables if (generateLocals && !frame.location().method().isNative()) { removeLocals(frame); } // dispatch the event dispatcher().dispatchMethodExitEvent(event); }
private Data processThis(MethodExitEvent event, ReferenceType ref, ThreadReference thread) { StackFrame stack=null; try { stack = thread.frame(0); } catch (IncompatibleThreadStateException e) { e.printStackTrace(); } Data valueThis = utils.getObj("this",stack.thisObject(),new ArrayList<Long>()); return valueThis; }
private void methodExitEvent(MethodExitEvent event) { String methodName = event.method().toString(); String className = ClassUtils.getClass(event.method().declaringType()); if (!excludesClassMethods.isExcluded(className,methodName) && !className.contains("$")){ if (!enableProfiling) methodExitManager.methodExitEvent((MethodExitEvent)event); } }
public F3MethodExitEvent(F3VirtualMachine f3vm, MethodExitEvent underlying) { super(f3vm, underlying); }
@Override protected MethodExitEvent underlying() { return (MethodExitEvent) super.underlying(); }
public boolean methodExitEvent(MethodExitEvent e) { return true; }
public VisitableMethodExitEvent(MethodExitEvent event) { this.event = event; }
@Override public void visit(MethodExitEvent event) { }
/** * Creates and dispatches an in-model {@code ReturnEvent} from the given {@code MethodExitEvent}. */ @Override public void dispatchMethodExitEvent(final MethodExitEvent event) { dispatchEvent(adapter().createMethodExitEvent(event)); }
@Override public void dispatchMethodResultEvent(final MethodExitEvent event) { dispatchEvent(adapter().createMethodResultEvent(event)); }
public void methodExitEvent(MethodExitEvent event) { ThreadReference thread = event.thread(); Method method = event.method(); String className = ClassUtils.getClass(method.declaringType()); String methodName = method.name(); List<Data> arguments = processArguments(method,thread); Value returnValue = event.returnValue(); Data returnObject = null; if (!(returnValue instanceof VoidValue)) returnObject = utils.getObj("return",returnValue,new ArrayList<Long>()); ReferenceType ref = method.declaringType(); // "class" where is declaring the method Data object_this = null; if (!Settings.getInstance().isExcludedThis()) object_this = processThis(event,ref, thread); MethodExitInfo info = new MethodExitInfo(methodName,className,returnObject,arguments,object_this); synchronized (writer) { writer.writeMethodExitInfo(info); } }
/** * Visit a {@code MethodExitEvent}. * * @param event Event to visit */ void visit(MethodExitEvent event);
/** * Creates and dispatches an in-model {@code ReturnEvent} from the given {@code MethodExitEvent}. */ public void dispatchMethodExitEvent(MethodExitEvent event);
/** * Creates and dispatches an assignment to a method's special result variable. */ public void dispatchMethodResultEvent(MethodExitEvent event);
/** * Notification of a method return in the target VM. */ void jdiMethodExit(MethodExitEvent event);
void exit(MethodExitEvent event);