Search in sources :

Example 1 with DebuggerStoppedException

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

the class XsltDebuggerSession method start.

public void start() {
    myClient.start();
    myState = Debugger.State.RUNNING;
    final BreakpointManager breakpointManager = myClient.getBreakpointManager();
    final Listener multicaster = myEventDispatcher.getMulticaster();
    try {
        if (!myClient.waitForDebuggee()) {
            multicaster.debuggerStopped();
            return;
        }
        myState = Debugger.State.SUSPENDED;
        do {
            if (myState == Debugger.State.SUSPENDED) {
                if (myTempBreakpoint != null) {
                    breakpointManager.removeBreakpoint(myTempBreakpoint);
                    myTempBreakpoint = null;
                }
                multicaster.debuggerSuspended();
            } else if (myState == Debugger.State.RUNNING) {
                multicaster.debuggerResumed();
            } else if (myState == Debugger.State.STOPPED) {
                break;
            }
        } while ((myState = myClient.waitForStateChange(myState)) != null);
        multicaster.debuggerStopped();
    } catch (DebuggerStoppedException e) {
        multicaster.debuggerStopped();
    } catch (RuntimeException e) {
        if (e.getCause() instanceof RemoteException) {
            if (e.getCause().getCause() instanceof SocketException) {
                multicaster.debuggerStopped();
                return;
            }
        }
        throw e;
    } finally {
        myState = Debugger.State.STOPPED;
        close();
    }
}
Also used : SocketException(java.net.SocketException) EventListener(java.util.EventListener) RemoteException(java.rmi.RemoteException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 2 with DebuggerStoppedException

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

the class XsltBreakpointHandler method registerBreakpoint.

@Override
public void registerBreakpoint(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint) {
    final XSourcePosition sourcePosition = breakpoint.getSourcePosition();
    if (sourcePosition == null || !sourcePosition.getFile().exists() || !sourcePosition.getFile().isValid()) {
        // ???
        return;
    }
    final VirtualFile file = sourcePosition.getFile();
    final Project project = myXsltDebugProcess.getSession().getProject();
    final String fileURL = getFileURL(file);
    final int lineNumber = getActualLineNumber(breakpoint, project);
    if (lineNumber == -1) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Unsupported breakpoint position");
        return;
    }
    try {
        final BreakpointManager manager = myXsltDebugProcess.getBreakpointManager();
        Breakpoint bp;
        if ((bp = manager.getBreakpoint(fileURL, lineNumber)) != null) {
            bp.setEnabled(true);
        } else {
            manager.setBreakpoint(fileURL, lineNumber);
        }
    } catch (DebuggerStoppedException ignore) {
    } catch (VMPausedException e) {
        final XDebugSession session = myXsltDebugProcess.getSession();
        session.reportMessage("Target VM is not responding. Breakpoint can not be set", MessageType.ERROR);
        session.updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_invalid_breakpoint, "Target VM is not responding. Breakpoint can not be set");
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) XDebugSession(com.intellij.xdebugger.XDebugSession) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) VMPausedException(org.intellij.plugins.xsltDebugger.VMPausedException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 3 with DebuggerStoppedException

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

the class XsltBreakpointHandler method unregisterBreakpoint.

@Override
public void unregisterBreakpoint(@NotNull XLineBreakpoint<XBreakpointProperties> breakpoint, final boolean temporary) {
    final XSourcePosition sourcePosition = breakpoint.getSourcePosition();
    if (sourcePosition == null || !sourcePosition.getFile().exists() || !sourcePosition.getFile().isValid()) {
        // ???
        return;
    }
    final VirtualFile file = sourcePosition.getFile();
    final Project project = myXsltDebugProcess.getSession().getProject();
    final String fileURL = getFileURL(file);
    final int lineNumber = getActualLineNumber(breakpoint, project);
    try {
        final BreakpointManager manager = myXsltDebugProcess.getBreakpointManager();
        if (temporary) {
            final Breakpoint bp = manager.getBreakpoint(fileURL, lineNumber);
            if (bp != null) {
                bp.setEnabled(false);
            }
        } else {
            manager.removeBreakpoint(fileURL, lineNumber);
        }
    } catch (DebuggerStoppedException ignore) {
    } catch (VMPausedException e) {
        myXsltDebugProcess.getSession().reportMessage("Target VM is not responding. Breakpoint can not be removed", MessageType.ERROR);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XSourcePosition(com.intellij.xdebugger.XSourcePosition) VMPausedException(org.intellij.plugins.xsltDebugger.VMPausedException) BreakpointManager(org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager) Breakpoint(org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Example 4 with DebuggerStoppedException

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

the class XalanSupport method init.

public static boolean init(Transformer transformer, LocalDebugger dbg) {
    if (transformer instanceof TransformerImpl) {
        try {
            System.out.println("XALAN: " + Class.forName("org.apache.xalan.Version", true, transformer.getClass().getClassLoader()).getMethod("getVersion").invoke(null));
            final TransformerImpl tr = (TransformerImpl) transformer;
            tr.setErrorListener(new DefaultErrorHandler(false) {

                @Override
                public void fatalError(TransformerException exception) throws TransformerException {
                    if (!(exception.getCause() instanceof DebuggerStoppedException)) {
                        super.fatalError(exception);
                    }
                }
            });
            try {
                tr.getTraceManager().addTraceListener(new XalanTraceListener(dbg, tr));
            } catch (TooManyListenersException e) {
                throw new AssertionError(e);
            }
            return true;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    return false;
}
Also used : TransformerImpl(org.apache.xalan.transformer.TransformerImpl) TooManyListenersException(java.util.TooManyListenersException) DefaultErrorHandler(org.apache.xml.utils.DefaultErrorHandler) TransformerException(javax.xml.transform.TransformerException) TooManyListenersException(java.util.TooManyListenersException) TransformerException(javax.xml.transform.TransformerException) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException) DebuggerStoppedException(org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)

Aggregations

DebuggerStoppedException (org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)4 BreakpointManager (org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager)3 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 XSourcePosition (com.intellij.xdebugger.XSourcePosition)2 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)2 VMPausedException (org.intellij.plugins.xsltDebugger.VMPausedException)2 Breakpoint (org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint)2 XDebugSession (com.intellij.xdebugger.XDebugSession)1 SocketException (java.net.SocketException)1 RemoteException (java.rmi.RemoteException)1 EventListener (java.util.EventListener)1 TooManyListenersException (java.util.TooManyListenersException)1 TransformerException (javax.xml.transform.TransformerException)1 TransformerImpl (org.apache.xalan.transformer.TransformerImpl)1 DefaultErrorHandler (org.apache.xml.utils.DefaultErrorHandler)1