com.intellij.debugger.DefaultDebugEnvironment Java Examples

The following examples show how to use com.intellij.debugger.DefaultDebugEnvironment. 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: MultiRunDebuggerSessionListener.java    From intellij with Apache License 2.0 5 votes vote down vote up
public MultiRunDebuggerSessionListener(
    ExecutionEnvironment executionEnvironment, RemoteState state) {
  this.executionEnvironment = executionEnvironment;
  this.debuggerManager = DebuggerManagerEx.getInstanceEx(executionEnvironment.getProject());
  RemoteConnection remoteConnection = state.getRemoteConnection();
  debugEnvironment =
      new DefaultDebugEnvironment(executionEnvironment, state, remoteConnection, true);
}
 
Example #2
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);
            }
          });
}