use of com.intellij.debugger.engine.SuspendContextImpl in project intellij-community by JetBrains.
the class JvmSmartStepIntoActionHandler method isEnabled.
public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
final DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
DebuggerSession debuggerSession = context.getDebuggerSession();
final boolean isPaused = debuggerSession != null && debuggerSession.isPaused();
final SuspendContextImpl suspendContext = context.getSuspendContext();
final boolean hasCurrentThread = suspendContext != null && suspendContext.getThread() != null;
return isPaused && hasCurrentThread;
}
use of com.intellij.debugger.engine.SuspendContextImpl in project intellij-community by JetBrains.
the class ThreadDescriptorImpl method setContext.
public void setContext(EvaluationContextImpl context) {
final ThreadReferenceProxyImpl thread = getThreadReference();
final SuspendManager suspendManager = context != null ? context.getDebugProcess().getSuspendManager() : null;
final SuspendContextImpl suspendContext = context != null ? context.getSuspendContext() : null;
try {
myIsSuspended = suspendManager != null ? suspendManager.isSuspended(thread) : thread.isSuspended();
} catch (ObjectCollectedException e) {
myIsSuspended = false;
}
myIsExpandable = calcExpandable(myIsSuspended);
mySuspendContext = suspendManager != null ? SuspendManagerUtil.findContextByThread(suspendManager, thread) : suspendContext;
myIsAtBreakpoint = thread.isAtBreakpoint();
myIsCurrent = suspendContext != null ? suspendContext.getThread() == thread : false;
myIsFrozen = suspendManager != null ? suspendManager.isFrozen(thread) : myIsSuspended;
}
use of com.intellij.debugger.engine.SuspendContextImpl in project intellij-community by JetBrains.
the class ReloadClassesWorker method reloadClasses.
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);
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.onHotSwapFinished();
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);
}
}
}
use of com.intellij.debugger.engine.SuspendContextImpl in project intellij-community by JetBrains.
the class SourceCodeChecker method checkSource.
public static void checkSource(DebuggerContextImpl debuggerContext) {
if (!Registry.is("debugger.check.source")) {
return;
}
SuspendContextImpl suspendContext = debuggerContext.getSuspendContext();
if (suspendContext == null) {
return;
}
suspendContext.getDebugProcess().getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public Priority getPriority() {
return Priority.LOW;
}
@Override
public void contextAction() throws Exception {
try {
StackFrameProxyImpl frameProxy = debuggerContext.getFrameProxy();
if (frameProxy == null) {
return;
}
Location location = frameProxy.location();
check(location, debuggerContext.getSourcePosition(), suspendContext.getDebugProcess().getProject());
//checkAllClasses(debuggerContext);
} catch (EvaluateException e) {
LOG.info(e);
}
}
});
}
use of com.intellij.debugger.engine.SuspendContextImpl in project intellij-community by JetBrains.
the class SuspendContextCommandImpl method action.
@Override
public final void action() throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("trying " + this);
}
final SuspendContextImpl suspendContext = getSuspendContext();
if (suspendContext == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("skip processing - context is null " + this);
}
notifyCancelled();
return;
}
if (suspendContext.myInProgress) {
suspendContext.postponeCommand(this);
} else {
try {
if (!suspendContext.isResumed()) {
suspendContext.myInProgress = true;
contextAction(suspendContext);
} else {
notifyCancelled();
}
} finally {
suspendContext.myInProgress = false;
if (suspendContext.isResumed()) {
for (SuspendContextCommandImpl postponed = suspendContext.pollPostponedCommand(); postponed != null; postponed = suspendContext.pollPostponedCommand()) {
postponed.notifyCancelled();
}
} else {
SuspendContextCommandImpl postponed = suspendContext.pollPostponedCommand();
if (postponed != null) {
final Stack<SuspendContextCommandImpl> stack = new Stack<>();
while (postponed != null) {
stack.push(postponed);
postponed = suspendContext.pollPostponedCommand();
}
final DebuggerManagerThreadImpl managerThread = suspendContext.getDebugProcess().getManagerThread();
while (!stack.isEmpty()) {
managerThread.pushBack(stack.pop());
}
}
}
}
}
}
Aggregations