return;
}
// determine the environment variables
String[] envVarString = null;
DBGpTarget target = null;
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
// check the launch for stop at first line, if not there go to
// project specifics
boolean stopAtFirstLine = PHPProjectPreferences
.getStopAtFirstLine(project);
stopAtFirstLine = configuration
.getAttribute(IDebugParametersKeys.FIRST_LINE_BREAKPOINT,
stopAtFirstLine);
String sessionID = DBGpSessionHandler.getInstance()
.generateSessionId();
String ideKey = null;
if (DBGpProxyHandler.instance.useProxy()) {
ideKey = DBGpProxyHandler.instance.getCurrentIdeKey();
if (DBGpProxyHandler.instance.registerWithProxy() == false) {
displayErrorMessage(PHPDebugCoreMessages.XDebug_ExeLaunchConfigurationDelegate_2
+ DBGpProxyHandler.instance.getErrorMsg());
DebugPlugin.getDefault().getLaunchManager()
.removeLaunch(launch);
return;
}
} else {
ideKey = DBGpSessionHandler.getInstance().getIDEKey();
}
target = new DBGpTarget(launch, phpFile.lastSegment(), ideKey,
sessionID, stopAtFirstLine);
target.setPathMapper(PathMapperRegistry
.getByLaunchConfiguration(configuration));
DBGpSessionHandler.getInstance().addSessionListener(target);
envVarString = createDebugLaunchEnvironment(configuration,
sessionID, ideKey, phpExe);
} else {
envVarString = PHPLaunchUtilities.getEnvironment(configuration,
new String[] { getLibraryPath(phpExe) });
}
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 30);
subMonitor.beginTask(
PHPDebugCoreMessages.XDebug_ExeLaunchConfigurationDelegate_3,
10);
// determine the working directory. default is the location of the
// script
IPath workingPath = phpFile.removeLastSegments(1);
File workingDir = workingPath.makeAbsolute().toFile();
boolean found = false;
for (int i = 0; i < envVarString.length && !found; i++) {
String envEntity = envVarString[i];
String[] elements = envEntity.split("="); //$NON-NLS-1$
if (elements.length > 0 && elements[0].equals("XDEBUG_WORKING_DIR")) { //$NON-NLS-1$
found = true;
workingPath = new Path(elements[1]);
File temp = workingPath.makeAbsolute().toFile();
if (temp.exists()) {
workingDir = temp;
}
}
}
// Detect PHP SAPI type and thus where we need arguments
File phpExeFile = new File(phpExeString);
String sapiType = null;
String phpV = null;
PHPexeItem[] items = PHPexes.getInstance().getAllItems();
for (PHPexeItem item : items) {
if (item.getExecutable().equals(phpExeFile)) {
sapiType = item.getSapiType();
phpV = item.getVersion();
break;
}
}
String[] args = null;
if (PHPexeItem.SAPI_CLI.equals(sapiType)) {
args = PHPLaunchUtilities.getProgramArguments(launch
.getLaunchConfiguration());
}
// define the command line for launching
String[] cmdLine = null;
cmdLine = PHPLaunchUtilities.getCommandLine(configuration,
phpExe.toOSString(), tempIni.toString(), phpFile.toOSString(),
args, phpV);
// Launch the process
final Process phpExeProcess = DebugPlugin.exec(cmdLine, workingDir,
envVarString);
// Attach a crash detector
new Thread(new ProcessCrashDetector(launch, phpExeProcess)).start();
IProcess eclipseProcessWrapper = null;
if (phpExeProcess != null) {
subMonitor.worked(10);
eclipseProcessWrapper = DebugPlugin.newProcess(launch,
phpExeProcess, phpExe.toOSString(), processAttributes);
if (eclipseProcessWrapper == null) {
// another error so we stop everything somehow
phpExeProcess.destroy();
subMonitor.done();
DebugPlugin.getDefault().getLaunchManager()
.removeLaunch(launch);
throw new CoreException(new Status(IStatus.ERROR,
PHPDebugPlugin.ID, 0, null, null));
}
// if launching in debug mode, create the debug infrastructure and
// link it with the launched process
if (mode.equals(ILaunchManager.DEBUG_MODE) && target != null) {
target.setProcess(eclipseProcessWrapper);
launch.addDebugTarget(target);
subMonitor
.subTask(PHPDebugCoreMessages.XDebug_ExeLaunchConfigurationDelegate_4);
target.waitForInitialSession(
(DBGpBreakpointFacade) IDELayerFactory.getIDELayer(),
XDebugPreferenceMgr.createSessionPreferences(), monitor);
}
} else {