Search in sources :

Example 1 with IJavaDebugTarget

use of org.eclipse.jdt.debug.core.IJavaDebugTarget in project jbosstools-openshift by jbosstools.

the class OpenShiftLaunchController method getHotCodeReplaceListener.

protected IJavaHotCodeReplaceListener getHotCodeReplaceListener(final IServer server, final ILaunch launch) {
    return new ClassCollectingHCRListener(server, launch) {

        protected void prePublish(IJavaDebugTarget target, IModule[] modules) {
            try {
                getLaunch().terminate();
            } catch (DebugException de) {
                OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to terminate debug session", de));
            }
        }

        @Override
        protected void postPublish(IJavaDebugTarget target, IModule[] modules) {
            IServer server = getServer();
            waitModulesStarted(modules);
            executeJMXGarbageCollection(server, modules);
            sleep(3000);
            String portAttr = launch.getAttribute(LAUNCH_DEBUG_PORT_PROP);
            int port = DebugContext.NO_DEBUG_PORT;
            try {
                port = Integer.parseInt(portAttr);
            } catch (NumberFormatException nfe) {
            // TODO
            }
            try {
                ILaunch newLaunch = attachRemoteDebugger(server, port, new NullProgressMonitor());
                if (newLaunch != null) {
                    overrideHotcodeReplace(server, newLaunch);
                }
                setLaunch(newLaunch);
            } catch (CoreException ce) {
                OpenShiftCoreActivator.pluginLog().logError(toCoreException("Unable to restart debug session", ce));
            }
        }
    };
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ClassCollectingHCRListener(org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener) IServer(org.eclipse.wst.server.core.IServer) IJavaDebugTarget(org.eclipse.jdt.debug.core.IJavaDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) OpenShiftServerUtils.toCoreException(org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException) ILaunch(org.eclipse.debug.core.ILaunch) DebugException(org.eclipse.debug.core.DebugException)

Example 2 with IJavaDebugTarget

use of org.eclipse.jdt.debug.core.IJavaDebugTarget 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)

Example 3 with IJavaDebugTarget

use of org.eclipse.jdt.debug.core.IJavaDebugTarget in project jbosstools-openshift by jbosstools.

the class OpenShiftLaunchController method overrideHotcodeReplace.

protected boolean overrideHotcodeReplace(IServer server, ILaunch launch) throws CoreException {
    IJavaHotCodeReplaceListener l = getHotCodeReplaceListener(server, launch);
    IDebugTarget[] targets = launch.getDebugTargets();
    if (targets != null && l != null) {
        for (int i = 0; i < targets.length; i++) {
            if (targets[i] instanceof IJavaDebugTarget) {
                ((IJavaDebugTarget) targets[i]).addHotCodeReplaceListener(l);
            }
        }
    }
    return true;
}
Also used : IJavaDebugTarget(org.eclipse.jdt.debug.core.IJavaDebugTarget) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) IJavaHotCodeReplaceListener(org.eclipse.jdt.debug.core.IJavaHotCodeReplaceListener)

Aggregations

IJavaDebugTarget (org.eclipse.jdt.debug.core.IJavaDebugTarget)3 IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)2 Field (com.sun.jdi.Field)1 ThreadReference (com.sun.jdi.ThreadReference)1 Value (com.sun.jdi.Value)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 DebugException (org.eclipse.debug.core.DebugException)1 ILaunch (org.eclipse.debug.core.ILaunch)1 IThread (org.eclipse.debug.core.model.IThread)1 IJavaHotCodeReplaceListener (org.eclipse.jdt.debug.core.IJavaHotCodeReplaceListener)1 JDIThread (org.eclipse.jdt.internal.debug.core.model.JDIThread)1 IServer (org.eclipse.wst.server.core.IServer)1 ClassCollectingHCRListener (org.jboss.ide.eclipse.as.core.util.ClassCollectingHCRListener)1 OpenShiftServerUtils.toCoreException (org.jboss.tools.openshift.core.server.OpenShiftServerUtils.toCoreException)1