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));
}
}
};
}
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;
}
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;
}
Aggregations