From 6687297c401112725fac98b4576997a421b9783f Mon Sep 17 00:00:00 2001 From: cperkonig Date: Wed, 11 Feb 2004 22:16:22 +0000 Subject: [PATCH 1/1] modification to debug on a remote server --- .../phpdt/internal/launching/DebuggerRunner.java | 50 ++++++++++++------- .../launching/InterpreterRunnerConfiguration.java | 27 +++++++++++ .../launching/PHPLaunchConfigurationAttribute.java | 3 + .../launching/PHPLaunchConfigurationDelegate.java | 2 +- 4 files changed, 62 insertions(+), 20 deletions(-) diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java index c7bb124..01e4f6c 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java @@ -8,6 +8,7 @@ http://www.eclipse.org/legal/cpl-v10.html Contributors: IBM Corporation - Initial implementation Vicente Fernando - www.alfersoft.com.ar + Christian Perkonig - remote Debug **********************************************************************/ package net.sourceforge.phpdt.internal.launching; @@ -28,33 +29,44 @@ public class DebuggerRunner extends InterpreterRunner { 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(); diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java index 55c99f3..8cec3f2 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java @@ -84,4 +84,31 @@ public class InterpreterRunnerConfiguration { 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 ""; + } + } diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java index d6b853e..04b1516 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationAttribute.java @@ -15,4 +15,7 @@ public interface PHPLaunchConfigurationAttribute { static final String WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".WORKING_DIRECTORY"; static final String USE_DEFAULT_LOAD_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_LOAD_PATH"; static final String USE_DEFAULT_WORKING_DIRECTORY = PHPLaunchingPlugin.PLUGIN_ID + ".USE_DEFAULT_WORKING_DIRECTORY"; + static final String REMOTE_DEBUG = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_DEBUG"; + static final String REMOTE_PATH = PHPLaunchingPlugin.PLUGIN_ID + ".REMOTE_PATH"; + static final String FILE_MAP = PHPLaunchingPlugin.PLUGIN_ID + ".FILE_MAP"; } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java index 58ccc37..55e9eaf 100644 --- a/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java +++ b/net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java @@ -11,7 +11,7 @@ Contributors: **********************************************************************/ package net.sourceforge.phpdt.internal.launching; -import java.io.OutputStream; +//import java.io.OutputStream; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -- 1.7.1