1 /**********************************************************************
2 Copyright (c) 2000, 2002 IBM Corp. and others.
3 All rights reserved. This program and the accompanying materials
4 are made available under the terms of the Common Public License v1.0
5 which accompanies this distribution, and is available at
6 http://www.eclipse.org/legal/cpl-v10.html
9 IBM Corporation - Initial implementation
10 Vicente Fernando - www.alfersoft.com.ar
11 Christian Perkonig - remote Debug
12 **********************************************************************/
13 package net.sourceforge.phpdt.internal.launching;
15 import java.util.Iterator;
17 import net.sourceforge.phpdt.internal.core.JavaProject;
18 import net.sourceforge.phpdt.internal.debug.core.PHPDBGProxy;
19 import net.sourceforge.phpdt.internal.debug.core.model.PHPDebugTarget;
21 import org.eclipse.core.resources.IProject;
22 import org.eclipse.debug.core.ILaunch;
23 import org.eclipse.debug.core.model.IProcess;
24 //import net.sourceforge.phpeclipse.resourcesview.PHPProject;
26 public class DebuggerRunner extends InterpreterRunner {
28 public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) {
31 PHPDBGProxy newPHPDBGProxy= new PHPDBGProxy(configuration.useRemoteDebugger(),
32 configuration.getRemoteSourcePath());
36 IProcess process =null;
37 PHPDebugTarget debugTarget = new PHPDebugTarget(launch, process);
38 newPHPDBGProxy.setDebugTarget(debugTarget);
39 newPHPDBGProxy.start();
40 if (configuration.useRemoteDebugger())
42 // listener for remote debuger is started
46 setEnvironmentVariables(configuration,newPHPDBGProxy.getPort());
47 // env=configuration.getEnvironment();
48 process = super.run(configuration, launch);
49 debugTarget.setProcess(process);
51 launch.addDebugTarget(debugTarget);
56 protected void setEnvironmentVariables(InterpreterRunnerConfiguration configuration,int listenPort) {
58 String env[]= new String[18];
59 long id = Math.round(Math.random()*100000);
62 DBGSessID = "DBGSESSID="+id+"@clienthost:" + listenPort;
63 configuration.addEnvironmentValue("HTTP_COOKIE",DBGSessID,false);
64 /* configuration.addEnvironmentValue("REDIRECT_URL",OSFilePath,true);
65 configuration.addEnvironmentValue("REQUEST_URI",OSFilePath,true);
66 configuration.addEnvironmentValue("PATH_INFO",OSFilePath,true);
67 configuration.addEnvironmentValue("PATH_TRANSLATED",OSFilePath,true);
68 configuration.addEnvironmentValue("SCRIPT_FILENAME",interpreter,true);
69 configuration.addEnvironmentValue("SERVER_PROTOCOL","HTTP / 1.1",true);
72 env[0]= "HTTP_COOKIE=" + DBGSessID;
73 env[1]= "REDIRECT_QUERY_STRING=";
74 env[2]= "REDIRECT_STATUS=200";
75 env[3]= "REDIRECT_URL=" + OSFilePath;
76 env[4]= "SERVER_SOFTWARE=DBG / 2.1";
77 env[5]= "SERVER_NAME=localhost";
78 env[6]= "SERVER_ADDR=127.0.0.1";
79 env[7]= "SERVER_PORT=80";
80 env[8]= "REMOTE_ADDR=127.0.0.1";
81 env[9]= "SCRIPT_FILENAME=" + interpreter;
82 env[10]= "GATEWAY_INTERFACE=CGI / 1.1";
83 env[11]= "SERVER_PROTOCOL=HTTP / 1.1";
84 env[12]= "REQUEST_METHOD=GET";
85 env[13]= "QUERY_STRING=test=1";
86 env[14]= "REQUEST_URI=" + OSFilePath;
87 env[15]= "PATH_INFO=" + OSFilePath;
88 env[16]= "PATH_TRANSLATED=" + OSFilePath;
89 env[17]= "SystemRoot=" + Environment.getenv("SystemRoot");
94 protected String getDebugCommandLineArgument() {
98 protected String renderLoadPath(InterpreterRunnerConfiguration configuration) {
99 StringBuffer loadPath = new StringBuffer();
101 JavaProject project = configuration.getProject();
102 addToLoadPath(loadPath, project.getProject());
104 Iterator referencedProjects = project.getReferencedProjects().iterator();
105 while (referencedProjects.hasNext())
106 addToLoadPath(loadPath, (IProject) referencedProjects.next());
108 return loadPath.toString();