use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.
the class BreakpointWithHighlighter method updateUI.
/**
* updates the state of breakpoint and all the related UI widgets etc
*/
@Override
public final void updateUI() {
if (!isVisible() || ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
if (!isValid()) {
return;
}
DebuggerContextImpl context = DebuggerManagerEx.getInstanceEx(myProject).getContext();
DebugProcessImpl debugProcess = context.getDebugProcess();
if (debugProcess == null || !debugProcess.isAttached()) {
updateCaches(null);
updateGutter();
} else {
debugProcess.getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
ApplicationManager.getApplication().runReadAction(() -> {
if (!myProject.isDisposed()) {
updateCaches(debugProcess);
}
});
DebuggerInvocationUtil.swingInvokeLater(myProject, BreakpointWithHighlighter.this::updateGutter);
}
});
}
});
}
use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.
the class DebuggerManagerThreadImpl method terminateAndInvoke.
/**
* waits COMMAND_TIMEOUT milliseconds
* if worker thread is still processing the same command
* calls terminateCommand
*/
public void terminateAndInvoke(DebuggerCommandImpl command, int terminateTimeoutMillis) {
final DebuggerCommandImpl currentCommand = myEvents.getCurrentEvent();
invoke(command);
if (currentCommand != null) {
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
if (currentCommand == myEvents.getCurrentEvent()) {
// if current command is still in progress, cancel it
getCurrentRequest().requestStop();
try {
getCurrentRequest().join();
} catch (InterruptedException ignored) {
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (!myDisposed) {
startNewWorkerThread();
}
}
}
}, terminateTimeoutMillis, TimeUnit.MILLISECONDS);
}
}
use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.
the class SuspendManagerImpl method processVote.
private void processVote(final SuspendContextImpl suspendContext) {
LOG.assertTrue(suspendContext.myVotesToVote > 0);
suspendContext.myVotesToVote--;
if (LOG.isDebugEnabled()) {
LOG.debug("myVotesToVote = " + suspendContext.myVotesToVote);
}
if (suspendContext.myVotesToVote == 0) {
if (suspendContext.myIsVotedForResume) {
// resume in a separate request to allow other requests be processed (e.g. dependent bpts enable)
myDebugProcess.getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
resume(suspendContext);
}
@Override
public Priority getPriority() {
return Priority.HIGH;
}
});
} else {
LOG.debug("vote paused");
myDebugProcess.logThreads();
myDebugProcess.cancelRunToCursorBreakpoint();
final ThreadReferenceProxyImpl thread = suspendContext.getThread();
myDebugProcess.deleteStepRequests(thread != null ? thread.getThreadReference() : null);
notifyPaused(suspendContext);
}
}
}
use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.
the class DebugProcessImpl method createVirtualMachine.
private void createVirtualMachine(final DebugEnvironment environment) {
final String sessionName = environment.getSessionName();
final long pollTimeout = environment.getPollTimeout();
final Semaphore semaphore = new Semaphore();
semaphore.down();
final AtomicBoolean connectorIsReady = new AtomicBoolean(false);
myDebugProcessDispatcher.addListener(new DebugProcessListener() {
@Override
public void connectorIsReady() {
connectorIsReady.set(true);
semaphore.up();
myDebugProcessDispatcher.removeListener(this);
}
});
// reload to make sure that source positions are initialized
DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager().reloadBreakpoints();
getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() {
VirtualMachine vm = null;
try {
final long time = System.currentTimeMillis();
do {
try {
vm = createVirtualMachineInt();
break;
} catch (final ExecutionException e) {
if (pollTimeout > 0 && !myConnection.isServerMode() && e.getCause() instanceof IOException) {
synchronized (this) {
try {
wait(500);
} catch (InterruptedException ignored) {
break;
}
}
} else {
ProcessHandler processHandler = getProcessHandler();
boolean terminated = processHandler != null && (processHandler.isProcessTerminating() || processHandler.isProcessTerminated());
fail();
DebuggerInvocationUtil.swingInvokeLater(myProject, () -> {
// this problem to the user
if ((myExecutionResult != null && !terminated) || !connectorIsReady.get()) {
ExecutionUtil.handleExecutionError(myProject, ToolWindowId.DEBUG, sessionName, e);
}
});
break;
}
}
} while (System.currentTimeMillis() - time < pollTimeout);
} finally {
semaphore.up();
}
if (vm != null) {
final VirtualMachine vm1 = vm;
afterProcessStarted(() -> getManagerThread().schedule(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
commitVM(vm1);
}
}));
}
}
@Override
protected void commandCancelled() {
try {
super.commandCancelled();
} finally {
semaphore.up();
}
}
});
semaphore.waitFor();
}
use of com.intellij.debugger.engine.events.DebuggerCommandImpl in project intellij-community by JetBrains.
the class ExportThreadsAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
final Project project = e.getProject();
if (project == null) {
return;
}
DebuggerContextImpl context = (DebuggerManagerEx.getInstanceEx(project)).getContext();
final DebuggerSession session = context.getDebuggerSession();
if (session != null && session.isAttached()) {
final DebugProcessImpl process = context.getDebugProcess();
if (process != null) {
process.getManagerThread().invoke(new DebuggerCommandImpl() {
protected void action() throws Exception {
final List<ThreadState> threads = ThreadDumpAction.buildThreadStates(process.getVirtualMachineProxy());
ApplicationManager.getApplication().invokeLater(() -> ExportToTextFileAction.export(project, ThreadDumpPanel.createToFileExporter(project, threads)), ModalityState.NON_MODAL);
}
});
}
}
}
Aggregations