public List<MonitorInfo> getOwnedMonitors() { List<MonitorInfo> threadMonitors; try { threadMonitors = getThread().getOwnedMonitorsAndFrames(); } catch (InvalidStackFrameException itsex) { threadMonitors = Collections.emptyList(); } catch (VMDisconnectedException e) { threadMonitors = Collections.emptyList(); } if (threadMonitors.size() == 0) { return threadMonitors; } List<MonitorInfo> frameMonitors = new ArrayList<MonitorInfo>(); for (MonitorInfo mi : threadMonitors) { if (this.equals(mi.getFrame())) { frameMonitors.add(mi); } } return Collections.unmodifiableList(frameMonitors); }
private List<StackFrame> getFilteredFrames() throws IncompatibleThreadStateException { List<StackFrame> frames = F3Wrapper.wrapFrames(virtualMachine(), underlying().frames()); List<StackFrame> filteredFrames = new ArrayList<StackFrame>(frames.size()); try { for (StackFrame fr : frames) { F3StackFrame f3fr = (F3StackFrame) fr; // don't add F3 synthetic frames if (f3fr.location().method().isF3InternalMethod()) { continue; } else { filteredFrames.add(f3fr); } } } catch (InvalidStackFrameException exp) { throw new IncompatibleThreadStateException(exp.getMessage()); } return filteredFrames; }
public void actionPerformed(AnActionEvent e) { Project project = e.getData(PlatformDataKeys.PROJECT); StackFrameProxyImpl stackFrame = getStackFrameProxy(e); if(stackFrame == null) { return; } try { DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext()); DebugProcessImpl debugProcess = debuggerContext.getDebugProcess(); if(debugProcess == null) { return; } debugProcess.getManagerThread().schedule(debugProcess.createPopFrameCommand(debuggerContext, stackFrame)); } catch (NativeMethodException e2){ Messages.showMessageDialog(project, DebuggerBundle.message("error.native.method.exception"), ActionsBundle.actionText(DebuggerActions.POP_FRAME), Messages.getErrorIcon()); } catch (InvalidStackFrameException ignored) { } catch(VMDisconnectedException vde) { } }
RuntimeException toJDIException() { switch (errorCode) { case JDWP.Error.INVALID_OBJECT: return new ObjectCollectedException(); case JDWP.Error.INVALID_MODULE: return new InvalidModuleException(); case JDWP.Error.VM_DEAD: return new VMDisconnectedException(); case JDWP.Error.OUT_OF_MEMORY: return new VMOutOfMemoryException(); case JDWP.Error.CLASS_NOT_PREPARED: return new ClassNotPreparedException(); case JDWP.Error.INVALID_FRAMEID: case JDWP.Error.NOT_CURRENT_FRAME: return new InvalidStackFrameException(); case JDWP.Error.NOT_IMPLEMENTED: return new UnsupportedOperationException(); case JDWP.Error.INVALID_INDEX: case JDWP.Error.INVALID_LENGTH: return new IndexOutOfBoundsException(); case JDWP.Error.TYPE_MISMATCH: return new InconsistentDebugInfoException(); case JDWP.Error.INVALID_THREAD: return new IllegalThreadStateException(); default: return new InternalException("Unexpected JDWP Error: " + errorCode, errorCode); } }
public ObjectReference thisObject() { validateStackFrame(); MethodImpl currentMethod = (MethodImpl)location.method(); if (currentMethod.isStatic() || currentMethod.isNative()) { return null; } else { if (thisObject == null) { PacketStream ps; /* protect against defunct frame id */ synchronized (vm.state()) { validateStackFrame(); ps = JDWP.StackFrame.ThisObject. enqueueCommand(vm, thread, id); } /* actually get it, now that order is guaranteed */ try { thisObject = JDWP.StackFrame.ThisObject. waitForReply(vm, ps).objectThis; } catch (JDWPException exc) { switch (exc.errorCode()) { case JDWP.Error.INVALID_FRAMEID: case JDWP.Error.THREAD_NOT_SUSPENDED: case JDWP.Error.INVALID_THREAD: throw new InvalidStackFrameException(); default: throw exc.toJDIException(); } } } } return thisObject; }
void pop() throws IncompatibleThreadStateException { validateStackFrame(); // flush caches and disable caching until command completion CommandSender sender = new CommandSender() { public PacketStream send() { return JDWP.StackFrame.PopFrames.enqueueCommand(vm, thread, id); } }; try { PacketStream stream = thread.sendResumingCommand(sender); JDWP.StackFrame.PopFrames.waitForReply(vm, stream); } catch (JDWPException exc) { switch (exc.errorCode()) { case JDWP.Error.THREAD_NOT_SUSPENDED: throw new IncompatibleThreadStateException( "Thread not current or suspended"); case JDWP.Error.INVALID_THREAD: /* zombie */ throw new IncompatibleThreadStateException("zombie"); case JDWP.Error.NO_MORE_FRAMES: throw new InvalidStackFrameException( "No more frames on the stack"); default: throw exc.toJDIException(); } } // enable caching - suspended again vm.state().freeze(); }
/** * Pop a StackFrame from its thread. * * @param frame * the StackFrame will be popped */ public static void pop(StackFrame frame) throws DebugException { try { frame.thread().popFrames(frame); } catch (IncompatibleThreadStateException | InvalidStackFrameException e) { throw new DebugException(e.getMessage(), e); } }
private EvaluateException processException(Exception e) { if(e instanceof InconsistentDebugInfoException) { return new EvaluateException(DebuggerBundle.message("error.inconsistent.debug.info"), null); } else if(e instanceof InvalidStackFrameException) { return new EvaluateException(DebuggerBundle.message("error.invalid.stackframe"), null); } else { return EvaluateExceptionUtil.DEBUG_INFO_UNAVAILABLE; } }
private void validateMonitorInfo() { if (!isValid) { throw new InvalidStackFrameException("Thread has been resumed"); } }
void validateStackFrame() { if (!isValid) { throw new InvalidStackFrameException("Thread has been resumed"); } }
public void setValue(LocalVariable variableIntf, Value valueIntf) throws InvalidTypeException, ClassNotLoadedException { validateStackFrame(); validateMirror(variableIntf); validateMirrorOrNull(valueIntf); LocalVariableImpl variable = (LocalVariableImpl)variableIntf; ValueImpl value = (ValueImpl)valueIntf; if (!variable.isVisible(this)) { throw new IllegalArgumentException(variable.name() + " is not valid at this frame location"); } try { // Validate and convert value if necessary value = ValueImpl.prepareForAssignment(value, variable); JDWP.StackFrame.SetValues.SlotInfo[] slotVals = new JDWP.StackFrame.SetValues.SlotInfo[1]; slotVals[0] = new JDWP.StackFrame.SetValues. SlotInfo(variable.slot(), value); PacketStream ps; /* protect against defunct frame id */ synchronized (vm.state()) { validateStackFrame(); ps = JDWP.StackFrame.SetValues. enqueueCommand(vm, thread, id, slotVals); } /* actually set it, now that order is guaranteed */ try { JDWP.StackFrame.SetValues.waitForReply(vm, ps); } catch (JDWPException exc) { switch (exc.errorCode()) { case JDWP.Error.INVALID_FRAMEID: case JDWP.Error.THREAD_NOT_SUSPENDED: case JDWP.Error.INVALID_THREAD: throw new InvalidStackFrameException(); default: throw exc.toJDIException(); } } } catch (ClassNotLoadedException e) { /* * Since we got this exception, * the variable type must be a reference type. The value * we're trying to set is null, but if the variable's * class has not yet been loaded through the enclosing * class loader, then setting to null is essentially a * no-op, and we should allow it without an exception. */ if (value != null) { throw e; } } }
public List<Value> getArgumentValues() { validateStackFrame(); MethodImpl mmm = (MethodImpl)location.method(); List<String> argSigs = mmm.argumentSignatures(); int count = argSigs.size(); JDWP.StackFrame.GetValues.SlotInfo[] slots = new JDWP.StackFrame.GetValues.SlotInfo[count]; int slot; if (mmm.isStatic()) { slot = 0; } else { slot = 1; } for (int ii = 0; ii < count; ++ii) { char sigChar = argSigs.get(ii).charAt(0); slots[ii] = new JDWP.StackFrame.GetValues.SlotInfo(slot++,(byte)sigChar); if (sigChar == 'J' || sigChar == 'D') { slot++; } } PacketStream ps; /* protect against defunct frame id */ synchronized (vm.state()) { validateStackFrame(); ps = JDWP.StackFrame.GetValues.enqueueCommand(vm, thread, id, slots); } ValueImpl[] values; try { values = JDWP.StackFrame.GetValues.waitForReply(vm, ps).values; } catch (JDWPException exc) { switch (exc.errorCode()) { case JDWP.Error.INVALID_FRAMEID: case JDWP.Error.THREAD_NOT_SUSPENDED: case JDWP.Error.INVALID_THREAD: throw new InvalidStackFrameException(); default: throw exc.toJDIException(); } } if (count != values.length) { throw new InternalException( "Wrong number of values returned from target VM"); } return Arrays.asList((Value[])values); }