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); } }
public ExceptionEvent resumeToException() { return (ExceptionEvent) resumeToEvent(new EventFilter() { public boolean match(Event evt) { return (evt instanceof ExceptionEvent); } }); }
@Override public synchronized void jdiExceptionThrown(final ExceptionEvent event) { if (!override && !owner.isStarted()) { return; } try { delegate.handleExceptionThrown(event); } catch (final Throwable e) { JiveDebugPlugin.log(e); } }
IJiveEvent createCatchEvent(final StackFrame catchFrame, final ExceptionEvent event) { final IThreadValue threadId = resolveThread(catchFrame); final StackFrame frame = executionState().framePeek(catchFrame.thread().uniqueID()); if (!executionState().containsInModelFrame(frame)) { throw new IllegalStateException("A method contour was not found for the given stack frame."); } final IMethodContour catcher = executionState().lookupContour(frame); final IValue exception = resolveReference(event.thread(), event.exception(), null); final IContourMember variable = resolveCatchVariable(event, catchFrame, catcher); // update the source location-- no harm done if the location hasn't changed executionState().nextLine(threadId, resolveLine(event.catchLocation())); final ILineValue line = executionState().currentLine(threadId); return eventFactory().createExceptionCatchEvent(threadId, line, exception, variable); }
private void eventLoop() throws InterruptedException { System.out.println("eventLoop started"); EventQueue eventQueue = vm.eventQueue(); boolean isRunning = true; while (isRunning) { EventSet eventSet = eventQueue.remove(); boolean mayResume = true; for (Event event : eventSet) { System.out.println(event); if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) { isRunning = false; } else if (event instanceof ExceptionEvent) { mayResume = false; } } if (mayResume) eventSet.resume(); } }
private Data processThis(ExceptionEvent 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; }
/** * 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); } }
public void exceptionEvent(ExceptionEvent evt) { synchronized (listeners) { for (EventNotifier en : listeners) { en.exceptionEvent(evt); } } }
/** * We call this method just before throwing an Exception and make sure it ExceptionEvent. */ private void checkExceptionEvent() { Event event = resumeToAnyEvent(); System.out.println("Exception request is " + event); Assert.assertTrue(event instanceof ExceptionEvent || event instanceof ThreadStartEvent); list(); }
@Override public boolean handleEvent(final Event event, final JDIDebugTarget target, final boolean suspendVote, final EventSet eventSet) { if (owner.isActive()) { owner.jdiHandler().jdiExceptionThrown((ExceptionEvent) event); } return true; }
IJiveEvent createThrowEvent(final ExceptionEvent event, final boolean framePopped) { final IThreadValue threadId = resolveThread(event); final IValue thrower = resolveThrower(event.thread(), framePopped); final IValue exception = resolveReference(event.thread(), event.exception(), null); // defensively record the location-- no harm done if the location hasn't changed final ILineValue nextLine = resolveLine(event.location()); if (nextLine != valueFactory().createUnavailableLine()) { executionState().nextLine(threadId, nextLine); } final ILineValue line = executionState().currentLine(threadId); return eventFactory() .createExceptionThrowEvent(threadId, line, exception, thrower, framePopped); }
private ExceptionEvent outstandingException(final ThreadReference thread) { final ExceptionEvent result = executionState().lookupException(thread.uniqueID()); if (result == null) { throw new IllegalStateException("An exception has not occurred on the thread."); } return result; }
void handleThreadDeath(final ThreadDeathEvent event) { final ThreadReference thread = event.thread(); /** * If a thread dies with outstanding frames, then all frames are popped with an exception. An * unexpected termination is gracefully handled by the execution model. */ while (executionState().frameCount(thread.uniqueID()) != 0) { // if by any chance the VM generated a throw event if (executionState().containsException(thread.uniqueID())) { final ExceptionEvent exception = outstandingException(thread); dispatcher().dispatchThrowEvent(exception, true); } else { dispatcher().dispatchThrowEvent(thread, true); } } if (executionState().containsException(thread.uniqueID())) { removeException(thread); } handlePendingReturned(null, null, event.thread()); final IThreadValue threadValue = owner.model().valueFactory() .createThread(thread.uniqueID(), thread.name()); // avoid duplicate thread termination final IThreadStartEvent threadStart = owner.model().lookupThread(threadValue); if (threadStart != null && threadStart.terminator() == null) { dispatcher().dispatchThreadDeath(event.thread()); } }
/** * Notification of an exception in the target VM. When an exception is thrown which satisfies a * currently enabled exception request, an event set containing an instance of this class will be * added to the VM's event queue. If the exception is thrown from a non-native method, the * exception event is generated at the location where the exception is thrown. If the exception is * thrown from a native method, the exception event is generated at the first non-native location * reached after the exception is thrown. * * @param event * * @see <a href="">http://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/index.html</a> */ @Override public void jdiExceptionThrown(final ExceptionEvent event) { // // this.currentEvent = event; this.currentThread = event.thread(); // // this.currentEvent = null; this.currentThread = null; }
/** * Gets the observable object for exception events. * @return the observable object for exception events */ @Override public Observable<DebugEvent> exceptionEvents() { return this.events().filter(debugEvent -> debugEvent.event instanceof ExceptionEvent); }
protected ObjectReference getThisObject(SuspendContextImpl context, LocatableEvent event) throws EvaluateException { if(event instanceof ExceptionEvent) { return ((ExceptionEvent) event).exception(); } return super.getThisObject(context, event); //To change body of overriden methods use Options | File Templates. }
public String getEventMessage(LocatableEvent event) { String exceptionName = (getQualifiedName() != null)? getQualifiedName() : CommonClassNames.JAVA_LANG_THROWABLE; String threadName = null; if (event instanceof ExceptionEvent) { ExceptionEvent exceptionEvent = (ExceptionEvent)event; try { exceptionName = exceptionEvent.exception().type().name(); threadName = exceptionEvent.thread().name(); } catch (Exception ignore) { } } final Location location = event.location(); final String locationQName = DebuggerUtilsEx.getLocationMethodQName(location); String locationFileName; try { locationFileName = location.sourceName(); } catch (AbsentInformationException e) { locationFileName = ""; } final int locationLine = Math.max(0, location.lineNumber()); if (threadName != null) { return DebuggerBundle.message( "exception.breakpoint.console.message.with.thread.info", exceptionName, threadName, locationQName, locationFileName, locationLine ); } else { return DebuggerBundle.message( "exception.breakpoint.console.message", exceptionName, locationQName, locationFileName, locationLine ); } }
public F3ExceptionEvent(F3VirtualMachine f3vm, ExceptionEvent underlying) { super(f3vm, underlying); }
@Override protected ExceptionEvent underlying() { return (ExceptionEvent) super.underlying(); }
public void exceptionEvent(ExceptionEvent e) { }
public VisitableExceptionEvent(ExceptionEvent event) { this.event = event; }
@Override public void visit(ExceptionEvent event) { }
/** * Creates and dispatches a {@code CatchEvent} for the method activation represented by the given * {@code StackFrame}, which must be a valid object. A {@code StackFrame} object is valid if it is * obtained from a suspended VM. It is invalidated once the VM is resumed. */ @Override public void dispatchCatchEvent(final StackFrame catchFrame, final ExceptionEvent event) { dispatchEvent(adapter().createCatchEvent(catchFrame, event)); }
/** * Creates and dispatches a {@code ThrowEvent} for the topmost stack frame of the given thread. * Throw events are generated for the stack frame where the exception is thrown (regardless if it * is caught there) and for any subsequent stack frame that does not handle the exception. */ @Override public void dispatchThrowEvent(final ExceptionEvent event, final boolean framePopped) { dispatchEvent(adapter().createThrowEvent(event, framePopped)); }
@Override public ExceptionEvent lookupException(final long threadID) { return threadToException.get(threadID); }
@Override public boolean observedException(final long threadId, final ExceptionEvent event) { final Object old = threadToException.putIfAbsent(threadId, event); return old == null && event != null; }
void handleExceptionThrown(final ExceptionEvent event) throws IncompatibleThreadStateException { boolean mapException = false; // Check if the exception was thrown in-model final ReferenceType throwingType = event.location().declaringType(); if (eventFilter().acceptsType(throwingType)) { mapException = true; } else { // Check if the exception wasn't caught final Location catchLocation = event.catchLocation(); if (catchLocation == null) { // Check if there are any in-model frames on the stack if (containsInModelFrames(event.thread(), null)) { mapException = true; } } else { // Check if the exception was caught in-model final ReferenceType catchingType = catchLocation.declaringType(); if (eventFilter().acceptsType(catchingType)) { mapException = true; } else { // Check if there are any in-model frames between the // throw and catch locations if (containsInModelFrames(event.thread(), catchLocation)) { mapException = true; } } } } if (mapException) { executionState().observedException(event.thread().uniqueID(), event); } }
public void processExceptionEvent(ExceptionEvent exEvent) { isUnderDebug = true; debugOrAnswerSema.release(); }
/** * Visit a {@code ExceptionEvent}. * * @param event Event to visit */ void visit(ExceptionEvent event);
/** * Creates and dispatches a {@code CatchEvent} for the method activation represented by the given * {@code StackFrame}, which must be a valid object. A {@code StackFrame} object is valid if it is * obtained from a suspended VM. It is invalidated once the VM is resumed. * * @param exception */ public void dispatchCatchEvent(StackFrame catchFrame, ExceptionEvent exception);
/** * Creates and dispatches a {@code ThrowEvent} for the topmost stack frame of the given thread. * Throw events are generated for the stack frame where the exception is thrown (regardless if it * is caught there) and for any subsequent stack frame that does not handle the exception. */ public void dispatchThrowEvent(ExceptionEvent exception, boolean framePopped);
/** * Notification of an exception in the target VM. */ void jdiExceptionThrown(ExceptionEvent event);
public void exceptionEvent(ExceptionEvent event) { ThreadReference thread = event.thread(); Location lo = event.catchLocation(); String classException = event.location().declaringType().name(); if (!classException.contains("ClassLoader") && lo == null) { try { List<StackFrame> list = null; list = thread.frames(); int i = 0; while (list.size() > i) { StackFrame frame = list.get(i); String className = frame.location().declaringType().name(); if (!utils.isExcludedClass(className)){ String method = frame.location().method().name(); List<Data> arguments = processArguments(frame.location() .method(), frame.thread()); Data returnObject = utils.getObjectFromObjectReference( false, "Exception", event.exception(), new ArrayList<Long>()); ReferenceType ref = event.location().method() .declaringType(); // "class" where is declaring the // method Data object_this = processThis(event, ref, thread); MethodExitInfo info = new MethodExitInfo(method, className, returnObject, arguments, object_this); writer.writeMethodExitInfo(info); } i++; } } catch (IncompatibleThreadStateException e) { } } }
public ExceptionEvent lookupException(long threadId);
public boolean observedException(long threadId, ExceptionEvent event);