@Override
  public void createRequest(@NotNull DebugProcessImpl debugProcess) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    // check is this breakpoint is enabled, vm reference is valid and there're no requests created
    // yet
    if (!isEnabled()
        || !debugProcess.isAttached()
        || isMuted(debugProcess)
        || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
      return;
    }

    if (!isValid()) {
      return;
    }

    SourcePosition position = getSourcePosition();
    if (position != null) {
      createOrWaitPrepare(debugProcess, position);
    } else {
      LOG.error(
          "Unable to create request for breakpoint with null position: "
              + getDisplayName()
              + " at "
              + myXBreakpoint.getSourcePosition());
    }
    updateUI();
  }
예제 #2
0
  private void runAction(final EvaluationContextImpl context, LocatableEvent event) {
    if (LOG_ENABLED || LOG_EXPRESSION_ENABLED) {
      final StringBuilder buf = StringBuilderSpinAllocator.alloc();
      try {
        if (LOG_ENABLED) {
          buf.append(getEventMessage(event));
          buf.append("\n");
        }
        final DebugProcessImpl debugProcess = context.getDebugProcess();
        final TextWithImports expressionToEvaluate = getLogMessage();
        if (LOG_EXPRESSION_ENABLED
            && expressionToEvaluate != null
            && !"".equals(expressionToEvaluate.getText())) {
          if (!debugProcess.isAttached()) {
            return;
          }

          try {
            ExpressionEvaluator evaluator =
                DebuggerInvocationUtil.commitAndRunReadAction(
                    getProject(),
                    new EvaluatingComputable<ExpressionEvaluator>() {
                      public ExpressionEvaluator compute() throws EvaluateException {
                        return EvaluatorBuilderImpl.build(
                            expressionToEvaluate,
                            ContextUtil.getContextElement(context),
                            ContextUtil.getSourcePosition(context));
                      }
                    });
            final Value eval = evaluator.evaluate(context);
            final String result =
                eval instanceof VoidValue ? "void" : DebuggerUtils.getValueAsString(context, eval);
            buf.append(result);
          } catch (EvaluateException e) {
            buf.append(DebuggerBundle.message("error.unable.to.evaluate.expression"));
            buf.append(" \"");
            buf.append(expressionToEvaluate);
            buf.append("\"");
            buf.append(" : ");
            buf.append(e.getMessage());
          }
          buf.append("\n");
        }
        if (buf.length() > 0) {
          debugProcess.printToConsole(buf.toString());
        }
      } finally {
        StringBuilderSpinAllocator.dispose(buf);
      }
    }
  }
  @Override
  public void createRequest(@NotNull DebugProcessImpl debugProcess) {
    DebuggerManagerThreadImpl.assertIsManagerThread();
    // check is this breakpoint is enabled, vm reference is valid and there're no requests created
    // yet
    if (!isEnabled()
        || !debugProcess.isAttached()
        || isMuted(debugProcess)
        || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
      return;
    }

    if (!isValid()) {
      return;
    }

    createOrWaitPrepare(debugProcess, getSourcePosition());
    updateUI();
  }
 public void createRequest(DebugProcessImpl debugProcess) {
   DebuggerManagerThreadImpl.assertIsManagerThread();
   if (!ENABLED
       || !debugProcess.isAttached()
       || debugProcess.areBreakpointsMuted()
       || !debugProcess.getRequestsManager().findRequests(this).isEmpty()) {
     return;
   }
   try {
     RequestManagerImpl requestManager = debugProcess.getRequestsManager();
     if (WATCH_ENTRY) {
       MethodEntryRequest entryRequest =
           (MethodEntryRequest) findRequest(debugProcess, MethodEntryRequest.class);
       if (entryRequest == null) {
         entryRequest = requestManager.createMethodEntryRequest(this);
       } else {
         entryRequest.disable();
       }
       entryRequest.addClassFilter(myClassPattern);
       debugProcess.getRequestsManager().enableRequest(entryRequest);
     }
     if (WATCH_EXIT) {
       MethodExitRequest exitRequest =
           (MethodExitRequest) findRequest(debugProcess, MethodExitRequest.class);
       if (exitRequest == null) {
         exitRequest = requestManager.createMethodExitRequest(this);
       } else {
         exitRequest.disable();
       }
       exitRequest.addClassFilter(myClassPattern);
       debugProcess.getRequestsManager().enableRequest(exitRequest);
     }
   } catch (Exception e) {
     LOG.debug(e);
   }
 }