コード例 #1
0
  @Override
  public void computeTypeSourcePosition(@NotNull final XNavigatable navigatable) {
    if (myEvaluationContext.getSuspendContext().isResumed()) return;
    DebugProcessImpl debugProcess = myEvaluationContext.getDebugProcess();
    debugProcess
        .getManagerThread()
        .schedule(
            new JumpToObjectAction.NavigateCommand(
                getDebuggerContext(), myValueDescriptor, debugProcess, null) {
              @Override
              public Priority getPriority() {
                return Priority.HIGH;
              }

              @Override
              protected void doAction(@Nullable final SourcePosition sourcePosition) {
                if (sourcePosition != null) {
                  ApplicationManager.getApplication()
                      .runReadAction(
                          new Runnable() {
                            @Override
                            public void run() {
                              navigatable.setSourcePosition(
                                  DebuggerUtilsEx.toXSourcePosition(sourcePosition));
                            }
                          });
                }
              }
            });
  }
コード例 #2
0
  @Override
  public void computeChildren(@NotNull final XCompositeNode node) {
    if (node.isObsolete()) return;
    XStackFrame xFrame = getDescriptor().getXStackFrame();
    if (xFrame != null) {
      xFrame.computeChildren(node);
      return;
    }
    myDebugProcess
        .getManagerThread()
        .schedule(
            new DebuggerContextCommandImpl(
                myDebugProcess.getDebuggerContext(), myDescriptor.getFrameProxy().threadProxy()) {
              @Override
              public Priority getPriority() {
                return Priority.NORMAL;
              }

              @Override
              public void threadAction() {
                if (node.isObsolete()) return;
                XValueChildrenList children = new XValueChildrenList();
                buildVariablesThreadAction(getFrameDebuggerContext(), children, node);
                node.addChildren(children, true);
              }
            });
  }
コード例 #3
0
 @Override
 public void setSelected(AnActionEvent e, boolean watch) {
   myWatchesReturnValues = watch;
   DebuggerSettings.getInstance().WATCH_RETURN_VALUES = watch;
   DebugProcessImpl process = getCurrentDebugProcess(e.getProject());
   if (process != null) {
     process.setWatchMethodReturnValuesEnabled(watch);
   }
 }
コード例 #4
0
  /**
   * Associates breakpoint with class. Create requests for loaded class and registers callback for
   * loading classes
   *
   * @param debugProcess the requesting process
   */
  protected void createOrWaitPrepare(DebugProcessImpl debugProcess, String classToBeLoaded) {
    debugProcess.getRequestsManager().callbackOnPrepareClasses(this, classToBeLoaded);

    List list = debugProcess.getVirtualMachineProxy().classesByName(classToBeLoaded);
    for (final Object aList : list) {
      ReferenceType refType = (ReferenceType) aList;
      if (refType.isPrepared()) {
        processClassPrepare(debugProcess, refType);
      }
    }
  }
コード例 #5
0
  protected void createOrWaitPrepare(
      final DebugProcessImpl debugProcess, final SourcePosition classPosition) {
    debugProcess.getRequestsManager().callbackOnPrepareClasses(this, classPosition);

    List list = debugProcess.getPositionManager().getAllClasses(classPosition);
    for (final Object aList : list) {
      ReferenceType refType = (ReferenceType) aList;
      if (refType.isPrepared()) {
        processClassPrepare(debugProcess, refType);
      }
    }
  }
コード例 #6
0
 @Override
 public void update(@NotNull final AnActionEvent e) {
   super.update(e);
   final Presentation presentation = e.getPresentation();
   DebugProcessImpl process = getCurrentDebugProcess(e.getProject());
   if (process == null || process.canGetMethodReturnValue()) {
     presentation.setEnabled(true);
     presentation.setText(myText);
   } else {
     presentation.setEnabled(false);
     presentation.setText(myTextUnavailable);
   }
 }
