use of com.intellij.debugger.apiAdapters.TransportServiceWrapper in project intellij-community by JetBrains.
the class DebuggerManagerImpl method createDebugParameters.
@SuppressWarnings({ "HardCodedStringLiteral" })
public static RemoteConnection createDebugParameters(final JavaParameters parameters, final boolean debuggerInServerMode, int transport, final String debugPort, boolean checkValidity) throws ExecutionException {
if (checkValidity) {
checkTargetJPDAInstalled(parameters);
}
final boolean useSockets = transport == DebuggerSettings.SOCKET_TRANSPORT;
String address = "";
if (StringUtil.isEmptyOrSpaces(debugPort)) {
try {
address = DebuggerUtils.getInstance().findAvailableDebugAddress(useSockets);
} catch (ExecutionException e) {
if (checkValidity) {
throw e;
}
}
} else {
address = debugPort;
}
final TransportServiceWrapper transportService = TransportServiceWrapper.getTransportService(useSockets);
final String debugAddress = debuggerInServerMode && useSockets ? "127.0.0.1:" + address : address;
String debuggeeRunProperties = "transport=" + transportService.transportId() + ",address=" + debugAddress;
if (debuggerInServerMode) {
debuggeeRunProperties += ",suspend=y,server=n";
} else {
debuggeeRunProperties += ",suspend=n,server=y";
}
if (StringUtil.containsWhitespaces(debuggeeRunProperties)) {
debuggeeRunProperties = "\"" + debuggeeRunProperties + "\"";
}
final String _debuggeeRunProperties = debuggeeRunProperties;
ApplicationManager.getApplication().runReadAction(() -> {
JavaSdkUtil.addRtJar(parameters.getClassPath());
final Sdk jdk = parameters.getJdk();
final boolean forceClassicVM = shouldForceClassicVM(jdk);
final boolean forceNoJIT = shouldForceNoJIT(jdk);
final String debugKey = System.getProperty(DEBUG_KEY_NAME, "-Xdebug");
final boolean needDebugKey = shouldAddXdebugKey(jdk) || !"-Xdebug".equals(debugKey);
if (forceClassicVM || forceNoJIT || needDebugKey || !isJVMTIAvailable(jdk)) {
parameters.getVMParametersList().replaceOrPrepend("-Xrunjdwp:", "-Xrunjdwp:" + _debuggeeRunProperties);
} else {
// use newer JVMTI if available
parameters.getVMParametersList().replaceOrPrepend("-Xrunjdwp:", "");
parameters.getVMParametersList().replaceOrPrepend("-agentlib:jdwp=", "-agentlib:jdwp=" + _debuggeeRunProperties);
}
if (forceNoJIT) {
parameters.getVMParametersList().replaceOrPrepend("-Djava.compiler=", "-Djava.compiler=NONE");
parameters.getVMParametersList().replaceOrPrepend("-Xnoagent", "-Xnoagent");
}
if (needDebugKey) {
parameters.getVMParametersList().replaceOrPrepend(debugKey, debugKey);
} else {
// deliberately skip outdated parameter because it can disable full-speed debugging for some jdk builds
// see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6272174
parameters.getVMParametersList().replaceOrPrepend("-Xdebug", "");
}
parameters.getVMParametersList().replaceOrPrepend("-classic", forceClassicVM ? "-classic" : "");
});
return new RemoteConnection(useSockets, "127.0.0.1", address, debuggerInServerMode);
}
Aggregations