com.intellij.xdebugger.XDebugProcessStarter Java Examples

The following examples show how to use com.intellij.xdebugger.XDebugProcessStarter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeaveDebuggerRunner.java    From mule-intellij-plugins with Apache License 2.0 6 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(final RunProfileState state, final @NotNull ExecutionEnvironment env)
        throws ExecutionException
{

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter()
    {
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) throws ExecutionException
        {
            WeaveRunnerCommandLine weaveRunnerCommandLine = (WeaveRunnerCommandLine) state;
            final String weaveFile = weaveRunnerCommandLine.getModel().getWeaveFile();
            final Project project = weaveRunnerCommandLine.getEnvironment().getProject();
            final VirtualFile projectFile = project.getBaseDir();
            final String path = project.getBasePath();
            final String relativePath = weaveFile.substring(path.length());
            final VirtualFile fileByRelativePath = projectFile.findFileByRelativePath(relativePath);
            final DebuggerClient localhost = new DebuggerClient(new WeaveDebuggerClientListener(session, fileByRelativePath), new TcpClientDebuggerProtocol("localhost", 6565));
            final ExecutionResult result = state.execute(env.getExecutor(), WeaveDebuggerRunner.this);
            new DebuggerConnector(localhost).start();
            return new WeaveDebugProcess(session, localhost, result);
        }
    }).getRunContentDescriptor();

}
 
Example #2
Source File: BlazeGoDebugRunner.java    From intellij with Apache License 2.0 6 votes vote down vote up
private RunContentDescriptor doExecute(ExecutionEnvironment environment, RunProfileState state)
    throws ExecutionException {
  if (!(state instanceof BlazeGoDummyDebugProfileState)) {
    return null;
  }
  BlazeGoDummyDebugProfileState blazeState = (BlazeGoDummyDebugProfileState) state;
  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) throws ExecutionException {
              RemoteVmConnection connection = new DlvRemoteVmConnection(true);
              XDebugProcess process =
                  new DlvDebugProcess(session, connection, executionResult, true, false);
              connection.open(goState.getDebugAddress());
              return process;
            }
          })
      .getRunContentDescriptor();
}
 
Example #3
Source File: XQueryDebuggerRunner.java    From intellij-xquery with Apache License 2.0 6 votes vote down vote up
private XDebugProcessStarter getProcessStarter(final RunProfileState runProfileState, final ExecutionEnvironment
        executionEnvironment) throws ExecutionException {
    int port = getAvailablePort();
    ((XQueryRunProfileState) runProfileState).setPort(port);
    return new XDebugProcessStarter() {
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
            final ExecutionResult result = runProfileState.execute(executionEnvironment.getExecutor(), XQueryDebuggerRunner.this);
            XQueryDebugProcess.XQueryDebuggerIde debuggerIde = new XQueryDebugProcess.XQueryDebuggerIde(session, result.getProcessHandler());
            final DBGpIde dbgpIde = ide().withPort(port).withDebuggerIde(debuggerIde).build();
            dbgpIde.startListening();
            result.getProcessHandler().addProcessListener(new ProcessAdapter() {
                @Override
                public void processTerminated(ProcessEvent event) {
                    dbgpIde.stopListening();
                }
            });
            return new XQueryDebugProcess(session, result, dbgpIde);
        }
    };
}
 
Example #4
Source File: CppBaseDebugRunner.java    From CppTools with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
protected RunContentDescriptor doExecute(Project project, RunProfileState runProfileState, RunContentDescriptor runContentDescriptor, ExecutionEnvironment env) throws ExecutionException {
  FileDocumentManager.getInstance().saveAllDocuments();

  final RunProfile runProfile = env.getRunProfile();

  final XDebugSession debugSession =
      XDebuggerManager.getInstance(project).startSession(this, env, runContentDescriptor, new XDebugProcessStarter() {
        @NotNull
        public XDebugProcess start(@NotNull final XDebugSession session) {
          return new CppDebugProcess(session, CppBaseDebugRunner.this, (BaseCppConfiguration)runProfile);
        }
      });

  return debugSession.getRunContentDescriptor();
}
 
Example #5
Source File: RoboVmRunner.java    From robovm-idea with GNU General Public License v2.0 5 votes vote down vote up
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state,
                                                    @NotNull ExecutionEnvironment env,
                                                    RemoteConnection connection,
                                                    boolean pollConnection) throws ExecutionException {
    DebugEnvironment environment = new DefaultDebugUIEnvironment(env, state, connection, pollConnection).getEnvironment();
    final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
    if (debuggerSession == null) {
        return null;
    }

    final DebugProcessImpl debugProcess = debuggerSession.getProcess();
    if (debugProcess.isDetached() || debugProcess.isDetaching()) {
        debuggerSession.dispose();
        return null;
    }
    // optimization: that way BatchEvaluator will not try to lookup the class file in remote VM
    // which is an expensive operation when executed first time
    debugProcess.putUserData(BatchEvaluator.REMOTE_SESSION_KEY, Boolean.TRUE);

    return XDebuggerManager.getInstance(env.getProject()).startSession(env, new XDebugProcessStarter() {
        @Override
        @NotNull
        public XDebugProcess start(@NotNull XDebugSession session) {
            XDebugSessionImpl sessionImpl = (XDebugSessionImpl)session;
            ExecutionResult executionResult = debugProcess.getExecutionResult();
            sessionImpl.addExtraActions(executionResult.getActions());
            if (executionResult instanceof DefaultExecutionResult) {
                sessionImpl.addRestartActions(((DefaultExecutionResult)executionResult).getRestartActions());
                sessionImpl.addExtraStopActions(((DefaultExecutionResult)executionResult).getAdditionalStopActions());
            }
            return JavaDebugProcess.create(session, debuggerSession);
        }
    }).getRunContentDescriptor();
}
 