コード例 #7
0
  @Override
  public void evaluate(
      @NotNull final XExpression expression,
      @NotNull final XEvaluationCallback callback,
      @Nullable XSourcePosition expressionPosition) {
    myDebugProcess
        .getManagerThread()
        .schedule(
            new DebuggerContextCommandImpl(
                myDebugProcess.getDebuggerContext(),
                myStackFrame.getStackFrameProxy().threadProxy()) {
              @Override
              public Priority getPriority() {
                return Priority.NORMAL;
              }

              @Override
              public void threadAction() {
                if (DebuggerUIUtil.isObsolete(callback)) {
                  return;
                }

                JavaDebugProcess process = myDebugProcess.getXdebugProcess();
                if (process == null) {
                  callback.errorOccurred("No debug process");
                  return;
                }
                TextWithImports text = TextWithImportsImpl.fromXExpression(expression);
                NodeManagerImpl nodeManager = process.getNodeManager();
                WatchItemDescriptor descriptor =
                    nodeManager.getWatchItemDescriptor(null, text, null);
                EvaluationContextImpl evalContext =
                    myStackFrame
                        .getFrameDebuggerContext(getDebuggerContext())
                        .createEvaluationContext();
                if (evalContext == null) {
                  callback.errorOccurred("Context is not available");
                  return;
                }
                descriptor.setContext(evalContext);
                @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
                EvaluateException exception = descriptor.getEvaluateException();
                if (exception != null && descriptor.getValue() == null) {
                  callback.errorOccurred(exception.getMessage());
                  return;
                }
                callback.evaluated(
                    JavaValue.create(null, descriptor, evalContext, nodeManager, true));
              }
            });
  }
コード例 #8
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);
      }
    }
  }
コード例 #9
0
 private void assertNotResumed() {
   if (myIsResumed) {
     if (myDebugProcess.isAttached()) {
       LOG.error("Cannot access SuspendContext. SuspendContext is resumed.");
     }
   }
 }
コード例 #10
0
 @Override
 public void computeExecutionStacks(final XExecutionStackContainer container) {
   myDebugProcess
       .getManagerThread()
       .schedule(
           new SuspendContextCommandImpl(this) {
             @Override
             public void contextAction() throws Exception {
               List<JavaExecutionStack> res = new ArrayList<JavaExecutionStack>();
               Collection<ThreadReferenceProxyImpl> threads =
                   getDebugProcess().getVirtualMachineProxy().allThreads();
               JavaExecutionStack currentStack = null;
               for (ThreadReferenceProxyImpl thread : threads) {
                 boolean current = thread == myThread;
                 JavaExecutionStack stack =
                     new JavaExecutionStack(thread, myDebugProcess, current);
                 if (!current) {
                   res.add(stack);
                 } else {
                   currentStack = stack;
                 }
               }
               Collections.sort(res, THREADS_COMPARATOR);
               if (currentStack != null) {
                 res.add(0, currentStack);
               }
               container.addExecutionStack(res, true);
             }
           });
 }
コード例 #11
0
 public void setThread(ThreadReference thread) {
   assertNotResumed();
   ThreadReferenceProxyImpl threadProxy =
       myDebugProcess.getVirtualMachineProxy().getThreadReferenceProxy(thread);
   LOG.assertTrue(myThread == null || myThread == threadProxy);
   myThread = threadProxy;
 }
コード例 #12
0
    public String getName(DebugProcessImpl process) throws EvaluateException {
      List<ReferenceType> allClasses = process.getPositionManager().getAllClasses(mySourcePosition);
      if (!allClasses.isEmpty()) {
        return allClasses.get(0).name();
      }

      throw EvaluateExceptionUtil.createEvaluateException(
          DebuggerBundle.message("error.class.not.loaded", getDisplayName(process)));
    }
コード例 #13
0
  @Nullable
  public static String getSourcePositionPackageDisplayName(
      DebugProcessImpl debugProcess, @Nullable SourcePosition position) {
    if (position == null) {
      return null;
    }
    final PsiFile positionFile = position.getFile();
    if (positionFile instanceof JspFile) {
      final PsiDirectory dir = positionFile.getContainingDirectory();
      return dir != null ? dir.getVirtualFile().getPresentableUrl() : null;
    }

    final PsiClass psiClass = getClassAt(position);

    if (psiClass != null) {
      PsiClass toplevel = PsiUtil.getTopLevelClass(psiClass);
      if (toplevel != null) {
        String qName = toplevel.getQualifiedName();
        if (qName != null) {
          int i = qName.lastIndexOf('.');
          return i > 0 ? qName.substring(0, i) : "";
        }
      }
    }

    if (positionFile instanceof PsiClassOwner) {
      String name = ((PsiClassOwner) positionFile).getPackageName();
      if (!StringUtil.isEmpty(name)) {
        return name;
      }
    }

    if (debugProcess != null && debugProcess.isAttached()) {
      List<ReferenceType> allClasses = debugProcess.getPositionManager().getAllClasses(position);
      if (!allClasses.isEmpty()) {
        final String className = allClasses.get(0).name();
        int dotIndex = className.lastIndexOf('.');
        if (dotIndex >= 0) {
          return className.substring(0, dotIndex);
        }
      }
    }
    return "";
  }
