Search in sources :

Example 6 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class XBreakpointManagerTest method testSerialize.

public void testSerialize() {
    XLineBreakpoint<MyBreakpointProperties> breakpoint = addLineBreakpoint(myBreakpointManager, "myurl", 239, new MyBreakpointProperties("z1"));
    breakpoint.setCondition("cond");
    breakpoint.setLogExpression("log");
    breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
    breakpoint.setLogMessage(true);
    addBreakpoint(myBreakpointManager, new MyBreakpointProperties("z2"));
    reload();
    List<XBreakpoint<?>> breakpoints = getAllBreakpoints();
    assertEquals("Expected 3 breakpoints, actual: " + breakpoints, 3, breakpoints.size());
    assertTrue(myBreakpointManager.isDefaultBreakpoint(breakpoints.get(0)));
    assertEquals("default", assertInstanceOf(breakpoints.get(0).getProperties(), MyBreakpointProperties.class).myOption);
    assertTrue(breakpoints.get(0).isEnabled());
    XLineBreakpoint lineBreakpoint = assertInstanceOf(breakpoints.get(1), XLineBreakpoint.class);
    assertEquals(239, lineBreakpoint.getLine());
    assertEquals("myurl", lineBreakpoint.getFileUrl());
    assertEquals("z1", assertInstanceOf(lineBreakpoint.getProperties(), MyBreakpointProperties.class).myOption);
    assertEquals("cond", lineBreakpoint.getCondition());
    assertEquals("log", lineBreakpoint.getLogExpression());
    assertTrue(lineBreakpoint.isLogMessage());
    assertEquals(SuspendPolicy.NONE, lineBreakpoint.getSuspendPolicy());
    assertEquals("z2", assertInstanceOf(breakpoints.get(2).getProperties(), MyBreakpointProperties.class).myOption);
    assertEquals(SuspendPolicy.ALL, breakpoints.get(2).getSuspendPolicy());
    assertFalse(breakpoints.get(2).isLogMessage());
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 7 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-plugins by JetBrains.

the class FlexBreakpointsHandler method updateBreakpointStatusToVerified.

void updateBreakpointStatusToVerified(String breakPointNumber) {
    int spacePos = breakPointNumber.indexOf(' ');
    // "24 at 0xf3103"
    if (spacePos != -1)
        breakPointNumber = breakPointNumber.substring(0, spacePos);
    final int index = Integer.parseInt(breakPointNumber);
    final XLineBreakpoint<XBreakpointProperties> breakpoint = myIndexToBreakpointMap.get(index);
    if (breakpoint != null) {
        myDebugProcess.getSession().updateBreakpointPresentation(breakpoint, AllIcons.Debugger.Db_verified_breakpoint, null);
    } else {
    // run to cursor
    }
}
Also used : XBreakpointProperties(com.intellij.xdebugger.breakpoints.XBreakpointProperties) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 8 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-plugins by JetBrains.

the class FlexDebugProcess method processOneCommandLoop.

private void processOneCommandLoop() throws IOException, InterruptedException {
    assert Thread.currentThread() == myDebuggerManagerThread;
    final DebuggerCommand command = postCommand();
    if (command == null)
        return;
    boolean explicitlyContinueRead = false;
    do {
        final CommandOutputProcessingType outputProcessingType = command.getOutputProcessingMode();
        if (outputProcessingType == CommandOutputProcessingType.NO_PROCESSING || (outputProcessingType == CommandOutputProcessingType.DEFAULT_PROCESSING && !reader.hasSomeDataPending())) {
            return;
        }
        if (myCheckForUnexpectedStartupStop && !(command instanceof DumpOutputCommand)) {
            myCheckForUnexpectedStartupStop = false;
        }
        @NonNls String commandOutput = null;
        try {
            commandOutput = command.read(this);
        } catch (IOException e) {
            if (!(command instanceof QuitCommand)) {
                throw e;
            }
        }
        if (command instanceof QuitCommand) {
            // request to finish
            Thread.currentThread().interrupt();
        }
        if (commandOutput == null)
            break;
        if (commandOutput.contains("Player session terminated") && !(command instanceof SuspendResumeDebuggerCommand)) {
            handleProbablyUnexpectedStop(commandOutput);
            break;
        }
        commandOutput = commandOutput.trim();
        log(commandOutput);
        if (outputProcessingType == CommandOutputProcessingType.SPECIAL_PROCESSING) {
            log("Processed by " + command);
            if (command.onTextAvailable(commandOutput) == CommandOutputProcessingMode.DONE)
                break;
            explicitlyContinueRead = true;
            continue;
        }
        ResponseLineIterator iterator = new ResponseLineIterator(commandOutput);
        boolean toInsertContinue = false;
        boolean encounteredNonsuspendableBreakpoint = false;
        int index;
        while (iterator.hasNext()) {
            final String line = iterator.next();
            if (line.startsWith("Active worker has changed to worker ")) {
                try {
                    final String workerText = line.substring("Active worker has changed to worker ".length());
                    if ("Main Thread".equals(workerText)) {
                        myCurrentWorker = 0;
                    } else {
                        myCurrentWorker = Integer.parseInt(workerText);
                    }
                } catch (NumberFormatException e) {
                    log("Unexpected worker number");
                }
            } else if (line.contains("Additional ActionScript code has been loaded")) {
                if (!suspended)
                    reader.readLine(false);
                myKnownFilesInfo.setUpToDate(false);
            } else if ((index = line.indexOf(BREAKPOINT_MARKER)) != -1 && !line.contains(" created")) {
                // Breakpoint 1, aaa() at A.mxml:14
                try {
                    final int from = index + BREAKPOINT_MARKER.length();
                    // Breakpoint 1, aaa() at A.mxml:14
                    // Breakpoint 2: file ConfigurationService.as
                    // Breakpoint 3 at 0xFFF
                    int endOfBreakpointIndexPosition = line.indexOf(',', from);
                    final int colonIndex = line.indexOf(':', from);
                    final int spaceIndex = line.indexOf(' ', from);
                    if (endOfBreakpointIndexPosition != -1) {
                        if (colonIndex != -1) {
                            endOfBreakpointIndexPosition = Math.min(colonIndex, endOfBreakpointIndexPosition);
                        }
                        if (spaceIndex != -1) {
                            endOfBreakpointIndexPosition = Math.min(spaceIndex, endOfBreakpointIndexPosition);
                        }
                        index = Integer.parseInt(line.substring(from, endOfBreakpointIndexPosition));
                        final XLineBreakpoint<XBreakpointProperties> breakpoint = myBreakpointsHandler.getBreakpointByIndex(index);
                        if (breakpoint != null) {
                            FlexStackFrame frame = new FlexStackFrame(this, breakpoint.getSourcePosition());
                            boolean suspend = false;
                            if (evaluateCondition(breakpoint.getConditionExpression(), frame)) {
                                String message = evaluateMessage(breakpoint.getLogExpressionObject(), frame);
                                suspend = getSession().breakpointReached(breakpoint, message, new FlexSuspendContext(frame));
                            }
                            if (!suspend) {
                                encounteredNonsuspendableBreakpoint = true;
                                toInsertContinue = true;
                            }
                        } else {
                            // run to cursor break point
                            insertCommand(myBreakpointsHandler.new RemoveBreakpointCommand(index, breakpoint));
                        }
                    }
                } catch (NumberFormatException ex) {
                    log(ex);
                }
            } else if (line.length() > 0 && Character.isDigit(line.charAt(0))) {
                // we are on new location: e.g. " 119           trace('\x30 \123')"
                if (!encounteredNonsuspendableBreakpoint)
                    insertCommand(new DumpSourceLocationCommand(this));
            } else if (handleStdResponse(line, iterator)) {
            } else if (line.startsWith(RESOLVED_BREAKPOINT_MARKER)) {
                // TODO: move to break point handler
                // Resolved breakpoint 1 to aaa() at A.mxml:14
                final String breakPointNumber = line.substring(RESOLVED_BREAKPOINT_MARKER.length(), line.indexOf(' ', RESOLVED_BREAKPOINT_MARKER.length()));
                myBreakpointsHandler.updateBreakpointStatusToVerified(breakPointNumber);
            } else if (line.startsWith(ATTEMPTING_TO_RESOLVE_BREAKPOINT_MARKER)) {
                // TODO: move to break point handler
                int breakpointId = Integer.parseInt(line.substring(ATTEMPTING_TO_RESOLVE_BREAKPOINT_MARKER.length(), line.indexOf(',')));
                final XLineBreakpoint<XBreakpointProperties> breakpoint = myBreakpointsHandler.getBreakpointByIndex(breakpointId);
                if (iterator.hasNext() && iterator.getNext().contains("no executable code")) {
                    iterator.next();
                    myBreakpointsHandler.updateBreakpointStatusToInvalid(breakpoint);
                    toInsertContinue = true;
                } else if (iterator.hasNext() && iterator.getNext().contains(AMBIGUOUS_MATCHING_FILE_NAMES)) {
                    iterator.next();
                    iterator.next();
                    while (iterator.hasNext() && iterator.getNext().contains("#")) {
                        iterator.next();
                    }
                    if (getFileId(breakpoint.getSourcePosition().getFile().getPath()) != null) {
                        final XBreakpointHandler handler = getBreakpointHandlers()[0];
                        handler.unregisterBreakpoint(breakpoint, false);
                        handler.registerBreakpoint(breakpoint);
                    }
                    toInsertContinue = true;
                }
            } else if (line.startsWith("Set additional breakpoints")) {
                //Set additional breakpoints as desired, and then type 'continue'.
                // TODO: move to break point handler
                toInsertContinue = true;
            } else if (line.contains("Execution halted")) {
                if (!getSession().isPaused()) {
                    getSession().pause();
                }
            }
        }
        if (toInsertContinue)
            insertCommand(new ContinueCommand());
    } while (explicitlyContinueRead || reader.hasSomeDataPending());
}
Also used : NonNls(org.jetbrains.annotations.NonNls) IOException(java.io.IOException) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XBreakpointProperties(com.intellij.xdebugger.breakpoints.XBreakpointProperties) XBreakpointHandler(com.intellij.xdebugger.breakpoints.XBreakpointHandler)

Example 9 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint in project intellij-community by JetBrains.

the class ToggleBreakpointEnabledAction method findLineBreakpoints.

@NotNull
private static Set<XLineBreakpoint> findLineBreakpoints(AnActionEvent e) {
    Project project = e.getProject();
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (project == null || editor == null)
        return Collections.emptySet();
    XBreakpointManagerImpl breakpointManager = (XBreakpointManagerImpl) XDebuggerManager.getInstance(project).getBreakpointManager();
    XLineBreakpointManager lineBreakpointManager = breakpointManager.getLineBreakpointManager();
    Document document = editor.getDocument();
    Collection<Range<Integer>> lineRanges = new ArrayList<>();
    for (Caret caret : editor.getCaretModel().getAllCarets()) {
        lineRanges.add(new Range<>(document.getLineNumber(caret.getSelectionStart()), document.getLineNumber(caret.getSelectionEnd())));
    }
    Collection<XLineBreakpointImpl> breakpoints = lineBreakpointManager.getDocumentBreakpoints(document);
    HashSet<XLineBreakpoint> res = new HashSet<>();
    for (XLineBreakpointImpl breakpoint : breakpoints) {
        int line = breakpoint.getLine();
        for (Range<Integer> range : lineRanges) {
            if (range.isWithin(line)) {
                res.add(breakpoint);
            }
        }
    }
    return res;
}
Also used : XLineBreakpointImpl(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl) XLineBreakpointManager(com.intellij.xdebugger.impl.breakpoints.XLineBreakpointManager) Document(com.intellij.openapi.editor.Document) Range(com.intellij.util.Range) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) XBreakpointManagerImpl(com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl) Project(com.intellij.openapi.project.Project) Editor(com.intellij.openapi.editor.Editor) Caret(com.intellij.openapi.editor.Caret) HashSet(com.intellij.util.containers.HashSet) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with XLineBreakpoint

