Search in sources :

Example 1 with IThread

use of org.eclipse.debug.core.model.IThread in project liferay-ide by liferay.

the class PortalSourceLookupParticipant method getTemplateName.

private String getTemplateName(IStackFrame frame) throws DebugException {
    String retval = null;
    IThread thread = frame.getThread();
    IBreakpoint[] bps = thread.getBreakpoints();
    if (bps.length == 1) {
        IBreakpoint bp = thread.getBreakpoints()[0];
        retval = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, null);
    } else {
        if (thread instanceof FMThread) {
            FMThread fmThread = (FMThread) thread;
            Breakpoint stepBp = fmThread.getStepBreakpoint();
            if (stepBp != null) {
                // $NON-NLS-1$
                retval = stepBp.getTemplateName().replaceAll(FMDebugTarget.FM_TEMPLATE_SERVLET_CONTEXT, "");
            }
        }
    }
    return retval;
}
Also used : Breakpoint(freemarker.debug.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) FMThread(com.liferay.ide.portal.core.debug.fm.FMThread) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IThread(org.eclipse.debug.core.model.IThread)

Example 2 with IThread

use of org.eclipse.debug.core.model.IThread 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

IThread (org.eclipse.debug.core.model.IThread)2 FMThread (com.liferay.ide.portal.core.debug.fm.FMThread)1 Field (com.sun.jdi.Field)1 ThreadReference (com.sun.jdi.ThreadReference)1 Value (com.sun.jdi.Value)1 Breakpoint (freemarker.debug.Breakpoint)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)1 IJavaDebugTarget (org.eclipse.jdt.debug.core.IJavaDebugTarget)1 JDIThread (org.eclipse.jdt.internal.debug.core.model.JDIThread)1