コード例 #14
0
 @Override
 public void removeDebugProcessListener(
     final ProcessHandler processHandler, final DebugProcessListener listener) {
   DebugProcessImpl debugProcess = getDebugProcess(processHandler);
   if (debugProcess != null) {
     debugProcess.removeDebugProcessListener(listener);
   } else {
     processHandler.addProcessListener(
         new ProcessAdapter() {
           @Override
           public void startNotified(ProcessEvent event) {
             DebugProcessImpl debugProcess = getDebugProcess(processHandler);
             if (debugProcess != null) {
               debugProcess.removeDebugProcessListener(listener);
             }
             processHandler.removeProcessListener(this);
           }
         });
   }
 }
コード例 #15
0
 public JavaStackFrame(@NotNull StackFrameDescriptorImpl descriptor, boolean update) {
   myDescriptor = descriptor;
   if (update) {
     myDescriptor.setContext(null);
     myDescriptor.updateRepresentation(null, DescriptorLabelListener.DUMMY_LISTENER);
   }
   myEqualityObject =
       update ? NodeManagerImpl.getContextKeyForFrame(myDescriptor.getFrameProxy()) : null;
   myDebugProcess = ((DebugProcessImpl) descriptor.getDebugProcess());
   myNodeManager = myDebugProcess.getXdebugProcess().getNodeManager();
   myXSourcePosition =
       myDescriptor.getSourcePosition() != null
           ? DebuggerUtilsEx.toXSourcePosition(myDescriptor.getSourcePosition())
           : null;
 }
コード例 #16
0
 @Override
 public void customizePresentation(@NotNull ColoredTextContainer component) {
   StackFrameDescriptorImpl selectedDescriptor = null;
   DebuggerSession session = myDebugProcess.getSession();
   if (session != null) {
     XDebugSession xSession = session.getXDebugSession();
     if (xSession != null) {
       XStackFrame frame = xSession.getCurrentStackFrame();
       if (frame instanceof JavaStackFrame) {
         selectedDescriptor = ((JavaStackFrame) frame).getDescriptor();
       }
     }
   }
   FRAME_RENDERER.customizePresentation(myDescriptor, component, selectedDescriptor);
 }
コード例 #17
0
  @Nullable
  public static String getSourcePositionClassDisplayName(
      DebugProcessImpl debugProcess, @Nullable SourcePosition position) {
    if (position == null) {
      return null;
    }
    final PsiFile positionFile = position.getFile();
    if (positionFile instanceof JspFile) {
      return positionFile.getName();
    }

    final PsiClass psiClass = getClassAt(position);

    if (psiClass != null) {
      final String qName = psiClass.getQualifiedName();
      if (qName != null) {
        return qName;
      }
    }

    if (debugProcess != null && debugProcess.isAttached()) {
      List<ReferenceType> allClasses = debugProcess.getPositionManager().getAllClasses(position);
      if (!allClasses.isEmpty()) {
        return allClasses.get(0).name();
      }
    }
    if (psiClass == null) {
      if (positionFile instanceof PsiClassOwner) {
        return positionFile.getName();
      }

      return DebuggerBundle.message(
          "string.file.line.position", positionFile.getName(), position.getLine());
    }
    return calcClassDisplayName(psiClass);
  }