Example #6
Source File: HaxeFlashDebuggingUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static RunContentDescriptor getDescriptor(final Module module,
                                                 ExecutionEnvironment env,
                                                 String urlToLaunch,
                                                 String flexSdkName) throws ExecutionException {
  final Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(flexSdkName);
  if (flexSdk == null) {
    throw new ExecutionException(HaxeBundle.message("flex.sdk.not.found", flexSdkName));
  }

  final FlexBuildConfiguration bc = new FakeFlexBuildConfiguration(flexSdk, urlToLaunch);

  final XDebugSession debugSession =
    XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        try {
          final FlashRunnerParameters params = new FlashRunnerParameters();
          params.setModuleName(module.getName());
          return new HaxeDebugProcess(session, bc, params);
        }
        catch (IOException e) {
          throw new ExecutionException(e.getMessage(), e);
        }
      }
    });

  return debugSession.getRunContentDescriptor();
}
 
Example #7
Source File: HaxeFlashDebuggingUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static RunContentDescriptor getNMEDescriptor(final HaxeDebugRunner runner,
                                                    final Module module,
                                                    final ExecutionEnvironment env,
                                                    final Executor executor, String flexSdkName) throws ExecutionException {
  final Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(flexSdkName);
  if (flexSdk == null) {
    throw new ExecutionException(HaxeBundle.message("flex.sdk.not.found", flexSdkName));
  }

  final FlexBuildConfiguration bc = new FakeFlexBuildConfiguration(flexSdk, null);

  final XDebugSession debugSession =
    XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        try {
          NMERunningState runningState = new NMERunningState(env, module, false, true);
          final ExecutionResult executionResult = runningState.execute(executor, runner);
          final BCBasedRunnerParameters params = new BCBasedRunnerParameters();
          params.setModuleName(module.getName());
          return new HaxeDebugProcess(session, bc, params);
        }
        catch (IOException e) {
          throw new ExecutionException(e.getMessage(), e);
        }
      }
    });

  return debugSession.getRunContentDescriptor();
}
 
Example #8
Source File: HaxeFlashDebuggingUtil.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
public static RunContentDescriptor getOpenFLDescriptor(final HaxeDebugRunner runner,
                                                       final Module module,
                                                       final ExecutionEnvironment env,
                                                       final Executor executor, String flexSdkName) throws ExecutionException {
  final Sdk flexSdk = FlexSdkUtils.findFlexOrFlexmojosSdk(flexSdkName);
  if (flexSdk == null) {
    throw new ExecutionException(HaxeBundle.message("flex.sdk.not.found", flexSdkName));
  }

  final FlexBuildConfiguration bc = new FakeFlexBuildConfiguration(flexSdk, null);

  final XDebugSession debugSession =
    XDebuggerManager.getInstance(module.getProject()).startSession(env, new XDebugProcessStarter() {
      @NotNull
      public XDebugProcess start(@NotNull final XDebugSession session) throws ExecutionException {
        try {
          OpenFLRunningState runningState = new OpenFLRunningState(env, module, false, true);
          final ExecutionResult executionResult = runningState.execute(executor, runner);
          final BCBasedRunnerParameters params = new BCBasedRunnerParameters();
          params.setModuleName(module.getName());
          return new HaxeDebugProcess(session, bc, params);
        }
        catch (IOException e) {
          throw new ExecutionException(e.getMessage(), e);
        }
      }
    });

  return debugSession.getRunContentDescriptor();
}
 
Example #9
Source File: XQueryDebuggerRunner.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
private RunContentDescriptor createContentDescriptor(final RunProfileState runProfileState,
                                                     final ExecutionEnvironment environment) throws ExecutionException {
    XDebuggerManager debuggerManager = XDebuggerManager.getInstance(environment.getProject());
    XDebugProcessStarter processStarter = getProcessStarter(runProfileState, environment);
    final XDebugSession debugSession = debuggerManager.startSession(environment, processStarter);
    return debugSession.getRunContentDescriptor();
}
 
Example #10
Source File: TestExecutionState.java    From buck with Apache License 2.0 4 votes vote down vote up
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);
            }
          });
}