use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.
the class DebugProcessEvents method processLocatableEvent.
private void processLocatableEvent(final SuspendContextImpl suspendContext, final LocatableEvent event) {
ThreadReference thread = event.thread();
//LOG.assertTrue(thread.isSuspended());
preprocessEvent(suspendContext, thread);
//we use schedule to allow processing other events during processing this one
//this is especially necessary if a method is breakpoint condition
getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction() throws Exception {
final SuspendManager suspendManager = getSuspendManager();
SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, suspendContext.getThread());
if (evaluatingContext != null && !DebuggerSession.enableBreakpointsDuringEvaluation()) {
// is inside evaluation, so ignore any breakpoints
suspendManager.voteResume(suspendContext);
return;
}
final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager().findRequestor(event.request());
boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy());
boolean requestHit;
try {
requestHit = (requestor != null) && requestor.processLocatableEvent(this, event);
} catch (final LocatableEventRequestor.EventProcessingException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug(ex.getMessage());
}
final boolean[] considerRequestHit = new boolean[] { true };
DebuggerInvocationUtil.invokeAndWait(getProject(), () -> {
final String displayName = requestor instanceof Breakpoint ? ((Breakpoint) requestor).getDisplayName() : requestor.getClass().getSimpleName();
final String message = DebuggerBundle.message("error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage());
considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES;
}, ModalityState.NON_MODAL);
requestHit = considerRequestHit[0];
resumePreferred = !requestHit;
}
if (requestHit && requestor instanceof Breakpoint) {
// if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy
ApplicationManager.getApplication().runReadAction(() -> {
XDebugSession session = getSession().getXDebugSession();
if (session != null) {
XBreakpoint breakpoint = ((Breakpoint) requestor).getXBreakpoint();
if (breakpoint != null) {
((XDebugSessionImpl) session).processDependencies(breakpoint);
}
}
});
}
if (!requestHit || resumePreferred) {
suspendManager.voteResume(suspendContext);
} else {
if (myReturnValueWatcher != null) {
myReturnValueWatcher.disable();
}
//if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
// // there could be explicit resume as a result of call to voteSuspend()
// // e.g. when breakpoint was considered invalid, in that case the filter will be applied _after_
// // resuming and all breakpoints in other threads will be ignored.
// // As resume() implicitly cleares the filter, the filter must be always applied _before_ any resume() action happens
// myBreakpointManager.applyThreadFilter(DebugProcessEvents.this, event.thread());
//}
suspendManager.voteSuspend(suspendContext);
showStatusText(DebugProcessEvents.this, event);
}
}
});
}
use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.
the class DebugProcessEvents method processStepEvent.
private void processStepEvent(SuspendContextImpl suspendContext, StepEvent event) {
final ThreadReference thread = event.thread();
//LOG.assertTrue(thread.isSuspended());
preprocessEvent(suspendContext, thread);
//noinspection HardCodedStringLiteral
RequestHint hint = (RequestHint) event.request().getProperty("hint");
deleteStepRequests(event.thread());
boolean shouldResume = false;
final Project project = getProject();
if (hint != null) {
final int nextStepDepth = hint.getNextStepDepth(suspendContext);
if (nextStepDepth == RequestHint.RESUME) {
getSession().clearSteppingThrough();
shouldResume = true;
} else if (nextStepDepth != RequestHint.STOP) {
final ThreadReferenceProxyImpl threadProxy = suspendContext.getThread();
doStep(suspendContext, threadProxy, hint.getSize(), nextStepDepth, hint);
shouldResume = true;
}
if (!shouldResume && hint.isRestoreBreakpoints()) {
DebuggerManagerEx.getInstanceEx(project).getBreakpointManager().enableBreakpoints(this);
}
}
if (shouldResume) {
getSuspendManager().voteResume(suspendContext);
} else {
showStatusText("");
if (myReturnValueWatcher != null) {
myReturnValueWatcher.disable();
}
getSuspendManager().voteSuspend(suspendContext);
if (hint != null) {
final MethodFilter methodFilter = hint.getMethodFilter();
if (methodFilter instanceof NamedMethodFilter && !hint.wasStepTargetMethodMatched()) {
final String message = "Method <b>" + ((NamedMethodFilter) methodFilter).getMethodName() + "()</b> has not been called";
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(message, MessageType.INFO).notify(project);
}
if (hint.wasStepTargetMethodMatched() && hint.isResetIgnoreFilters()) {
checkPositionNotFiltered(suspendContext.getThread(), filters -> mySession.resetIgnoreStepFiltersFlag());
}
}
}
}
use of com.sun.jdi.ThreadReference in project kotlin by JetBrains.
the class DebuggerSteppingHelper method createStepRequest.
// copied from DebugProcessImpl.doStep
private static void createStepRequest(@NotNull SuspendContextImpl suspendContext, @Nullable ThreadReferenceProxyImpl stepThread, @NotNull EventRequestManager requestManager, int size, int depth) {
if (stepThread == null) {
return;
}
try {
ThreadReference stepThreadReference = stepThread.getThreadReference();
requestManager.deleteEventRequests(requestManager.stepRequests());
StepRequest stepRequest = requestManager.createStepRequest(stepThreadReference, size, depth);
List<ClassFilter> activeFilters = getActiveFilters();
if (!activeFilters.isEmpty()) {
String currentClassName = getCurrentClassName(stepThread);
if (currentClassName == null || !DebuggerUtilsEx.isFiltered(currentClassName, activeFilters)) {
// add class filters
for (ClassFilter filter : activeFilters) {
stepRequest.addClassExclusionFilter(filter.getPattern());
}
}
}
// suspend policy to match the suspend policy of the context:
// if all threads were suspended, then during stepping all the threads must be suspended
// if only event thread were suspended, then only this particular thread must be suspended during stepping
stepRequest.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD ? EventRequest.SUSPEND_EVENT_THREAD : EventRequest.SUSPEND_ALL);
stepRequest.enable();
} catch (ObjectCollectedException ignored) {
}
}
Aggregations