コード例 #18
0
 DebuggerContextImpl getFrameDebuggerContext() {
   DebuggerManagerThreadImpl.assertIsManagerThread();
   DebuggerContextImpl context = myDebugProcess.getDebuggerContext();
   if (context.getFrameProxy() != getStackFrameProxy()) {
     SuspendContextImpl threadSuspendContext =
         SuspendManagerUtil.getSuspendContextForThread(
             context.getSuspendContext(), getStackFrameProxy().threadProxy());
     context =
         DebuggerContextImpl.createDebuggerContext(
             myDebugProcess.mySession,
             threadSuspendContext,
             getStackFrameProxy().threadProxy(),
             getStackFrameProxy());
     context.setPositionCache(myDescriptor.getSourcePosition());
     context.initCaches();
   }
   return context;
 }
コード例 #19
0
  // copied from DebuggerTree
  private void buildVariablesThreadAction(
      DebuggerContextImpl debuggerContext, XValueChildrenList children, XCompositeNode node) {
    try {
      final EvaluationContextImpl evaluationContext = debuggerContext.createEvaluationContext();
      if (evaluationContext == null) {
        return;
      }
      if (!debuggerContext.isEvaluationPossible()) {
        node.setErrorMessage(MessageDescriptor.EVALUATION_NOT_POSSIBLE.getLabel());
        // myChildren.add(myNodeManager.createNode(MessageDescriptor.EVALUATION_NOT_POSSIBLE,
        // evaluationContext));
      }

      final Location location = myDescriptor.getLocation();

      final ObjectReference thisObjectReference = myDescriptor.getThisObject();
      if (thisObjectReference != null) {
        ValueDescriptorImpl thisDescriptor =
            myNodeManager.getThisDescriptor(null, thisObjectReference);
        children.add(JavaValue.create(thisDescriptor, evaluationContext, myNodeManager));
      } else if (location != null) {
        StaticDescriptorImpl staticDecriptor =
            myNodeManager.getStaticDescriptor(myDescriptor, location.declaringType());
        if (staticDecriptor.isExpandable()) {
          children.addTopGroup(
              new JavaStaticGroup(staticDecriptor, evaluationContext, myNodeManager));
        }
      }

      DebugProcessImpl debugProcess = debuggerContext.getDebugProcess();
      if (debugProcess == null) {
        return;
      }

      // add last method return value if any
      final Pair<Method, Value> methodValuePair = debugProcess.getLastExecutedMethod();
      if (methodValuePair != null) {
        ValueDescriptorImpl returnValueDescriptor =
            myNodeManager.getMethodReturnValueDescriptor(
                myDescriptor, methodValuePair.getFirst(), methodValuePair.getSecond());
        children.add(JavaValue.create(returnValueDescriptor, evaluationContext, myNodeManager));
      }
      // add context exceptions
      for (Pair<Breakpoint, Event> pair :
          DebuggerUtilsEx.getEventDescriptors(debuggerContext.getSuspendContext())) {
        final Event debugEvent = pair.getSecond();
        if (debugEvent instanceof ExceptionEvent) {
          final ObjectReference exception = ((ExceptionEvent) debugEvent).exception();
          if (exception != null) {
            final ValueDescriptorImpl exceptionDescriptor =
                myNodeManager.getThrownExceptionObjectDescriptor(myDescriptor, exception);
            children.add(JavaValue.create(exceptionDescriptor, evaluationContext, myNodeManager));
          }
        }
      }

      try {
        buildVariables(
            debuggerContext,
            evaluationContext,
            debugProcess,
            children,
            thisObjectReference,
            location);
        // if (classRenderer.SORT_ASCENDING) {
        //  Collections.sort(myChildren, NodeManagerImpl.getNodeComparator());
        // }
      } catch (EvaluateException e) {
        node.setErrorMessage(e.getMessage());
        // myChildren.add(myNodeManager.createMessageNode(new MessageDescriptor(e.getMessage())));
      }
    } catch (InvalidStackFrameException e) {
      LOG.info(e);
      // myChildren.clear();
      // notifyCancelled();
    } catch (InternalException e) {
      if (e.errorCode() == 35) {
        node.setErrorMessage(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()));
        // myChildren.add(
        //  myNodeManager.createMessageNode(new
        // MessageDescriptor(DebuggerBundle.message("error.corrupt.debug.info", e.getMessage()))));
      } else {
        throw e;
      }
    }
  }
