First submit for debug plugin
authorfvicente <fvicente>
Wed, 30 Jul 2003 01:55:31 +0000 (01:55 +0000)
committerfvicente <fvicente>
Wed, 30 Jul 2003 01:55:31 +0000 (01:55 +0000)
net.sourceforge.phpeclipse.launching/.classpath
net.sourceforge.phpeclipse.launching/plugin.xml
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/DebuggerRunner.java [new file with mode: 0644]
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunner.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/InterpreterRunnerConfiguration.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPInterpreter.java
net.sourceforge.phpeclipse.launching/src/net/sourceforge/phpdt/internal/launching/PHPLaunchConfigurationDelegate.java

index 9e4e573..a02671e 100644 (file)
@@ -1,39 +1,15 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
     <classpathentry kind="src" path="src/"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.1.0/runtime.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.runtime_2.1.0/runtimesrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.core.resources_2.1.0/resources.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.resources_2.1.0/resourcessrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui_2.1.0/ui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui_2.1.0/uisrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.1.0/ws/win32/swt.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.swt.win32_2.1.0/ws/win32/swtsrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.text_2.1.0/text.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.text_2.1.0/textsrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.jface_2.1.0/jface.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface_2.1.0/jfacesrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.jface.text_2.1.0/jfacetext.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface.text_2.1.0/jfacetextsrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui.views_2.1.0/views.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.views_2.1.0/viewssrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench_2.1.0/workbench.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench_2.1.0/workbenchsrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui.win32_2.1.0/workbenchwin32.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.ui.win32_2.1.0/workbenchwin32src.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench.texteditor_2.1.0/texteditor.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench.texteditor_2.1.0/texteditorsrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.ui.editors_2.1.0/editors.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.editors_2.1.0/editorssrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.debug.core_2.1.0/dtcore.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.core_2.1.0/dtcoresrc.zip"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.junit_3.8.1/junit.jar" sourcepath="ORG_ECLIPSE_JDT_SOURCE_SRC/org.junit_3.8.1/junitsrc.zip"/>
-    <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.7/xmlParserAPIs.jar"/>
-    <classpathentry kind="var" path="ECLIPSE_HOME/plugins/org.apache.xerces_4.0.7/xercesImpl.jar"/>
+    <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+    <classpathentry kind="src" path="/org.eclipse.core.resources"/>
+    <classpathentry kind="src" path="/org.eclipse.ui"/>
+    <classpathentry kind="src" path="/org.eclipse.debug.core"/>
+    <classpathentry kind="src" path="/org.junit"/>
+    <classpathentry kind="src" path="/org.apache.xerces"/>
     <classpathentry kind="src" path="/net.sourceforge.phpeclipse"/>
-    <classpathentry kind="var"
-        path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.1.0/boot.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.boot_2.1.0/bootsrc.zip"/>
-    <classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
+    <classpathentry kind="src" path="/net.sourceforge.phpeclipse.debug.core"/>
+    <classpathentry kind="src" path="/org.eclipse.core.boot"/>
+    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
     <classpathentry kind="output" path="bin"/>
 </classpath>
index ebe6405..f4a8503 100644 (file)
@@ -19,6 +19,7 @@
       <import plugin="org.junit"/>
       <import plugin="org.apache.xerces"/>
       <import plugin="net.sourceforge.phpeclipse"/>
+      <import plugin="net.sourceforge.phpeclipse.debug.core"/>
    </requires>
 
 
@@ -27,7 +28,7 @@
       <launchConfigurationType
             name="%LaunchConfigurationTypePHPApplication.name"
             delegate="net.sourceforge.phpdt.internal.launching.PHPLaunchConfigurationDelegate"
