Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormspector2007-07-19 09:21:52 -0400
committermspector2007-07-19 09:21:52 -0400
commitb2dac389ceffb8c12646e984a3c681b535ae2082 (patch)
tree59dca8a054c5c5688384f5d98b140bc3ddc51ec5
parent54a1f245f8daa8a459df660ad4473dd035b9d8fa (diff)
downloadorg.eclipse.pdt-b2dac389ceffb8c12646e984a3c681b535ae2082.tar.gz
org.eclipse.pdt-b2dac389ceffb8c12646e984a3c681b535ae2082.tar.xz
org.eclipse.pdt-b2dac389ceffb8c12646e984a3c681b535ae2082.zip
Add missing LD_LIBRARY_PATH environment variable when debugging using internal debugger
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/PHPExecutableDebuggerInitializer.java215
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java338
2 files changed, 553 insertions, 0 deletions
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/PHPExecutableDebuggerInitializer.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/PHPExecutableDebuggerInitializer.java
new file mode 100644
index 000000000..36a07a325
--- /dev/null
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/PHPExecutableDebuggerInitializer.java
@@ -0,0 +1,215 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend and IBM - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.debug.core.debugger;
+
+import java.io.*;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.php.internal.debug.core.PHPDebugCoreMessages;
+import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
+import org.eclipse.swt.widgets.Display;
+
+public class PHPExecutableDebuggerInitializer {
+
+ private HashMap systemEnvironmentVariables = null;
+ private ILaunch launch;
+
+ public PHPExecutableDebuggerInitializer(ILaunch launch) throws IOException {
+ this.launch = launch;
+ // Set a launch attribute to indicate that this is an executable launch.
+ initializeSystemEnvironmentVariables();
+ }
+
+ public PHPExecutableDebuggerInitializer() throws IOException {
+ // Set a launch attribute to indicate that this is an executable launch.
+ initializeSystemEnvironmentVariables();
+ }
+
+ public void initializeDebug(String phpExe, String fileName, String query) {
+
+ initializeDebug(phpExe, fileName, query, null, null);
+ }
+
+ public void initializeDebug(String phpExe, String fileName, String query, Map envVariables, String phpIniLocation) {
+ try {
+ IPath phpExePath = new Path(phpExe);
+ File workingDir = new File(phpExePath.removeLastSegments(1).toString());
+ String phpConfigDir = workingDir.getAbsolutePath();
+ if (phpIniLocation != null && !phpIniLocation.equals("")) {
+ phpConfigDir = phpIniLocation;
+ }
+
+ // Important!!!
+ // Note that php executable -c parameter (for php 4) must get the path to the directory that contains the php.ini file.
+ // We cannot use a full path to the php.ini file nor modify the file name! (for example php.temp.ini).
+ phpConfigDir = (new File(phpConfigDir)).getParentFile().getAbsolutePath();
+
+ systemEnvironmentVariables.put("REQUEST_METHOD", "GET");
+ systemEnvironmentVariables.put("SCRIPT_FILENAME", fileName);
+ systemEnvironmentVariables.put("SCRIPT_NAME", fileName);
+ systemEnvironmentVariables.put("PATH_TRANSLATED", fileName);
+ systemEnvironmentVariables.put("PATH_INFO", fileName);
+ systemEnvironmentVariables.put("QUERY_STRING", query + "&debug_host=127.0.0.1");
+ systemEnvironmentVariables.put("REDIRECT_STATUS", "1");
+ systemEnvironmentVariables.put("PHPRC", phpConfigDir);
+ if (envVariables != null) {
+ systemEnvironmentVariables.putAll(envVariables);
+ }
+
+ String OS = System.getProperty("os.name");
+ if (!OS.startsWith("Win")) {
+ if (OS.startsWith("Mac")) { //$NON-NLS-1$ //$NON-NLS-2$
+ systemEnvironmentVariables.put("DYLD_LIBRARY_PATH", workingDir.getAbsolutePath()); //$NON-NLS-1$
+ } else {
+ systemEnvironmentVariables.put("LD_LIBRARY_PATH", workingDir.getAbsolutePath()); //$NON-NLS-1$
+ }
+ }
+
+ String[] combinedEnvVars = mapAsArray(systemEnvironmentVariables);
+
+ String[] phpCmdArray = { phpExe, "-c", phpConfigDir, fileName };
+ Process p = Runtime.getRuntime().exec(phpCmdArray, combinedEnvVars, workingDir);
+
+ Runnable reader = new ProcessOutputReader(p);
+ new Thread(reader).start();
+
+ } catch (final Exception e) {
+ final Display display = Display.getDefault();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ String message = e.getLocalizedMessage();
+ message = message.replaceFirst(e.getClass().getName() + ": ", "");
+ MessageDialog.openError(display.getActiveShell(), "Error", NLS.bind("Error running PHP executable:\n\n{0}", message));
+ }
+ });
+ DebugPlugin.log(e);
+ }
+ }
+
+ private String[] mapAsArray(Map map) {
+ String[] strArr = new String[map.size()];
+ Iterator entries = map.entrySet().iterator();
+ int index = 0;
+ while (entries.hasNext()) {
+ Entry entry = (Entry) entries.next();
+ strArr[index++] = entry.getKey() + "=" + entry.getValue();
+ }
+ return strArr;
+ }
+
+ private void initializeSystemEnvironmentVariables() throws IOException {
+ ArrayList list = new ArrayList();
+ Process p;
+ Runtime r = Runtime.getRuntime();
+ String OS = System.getProperty("os.name").toLowerCase();
+ if (OS.indexOf("windows") > -1) {
+ if (OS.indexOf("windows 9") > -1) {
+ p = r.exec("command.com /c set");
+ } else {
+ p = r.exec("cmd.exe /c set");
+ }
+ } else if (OS.indexOf("linux") > -1) {
+ p = r.exec("env");
+ } else if (OS.indexOf("unix") > -1) {
+ p = r.exec("/bin/env");
+ } else if (OS.indexOf("sunos") > -1) {
+ p = r.exec("/bin/env");
+ } else if (OS.indexOf("mac") > -1) {
+ try {
+ p = r.exec("env");
+ } catch (IOException e) {
+ p = r.exec("setenv");
+ }
+ } else if (OS.indexOf("freebsd") > -1) {
+ p = r.exec("set");
+ } else {
+ System.out.println("OS not known: " + OS);
+ systemEnvironmentVariables = new HashMap(0);
+ return;
+ }
+ BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+ String line;
+ while ((line = br.readLine()) != null) {
+ list.add(line);
+ }
+ br.close();
+ systemEnvironmentVariables = new HashMap();
+ for (int i = 0; i < list.size(); i++) {
+ String[] env = ((String) list.get(i)).split("=");
+ if (env.length == 2) {
+ systemEnvironmentVariables.put(env[0], env[1]);
+ } else {
+ if (env.length == 1) {
+ systemEnvironmentVariables.put(env[0], "");
+ }
+ }
+ }
+ }
+
+ // the reader reads the output of the process
+ private class ProcessOutputReader implements Runnable {
+ Process p;
+
+ ProcessOutputReader(Process p) {
+ this.p = p;
+ }
+
+ public void run() {
+ try {
+ byte buff[] = new byte[1000];
+ InputStream in = p.getInputStream();
+ int c = in.read(buff);
+ while (c > 0) {
+ c = in.read(buff);
+ }
+ in = p.getErrorStream();
+ c = in.read(buff);
+ while (c != -1) {
+ c = in.read(buff);
+ }
+ } catch (IOException exc) {
+ PHPDebugPlugin.log(exc);
+ }
+ // In case this thread ended and we do not have any IDebugTarget (PHPDebugTarget) hooked in the
+ // launch that was created, we can tell that there is something wrong, and probably there is no debugger
+ // installed (e.g. the debugger dll/so is not properly configured in the php.ini).
+ if (launch != null && launch.getDebugTarget() == null) {
+ String launchName = launch.getLaunchConfiguration().getName();
+ boolean isRunMode = ILaunchManager.RUN_MODE.equals(launch.getLaunchMode());
+ String msg = null;
+ if (isRunMode) {
+ msg = MessageFormat.format(PHPDebugCoreMessages.Debugger_Error_Message_3, new String[] { launchName });
+ } else {
+ msg = MessageFormat.format(PHPDebugCoreMessages.Debugger_Error_Message_2, new String[] { launchName });
+ }
+ final String message = msg;
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openWarning(Display.getDefault().getActiveShell(), PHPDebugCoreMessages.Debugger_Error, message);
+ DebugPlugin.getDefault().getLaunchManager().removeLaunch(launch);
+ }
+ });
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java
new file mode 100644
index 000000000..dea94b28c
--- /dev/null
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/launching/PHPExecutableLaunchDelegate.java
@@ -0,0 +1,338 @@
+/*******************************************************************************
+ * Copyright (c) 2006 Zend Corporation and IBM Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Zend and IBM - Initial implementation
+ *******************************************************************************/
+package org.eclipse.php.internal.debug.core.launching;
+
+import java.io.File;
+import java.text.MessageFormat;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.*;
+import org.eclipse.debug.core.*;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.LaunchConfigurationDelegate;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.RefreshTab;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.php.debug.core.debugger.parameters.IDebugParametersInitializer;
+import org.eclipse.php.debug.core.debugger.parameters.IDebugParametersKeys;
+import org.eclipse.php.internal.core.PHPCoreConstants;
+import org.eclipse.php.internal.core.phpIni.IniModifier;
+import org.eclipse.php.internal.core.project.PHPNature;
+import org.eclipse.php.internal.core.resources.ExternalFilesRegistry;
+import org.eclipse.php.internal.debug.core.IPHPConstants;
+import org.eclipse.php.internal.debug.core.Logger;
+import org.eclipse.php.internal.debug.core.PHPDebugCoreMessages;
+import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
+import org.eclipse.php.internal.debug.core.debugger.DebugParametersInitializersRegistry;
+import org.eclipse.php.internal.debug.core.debugger.PHPExecutableDebuggerInitializer;
+import org.eclipse.php.internal.debug.core.debugger.PHPSessionLaunchMapper;
+import org.eclipse.php.internal.debug.core.model.DebugSessionIdGenerator;
+import org.eclipse.php.internal.debug.core.preferences.PHPProjectPreferences;
+import org.eclipse.php.internal.debug.daemon.DaemonPlugin;
+import org.eclipse.swt.widgets.Display;
+
+public class PHPExecutableLaunchDelegate extends LaunchConfigurationDelegate {
+ /** Constant value indicating if the current platform is Windows */
+ private static final boolean WINDOWS = java.io.File.separatorChar == '\\';
+ public static final String SAVE_AUTOMATICALLY = "save_automatically";
+
+ /** Indicator for an executable ILaunch (inserted into the launch attributes) */
+ public static final String EXECUTABLE_LAUNCH = "executable_launch";
+
+ protected Map envVariables = null;
+
+ /**
+ * Override the extended getLaunch to create a PHPLaunch.
+ */
+ public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
+ return new PHPLaunch(configuration, mode, null);
+ }
+
+ public void debugPHPExecutable(final ILaunch launch, final String phpExe, final String fileToDebug) throws DebugException {
+ try {
+ launch.setAttribute(EXECUTABLE_LAUNCH, "true");
+ IDebugParametersInitializer parametersInitializer = DebugParametersInitializersRegistry.getBestMatchDebugParametersInitializer(launch);
+ final PHPExecutableDebuggerInitializer debuggerInitializer = new PHPExecutableDebuggerInitializer(launch);
+ debuggerInitializer.initializeDebug(new File(phpExe).getAbsolutePath(), new File(fileToDebug).getAbsolutePath(), parametersInitializer.generateQuery(launch), envVariables, launch.getAttribute(IDebugParametersKeys.PHP_INI_LOCATION));
+ } catch (final java.io.IOException e1) {
+ Logger.logException("PHPDebugTarget: Debugger didn't find file to debug.", e1);
+ final String errorMessage = PHPDebugCoreMessages.DebuggerFileNotFound_1;
+ throw new DebugException(new Status(IStatus.ERROR, PHPDebugPlugin.getID(), IPHPConstants.INTERNAL_ERROR, errorMessage, e1));
+ }
+ }
+
+ public void launch(final ILaunchConfiguration configuration, final String mode, final ILaunch launch, final IProgressMonitor monitor) throws CoreException {
+ // Check that the debug daemon is functional
+ if (!DaemonPlugin.getDefault().validateCommunicationDaemons()) {
+ monitor.setCanceled(true);
+ monitor.done();
+ return;
+ }
+ // Check for previous launches.
+ if (!PHPLaunchUtilities.notifyPreviousLaunches(launch)) {
+ monitor.setCanceled(true);
+ monitor.done();
+ return;
+ }
+ PHPLaunchUtilities.showDebugView();
+ IProgressMonitor subMonitor; // the total of monitor is 100
+ if (monitor.isCanceled())
+ return;
+
+ final String phpExeString = configuration.getAttribute(PHPCoreConstants.ATTR_LOCATION, (String) null);
+ final String projectName = configuration.getAttribute(PHPCoreConstants.ATTR_WORKING_DIRECTORY, (String) null);
+ final String fileNameString = configuration.getAttribute(PHPCoreConstants.ATTR_FILE, (String) null);
+ final boolean runWithDebugInfo = configuration.getAttribute(IPHPConstants.RUN_WITH_DEBUG_INFO, true);
+
+ if (monitor.isCanceled())
+ return;
+
+ if (fileNameString == null || fileNameString.equals(""))
+ return;
+
+ final IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ final IPath filePath = new Path(fileNameString);
+ IProject project = null;
+ IProject dummyProject = null;
+ String absolutePath = null;
+ if (projectName == null) {
+ IResource res = workspaceRoot.findMember(filePath);
+ if (res == null && (!WINDOWS || filePath.getDevice() != null)) {
+ // Get a dummy project because we are probably executing a file that is located out
+ // of the workspace.
+ dummyProject = ExternalFilesRegistry.getInstance().getExternalFilesProject();
+ project = dummyProject;
+ absolutePath = filePath.makeAbsolute().toString();
+ } else {
+ if (res == null || !res.isAccessible()) {
+ displayErrorMessage(NLS.bind(PHPDebugCoreMessages.Debugger_ResourceNotFound, filePath));
+ return;
+ }
+ }
+ if (project == null) {
+ project = res.getProject();
+ absolutePath = res.getLocation().toString();
+ }
+ if (project == null) {
+ displayErrorMessage(NLS.bind(PHPDebugCoreMessages.Debugger_InvalidDebugResource, filePath));
+ return;
+ }
+ } else {
+ try {
+ final IPath projectPath = new Path(projectName);
+ project = workspaceRoot.getProject(projectPath.lastSegment());
+ absolutePath = filePath.makeAbsolute().toString();
+ } catch (final Exception e) {
+ }
+ }
+
+ if (project == null || (!project.isAccessible() && project != dummyProject)) {
+ displayErrorMessage(NLS.bind(PHPDebugCoreMessages.Debugger_InvalidDebugResource, filePath));
+ return;
+ }
+
+ subMonitor = new SubProgressMonitor(monitor, 10); // 10 of 100
+ // if (!saveFiles(project, monitor)) {
+ // return;
+ // }
+ File phpIni = IniModifier.findPHPIni(phpExeString);
+ if (project != dummyProject && project.hasNature(PHPNature.ID)) {
+ if (phpIni != null) {
+ File tempIni = IniModifier.addIncludePath(phpIni, project);
+ if (tempIni != null) {
+ launch.setAttribute(IDebugParametersKeys.PHP_INI_LOCATION, tempIni.getAbsolutePath());
+ }
+ }
+ } else {
+ if (phpIni != null) {
+ launch.setAttribute(IDebugParametersKeys.PHP_INI_LOCATION, phpIni.getAbsolutePath());
+ }
+ }
+
+ if (mode.equals(ILaunchManager.DEBUG_MODE) || runWithDebugInfo == true) {
+ boolean stopAtFirstLine = false;
+ if (configuration.getAttribute(IDebugParametersKeys.OVERRIDE_FIRST_LINE_BREAKPOINT, false)) {
+ stopAtFirstLine = configuration.getAttribute(IDebugParametersKeys.FIRST_LINE_BREAKPOINT, false);
+ } else {
+ stopAtFirstLine = PHPProjectPreferences.getStopAtFirstLine(project);
+ }
+ final int requestPort = PHPProjectPreferences.getDebugPort(project);
+
+ // Set Project Name
+ final String projectString = project.getFullPath().toString();
+
+ ILaunchConfigurationWorkingCopy wc;
+ if (configuration.isWorkingCopy())
+ wc = (ILaunchConfigurationWorkingCopy) configuration;
+ else
+ wc = configuration.getWorkingCopy();
+ wc.setAttribute(IPHPConstants.PHP_Project, projectString);
+
+ // Set transfer encoding:
+ wc.setAttribute(IDebugParametersKeys.TRANSFER_ENCODING, PHPProjectPreferences.getTransferEncoding(project));
+ wc.setAttribute(IDebugParametersKeys.OUTPUT_ENCODING, PHPProjectPreferences.getOutputEncoding(project));
+ wc.doSave();
+
+ if (monitor.isCanceled())
+ return;
+
+ // Generate a session id for this launch and put it in the map
+ final int sessionID = DebugSessionIdGenerator.generateSessionID();
+ PHPSessionLaunchMapper.put(sessionID, launch);
+
+ // Define all needed debug attributes:
+ launch.setAttribute(IDebugParametersKeys.PORT, Integer.toString(requestPort));
+ launch.setAttribute(IDebugParametersKeys.FIRST_LINE_BREAKPOINT, Boolean.toString(stopAtFirstLine));
+ launch.setAttribute(IDebugParametersKeys.SESSION_ID, Integer.toString(sessionID));
+
+ // Trigger the debug session by initiating a debug requset to the php.exe
+ debugPHPExecutable(launch, phpExeString, absolutePath);
+ } else {
+ // resolve location
+ final IPath phpExe = new Path(phpExeString);
+
+ if (monitor.isCanceled())
+ return;
+
+ // resolve working directory
+ // String projectFolderString = configuration.getAttribute(PHPCoreConstants.ATTR_WORKING_DIRECTORY, (String)null);
+
+ IPath projectLocation = project.getRawLocation();
+ if (projectLocation == null)
+ projectLocation = project.getLocation();
+
+ if (monitor.isCanceled())
+ return;
+
+ // String fileNameString = configuration.getAttribute(PHPCoreConstants.ATTR_FILE, (String)null);
+ IPath phpFile = new Path(fileNameString);
+ if (fileNameString.startsWith("/"))
+ phpFile = phpFile.removeFirstSegments(1);
+
+ if (monitor.isCanceled())
+ return;
+
+ String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(configuration);
+
+ if (monitor.isCanceled())
+ return;
+
+ File workingDir = new File(phpExe.removeLastSegments(1).toString());
+ String phpConfigDir = workingDir.getAbsolutePath();
+
+ String phpIniLocation = launch.getAttribute(IDebugParametersKeys.PHP_INI_LOCATION);
+ if (phpIniLocation != null && !phpIniLocation.equals("")) {
+ phpConfigDir = phpIniLocation;
+ }
+ final IResource res = workspaceRoot.findMember(filePath);
+ String fileName = null;
+ if (res != null) {
+ fileName = res.getLocation().toOSString();
+ } else {
+ fileName = filePath.toOSString();
+ }
+
+ // Set library search path:
+ if (!WINDOWS) {
+ StringBuffer buf = new StringBuffer();
+ if (System.getProperty("os.name").startsWith("Mac")) { //$NON-NLS-1$ //$NON-NLS-2$
+ buf.append("DYLD_LIBRARY_PATH"); //$NON-NLS-1$
+ } else {
+ buf.append("LD_LIBRARY_PATH"); //$NON-NLS-1$
+ }
+ buf.append('=');
+ buf.append(workingDir.getAbsolutePath());
+ String[] envpNew = new String[envp == null ? 1 : envp.length + 1];
+ if (envp != null) {
+ System.arraycopy(envp, 0, envpNew, 0, envp.length);
+ }
+ envpNew[envpNew.length - 1] = buf.toString();
+ envp = envpNew;
+ }
+
+ final String[] cmdLine = new String[] { phpExe.toOSString(), "-c", phpConfigDir, fileName };
+
+ final Process p = DebugPlugin.exec(cmdLine, workingDir, envp);
+ IProcess process = null;
+
+ // add process type to process attributes
+ final Map processAttributes = new HashMap();
+ String programName = phpExe.lastSegment();
+ final String extension = phpExe.getFileExtension();
+ if (extension != null)
+ programName = programName.substring(0, programName.length() - (extension.length() + 1));
+ programName = programName.toLowerCase();
+ processAttributes.put(IProcess.ATTR_PROCESS_TYPE, programName);
+
+ if (p != null) {
+ subMonitor = new SubProgressMonitor(monitor, 80); // 10+80 of 100;
+ subMonitor.beginTask(MessageFormat.format("start launch", new String[] { configuration.getName() }), IProgressMonitor.UNKNOWN); //$NON-NLS-1$
+ process = DebugPlugin.newProcess(launch, p, phpExe.toOSString(), processAttributes);
+ if (process == null) {
+ p.destroy();
+ throw new CoreException(new Status(IStatus.ERROR, PHPDebugPlugin.getID(), 0, null, null));
+ }
+ subMonitor.done();
+
+ }
+ process.setAttribute(IProcess.ATTR_CMDLINE, fileNameString);
+
+ if (CommonTab.isLaunchInBackground(configuration)) {
+ // refresh resources after process finishes
+ /*
+ if (RefreshTab.getRefreshScope(configuration) != null) {
+ BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(configuration, process);
+ refresher.startBackgroundRefresh();
+ }
+ */
+ } else {
+ // wait for process to exit
+ while (!process.isTerminated())
+ try {
+ if (monitor.isCanceled()) {
+ process.terminate();
+ break;
+ }
+ Thread.sleep(50);
+ } catch (final InterruptedException e) {
+ }
+
+ // refresh resources
+ subMonitor = new SubProgressMonitor(monitor, 10); // 10+80+10 of 100;
+ RefreshTab.refreshResources(configuration, subMonitor);
+ }
+ }
+
+ }
+
+ private void displayErrorMessage(final String message) {
+ final Display display = Display.getDefault();
+ display.asyncExec(new Runnable() {
+ public void run() {
+ MessageDialog.openError(display.getActiveShell(), PHPDebugCoreMessages.Debugger_LaunchError_title, message);
+ }
+ });
+ }
+ //
+ // protected boolean saveBeforeLaunch(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
+ // if (configuration.getAttribute(PHPExecutableLaunchDelegate.SAVE_AUTOMATICALLY, false)) {
+ // return true;
+ // }
+ // return super.buildForLaunch(configuration, mode, monitor);
+ // }
+
+}

Back to the top