use of com.intellij.debugger.DefaultDebugEnvironment in project intellij-community by JetBrains.
the class GenericDebuggerRunner method attachVirtualMachine.
@Nullable
protected RunContentDescriptor attachVirtualMachine(RunProfileState state, @NotNull ExecutionEnvironment env, RemoteConnection connection, long pollTimeout) throws ExecutionException {
DebugEnvironment environment = new DefaultDebugEnvironment(env, state, connection, pollTimeout);
final DebuggerSession debuggerSession = DebuggerManagerEx.getInstanceEx(env.getProject()).attachVirtualMachine(environment);
if (debuggerSession == null) {
return null;
}
final DebugProcessImpl debugProcess = debuggerSession.getProcess();
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());
}
return JavaDebugProcess.create(session, debuggerSession);
}
}).getRunContentDescriptor();
}
use of com.intellij.debugger.DefaultDebugEnvironment 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.debugger.DefaultDebugEnvironment in project intellij-community by JetBrains.
the class JavaTestFrameworkDebuggerRunner method createContentDescriptor.
@Nullable
@Override
protected RunContentDescriptor createContentDescriptor(@NotNull final RunProfileState state, @NotNull final ExecutionEnvironment environment) throws ExecutionException {
final RunContentDescriptor res = super.createContentDescriptor(state, environment);
final ServerSocket socket = ((JavaTestFrameworkRunnableState) state).getForkSocket();
if (socket != null) {
Thread thread = new Thread(getThreadName() + " debugger runner") {
@Override
public void run() {
try {
final Socket accept = socket.accept();
try {
DataInputStream stream = new DataInputStream(accept.getInputStream());
try {
int read = stream.readInt();
while (read != -1) {
final DebugProcess process = DebuggerManager.getInstance(environment.getProject()).getDebugProcess(res.getProcessHandler());
if (process == null)
break;
final RemoteConnection connection = new RemoteConnection(true, "127.0.0.1", String.valueOf(read), true);
final DebugEnvironment env = new DefaultDebugEnvironment(environment, state, connection, true);
SwingUtilities.invokeLater(() -> {
try {
((DebugProcessImpl) process).reattach(env);
accept.getOutputStream().write(0);
} catch (Exception e) {
e.printStackTrace();
}
});
read = stream.readInt();
}
} finally {
stream.close();
}
} finally {
accept.close();
}
} catch (EOFException ignored) {
} catch (IOException e) {
e.printStackTrace();
}
}
};
thread.setDaemon(true);
thread.start();
}
return res;
}
Aggregations