-            modes="run"
+            modes="run,debug"
             id="net.sourceforge.phpdt.launching.LaunchConfigurationTypePHPApplication">
          <fileExtension
                default="true"
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
new file mode 100644 (file)
index 0000000..203a5b4
--- /dev/null
@@ -0,0 +1,88 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+       IBM Corporation - Initial implementation
+       Vicente Fernando - www.alfersoft.com.ar
+**********************************************************************/
+package net.sourceforge.phpdt.internal.launching;
+
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
+import net.sourceforge.phpdt.internal.debug.core.Environment;
+import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
+import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
+public class DebuggerRunner extends InterpreterRunner {
+
+       public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
+               String[] env;
+               PHPDBGProxy newPHPDBGProxy= new PHPDBGProxy();
+               newPHPDBGProxy.start();
+               env= setEnvironmentVariables(newPHPDBGProxy.getPort(), configuration.getAbsoluteFileName());
+               
+               IProcess process = super.run(configuration, launch, env);
+               PHPDebugTarget debugTarget = new PHPDebugTarget(launch, process);
+               newPHPDBGProxy.setDebugTarget(debugTarget);
+               launch.addDebugTarget(debugTarget);
+
+               return process;
+       }
+
+       protected String[] setEnvironmentVariables(int listenPort, String AbsoluteFileName) {
+               IPath FilePath= new Path(AbsoluteFileName);
+               String OSFilePath= FilePath.toOSString();
+               String DBGSessID;
+               String env[]= new String[18];
+
+               DBGSessID = "DBGSESSID=0753972710000018@clienthost:" + listenPort;
+
+               env[0]= "HTTP_COOKIE=" + DBGSessID;
+               env[1]= "REDIRECT_QUERY_STRING=";
+               env[2]= "REDIRECT_STATUS=200";
+               env[3]= "REDIRECT_URL=" + OSFilePath;
+               env[4]= "SERVER_SOFTWARE=DBG / 2.1";
+               env[5]= "SERVER_NAME=localhost";
+               env[6]= "SERVER_ADDR=127.0.0.1";
+               env[7]= "SERVER_PORT=80";
+               env[8]= "REMOTE_ADDR=127.0.0.1";
+               env[9]= "SCRIPT_FILENAME=c:\\php\\php.exe";
+               env[10]= "GATEWAY_INTERFACE=CGI / 1.1";
+               env[11]= "SERVER_PROTOCOL=HTTP / 1.1";
+               env[12]= "REQUEST_METHOD=GET";
+               env[13]= "QUERY_STRING=";
+               env[14]= "REQUEST_URI=" + OSFilePath;
+               env[15]= "PATH_INFO=" + OSFilePath;
+               env[16]= "PATH_TRANSLATED=" + OSFilePath;
+               env[17]= "SystemRoot=" + Environment.getenv("SystemRoot");
+
+               return env;
+       }
+
+       protected String getDebugCommandLineArgument() {
+               return "";
+       }
+
+       protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
+               StringBuffer loadPath = new StringBuffer();
+
+               PHPProject project = configuration.getProject();
+               addToLoadPath(loadPath, project.getProject());
+
+               Iterator referencedProjects = project.getReferencedProjects().iterator();
+               while (referencedProjects.hasNext())
+                       addToLoadPath(loadPath, (IProject) referencedProjects.next());
+
+               return loadPath.toString();
+       }
+}
index 13eb2cc..967d643 100644 (file)
@@ -2,24 +2,28 @@ package net.sourceforge.phpdt.internal.launching;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Iterator;
 
 import org.eclipse.core.boot.BootLoader;
+import org.eclipse.core.resources.IProject;
 import org.eclipse.debug.core.DebugPlugin;
 import org.eclipse.debug.core.ILaunch;
 import org.eclipse.debug.core.model.IProcess;
 
