Search in sources :

Example 1 with DlvDebugProcess

use of com.goide.dlv.DlvDebugProcess in project nocalhost-intellij-plugin by nocalhost.

the class NocalhostGoDlvDebugRunner method attachDlv.

private RunContentDescriptor attachDlv(RunProfileState state, @NotNull ExecutionEnvironment env, String debugPort) throws ExecutionException {
    NocalhostGoConfigurationFactory factory = (NocalhostGoConfigurationFactory) (new NocalhostGoConfigurationType().getConfigurationFactories())[0];
    NocalhostGoConfiguration configuration = (NocalhostGoConfiguration) factory.createTemplateConfiguration(env.getProject());
    Executor executor = DefaultDebugExecutor.getDebugExecutorInstance();
    ExecutionEnvironment environment = ExecutionEnvironmentBuilder.create(env.getProject(), executor, configuration).build();
    NocalhostRunner runner = Objects.requireNonNull(ProgramRunner.PROGRAM_RUNNER_EP.findExtension(NocalhostRunner.class));
    InetSocketAddress socketAddress = new InetSocketAddress("localhost", Integer.parseInt(debugPort));
    ExecutionResult executionResult = state.execute(environment.getExecutor(), runner);
    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {

        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException {
            DlvDebugProcess process = new DlvDebugProcess(session, new NocalhostGoDlvRemoteVmConnection(DlvDisconnectOption.DETACH), executionResult, true);
            process.connect(socketAddress);
            return process;
        }
    }).getRunContentDescriptor();
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DlvDebugProcess(com.goide.dlv.DlvDebugProcess) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) InetSocketAddress(java.net.InetSocketAddress) ExecutionResult(com.intellij.execution.ExecutionResult) NocalhostRunner(dev.nocalhost.plugin.intellij.configuration.NocalhostRunner) NotNull(org.jetbrains.annotations.NotNull) DefaultDebugExecutor(com.intellij.execution.executors.DefaultDebugExecutor) Executor(com.intellij.execution.Executor) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter)

Example 2 with DlvDebugProcess

use of com.goide.dlv.DlvDebugProcess in project intellij by bazelbuild.

the class BlazeGoDebugRunner method doExecute.

protected RunContentDescriptor doExecute(ExecutionEnvironment environment, BlazeGoDummyDebugProfileState blazeState) throws ExecutionException {
    EventLoggingService.getInstance().logEvent(getClass(), "debugging-go");
    GoApplicationRunningState goState = blazeState.toNativeState(environment);
    ExecutionResult executionResult = goState.execute(environment.getExecutor(), this);
    return XDebuggerManager.getInstance(environment.getProject()).startSession(environment, new XDebugProcessStarter() {

        @Override
        public XDebugProcess start(XDebugSession session) {
            RemoteVmConnection<?> connection = new DlvRemoteVmConnection(DlvDisconnectOption.KILL);
            XDebugProcess process = new DlvDebugProcess(session, connection, executionResult, /* remote= */
            true);
            connection.open(goState.getDebugAddress());
            return process;
        }
    }).getRunContentDescriptor();
}
Also used : XDebugSession(com.intellij.xdebugger.XDebugSession) DlvDebugProcess(com.goide.dlv.DlvDebugProcess) XDebugProcess(com.intellij.xdebugger.XDebugProcess) GoApplicationRunningState(com.goide.execution.application.GoApplicationRunningState) XDebugProcessStarter(com.intellij.xdebugger.XDebugProcessStarter) ExecutionResult(com.intellij.execution.ExecutionResult) DlvRemoteVmConnection(com.goide.dlv.DlvRemoteVmConnection)

Aggregations

DlvDebugProcess (com.goide.dlv.DlvDebugProcess)2 ExecutionResult (com.intellij.execution.ExecutionResult)2 XDebugProcessStarter (com.intellij.xdebugger.XDebugProcessStarter)2 XDebugSession (com.intellij.xdebugger.XDebugSession)2 DlvRemoteVmConnection (com.goide.dlv.DlvRemoteVmConnection)1 GoApplicationRunningState (com.goide.execution.application.GoApplicationRunningState)1 Executor (com.intellij.execution.Executor)1 DefaultDebugExecutor (com.intellij.execution.executors.DefaultDebugExecutor)1 ExecutionEnvironment (com.intellij.execution.runners.ExecutionEnvironment)1 XDebugProcess (com.intellij.xdebugger.XDebugProcess)1 NocalhostRunner (dev.nocalhost.plugin.intellij.configuration.NocalhostRunner)1 InetSocketAddress (java.net.InetSocketAddress)1 NotNull (org.jetbrains.annotations.NotNull)1