mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
Java: split debugger and applications host:port pair
GitOrigin-RevId: f2a6277c81a7f4940b1a7c3421a95b721fcfcdb2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c7d47b95b
commit
786016fe4d
@@ -45,7 +45,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
|
||||
myPollTimeout = pollTimeout;
|
||||
|
||||
mySearchScope = createSearchScope(environment.getProject(), environment.getRunProfile());
|
||||
myNeedParametersSet = remoteConnection.isServerMode() && remoteConnection.isUseSockets() && "0".equals(remoteConnection.getAddress());
|
||||
myNeedParametersSet = remoteConnection.isServerMode() && remoteConnection.isUseSockets() && "0".equals(remoteConnection.getApplicationPort());
|
||||
}
|
||||
|
||||
private static GlobalSearchScope createSearchScope(@NotNull Project project, @Nullable RunProfile runProfile) {
|
||||
@@ -75,7 +75,7 @@ public class DefaultDebugEnvironment implements DebugEnvironment {
|
||||
DebuggerManagerImpl.createDebugParameters(((JavaCommandLine)state).getJavaParameters(),
|
||||
true,
|
||||
DebuggerSettings.SOCKET_TRANSPORT,
|
||||
myRemoteConnection.getAddress(),
|
||||
myRemoteConnection.getApplicationPort(),
|
||||
false);
|
||||
}
|
||||
return state.execute(environment.getExecutor(), environment.getRunner());
|
||||
|
||||
@@ -456,7 +456,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
throw new IOException(DebuggerBundle.message("error.debugger.already.listening"));
|
||||
}
|
||||
|
||||
final String address = myConnection.getAddress();
|
||||
final String port = myConnection.getDebuggerPort();
|
||||
|
||||
if (myConnection instanceof PidRemoteConnection && !((PidRemoteConnection)myConnection).isFixedAddress()) {
|
||||
PidRemoteConnection pidRemoteConnection = (PidRemoteConnection)myConnection;
|
||||
@@ -474,7 +474,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
return attachConnector((AttachingConnector)connector);
|
||||
}
|
||||
else {
|
||||
return connectorListen(address, (ListeningConnector)connector);
|
||||
return connectorListen(port, (ListeningConnector)connector);
|
||||
}
|
||||
}
|
||||
else if (myConnection.isServerMode()) {
|
||||
@@ -483,31 +483,31 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
if (myArguments == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.no.debug.listen.port"));
|
||||
}
|
||||
return connectorListen(address, connector);
|
||||
return connectorListen(port, connector);
|
||||
}
|
||||
else { // is client mode, should attach to already running process
|
||||
AttachingConnector connector = (AttachingConnector)findConnector(myConnection.isUseSockets(), false);
|
||||
myArguments = connector.defaultArguments();
|
||||
if (myConnection.isUseSockets()) {
|
||||
final Connector.Argument hostnameArg = myArguments.get("hostname");
|
||||
if (hostnameArg != null && myConnection.getHostName() != null) {
|
||||
hostnameArg.setValue(myConnection.getHostName());
|
||||
if (hostnameArg != null && myConnection.getDebuggerHostName() != null) {
|
||||
hostnameArg.setValue(myConnection.getDebuggerHostName());
|
||||
}
|
||||
if (address == null) {
|
||||
if (port == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.no.debug.attach.port"));
|
||||
}
|
||||
final Connector.Argument portArg = myArguments.get("port");
|
||||
if (portArg != null) {
|
||||
portArg.setValue(address);
|
||||
portArg.setValue(port);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (address == null) {
|
||||
if (port == null) {
|
||||
throw new CantRunException(DebuggerBundle.message("error.no.shmem.address"));
|
||||
}
|
||||
final Connector.Argument nameArg = myArguments.get("name");
|
||||
if (nameArg != null) {
|
||||
nameArg.setValue(address);
|
||||
nameArg.setValue(port);
|
||||
}
|
||||
}
|
||||
final Connector.Argument timeoutArg = myArguments.get("timeout");
|
||||
@@ -555,7 +555,7 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
|
||||
if (port != null) {
|
||||
listeningAddress = port;
|
||||
}
|
||||
myConnection.setAddress(listeningAddress);
|
||||
myConnection.setApplicationPort(listeningAddress);
|
||||
|
||||
myDebugProcessDispatcher.getMulticaster().connectorIsReady();
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class GenericDebuggerRunner extends JavaPatchableProgramRunner<GenericDeb
|
||||
|
||||
if (debuggerRunnerSettings != null) {
|
||||
remoteConnection.setUseSockets(debuggerRunnerSettings.getTransport() == DebuggerSettings.SOCKET_TRANSPORT);
|
||||
remoteConnection.setAddress(debuggerRunnerSettings.getDebugPort());
|
||||
remoteConnection.setDebuggerPort(debuggerRunnerSettings.getDebugPort());
|
||||
}
|
||||
|
||||
return remoteConnection;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SAJDWPRemoteConnection extends PidRemoteConnection {
|
||||
public SAJDWPRemoteConnection(String pid, List<String> commands) {
|
||||
super(pid);
|
||||
setServerMode(true);
|
||||
setAddress("0");
|
||||
setDebuggerPort("0");
|
||||
myCommands = commands;
|
||||
}
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ public class DebuggerBundle {
|
||||
}
|
||||
|
||||
public static String getAddressDisplayName(final RemoteConnection connection) {
|
||||
return connection.isUseSockets() ? StringUtil.notNullize(connection.getHostName()) + ":" + connection.getAddress()
|
||||
: connection.getAddress();
|
||||
return connection.isUseSockets() ? StringUtil.notNullize(connection.getDebuggerHostName()) + ":" + connection.getDebuggerPort()
|
||||
: connection.getDebuggerPort();
|
||||
}
|
||||
|
||||
public static String getTransportName(final RemoteConnection connection) {
|
||||
|
||||
@@ -70,7 +70,7 @@ public class RemoteConfigurable extends SettingsEditor<RemoteConfiguration> {
|
||||
String getLaunchCommandLine(RemoteConnection connection) {
|
||||
String commandLine = JDK5to8.getLaunchCommandLine(connection);
|
||||
if (connection.isUseSockets() && !connection.isServerMode()) {
|
||||
commandLine = commandLine.replace(connection.getAddress(), "*:" + connection.getAddress());
|
||||
commandLine = commandLine.replace(connection.getApplicationPort(), "*:" + connection.getApplicationPort());
|
||||
}
|
||||
return commandLine;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
package com.intellij.execution.configurations;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.net.InetAddress;
|
||||
@@ -10,16 +11,22 @@ import java.net.UnknownHostException;
|
||||
public class RemoteConnection {
|
||||
private boolean myUseSockets;
|
||||
private boolean myServerMode;
|
||||
private String myHostName;
|
||||
private String myAddress;
|
||||
|
||||
private String myApplicationHostName;
|
||||
private String myApplicationPort;
|
||||
private String myDebuggerHostName;
|
||||
private String myDebuggerPort;
|
||||
|
||||
public static final String ONTHROW = ",onthrow=<FQ exception class name>";
|
||||
public static final String ONUNCAUGHT = ",onuncaught=<y/n>";
|
||||
|
||||
public RemoteConnection(boolean useSockets, String hostName, String address, boolean serverMode) {
|
||||
myUseSockets = useSockets;
|
||||
myServerMode = serverMode;
|
||||
myHostName = hostName;
|
||||
myAddress = address;
|
||||
myApplicationHostName = hostName;
|
||||
myDebuggerHostName = hostName;
|
||||
myApplicationPort = address;
|
||||
myDebuggerPort = address;
|
||||
}
|
||||
|
||||
public boolean isUseSockets() {
|
||||
@@ -30,15 +37,6 @@ public class RemoteConnection {
|
||||
return myServerMode;
|
||||
}
|
||||
|
||||
public String getHostName() {
|
||||
return myHostName;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return myAddress;
|
||||
}
|
||||
|
||||
|
||||
public void setUseSockets(boolean useSockets) {
|
||||
myUseSockets = useSockets;
|
||||
}
|
||||
@@ -47,16 +45,78 @@ public class RemoteConnection {
|
||||
myServerMode = serverMode;
|
||||
}
|
||||
|
||||
public void setHostName(String hostName) {
|
||||
myHostName = hostName;
|
||||
/**
|
||||
* @deprecated use {@link #getApplicationHostName()} or {@link #getDebuggerHostName()} instead depending on your needs
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2020.2")
|
||||
public String getHostName() {
|
||||
return myApplicationHostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #getApplicationPort()} or {@link #getDebuggerPort()} instead depending on your needs
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2020.2")
|
||||
public String getAddress() {
|
||||
return myApplicationPort;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setApplicationHostName(String)} or {@link #setDebuggerHostName(String)} instead depending on your needs
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2020.2")
|
||||
public void setHostName(String hostName) {
|
||||
myApplicationHostName = hostName;
|
||||
myDebuggerHostName = hostName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link #setApplicationPort(String)} or {@link #setDebuggerPort(String)} instead depending on your needs
|
||||
*/
|
||||
@Deprecated
|
||||
@ApiStatus.ScheduledForRemoval(inVersion = "2020.2")
|
||||
public void setAddress(String address) {
|
||||
myAddress = address;
|
||||
myApplicationPort = address;
|
||||
myDebuggerPort = address;
|
||||
}
|
||||
|
||||
public String getApplicationHostName() {
|
||||
return myApplicationHostName;
|
||||
}
|
||||
|
||||
public void setApplicationHostName(String hostName) {
|
||||
myApplicationHostName = hostName;
|
||||
}
|
||||
|
||||
public String getDebuggerHostName() {
|
||||
return myDebuggerHostName;
|
||||
}
|
||||
|
||||
public void setDebuggerHostName(String debuggerHostName) {
|
||||
myDebuggerHostName = debuggerHostName;
|
||||
}
|
||||
|
||||
public String getApplicationPort() {
|
||||
return myApplicationPort;
|
||||
}
|
||||
|
||||
public void setApplicationPort(String applicationPort) {
|
||||
myApplicationPort = applicationPort;
|
||||
}
|
||||
|
||||
public String getDebuggerPort() {
|
||||
return myDebuggerPort;
|
||||
}
|
||||
|
||||
public void setDebuggerPort(String debuggerPort) {
|
||||
myDebuggerPort = debuggerPort;
|
||||
}
|
||||
|
||||
public String getLaunchCommandLine() {
|
||||
final String address = getAddress();
|
||||
final String address = getApplicationPort();
|
||||
final boolean shmem = !isUseSockets();
|
||||
final boolean serverMode = isServerMode();
|
||||
|
||||
@@ -64,11 +124,11 @@ public class RemoteConnection {
|
||||
if (shmem) {
|
||||
if (serverMode) {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_shmem,server=n,address=" +
|
||||
((address.length() > 0)? address : "...") + ",suspend=y" + ONTHROW + ONUNCAUGHT;
|
||||
((address.length() > 0) ? address : "...") + ",suspend=y" + ONTHROW + ONUNCAUGHT;
|
||||
}
|
||||
else {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_shmem,server=y,suspend=n,address=" +
|
||||
((address.length() > 0)? address : "...");
|
||||
((address.length() > 0) ? address : "...");
|
||||
}
|
||||
}
|
||||
else { // socket transport
|
||||
@@ -85,11 +145,11 @@ public class RemoteConnection {
|
||||
catch (UnknownHostException ignored) {
|
||||
}
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=" + localHostName +
|
||||
((port == -1)? "<port>" : Integer.toString(port)) + ",suspend=y" + ONTHROW + ONUNCAUGHT;
|
||||
((port == -1) ? "<port>" : Integer.toString(port)) + ",suspend=y" + ONTHROW + ONUNCAUGHT;
|
||||
}
|
||||
else {
|
||||
result = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" +
|
||||
((port == -1)? "..." : Integer.toString(port));
|
||||
((port == -1) ? "..." : Integer.toString(port));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user