コード例 #20
0
  // copied from FrameVariablesTree
  private void buildVariables(
      DebuggerContextImpl debuggerContext,
      final EvaluationContextImpl evaluationContext,
      @NotNull DebugProcessImpl debugProcess,
      XValueChildrenList children,
      ObjectReference thisObjectReference,
      Location location)
      throws EvaluateException {
    final Set<String> visibleLocals = new HashSet<String>();
    if (NodeRendererSettings.getInstance().getClassRenderer().SHOW_VAL_FIELDS_AS_LOCAL_VARIABLES) {
      if (thisObjectReference != null
          && debugProcess.getVirtualMachineProxy().canGetSyntheticAttribute()) {
        final ReferenceType thisRefType = thisObjectReference.referenceType();
        if (thisRefType instanceof ClassType
            && location != null
            && thisRefType.equals(location.declaringType())
            && thisRefType.name().contains("$")) { // makes sense for nested classes only
          for (Field field : thisRefType.fields()) {
            if (DebuggerUtils.isSynthetic(field)
                && StringUtil.startsWith(
                    field.name(), FieldDescriptorImpl.OUTER_LOCAL_VAR_FIELD_PREFIX)) {
              final FieldDescriptorImpl fieldDescriptor =
                  myNodeManager.getFieldDescriptor(myDescriptor, thisObjectReference, field);
              children.add(JavaValue.create(fieldDescriptor, evaluationContext, myNodeManager));
              visibleLocals.add(fieldDescriptor.calcValueName());
            }
          }
        }
      }
    }

    boolean myAutoWatchMode = DebuggerSettings.getInstance().AUTO_VARIABLES_MODE;
    if (evaluationContext == null) {
      return;
    }
    final SourcePosition sourcePosition = debuggerContext.getSourcePosition();
    if (sourcePosition == null) {
      return;
    }

    try {
      if (!XDebuggerSettingsManager.getInstance().getDataViewSettings().isAutoExpressions()
          && !myAutoWatchMode) {
        // optimization
        superBuildVariables(evaluationContext, children);
      } else {
        final Map<String, LocalVariableProxyImpl> visibleVariables =
            getVisibleVariables(getStackFrameProxy());
        final Pair<Set<String>, Set<TextWithImports>> usedVars =
            ApplicationManager.getApplication()
                .runReadAction(
                    new Computable<Pair<Set<String>, Set<TextWithImports>>>() {
                      @Override
                      public Pair<Set<String>, Set<TextWithImports>> compute() {
                        return findReferencedVars(
                            ContainerUtil.union(visibleVariables.keySet(), visibleLocals),
                            sourcePosition);
                      }
                    });
        // add locals
        if (myAutoWatchMode) {
          for (String var : usedVars.first) {
            LocalVariableProxyImpl local = visibleVariables.get(var);
            if (local != null) {
              children.add(
                  JavaValue.create(
                      myNodeManager.getLocalVariableDescriptor(null, local),
                      evaluationContext,
                      myNodeManager));
            }
          }
        } else {
          superBuildVariables(evaluationContext, children);
        }
        final EvaluationContextImpl evalContextCopy =
            evaluationContext.createEvaluationContext(evaluationContext.getThisObject());
        evalContextCopy.setAutoLoadClasses(false);

        final Set<TextWithImports> extraVars =
            computeExtraVars(usedVars, sourcePosition, evaluationContext);

        // add extra vars
        addToChildrenFrom(extraVars, children, evaluationContext);

        // add expressions
        addToChildrenFrom(usedVars.second, children, evalContextCopy);
      }
    } catch (EvaluateException e) {
      if (e.getCause() instanceof AbsentInformationException) {
        children.add(
            new DummyMessageValueNode(
                MessageDescriptor.LOCAL_VARIABLES_INFO_UNAVAILABLE.getLabel(),
                XDebuggerUIConstants.INFORMATION_MESSAGE_ICON));
        // trying to collect values from variable slots
        try {
          for (Map.Entry<DecompiledLocalVariable, Value> entry :
              LocalVariablesUtil.fetchValues(getStackFrameProxy(), debugProcess).entrySet()) {
            children.add(
                JavaValue.create(
                    myNodeManager.getArgumentValueDescriptor(
                        null, entry.getKey(), entry.getValue()),
                    evaluationContext,
                    myNodeManager));
          }
        } catch (Exception ex) {
          LOG.info(ex);
        }
      } else {
        throw e;
      }
    }
  }
