Search in sources :

Example 1 with JDIThread

use of org.eclipse.jdt.internal.debug.core.model.JDIThread in project liferay-ide by liferay.

the class FMDebugTarget method suspendRelatedJavaThread.

boolean suspendRelatedJavaThread(final long remoteThreadId) throws DebugException {
    boolean retval = false;
    for (IDebugTarget target : this.launch.getDebugTargets()) {
        if (target instanceof IJavaDebugTarget) {
            IJavaDebugTarget javaTarget = (IJavaDebugTarget) target;
            IThread[] threads = javaTarget.getThreads();
            for (final IThread thread : threads) {
                if (thread instanceof JDIThread) {
                    JDIThread jdiThread = (JDIThread) thread;
                    ThreadReference underlyingThread = jdiThread.getUnderlyingThread();
                    Field tidField = underlyingThread.referenceType().fieldByName("tid");
                    Value tidValue = underlyingThread.getValue(tidField);
                    long threadId = Long.parseLong(tidValue.toString());
                    if (threadId == remoteThreadId) {
                        thread.suspend();
                        break;
                    }
                }
            }
        }
    }
    return retval;
}
Also used : Field(com.sun.jdi.Field) IJavaDebugTarget(org.eclipse.jdt.debug.core.IJavaDebugTarget) Value(com.sun.jdi.Value) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) ThreadReference(com.sun.jdi.ThreadReference) JDIThread(org.eclipse.jdt.internal.debug.core.model.JDIThread) JDIThread(org.eclipse.jdt.internal.debug.core.model.JDIThread) IThread(org.eclipse.debug.core.model.IThread)

Aggregations

Field (com.sun.jdi.Field)1 ThreadReference (com.sun.jdi.ThreadReference)1 Value (com.sun.jdi.Value)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 IThread (org.eclipse.debug.core.model.IThread)1 IJavaDebugTarget (org.eclipse.jdt.debug.core.IJavaDebugTarget)1 JDIThread (org.eclipse.jdt.internal.debug.core.model.JDIThread)1