Contributors:
IBM Corporation - Initial implementation
Vicente Fernando - www.alfersoft.com.ar
+ Christian Perkonig - remote Debug
**********************************************************************/
package net.sourceforge.phpdt.internal.launching;
public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
String[] env;
String name, value;
- PHPDBGProxy newPHPDBGProxy= new PHPDBGProxy();
+ PHPDBGProxy newPHPDBGProxy= new PHPDBGProxy(configuration.useRemoteDebugger(),
+ configuration.getRemoteSourcePath());
int pos;
- newPHPDBGProxy.start();
- env= setEnvironmentVariables(newPHPDBGProxy.getPort(), configuration.getAbsoluteFileName(), configuration.getInterpreter().getCommand());
-
- for(int i= 0; i < env.length; i++) {
- pos= env[i].indexOf("=");
- if(pos > -1) {
- name= env[i].substring(0, pos);
- value= env[i].substring(pos + 1);
- } else {
- name= env[i];
- value= "";
- }
- Environment.setenv(name, value);
- }
- // now enviroment settings is made with Environment class
- // because if new parameters are passed by array, doesn't inherit system vars
- IProcess process = super.run(configuration, launch, null);
+
+ IProcess process =null;
PHPDebugTarget debugTarget = new PHPDebugTarget(launch, process);
- newPHPDBGProxy.setDebugTarget(debugTarget);
+ newPHPDBGProxy.setDebugTarget(debugTarget);
+ newPHPDBGProxy.start();
+ if (configuration.useRemoteDebugger())
+ {
+ // listener for remote debuger is started
+ }
+ else
+ {
+
+ env= setEnvironmentVariables(newPHPDBGProxy.getPort(), configuration.getAbsoluteFileName(), configuration.getInterpreter().getCommand());
+ for(int i= 0; i < env.length; i++) {
+ pos= env[i].indexOf("=");
+ if(pos > -1) {
+ name= env[i].substring(0, pos);
+ value= env[i].substring(pos + 1);
+ } else {
+ name= env[i];
+ value= "";
+ }
+ Environment.setenv(name, value);
+ }
+ // now enviroment settings is made with Environment class
+ // because if new parameters are passed by array, doesn't inherit system vars
+ process = super.run(configuration, launch, null);
+ debugTarget.setProcess(process);
+ }
launch.addDebugTarget(debugTarget);
return process;
}
-
+
protected String[] setEnvironmentVariables(int listenPort, String AbsoluteFileName, String interpreter) {
IPath FilePath= new Path(AbsoluteFileName);
String OSFilePath= FilePath.toOSString();
return PHPRuntime.getDefault().getInterpreter(selectedInterpreter);
}
+
+ public boolean useRemoteDebugger() {
+ try {
+ return configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_DEBUG, false);
+ } catch(CoreException e) {
+ PHPLaunchingPlugin.log(e);
+ }
+ return false;
+ }
+
+ public String getRemoteSourcePath() {
+
+ IProject project = getProject().getProject();
+ if (useRemoteDebugger())
+ return project.getLocation().toOSString();
+ else
+ {
+ try {
+ return configuration.getAttribute(PHPLaunchConfigurationAttribute.REMOTE_PATH, "");
+ } catch(CoreException e) {
+ PHPLaunchingPlugin.log(e);
+ }
+ }
+
+ return "";
+ }
+
}