コード例 #21
0
  public void reloadClasses(final Map<String, HotSwapFile> modifiedClasses) {
    DebuggerManagerThreadImpl.assertIsManagerThread();

    if (modifiedClasses == null || modifiedClasses.size() == 0) {
      myProgress.addMessage(
          myDebuggerSession,
          MessageCategory.INFORMATION,
          DebuggerBundle.message("status.hotswap.loaded.classes.up.to.date"));
      return;
    }

    final DebugProcessImpl debugProcess = getDebugProcess();
    final VirtualMachineProxyImpl virtualMachineProxy = debugProcess.getVirtualMachineProxy();

    final Project project = debugProcess.getProject();
    final BreakpointManager breakpointManager =
        (DebuggerManagerEx.getInstanceEx(project)).getBreakpointManager();
    breakpointManager.disableBreakpoints(debugProcess);

    // virtualMachineProxy.suspend();

    try {
      RedefineProcessor redefineProcessor = new RedefineProcessor(virtualMachineProxy);

      int processedEntriesCount = 0;
      for (final Map.Entry<String, HotSwapFile> entry : modifiedClasses.entrySet()) {
        // stop if process is finished already
        if (debugProcess.isDetached() || debugProcess.isDetaching()) {
          break;
        }
        if (redefineProcessor.getProcessedClassesCount() == 0 && myProgress.isCancelled()) {
          // once at least one class has been actually reloaded, do not interrupt the whole process
          break;
        }
        processedEntriesCount++;
        final String qualifiedName = entry.getKey();
        if (qualifiedName != null) {
          myProgress.setText(qualifiedName);
          myProgress.setFraction(processedEntriesCount / (double) modifiedClasses.size());
        }
        try {
          redefineProcessor.processClass(qualifiedName, entry.getValue().file);
        } catch (IOException e) {
          reportProblem(qualifiedName, e);
        }
      }

      if (redefineProcessor.getProcessedClassesCount() == 0 && myProgress.isCancelled()) {
        // once at least one class has been actually reloaded, do not interrupt the whole process
        return;
      }

      redefineProcessor.processPending();
      myProgress.setFraction(1);

      final int partiallyRedefinedClassesCount =
          redefineProcessor.getPartiallyRedefinedClassesCount();
      if (partiallyRedefinedClassesCount == 0) {
        myProgress.addMessage(
            myDebuggerSession,
            MessageCategory.INFORMATION,
            DebuggerBundle.message(
                "status.classes.reloaded", redefineProcessor.getProcessedClassesCount()));
      } else {
        final String message =
            DebuggerBundle.message(
                "status.classes.not.all.versions.reloaded",
                partiallyRedefinedClassesCount,
                redefineProcessor.getProcessedClassesCount());
        myProgress.addMessage(myDebuggerSession, MessageCategory.WARNING, message);
      }

      LOG.debug("classes reloaded");
    } catch (Throwable e) {
      processException(e);
    }

    debugProcess.getPositionManager().clearCache();

    DebuggerContextImpl context = myDebuggerSession.getContextManager().getContext();
    SuspendContextImpl suspendContext = context.getSuspendContext();
    if (suspendContext != null) {
      XExecutionStack stack = suspendContext.getActiveExecutionStack();
      if (stack != null) {
        ((JavaExecutionStack) stack).initTopFrame();
      }
    }

    final Semaphore waitSemaphore = new Semaphore();
    waitSemaphore.down();
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(
        () -> {
          try {
            if (!project.isDisposed()) {
              breakpointManager.reloadBreakpoints();
              debugProcess.getRequestsManager().clearWarnings();
              if (LOG.isDebugEnabled()) {
                LOG.debug("requests updated");
                LOG.debug("time stamp set");
              }
              myDebuggerSession.refresh(false);

              XDebugSession session = myDebuggerSession.getXDebugSession();
              if (session != null) {
                session.rebuildViews();
              }
            }
          } catch (Throwable e) {
            LOG.error(e);
          } finally {
            waitSemaphore.up();
          }
        });

    waitSemaphore.waitFor();

    if (!project.isDisposed()) {
      try {
        breakpointManager.enableBreakpoints(debugProcess);
      } catch (Exception e) {
        processException(e);
      }
    }
  }