use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-plugins by JetBrains.
the class DartRunner method doExecuteDartDebug.
private RunContentDescriptor doExecuteDartDebug(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment env, @Nullable final String dasExecutionContextId) throws RuntimeConfigurationError, ExecutionException {
final DartSdk sdk = DartSdk.getDartSdk(env.getProject());
// already checked
assert (sdk != null);
final RunProfile runConfiguration = env.getRunProfile();
final VirtualFile contextFileOrDir;
VirtualFile currentWorkingDirectory;
final ExecutionResult executionResult;
final String debuggingHost;
final int observatoryPort;
if (runConfiguration instanceof DartRunConfigurationBase) {
contextFileOrDir = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().getDartFileOrDirectory();
final String cwd = ((DartRunConfigurationBase) runConfiguration).getRunnerParameters().computeProcessWorkingDirectory(env.getProject());
currentWorkingDirectory = LocalFileSystem.getInstance().findFileByPath((cwd));
executionResult = state.execute(env.getExecutor(), this);
if (executionResult == null) {
return null;
}
debuggingHost = null;
observatoryPort = ((DartCommandLineRunningState) state).getObservatoryPort();
} else if (runConfiguration instanceof DartRemoteDebugConfiguration) {
final String path = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getDartProjectPath();
contextFileOrDir = LocalFileSystem.getInstance().findFileByPath(path);
if (contextFileOrDir == null) {
throw new RuntimeConfigurationError("Folder not found: " + FileUtil.toSystemDependentName(path));
}
currentWorkingDirectory = contextFileOrDir;
executionResult = null;
debuggingHost = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getHost();
observatoryPort = ((DartRemoteDebugConfiguration) runConfiguration).getParameters().getPort();
} else {
LOG.error("Unexpected run configuration: " + runConfiguration.getClass().getName());
return null;
}
FileDocumentManager.getInstance().saveAllDocuments();
final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(env.getProject());
final XDebugSession debugSession = debuggerManager.startSession(env, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) {
final DartUrlResolver dartUrlResolver = getDartUrlResolver(env.getProject(), contextFileOrDir);
return new DartVmServiceDebugProcess(session, StringUtil.notNullize(debuggingHost, "localhost"), observatoryPort, executionResult, dartUrlResolver, dasExecutionContextId, runConfiguration instanceof DartRemoteDebugConfiguration, getTimeout(), currentWorkingDirectory);
}
});
return debugSession.getRunContentDescriptor();
}
use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-plugins by JetBrains.
the class KarmaDebugProgramRunner method createDescriptor.
@NotNull
private static RunContentDescriptor createDescriptor(@NotNull ExecutionEnvironment environment, @NotNull ExecutionResult executionResult, @NotNull KarmaConsoleView consoleView, @NotNull KarmaServer karmaServer, @NotNull DebuggableWebBrowser debuggableWebBrowser) throws ExecutionException {
Url url = Urls.newFromEncoded(karmaServer.formatUrl("/"));
DebuggableFileFinder fileFinder = getDebuggableFileFinder(karmaServer);
XDebugSession session = XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
JavaScriptDebugEngine debugEngine = debuggableWebBrowser.getDebugEngine();
WebBrowser browser = debuggableWebBrowser.getWebBrowser();
JavaScriptDebugProcess<? extends VmConnection> debugProcess = debugEngine.createDebugProcess(session, browser, fileFinder, url, executionResult, true);
debugProcess.addFirstLineBreakpointPattern("\\.browserify$");
debugProcess.setElementsInspectorEnabled(false);
debugProcess.setConsoleMessagesSupportEnabled(false);
debugProcess.setLayouter(consoleView.createDebugLayouter(debugProcess));
Alarm alarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, consoleView);
alarm.addRequest(() -> {
resumeTestRunning(executionResult.getProcessHandler());
Disposer.dispose(alarm);
}, 2000);
return debugProcess;
}
});
return session.getRunContentDescriptor();
}
use of com.intellij.xdebugger.XDebugProcessStarter in project buck by facebook.
the class TestExecutionState method attachDebugger.
private void attachDebugger(String title, String port) {
final RemoteConnection remoteConnection = new RemoteConnection(/* useSockets */
true, "localhost", port, /* serverMode */
false);
final RemoteStateState state = new RemoteStateState(mProject, remoteConnection);
final String name = title + " debugger (" + port + ")";
final ConfigurationFactory cfgFactory = ConfigurationTypeUtil.findConfigurationType("Remote").getConfigurationFactories()[0];
RunnerAndConfigurationSettings runSettings = RunManager.getInstance(mProject).createRunConfiguration(name, cfgFactory);
final Executor debugExecutor = DefaultDebugExecutor.getDebugExecutorInstance();
final ExecutionEnvironment env = new ExecutionEnvironmentBuilder(mProject, debugExecutor).runProfile(runSettings.getConfiguration()).build();
final int pollTimeout = 3000;
final DebugEnvironment environment = new DefaultDebugEnvironment(env, state, remoteConnection, pollTimeout);
ApplicationManager.getApplication().invokeLater(() -> {
try {
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(mProject).attachVirtualMachine(environment);
if (debuggerSession == null) {
return;
}
XDebuggerManager.getInstance(mProject).startSessionAndShowTab(name, null, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull XDebugSession session) {
return JavaDebugProcess.create(session, debuggerSession);
}
});
} catch (ExecutionException e) {
LOG.error("failed to attach to debugger on port " + port + " with polling timeout " + pollTimeout);
}
});
}
use of com.intellij.xdebugger.XDebugProcessStarter in project intellij-plugins by JetBrains.
the class FlexRunner method doExecute.
@Override
protected RunContentDescriptor doExecute(@NotNull final RunProfileState state, @NotNull ExecutionEnvironment env) throws ExecutionException {
final BCBasedRunnerParameters parameters = ((RemoteFlashRunConfiguration) env.getRunProfile()).getRunnerParameters();
RunContentDescriptor runContentDescriptor = XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
@Override
@NotNull
public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
try {
return DebugPathManager.IS_DEV ? new MyFlexDebugProcessAbleToResolveFileDebugId(callback, session, buildConfiguration, parameters) : new MyFlexDebugProcess(callback, session, buildConfiguration, parameters);
} catch (IOException e) {
throw new ExecutionException(e.getMessage(), e);
} finally {
buildConfiguration = null;
}
}
}).getRunContentDescriptor();
ProcessHandler processHandler = runContentDescriptor.getProcessHandler();
assert processHandler != null;
//noinspection deprecation
processHandler.putUserData(ProcessHandler.SILENTLY_DESTROY_ON_CLOSE, true);
return runContentDescriptor;
}
Aggregations