private void stepDone(EventRequest er) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper { JPDAThreadImpl t; if (er instanceof StepRequest) { StepRequest sr = (StepRequest) er; t = ((JPDADebuggerImpl) debugger).getThread(StepRequestWrapper.thread(sr)); } else { ThreadReference tr = (ThreadReference) EventRequestWrapper.getProperty(er, "thread"); // NOI18N if (tr != null) { t = ((JPDADebuggerImpl) debugger).getThread(tr); } else { t = null; } } if (t != null) { t.setInStep(false, null); } }
/** * Test whether the method is considered to be synthetic * @param m The method * @param loc The current location in that method * @return 0 when not synthetic * positive when suggested step depth is returned * negative when is synthetic and no further step depth is suggested. */ public static int isSyntheticMethod(Method m, Location loc) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper { String name = TypeComponentWrapper.name(m); if (name.startsWith("lambda$")) { // NOI18N int lineNumber = LocationWrapper.lineNumber(loc); if (lineNumber == 1) { // We're in the initialization of the Lambda. We need to step over it. return StepRequest.STEP_OVER; } return 0; // Do not treat Lambda methods as synthetic, because they contain user code. } else { // Do check the class for being Lambda synthetic class: ReferenceType declaringType = LocationWrapper.declaringType(loc); try { String className = ReferenceTypeWrapper.name(declaringType); if (className.contains("$$Lambda$")) { // NOI18N // Lambda synthetic class return -1; } } catch (ObjectCollectedExceptionWrapper ex) { } } return TypeComponentWrapper.isSynthetic(m) ? -1 : 0; }
@Override public void perform(String[] argv, Context ctx) { if (argv.length > 0) { switch (argv[0]) { case "into": singleStep(ctx, StepRequest.STEP_INTO); break; case "out": singleStep(ctx, StepRequest.STEP_OUT); break; case "over": singleStep(ctx, StepRequest.STEP_OVER); break; case "check": checkStep(ctx); } } else { singleStep(ctx, StepRequest.STEP_OVER); } }
void deleteStepRequests(@Nullable final ThreadReference stepThread) { EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager(); List<StepRequest> stepRequests = requestManager.stepRequests(); if (!stepRequests.isEmpty()) { final List<StepRequest> toDelete = new ArrayList<StepRequest>(stepRequests.size()); for (final StepRequest request : stepRequests) { ThreadReference threadReference = request.thread(); // [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occurs try { if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) { toDelete.add(request); } } catch (IllegalThreadStateException e) { LOG.info(e); // undocumented by JDI: may be thrown when querying thread status } catch (ObjectCollectedException ignored) { } } requestManager.deleteEventRequests(toDelete); } }
@Override public void contextAction() { showStatusText(DebuggerBundle.message("status.step.over")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl stepThread = getContextThread(); // need this hint while stepping over for JSR45 support: // several lines of generated java code may correspond to a single line in the source file, // from which the java code was generated RequestHint hint = new RequestHint(stepThread, suspendContext, StepRequest.STEP_OVER); hint.setRestoreBreakpoints(myIsIgnoreBreakpoints); hint.setIgnoreFilters(myIsIgnoreBreakpoints || mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(stepThread); final MethodReturnValueWatcher rvWatcher = myReturnValueWatcher; if (rvWatcher != null) { rvWatcher.enable(stepThread.getThreadReference()); } doStep(suspendContext, stepThread, myStepSize, StepRequest.STEP_OVER, hint); if (myIsIgnoreBreakpoints) { DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().disableBreakpoints(DebugProcessImpl.this); } super.contextAction(); }
private void doStep(int depth, SuspendPolicy suspendPolicy) throws DebuggerException { lock.lock(); try { clearSteps(); StepRequest request = getEventManager().createStepRequest(getCurrentThread(), StepRequest.STEP_LINE, depth); request.addCountFilter(1); request.setSuspendPolicy(toSuspendEventRequest(suspendPolicy)); request.enable(); resume(newDto(ResumeActionDto.class)); } finally { lock.unlock(); } }
public void contextAction() { showStatusText(DebuggerBundle.message("status.step.into")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl stepThread = getContextThread(); final RequestHint hint = mySmartStepFilter != null? new RequestHint(stepThread, suspendContext, mySmartStepFilter) : new RequestHint(stepThread, suspendContext, StepRequest.STEP_INTO); if (myForcedIgnoreFilters) { try { mySession.setIgnoreStepFiltersFlag(stepThread.frameCount()); } catch (EvaluateException e) { LOG.info(e); } } hint.setIgnoreFilters(myForcedIgnoreFilters || mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(stepThread); doStep(suspendContext, stepThread, StepRequest.STEP_INTO, hint); super.contextAction(); }
public void contextAction() { showStatusText(DebuggerBundle.message("status.step.over")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl stepThread = getContextThread(); // need this hint whil stepping over for JSR45 support: // several lines of generated java code may correspond to a single line in the source file, // from which the java code was generated RequestHint hint = new RequestHint(stepThread, suspendContext, StepRequest.STEP_OVER); hint.setRestoreBreakpoints(myIsIgnoreBreakpoints); hint.setIgnoreFilters(myIsIgnoreBreakpoints || mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(stepThread); final MethodReturnValueWatcher rvWatcher = myReturnValueWatcher; if (rvWatcher != null) { rvWatcher.enable(stepThread.getThreadReference()); } doStep(suspendContext, stepThread, StepRequest.STEP_OVER, hint); if (myIsIgnoreBreakpoints) { DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().disableBreakpoints(DebugProcessImpl.this); } super.contextAction(); }
protected void createRequest() { final EventRequestManager manager = getEventRequestManager(); if (manager != null) { try { if (stepRequest != null) { removeRequest(); } stepRequest = manager.createStepRequest(getUnderlyingThread(), StepRequest.STEP_LINE, StepRequest.STEP_INTO); final JiveDebugTarget target = (JiveDebugTarget) getDebugTarget(); final IModelFilter requestFilter = target.jdiManager().modelFilter(); requestFilter.filter(stepRequest); stepRequest.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); stepRequest.enable(); addJDIEventListener(this, stepRequest); } catch (final RuntimeException e) { logError(e); } } }
final String run(String[] args) { if (jdb.status != Status.STARTED) { return String.format(NOT_VALID_UNTIL_STARTED, "stepi"); } StepRequest request = jdb.eventRequestManager.createStepRequest(jdb.thread, StepRequest.STEP_MIN, StepRequest.STEP_INTO); request.addCountFilter(1);// next step only request.enable(); return "Step one instruction."; }
private static int getJDIAction (Object action) { if (action == ActionsManager.ACTION_STEP_OUT) return StepRequest.STEP_OUT; if (action == ActionsManager.ACTION_STEP_OVER) return StepRequest.STEP_OVER; throw new IllegalArgumentException (); }
private void addPatternsToRequest (String[] patterns, StepRequest stepRequest) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper { if (stepRequest == null) return; int i, k = patterns.length; for (i = 0; i < k; i++) { try { StepRequestWrapper.addClassExclusionFilter(stepRequest, patterns [i]); } catch (InvalidRequestStateException irex) { // The request is gone - ignore return ; } smartLogger.log(Level.FINER, " add pattern: {0}", patterns[i]); } }
/** * Removes binding between the specified event request and a registered object. * * @param req request * @see #register */ public synchronized void unregister (EventRequest req) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper { Executor e = (Executor) EventRequestWrapper.getProperty(req, "executor"); EventRequestWrapper.putProperty (req, "executor", null); // NOI18N if (e != null) { e.removed(req); } if (req instanceof StepRequest) { ThreadReference tr = StepRequestWrapper.thread((StepRequest) req); debugger.getThread(tr).setInStep(false, null); } }
private boolean setUpBoundaryStepRequest(EventRequestManager erm, ThreadReference trRef, boolean isNextOperationFromDifferentExpression) throws InternalExceptionWrapper, VMDisconnectedExceptionWrapper, ObjectCollectedExceptionWrapper { boundaryStepRequest = EventRequestManagerWrapper.createStepRequest( erm, trRef, StepRequest.STEP_LINE, StepRequest.STEP_OVER ); if (isNextOperationFromDifferentExpression) { EventRequestWrapper.addCountFilter(boundaryStepRequest, 2); } else { EventRequestWrapper.addCountFilter(boundaryStepRequest, 1); } ((JPDADebuggerImpl) debugger).getOperator().register(boundaryStepRequest, this); EventRequestWrapper.setSuspendPolicy(boundaryStepRequest, debugger.getSuspend()); try { EventRequestWrapper.enable (boundaryStepRequest); requestsToCancel.add(boundaryStepRequest); } catch (IllegalThreadStateException itsex) { // the thread named in the request has died. ((JPDADebuggerImpl) debugger).getOperator().unregister(boundaryStepRequest); boundaryStepRequest = null; return false; } catch (InvalidRequestStateExceptionWrapper ex) { Exceptions.printStackTrace(ex); ((JPDADebuggerImpl) debugger).getOperator().unregister(boundaryStepRequest); boundaryStepRequest = null; return false; } return true; }
private static StepRequest createStepRequest(ThreadReference thread, int stepSize, int stepDepth, String[] stepFilters) { StepRequest request = thread.virtualMachine().eventRequestManager().createStepRequest(thread, stepSize, stepDepth); if (stepFilters != null) { for (String stepFilter : stepFilters) { request.addClassExclusionFilter(stepFilter); } } request.setSuspendPolicy(EventRequest.SUSPEND_EVENT_THREAD); request.addCountFilter(1); return request; }
private void stepIntoThread(ThreadReference thread) { StepRequest request = DebugUtility.createStepIntoRequest(thread, this.context.getStepFilters().classNameFilters); currentDebugSession.getEventHub().stepEvents().filter(debugEvent -> request.equals(debugEvent.event.request())) .take(1).subscribe(debugEvent -> { debugEvent.shouldResume = false; // Have to send to events to keep the UI sync with the step in operations: context.getProtocolServer().sendEvent(new Events.StoppedEvent("step", thread.uniqueID())); context.getProtocolServer().sendEvent(new Events.ContinuedEvent(thread.uniqueID())); }); request.enable(); thread.resume(); }
@Override public void contextAction() { showStatusText(DebuggerBundle.message("status.step.out")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl thread = getContextThread(); RequestHint hint = new RequestHint(thread, suspendContext, StepRequest.STEP_OUT); hint.setIgnoreFilters(mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(thread); final MethodReturnValueWatcher rvWatcher = myReturnValueWatcher; if (rvWatcher != null) { rvWatcher.enable(thread.getThreadReference()); } doStep(suspendContext, thread, myStepSize, StepRequest.STEP_OUT, hint); super.contextAction(); }
@Override public void contextAction() { showStatusText(DebuggerBundle.message("status.step.into")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl stepThread = getContextThread(); final RequestHint hint = mySmartStepFilter != null? new RequestHint(stepThread, suspendContext, mySmartStepFilter) : new RequestHint(stepThread, suspendContext, StepRequest.STEP_INTO); hint.setResetIgnoreFilters(mySmartStepFilter != null && !mySession.shouldIgnoreSteppingFilters()); if (myForcedIgnoreFilters) { try { mySession.setIgnoreStepFiltersFlag(stepThread.frameCount()); } catch (EvaluateException e) { LOG.info(e); } } hint.setIgnoreFilters(myForcedIgnoreFilters || mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(stepThread); if (myBreakpoint != null) { myBreakpoint.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD? DebuggerSettings.SUSPEND_THREAD : DebuggerSettings.SUSPEND_ALL); myBreakpoint.createRequest(suspendContext.getDebugProcess()); setRunToCursorBreakpoint(myBreakpoint); } doStep(suspendContext, stepThread, myStepSize, StepRequest.STEP_INTO, hint); super.contextAction(); }
private void clearSteps() throws DebuggerException { List<StepRequest> snapshot = new ArrayList<>(getEventManager().stepRequests()); for (StepRequest stepRequest : snapshot) { if (stepRequest.thread().equals(getCurrentThread())) { getEventManager().deleteEventRequest(stepRequest); } } }
public static List<StepRequest> wrapStepRequests( F3VirtualMachine f3vm, List<StepRequest> reqs) { if (reqs == null) { return null; } List<StepRequest> result = new ArrayList<StepRequest>(); for (StepRequest req : reqs) { result.add(wrap(f3vm, req)); } return result; }
private StepEvent doStep(ThreadReference thread, int gran, int depth) { final StepRequest sr = eventRequestManager().createStepRequest(thread, gran, depth); sr.addClassExclusionFilter("java.*"); sr.addClassExclusionFilter("sun.*"); sr.addClassExclusionFilter("com.sun.*"); sr.addCountFilter(1); sr.enable(); StepEvent retEvent = (StepEvent)resumeToEvent(sr); eventRequestManager().deleteEventRequest(sr); return retEvent; }
public boolean next() { StepRequest req = evaluator.commandNext(false); if (req != null) { resumeToEvent(req); return true; } else { return false; } }
public boolean step(String command) { StepRequest req = evaluator.commandStep(new StringTokenizer(command), false); if (req != null) { resumeToEvent(req); return true; } else { return false; } }
public boolean stepi() { StepRequest req = evaluator.commandStepi(false); if (req != null) { resumeToEvent(req); return true; } else { return false; } }
final String run(String[] args) { if (jdb.status != Status.STARTED) { return String.format(NOT_VALID_UNTIL_STARTED, "step"); } StepRequest request = jdb.eventRequestManager.createStepRequest(jdb.thread, StepRequest.STEP_LINE, StepRequest.STEP_INTO); request.addCountFilter(1);// next step only request.enable(); return "Step one line."; }
final String run(String[] args) { if (jdb.status != Status.STARTED) { return String.format(NOT_VALID_UNTIL_STARTED, "next"); } StepRequest request = jdb.eventRequestManager.createStepRequest(jdb.thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER); request.addCountFilter(1);// next step only request.enable(); return "Step one line (over calls)"; }
void deleteStepRequests(@Nullable final ThreadReference stepThread) { EventRequestManager requestManager = getVirtualMachineProxy().eventRequestManager(); List<StepRequest> stepRequests = requestManager.stepRequests(); if (!stepRequests.isEmpty()) { final List<StepRequest> toDelete = new ArrayList<StepRequest>(stepRequests.size()); for (final StepRequest request : stepRequests) { ThreadReference threadReference = request.thread(); // [jeka] on attempt to delete a request assigned to a thread with unknown status, a JDWP error occures if (threadReference.status() != ThreadReference.THREAD_STATUS_UNKNOWN && (stepThread == null || stepThread.equals(threadReference))) { toDelete.add(request); } } requestManager.deleteEventRequests(toDelete); } }
public void contextAction() { showStatusText(DebuggerBundle.message("status.step.out")); final SuspendContextImpl suspendContext = getSuspendContext(); final ThreadReferenceProxyImpl thread = getContextThread(); RequestHint hint = new RequestHint(thread, suspendContext, StepRequest.STEP_OUT); hint.setIgnoreFilters(mySession.shouldIgnoreSteppingFilters()); applyThreadFilter(thread); final MethodReturnValueWatcher rvWatcher = myReturnValueWatcher; if (rvWatcher != null) { rvWatcher.enable(thread.getThreadReference()); } doStep(suspendContext, thread, StepRequest.STEP_OUT, hint); super.contextAction(); }
@Override public boolean handleEvent(final Event event, final JDIDebugTarget target, final boolean suspendVote, final EventSet eventSet) { final StepEvent stepEvent = (StepEvent) event; if (isActive()) { jdiHandler.jdiStep(stepEvent); } boolean result = true; final JDTStepHandler stepHandler = getPendingStepHandler(); if (stepHandler != null) { switch (stepHandler.getStepKind()) { case StepRequest.STEP_INTO: if (shouldHandleStepInto(stepEvent.location())) { result = stepHandler.handleEvent(event, target, suspendVote, eventSet); } break; case StepRequest.STEP_OVER: if (shouldHandleStepOver(stepEvent.location())) { result = stepHandler.handleEvent(event, target, suspendVote, eventSet); } break; case StepRequest.STEP_OUT: if (shouldHandleStepReturn(stepEvent.location())) { result = stepHandler.handleEvent(event, target, suspendVote, eventSet); } break; default: // TODO log error break; } } return result; }
public ThreadTrace(ThreadReference thread, VirtualMachine vm) { this.thread = thread; this.vm=vm; EventRequestManager mgr = vm.eventRequestManager(); StepRequest request = mgr.createStepRequest(this.thread, StepRequest.STEP_LINE, StepRequest.STEP_OVER); request.setSuspendPolicy(EventRequest.SUSPEND_ALL); request.addCountFilter(1); request.enable(); }
public void runAction(final Object action) { runAction(getJDIAction(action), StepRequest.STEP_LINE, true, null, null, null); }
private StepRequest setStepRequest (int step) { return setStepRequest(step, StepRequest.STEP_LINE); }
private StepRequest setStepRequest (int step, JPDAThreadImpl[] resumeThreadPtr) { return setStepRequest(step, StepRequest.STEP_LINE, resumeThreadPtr); }
static void addExcludes(StepRequest request) { for (String pattern : excludes()) { request.addClassExclusionFilter(pattern); } }
StepRequestImpl(ThreadReference thread, int size, int depth) { this.thread = (ThreadReferenceImpl)thread; this.size = size; this.depth = depth; /* * Translate size and depth to corresponding JDWP values. */ int jdwpSize; switch (size) { case STEP_MIN: jdwpSize = JDWP.StepSize.MIN; break; case STEP_LINE: jdwpSize = JDWP.StepSize.LINE; break; default: throw new IllegalArgumentException("Invalid step size"); } int jdwpDepth; switch (depth) { case STEP_INTO: jdwpDepth = JDWP.StepDepth.INTO; break; case STEP_OVER: jdwpDepth = JDWP.StepDepth.OVER; break; case STEP_OUT: jdwpDepth = JDWP.StepDepth.OUT; break; default: throw new IllegalArgumentException("Invalid step depth"); } /* * Make sure this isn't a duplicate */ List<StepRequest> requests = stepRequests(); Iterator<StepRequest> iter = requests.iterator(); while (iter.hasNext()) { StepRequest request = iter.next(); if ((request != this) && request.isEnabled() && request.thread().equals(thread)) { throw new DuplicateRequestException( "Only one step request allowed per thread"); } } filters.add(JDWP.EventRequest.Set.Modifier.Step. create(this.thread, jdwpSize, jdwpDepth)); requestList().add(this); }