use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.
the class CompilingEvaluator method evaluate.
@Override
public Value evaluate(final EvaluationContext evaluationContext) throws EvaluateException {
DebugProcess process = evaluationContext.getDebugProcess();
EvaluationContextImpl autoLoadContext = ((EvaluationContextImpl) evaluationContext).createEvaluationContext(evaluationContext.getThisObject());
autoLoadContext.setAutoLoadClasses(true);
ClassLoaderReference classLoader = ClassLoadingUtils.getClassLoader(autoLoadContext, process);
autoLoadContext.setClassLoader(classLoader);
String version = ((VirtualMachineProxyImpl) process.getVirtualMachineProxy()).version();
Collection<ClassObject> classes = compile(JdkVersionUtil.getVersion(version));
defineClasses(classes, autoLoadContext, process, classLoader);
try {
// invoke base evaluator on call code
SourcePosition position = ContextUtil.getSourcePosition(evaluationContext);
ExpressionEvaluator evaluator = DebuggerInvocationUtil.commitAndRunReadAction(myProject, new EvaluatingComputable<ExpressionEvaluator>() {
@Override
public ExpressionEvaluator compute() throws EvaluateException {
TextWithImports callCode = getCallCode();
PsiElement copyContext = myData.getAnchor();
CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(callCode, copyContext);
return factory.getEvaluatorBuilder().build(factory.createCodeFragment(callCode, copyContext, myProject), position);
}
});
return evaluator.evaluate(autoLoadContext);
} catch (Exception e) {
throw new EvaluateException("Error during generated code invocation " + e, e);
}
}
use of com.intellij.debugger.engine.DebugProcess 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;
}
use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.
the class CompoundTypeRenderer method getContext.
protected final PsiElement getContext(Project project, DebuggerContext context) {
DebugProcess process = context.getDebugProcess();
GlobalSearchScope scope = process != null ? process.getSearchScope() : GlobalSearchScope.allScope(project);
return DebuggerUtils.findClass(getClassName(), project, scope);
}
use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.
the class LabelRenderer method calcLabel.
public String calcLabel(ValueDescriptor descriptor, EvaluationContext evaluationContext, DescriptorLabelListener labelListener) throws EvaluateException {
final Value value = descriptor.getValue();
String result;
final DebugProcess debugProcess = evaluationContext.getDebugProcess();
if (value != null) {
try {
final ExpressionEvaluator evaluator = myLabelExpression.getEvaluator(debugProcess.getProject());
if (!debugProcess.isAttached()) {
throw EvaluateExceptionUtil.PROCESS_EXITED;
}
EvaluationContext thisEvaluationContext = evaluationContext.createEvaluationContext(value);
Value labelValue = evaluator.evaluate(thisEvaluationContext);
result = DebuggerUtils.getValueAsString(thisEvaluationContext, labelValue);
} catch (final EvaluateException ex) {
throw new EvaluateException(DebuggerBundle.message("error.unable.to.evaluate.expression") + " " + ex.getMessage(), ex);
}
} else {
//noinspection HardCodedStringLiteral
result = "null";
}
return result;
}
use of com.intellij.debugger.engine.DebugProcess in project intellij-community by JetBrains.
the class JavaDebuggerLauncherImpl method startDebugSession.
@Override
public void startDebugSession(@NotNull JavaDebugConnectionData info, @NotNull ExecutionEnvironment executionEnvironment, @NotNull RemoteServer<?> server) throws ExecutionException {
final Project project = executionEnvironment.getProject();
final DebuggerPanelsManager manager = DebuggerPanelsManager.getInstance(project);
final JavaDebugServerModeHandler serverModeHandler = info.getServerModeHandler();
boolean serverMode = serverModeHandler != null;
final RemoteConnection remoteConnection = new RemoteConnection(true, info.getHost(), String.valueOf(info.getPort()), serverMode);
DebugEnvironment debugEnvironment = new RemoteServerDebugEnvironment(project, remoteConnection, executionEnvironment.getRunProfile());
DebugUIEnvironment debugUIEnvironment = new RemoteServerDebugUIEnvironment(debugEnvironment, executionEnvironment);
RunContentDescriptor debugContentDescriptor = manager.attachVirtualMachine(debugUIEnvironment);
LOG.assertTrue(debugContentDescriptor != null);
ProcessHandler processHandler = debugContentDescriptor.getProcessHandler();
LOG.assertTrue(processHandler != null);
if (serverMode) {
serverModeHandler.attachRemote();
DebuggerManager.getInstance(executionEnvironment.getProject()).addDebugProcessListener(processHandler, new DebugProcessListener() {
public void processDetached(DebugProcess process, boolean closedByUser) {
try {
serverModeHandler.detachRemote();
} catch (ExecutionException e) {
LOG.info(e);
}
}
});
}
}
Aggregations