Search in sources :

Example 1 with ErlangDebugTarget

use of org.erlide.backend.debug.model.ErlangDebugTarget in project erlide_eclipse by erlang.

the class DebuggerTraceView method handleDebugEvents.

@Override
public void handleDebugEvents(final DebugEvent[] events) {
    for (final DebugEvent event : events) {
        if (event.getKind() == DebugEvent.MODEL_SPECIFIC && event.getDetail() == ErlangDebugTarget.TRACE_CHANGED) {
            final Object source = event.getSource();
            if (source instanceof ErlangDebugTarget) {
                final TraceChangedEventData data = (TraceChangedEventData) event.getData();
                traceChanged(data, source);
            }
        }
    }
}
Also used : ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) TraceChangedEventData(org.erlide.backend.debug.model.TraceChangedEventData) DebugEvent(org.eclipse.debug.core.DebugEvent) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject)

Example 2 with ErlangDebugTarget

use of org.erlide.backend.debug.model.ErlangDebugTarget in project erlide_eclipse by erlang.

the class ErlangDebuggerBackendListener method moduleLoaded.

@Override
public void moduleLoaded(final IBackend backend, final IProject project, final String moduleName) {
    try {
        final ErlangDebugTarget erlangDebugTarget = debugTargetOfBackend(backend.getOtpRpc());
        if (erlangDebugTarget != null && erlangDebugTarget.getInterpretedModules().contains(moduleName)) {
            if (isModuleRunningInInterpreter(erlangDebugTarget, backend.getOtpRpc(), moduleName)) {
                abortContinueDialog(erlangDebugTarget);
            } else {
                final ILaunchConfiguration launchConfiguration = erlangDebugTarget.getLaunch().getLaunchConfiguration();
                final EnumSet<ErlDebugFlags> debugFlags = ErlDebugFlags.makeSet(launchConfiguration.getAttribute(ErlRuntimeAttributes.DEBUG_FLAGS, ErlDebugFlags.getFlag(ErlDebugFlags.DEFAULT_DEBUG_FLAGS)));
                final boolean distributed = debugFlags.contains(ErlDebugFlags.DISTRIBUTED_DEBUG);
                erlangDebugTarget.interpret(project, moduleName, distributed, true);
            }
        }
    } catch (final CoreException e) {
        ErlLogger.error(e);
    }
}
Also used : ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ErlDebugFlags(org.erlide.runtime.api.ErlDebugFlags)

Example 3 with ErlangDebugTarget

use of org.erlide.backend.debug.model.ErlangDebugTarget in project erlide_eclipse by erlang.

the class BreakpointMarkerUpdater method updateMarker.

@Override
public boolean updateMarker(final IMarker marker, final IDocument document, final Position position) {
    if (position.isDeleted()) {
        return false;
    }
    try {
        final int line = MarkerUtilities.getLineNumber(marker);
        final int newLine = document.getLineOfOffset(position.getOffset()) + 1;
        if (line == newLine) {
            return true;
        }
        final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
        final IBreakpoint breakpoint = manager.getBreakpoint(marker);
        if (breakpoint == null) {
            return false;
        }
        if (breakpoint instanceof ErlangLineBreakpoint) {
            final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
            final ErlangDebugTarget target = erlangLineBreakpoint.getTarget();
            erlangLineBreakpoint.remove(target);
            MarkerUtilities.setLineNumber(marker, newLine);
            erlangLineBreakpoint.install(target);
            return true;
        }
        // if there exists a breakpoint on the line remove this one
        if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
            ensureRanges(document, marker, line);
            return lineBreakpointExists(marker.getResource(), line, marker) == null;
        }
        // a line breakpoint must be removed
        if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker) && line == -1) {
            return false;
        }
        MarkerUtilities.setLineNumber(marker, line);
        if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
            ensureRanges(document, marker, line);
        }
        return true;
    } catch (final BadLocationException e) {
        ErlLogger.error(e);
    } catch (final CoreException e) {
        ErlLogger.error(e);
    }
    return false;
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IErlangBreakpoint(org.erlide.backend.debug.IErlangBreakpoint) ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 4 with ErlangDebugTarget

use of org.erlide.backend.debug.model.ErlangDebugTarget in project erlide_eclipse by erlang.

the class Backend method postLaunch.

protected void postLaunch() throws DebugException {
    final Collection<IProject> projects = Lists.newArrayList(data.getProjects());
    registerProjectsWithExecutionBackend(projects);
    if (data.isDebug()) {
        // add debugTarget
        final ILaunch launch = getData().getLaunch();
        if (!debuggerIsRunning()) {
            debugTarget = new ErlangDebugTarget(launch, this, projects);
            launch.addDebugTarget(debugTarget);
            registerStartupFunctionStarter(data);
            debugTarget.sendStarted();
        }
    } else if (data.isManaged()) {
        // don't run this if the node is already running
        final ErlangFunctionCall initCall = data.getInitialCall();
        if (initCall != null) {
            runInitial(initCall.getModule(), initCall.getName(), initCall.getParameters());
        }
    }
}
Also used : ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) ErlangFunctionCall(org.erlide.util.ErlangFunctionCall) ILaunch(org.eclipse.debug.core.ILaunch) IProject(org.eclipse.core.resources.IProject)

Aggregations

ErlangDebugTarget (org.erlide.backend.debug.model.ErlangDebugTarget)4 CoreException (org.eclipse.core.runtime.CoreException)2 OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)1 IProject (org.eclipse.core.resources.IProject)1 DebugEvent (org.eclipse.debug.core.DebugEvent)1 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)1 ILaunch (org.eclipse.debug.core.ILaunch)1 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)1 IErlangBreakpoint (org.erlide.backend.debug.IErlangBreakpoint)1 TraceChangedEventData (org.erlide.backend.debug.model.TraceChangedEventData)1 ErlDebugFlags (org.erlide.runtime.api.ErlDebugFlags)1 ErlangFunctionCall (org.erlide.util.ErlangFunctionCall)1