Search in sources :

Example 16 with IDebugTarget

use of org.eclipse.debug.core.model.IDebugTarget in project webtools.sourceediting by eclipse.

the class JAXPJavaLaunchConfigurationDelegate method launch.

@Override
public synchronized void launch(ILaunchConfiguration configuration, final String mode, final ILaunch launch, IProgressMonitor monitor) throws CoreException {
    this.mode = mode;
    launchHelper.save(getLaunchConfigFile());
    // set the launch name
    IProcessorInstall install = getProcessorInstall(configuration, mode);
    String tfactory = getTransformerFactory(install);
    String name = install.getName();
    if (tfactory != null)
        // $NON-NLS-1$//$NON-NLS-2$
        name += "[" + tfactory + "]";
    // $NON-NLS-1$
    launch.setAttribute("launchName", name);
    // the super.launch will add a Java source director if we set it to null
    // here
    final ISourceLocator configuredLocator = launch.getSourceLocator();
    launch.setSourceLocator(null);
    super.launch(configuration, mode, launch, monitor);
    // now get the java source locator
    final ISourceLocator javaSourceLookupDirector = launch.getSourceLocator();
    // now add our own participant to the java director
    launch.setSourceLocator(new ISourceLocator() {

        public Object getSourceElement(IStackFrame stackFrame) {
            // simply look at one and then the other
            Object sourceElement = javaSourceLookupDirector.getSourceElement(stackFrame);
            if (sourceElement == null)
                sourceElement = configuredLocator.getSourceElement(stackFrame);
            return sourceElement;
        }
    });
    // IJavaDebugTarget javaTarget =
    // (IJavaDebugTarget)launch.getDebugTarget();
    // launch.removeDebugTarget(javaTarget);
    IDebugTarget javaTarget = launch.getDebugTarget();
    IDebugTarget xslTarget = new JAXPDebugTarget(launch, launch.getProcesses()[0], launchHelper);
    // remove java as the primary target and make xsl the primary target
    launch.removeDebugTarget(javaTarget);
    launch.addDebugTarget(xslTarget);
// add this here to make java the non-primary target
// launch.addDebugTarget(javaTarget);
// launch.addDebugTarget(new JavaXSLDebugTarget(launch,
// launch.getProcesses()[0], launchHelper, javaTarget));
}
Also used : JAXPDebugTarget(org.eclipse.wst.xsl.jaxp.launching.model.JAXPDebugTarget) IStackFrame(org.eclipse.debug.core.model.IStackFrame) IProcessorInstall(org.eclipse.wst.xsl.jaxp.launching.IProcessorInstall) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) ISourceLocator(org.eclipse.debug.core.model.ISourceLocator)

Example 17 with IDebugTarget

use of org.eclipse.debug.core.model.IDebugTarget in project webtools.servertools by eclipse.

the class ExternalDebugLaunchConfigurationDelegate method launch.

/* (non-Javadoc)
     * @see org.eclipse.debug.core.model.ILaunchConfigurationDelegate#launch(org.eclipse.debug.core.ILaunchConfiguration, java.lang.String, org.eclipse.debug.core.ILaunch, org.eclipse.core.runtime.IProgressMonitor)
     */
@SuppressWarnings({ "unchecked", "null" })
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask(NLS.bind(GenericServerCoreMessages.attachingToExternalGenericServer, new String[] { configuration.getName() }), 3);
    // check for cancellation
    if (monitor.isCanceled()) {
        return;
    }
    monitor.subTask(GenericServerCoreMessages.verifyingExternalServerDebuggingLaunchAttributes);
    String connectorId = getVMConnectorId(configuration);
    IVMConnector connector = null;
    if (connectorId == null) {
        connector = JavaRuntime.getDefaultVMConnector();
    } else {
        connector = JavaRuntime.getVMConnector(connectorId);
    }
    if (connector == null) {
        abort(GenericServerCoreMessages.externalServerDebugConnectorNotSpecified, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE);
    }
    Map argMap = configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, (Map) null);
    int connectTimeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT);
    // $NON-NLS-1$//$NON-NLS-2$
    argMap.put("timeout", "" + connectTimeout);
    // check for cancellation
    if (monitor.isCanceled()) {
        return;
    }
    monitor.worked(1);
    monitor.subTask(GenericServerCoreMessages.creatingExternalServerDebuggingSourceLocator);
    // set the default source locator if required
    setDefaultSourceLocator(launch, configuration);
    monitor.worked(1);
    // connect to remote VM
    connector.connect(argMap, monitor, launch);
    // check for cancellation
    if (monitor.isCanceled()) {
        IDebugTarget[] debugTargets = launch.getDebugTargets();
        for (int i = 0; i < debugTargets.length; i++) {
            IDebugTarget target = debugTargets[i];
            if (target.canDisconnect()) {
                target.disconnect();
            }
        }
        return;
    }
    monitor.done();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IVMConnector(org.eclipse.jdt.launching.IVMConnector) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) Map(java.util.Map)

Example 18 with IDebugTarget

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

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

Example 20 with IDebugTarget

use of org.eclipse.debug.core.model.IDebugTarget in project statecharts by Yakindu.

the class SCTHotModelReplacementManager method getAffectedTargets.

private List<IDebugTarget> getAffectedTargets() {
    List<IDebugTarget> targets = new ArrayList<IDebugTarget>();
    synchronized (activeTargets) {
        for (IDebugTarget debugTarget : activeTargets) {
            if (debugTarget instanceof SCTDebugTarget) {
                String resourceString = ((SCTDebugElement) debugTarget).getResourceString();
                IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourceString);
                if (changedFiles.contains(resource)) {
                    targets.add(debugTarget);
                }
            }
        }
    }
    return targets;
}
Also used : SCTDebugTarget(org.yakindu.sct.simulation.core.debugmodel.SCTDebugTarget) ArrayList(java.util.ArrayList) IDebugTarget(org.eclipse.debug.core.model.IDebugTarget) SCTDebugElement(org.yakindu.sct.simulation.core.debugmodel.SCTDebugElement) IResource(org.eclipse.core.resources.IResource)

Aggregations

IDebugTarget (org.eclipse.debug.core.model.IDebugTarget)23 DebugException (org.eclipse.debug.core.DebugException)4 ILaunch (org.eclipse.debug.core.ILaunch)4 EObject (org.eclipse.emf.ecore.EObject)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 IErlangDebugNode (org.erlide.backend.debug.IErlangDebugNode)3 OtpErlangAtom (com.ericsson.otp.erlang.OtpErlangAtom)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 PlatformObject (org.eclipse.core.runtime.PlatformObject)2 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)2 IProcess (org.eclipse.debug.core.model.IProcess)2 IJavaDebugTarget (org.eclipse.jdt.debug.core.IJavaDebugTarget)2 IVMConnector (org.eclipse.jdt.launching.IVMConnector)2 JAXPDebugTarget (org.eclipse.wst.xsl.jaxp.launching.model.JAXPDebugTarget)2 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)2 OtpErlangLong (com.ericsson.otp.erlang.OtpErlangLong)1 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1