use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.
the class BreakpointManager method applyThreadFilter.
public void applyThreadFilter(@NotNull final DebugProcessImpl debugProcess, @Nullable ThreadReference newFilterThread) {
final RequestManagerImpl requestManager = debugProcess.getRequestsManager();
final ThreadReference oldFilterThread = requestManager.getFilterThread();
if (Comparing.equal(newFilterThread, oldFilterThread)) {
// the filter already added
return;
}
requestManager.setFilterThread(newFilterThread);
if (newFilterThread == null || oldFilterThread != null) {
final List<Breakpoint> breakpoints = getBreakpoints();
for (Breakpoint breakpoint : breakpoints) {
if (LineBreakpoint.CATEGORY.equals(breakpoint.getCategory()) || MethodBreakpoint.CATEGORY.equals(breakpoint.getCategory())) {
requestManager.deleteRequest(breakpoint);
breakpoint.createRequest(debugProcess);
}
}
} else {
// important! need to add filter to _existing_ requests, otherwise Requestor->Request mapping will be lost
// and debugger trees will not be restored to original state
EventRequestManager eventRequestManager = requestManager.getVMRequestManager();
if (eventRequestManager != null) {
applyFilter(eventRequestManager.breakpointRequests(), request -> request.addThreadFilter(newFilterThread));
applyFilter(eventRequestManager.methodEntryRequests(), request -> request.addThreadFilter(newFilterThread));
applyFilter(eventRequestManager.methodExitRequests(), request -> request.addThreadFilter(newFilterThread));
}
}
}
use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.
the class ThreadGroupReferenceProxyImpl method threads.
public List<ThreadReferenceProxyImpl> threads() {
List<ThreadReference> list = getThreadGroupReference().threads();
List<ThreadReferenceProxyImpl> proxies = new ArrayList<>(list.size());
for (ThreadReference threadReference : list) {
proxies.add(getVirtualMachineProxy().getThreadReferenceProxy(threadReference));
}
return proxies;
}
use of com.sun.jdi.ThreadReference in project gravel by gravel-st.
the class VMTargetStarter method createJVM.
public VMRemoteTarget createJVM() throws IOException, InterruptedException, IncompatibleThreadStateException {
Process process = startSecondJVM(VMLocalTarget.class);
sleep(90);
// connect
VirtualMachine vm = new VMAcquirer().connect(debugPort);
ClassPrepareRequest createClassPrepareRequest = vm.eventRequestManager().createClassPrepareRequest();
createClassPrepareRequest.addClassFilter(VMLocalTarget.class.getName());
createClassPrepareRequest.enable();
vm.resume();
List<ThreadReference> allThreads = vm.allThreads();
for (ThreadReference threadReference : allThreads) {
System.out.println(threadReference + " isSuspended: " + threadReference.isSuspended() + " suspendCount: " + threadReference.suspendCount());
}
// process events
EventQueue eventQueue = vm.eventQueue();
while (true) {
EventSet eventSet = eventQueue.remove();
for (Event event : eventSet) {
if (event instanceof ClassPrepareEvent) {
event.request().disable();
installHaltPoint(vm);
}
if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) {
return null;
}
if (event instanceof BreakpointEvent) {
event.request().disable();
ThreadReference thread = ((BreakpointEvent) event).thread();
return new VMRemoteTarget(process, vm, thread, debugPort);
}
}
eventSet.resume();
}
}
use of com.sun.jdi.ThreadReference in project gravel by gravel-st.
the class VMTargetRemoteTest method testDNU.
@Test
public void testDNU() throws Throwable {
ObjectReference promise = remote.evaluateForked("3 fromage");
ThreadReference thread = ((ThreadReference) remote.invokeMethod(promise, "thread"));
remote.invokeMethod(thread, "start");
ObjectReference state = (ObjectReference) remote.invokeMethod(thread, "getState");
StringReference str = (StringReference) remote.invokeMethod(state, "toString");
System.out.println(str.value());
printStack(thread);
// assertFalse(thread.isSuspended());
printThreadState();
System.out.println("VMTargetStarter.sleep(1000)");
VMTargetStarter.sleep(1000);
printStack(thread);
printThreadState();
boolean isFinished = ((BooleanValue) remote.invokeMethod(promise, "isFinished")).booleanValue();
assertFalse(isFinished);
printThreadState();
printStack(thread);
assertTrue(thread.isAtBreakpoint());
}
use of com.sun.jdi.ThreadReference in project intellij-community by JetBrains.
the class ThreadBlockedMonitor method onThreadBlocked.
private static void onThreadBlocked(@NotNull final ThreadReference blockedThread, @NotNull final ThreadReference blockingThread, final DebugProcessImpl process) {
XDebugSessionImpl.NOTIFICATION_GROUP.createNotification(DebuggerBundle.message("status.thread.blocked.by", blockedThread.name(), blockingThread.name()), DebuggerBundle.message("status.thread.blocked.by.resume", blockingThread.name()), NotificationType.INFORMATION, (notification, event) -> {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
notification.expire();
process.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
ThreadReferenceProxyImpl threadProxy = process.getVirtualMachineProxy().getThreadReferenceProxy(blockingThread);
SuspendContextImpl suspendingContext = SuspendManagerUtil.getSuspendingContext(process.getSuspendManager(), threadProxy);
process.getManagerThread().invoke(process.createResumeThreadCommand(suspendingContext, threadProxy));
}
});
}
}).notify(process.getProject());
}
Aggregations