use of com.intellij.xdebugger.breakpoints.XLineBreakpoint 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)

Aggregations

XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)12 Project (com.intellij.openapi.project.Project)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 XSourcePosition (com.intellij.xdebugger.XSourcePosition)3 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)3 Document (com.intellij.openapi.editor.Document)2 XExpression (com.intellij.xdebugger.XExpression)2 XBreakpointProperties (com.intellij.xdebugger.breakpoints.XBreakpointProperties)2 VMPausedException (org.intellij.plugins.xsltDebugger.VMPausedException)2 Breakpoint (org.intellij.plugins.xsltDebugger.rt.engine.Breakpoint)2 BreakpointManager (org.intellij.plugins.xsltDebugger.rt.engine.BreakpointManager)2 DebuggerStoppedException (org.intellij.plugins.xsltDebugger.rt.engine.DebuggerStoppedException)2 Caret (com.intellij.openapi.editor.Caret)1 Editor (com.intellij.openapi.editor.Editor)1 Range (com.intellij.util.Range)1 HashSet (com.intellij.util.containers.HashSet)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 XBreakpointHandler (com.intellij.xdebugger.breakpoints.XBreakpointHandler)1 XBreakpointManagerImpl (com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl)1 XLineBreakpointImpl (com.intellij.xdebugger.impl.breakpoints.XLineBreakpointImpl)1