Java Code Examples for com.sun.jdi.ThreadReference#isSuspended()

The following examples show how to use com.sun.jdi.ThreadReference#isSuspended() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWTGrabHandler.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public boolean solveGrabbing(VirtualMachine vm) {
    if (vm == null) return true;
    if (Boolean.FALSE.equals(doGrabCheck)) {
        return true;
    }
    if (GraphicsEnvironment.isHeadless()) {
        doGrabCheck = Boolean.FALSE;
        return true;
    }
    // Check if AWT-EventQueue thread is suspended and a window holds a grab
    List<ThreadReference> allThreads = VirtualMachineWrapper.allThreads0(vm);
    for (ThreadReference t : allThreads) {
        if (!t.isSuspended()) continue;
        boolean success = solveGrabbing(t);
        if (!success) {
            return false;
        }
    }
    return true;
}
 
Example 2
Source File: JPDADebuggerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
    List<ThreadReference> allThreads = vm.allThreads();
    System.err.println("All Threads:");
    for (ThreadReference tr : allThreads) {
        String name = tr.name();
        boolean suspended = tr.isSuspended();
        int suspendCount = tr.suspendCount();
        int status = tr.status();
        System.err.println(name+"\t SUSP = "+suspended+", COUNT = "+suspendCount+", STATUS = "+status);
    }
    System.err.println("");
    if (!finish) {
        rp.post(this, INTERVAL);
    }
}
 
Example 3
Source File: JavaHotCodeReplaceProvider.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns a list of frames which should be popped in the given threads.
 */
private List<StackFrame> getAffectedFrames(List<ThreadReference> threads, List<String> replacedClassNames)
        throws DebugException {
    List<StackFrame> popFrames = new ArrayList<>();
    for (ThreadReference thread : threads) {
        if (thread.isSuspended()) {
            StackFrame affectedFrame = getAffectedFrame(thread, replacedClassNames);
            if (affectedFrame == null) {
                // No frame to drop to in this thread
                continue;
            }
            if (supportsDropToFrame(thread, affectedFrame)) {
                popFrames.add(affectedFrame);
            }
        }
    }
    return popFrames;
}
 
Example 4
Source File: JavaHotCodeReplaceProvider.java    From java-debug with Eclipse Public License 1.0 6 votes vote down vote up
private boolean containsObsoleteMethods() throws DebugException {
    List<ThreadReference> threads = currentDebugSession.getAllThreads();
    for (ThreadReference thread : threads) {
        if (!thread.isSuspended()) {
            continue;
        }
        List<StackFrame> frames = getStackFrames(thread, true);
        if (frames == null || frames.isEmpty()) {
            continue;
        }
        for (StackFrame frame : frames) {
            if (StackFrameUtility.isObsolete(frame)) {
                return true;
            }
        }
    }
    return false;
}
 
Example 5
Source File: ThreadsRequestHandler.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
private CompletableFuture<Response> resumeOthers(Requests.ThreadOperationArguments arguments, Response response, IDebugAdapterContext context) {
    List<ThreadReference> threads = DebugUtility.getAllThreadsSafely(context.getDebugSession());
    for (ThreadReference thread : threads) {
        long threadId = thread.uniqueID();
        if (threadId != arguments.threadId && thread.isSuspended()) {
            context.getExceptionManager().removeException(threadId);
            DebugUtility.resumeThread(thread);
            context.getProtocolServer().sendEvent(new Events.ContinuedEvent(threadId));
            checkThreadRunningAndRecycleIds(thread, context);
        }
    }

    return CompletableFuture.completedFuture(response);
}
 
Example 6
Source File: ThreadsRequestHandler.java    From java-debug with Eclipse Public License 1.0 5 votes vote down vote up
private CompletableFuture<Response> pauseOthers(Requests.ThreadOperationArguments arguments, Response response, IDebugAdapterContext context) {
    List<ThreadReference> threads = DebugUtility.getAllThreadsSafely(context.getDebugSession());
    for (ThreadReference thread : threads) {
        long threadId = thread.uniqueID();
        if (threadId != arguments.threadId && !thread.isCollected() && !thread.isSuspended()) {
            thread.suspend();
            context.getProtocolServer().sendEvent(new Events.StoppedEvent("pause", threadId));
        }
    }

    return CompletableFuture.completedFuture(response);
}