Search in sources :

Example 1 with Debugger

use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.

the class DebuggerConnector method connect.

@Nullable
private Debugger connect() {
    Throwable lastException = null;
    for (int i = 0; i < 10; i++) {
        if (myProcess.isProcessTerminated())
            return null;
        try {
            final Debugger realClient = EDTGuard.create(new RemoteDebuggerClient(myPort), myProcess);
            myProcess.notifyTextAvailable("Connected to XSLT debugger on port " + myPort + "\n", ProcessOutputTypes.SYSTEM);
            return realClient;
        } catch (ConnectException e) {
            lastException = e;
            try {
                Thread.sleep(500);
            } catch (InterruptedException e1) {
                break;
            }
        } catch (NotBoundException e) {
            lastException = e;
            try {
                Thread.sleep(200);
            } catch (InterruptedException e1) {
                break;
            }
        } catch (IOException e) {
            lastException = e;
            break;
        }
    }
    if (lastException != null) {
        Logger.getInstance(getClass().getName()).info("Could not connect to debugger", lastException);
        if (lastException.getMessage() != null) {
            myProcess.notifyTextAvailable("Connection error: " + lastException.getMessage() + "\n", ProcessOutputTypes.SYSTEM);
        }
    }
    return null;
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) NotBoundException(java.rmi.NotBoundException) RemoteDebuggerClient(org.intellij.plugins.xsltDebugger.rt.engine.remote.RemoteDebuggerClient) IOException(java.io.IOException) ConnectException(java.rmi.ConnectException) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Debugger

use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.

the class DebuggerConnector method run.

public void run() {
    final Debugger client = connect();
    if (client == null) {
        // client will be null if the process terminated prematurely for some reason. no need for an error message
        if (!myProcess.isProcessTerminated()) {
            myProcess.notifyTextAvailable("Failed to connect to debugged process. Terminating.\n", ProcessOutputTypes.SYSTEM);
            myProcess.destroyProcess();
        }
        return;
    }
    final XsltDebuggerSession session = XsltDebuggerSession.create(myProject, myProcess, client);
    final XsltDebugProcess dbgp = XsltDebugProcess.getInstance(myProcess);
    assert dbgp != null;
    dbgp.init(client);
    session.addListener(new XsltDebuggerSession.Listener() {

        @Override
        public void debuggerSuspended() {
            final OutputEventQueue queue = client.getEventQueue();
            StructureTabComponent.getInstance(myProcess).getEventModel().update(queue.getEvents());
        }

        @Override
        public void debuggerResumed() {
        }

        @Override
        public void debuggerStopped() {
            try {
                final OutputEventQueue queue = client.getEventQueue();
                StructureTabComponent.getInstance(myProcess).getEventModel().finalUpdate(queue.getEvents());
            } catch (Exception e) {
            // can fail when debugger is manually terminated
            }
        }
    });
    session.start();
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) XsltDebugProcess(org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess) IOException(java.io.IOException) NotBoundException(java.rmi.NotBoundException) ConnectException(java.rmi.ConnectException) OutputEventQueue(org.intellij.plugins.xsltDebugger.rt.engine.OutputEventQueue)

Example 3 with Debugger

use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.

the class XsltDebugProcess method init.

public void init(Debugger client) {
    myDebuggerSession = XsltDebuggerSession.getInstance(myProcessHandler);
    myDebuggerSession.addListener(new XsltDebuggerSession.Listener() {

        @Override
        public void debuggerSuspended() {
            final Debugger c = myDebuggerSession.getClient();
            getSession().positionReached(new MySuspendContext(myDebuggerSession, c.getCurrentFrame(), c.getSourceFrame()));
        }

        @Override
        public void debuggerResumed() {
        }

        @Override
        public void debuggerStopped() {
            myBreakpointManager = new BreakpointManagerImpl();
        }
    });
    final BreakpointManager mgr = client.getBreakpointManager();
    if (myBreakpointManager != mgr) {
        final List<Breakpoint> breakpoints = myBreakpointManager.getBreakpoints();
        for (Breakpoint breakpoint : breakpoints) {
            final Breakpoint bp = mgr.setBreakpoint(breakpoint.getUri(), breakpoint.getLine());
            bp.setEnabled(breakpoint.isEnabled());
            bp.setLogMessage(breakpoint.getLogMessage());
            bp.setTraceMessage(breakpoint.getTraceMessage());
            bp.setCondition(breakpoint.getCondition());
            bp.setSuspend(breakpoint.isSuspend());
        }
        myBreakpointManager = mgr;
    }
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) XsltDebuggerSession(org.intellij.plugins.xsltDebugger.XsltDebuggerSession) BreakpointManagerImpl(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManagerImpl)

Example 4 with Debugger

use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.

the class XsltDebugProcess method runToPosition.

@Override
public void runToPosition(@NotNull XSourcePosition position, @Nullable XSuspendContext context) {
    final PsiFile psiFile = PsiManager.getInstance(getSession().getProject()).findFile(position.getFile());
    assert psiFile != null;
    if (myDebuggerSession.canRunTo(position)) {
        myDebuggerSession.runTo(psiFile, position);
    } else {
        StatusBar.Info.set("Not a valid position in file '" + psiFile.getName() + "'", psiFile.getProject());
        final Debugger c = myDebuggerSession.getClient();
        getSession().positionReached(new MySuspendContext(myDebuggerSession, c.getCurrentFrame(), c.getSourceFrame()));
    }
}
Also used : Debugger(org.intellij.plugins.xsltDebugger.rt.engine.Debugger) PsiFile(com.intellij.psi.PsiFile)

Aggregations

Debugger (org.intellij.plugins.xsltDebugger.rt.engine.Debugger)4 IOException (java.io.IOException)2 ConnectException (java.rmi.ConnectException)2 NotBoundException (java.rmi.NotBoundException)2 PsiFile (com.intellij.psi.PsiFile)1 XsltDebuggerSession (org.intellij.plugins.xsltDebugger.XsltDebuggerSession)1 XsltDebugProcess (org.intellij.plugins.xsltDebugger.impl.XsltDebugProcess)1 Breakpoint (org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint)1 BreakpointManager (org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager)1 BreakpointManagerImpl (org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManagerImpl)1 OutputEventQueue (org.intellij.plugins.xsltDebugger.rt.engine.OutputEventQueue)1 RemoteDebuggerClient (org.intellij.plugins.xsltDebugger.rt.engine.remote.RemoteDebuggerClient)1 Nullable (org.jetbrains.annotations.Nullable)1