+import net.sourceforge.phpeclipse.resourcesview.PHPProject;
+
 public class InterpreterRunner {
 
        public InterpreterRunner() {
        }
 
-       public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
-               String commandLine = renderCommandLine(configuration);
+       public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch, String[] env) {               
+               String commandLine = renderCommandLine(configuration);          
                File workingDirectory = configuration.getAbsoluteWorkingDirectory();
 
                Process nativePHPProcess = null;
                try {
-                       nativePHPProcess = configuration.getInterpreter().exec(commandLine, workingDirectory);
+                       nativePHPProcess = configuration.getInterpreter().exec(commandLine, workingDirectory, env);
                } catch (IOException e) {
                        throw new RuntimeException("Unable to execute interpreter: " + commandLine + workingDirectory);
                }
@@ -55,23 +59,22 @@ public class InterpreterRunner {
                return buffer.toString();
        }
 
-//     protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
-//             StringBuffer loadPath = new StringBuffer();
-//
-//             PHPProject project = configuration.getProject();
-//             addToLoadPath(loadPath, project.getProject());
-//
-//             Iterator referencedProjects = project.getReferencedProjects().iterator();
-//             while (referencedProjects.hasNext())
-//                     addToLoadPath(loadPath, (IProject) referencedProjects.next());
-//
-//             return loadPath.toString();
-//     }
-
-//     protected void addToLoadPath(StringBuffer loadPath, IProject project) {
-//
-//             loadPath.append(" -I " + osDependentPath(project.getLocation().toOSString()));
-//     }
+       protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
+               StringBuffer loadPath = new StringBuffer();
+
+               PHPProject project = configuration.getProject();
+               addToLoadPath(loadPath, project.getProject());
+
+               Iterator referencedProjects = project.getReferencedProjects().iterator();
+               while (referencedProjects.hasNext())
+                       addToLoadPath(loadPath, (IProject) referencedProjects.next());
+
+               return loadPath.toString();
+       }
+
+       protected void addToLoadPath(StringBuffer loadPath, IProject project) {
+               loadPath.append(" -I " + osDependentPath(project.getLocation().toOSString()));
+       }
 
        protected String osDependentPath(String aPath) {
                if (BootLoader.getOS().equals(BootLoader.OS_WIN32))
@@ -83,5 +86,4 @@ public class InterpreterRunner {
        protected String getDebugCommandLineArgument() {
                return "" ;     
        }
-       
 }
index aab3b86..55c99f3 100644 (file)
@@ -81,7 +81,7 @@ public class InterpreterRunnerConfiguration {
                try {
                        selectedInterpreter = configuration.getAttribute(PHPLaunchConfigurationAttribute.SELECTED_INTERPRETER, "");
                } catch(CoreException e) {}
-               
+
                return PHPRuntime.getDefault().getInterpreter(selectedInterpreter);
        }
 }
index 63accc2..151d5f0 100644 (file)
@@ -43,8 +43,8 @@ public class PHPInterpreter {
                return null;
        }
        
-       public Process exec(String arguments, File workingDirectory) throws IOException {
-               return Runtime.getRuntime().exec(this.getCommand() + " " +  arguments, null, workingDirectory);
+       public Process exec(String arguments, File workingDirectory, String[] env) throws IOException {
+               return Runtime.getRuntime().exec(this.getCommand() + " " +  arguments, env, workingDirectory);
        }
        
        public boolean equals(Object other) {
index 618212e..a1b5e43 100644 (file)
@@ -1,3 +1,14 @@
+/**********************************************************************
+Copyright (c) 2000, 2002 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+       IBM Corporation - Initial implementation
+       Vicente Fernando - www.alfersoft.com.ar
+**********************************************************************/
 package net.sourceforge.phpdt.internal.launching;
 
 import org.eclipse.core.runtime.CoreException;
@@ -11,7 +22,7 @@ import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
 
 public class PHPLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
        protected static final InterpreterRunner interpreterRunner = new InterpreterRunner();
-//     protected static final DebuggerRunner debuggerRunner = new DebuggerRunner();
+       protected static final DebuggerRunner debuggerRunner = new DebuggerRunner();
 
        public PHPLaunchConfigurationDelegate() {
                super();
@@ -23,10 +34,11 @@ public class PHPLaunchConfigurationDelegate implements ILaunchConfigurationDeleg
        public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
                if (PHPRuntime.getDefault().getSelectedInterpreter() == null)
                        throw new CoreException(new Status(IStatus.ERROR, PHPLaunchingPlugin.PLUGIN_ID, IStatus.OK, "You must define an interpreter before running PHP.", null));
-//             if (mode.equals("debug")) {
-//                     debuggerRunner.run(new InterpreterRunnerConfiguration(configuration), launch);
-//             } else {
-                       interpreterRunner.run(new InterpreterRunnerConfiguration(configuration), launch);
-//             }               
+
+               if (mode.equals("debug")) {
+                       debuggerRunner.run(new InterpreterRunnerConfiguration(configuration), launch);
+               } else {
+                       interpreterRunner.run(new InterpreterRunnerConfiguration(configuration), launch, null);
+               }               
        }
 }