aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwgalanciak2014-01-06 14:19:53 (EST)
committerGerrit Code Review @ Eclipse.org2014-01-08 11:33:41 (EST)
commit2f047e4dca9dadf5b28b55d0f3b204153062cefc (patch)
tree416dbc99c6c989168437a3e3c25f666cbaa10ef3
parent64520adb3edacb67c9adff897a372babce2d0e7b (diff)
downloadorg.eclipse.pdt-2f047e4dca9dadf5b28b55d0f3b204153062cefc.zip
org.eclipse.pdt-2f047e4dca9dadf5b28b55d0f3b204153062cefc.tar.gz
org.eclipse.pdt-2f047e4dca9dadf5b28b55d0f3b204153062cefc.tar.bz2
Bug 424936 - Validate debugger during php executable creationrefs/changes/03/20303/2
Change-Id: I6f88eaa1c721095cba8a8831381d7f0f3aa74022 Signed-off-by: wgalanciak <wojciech.galanciak@gmail.com>
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.java6
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.properties3
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/AbstractDebuggerConfiguration.java32
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPexeItem.java16
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/XDebugDebuggerConfiguration.java64
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ZendDebuggerConfiguration.java30
-rw-r--r--plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeCompositeFragment.java18
-rw-r--r--plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeEditDialog.java1
8 files changed, 165 insertions, 5 deletions
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.java
index e5ce0e5..65a2cc1 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.java
@@ -77,6 +77,8 @@ public class PHPDebugCoreMessages extends NLS {
public static String ServerDebugHandler_0;
+ public static String ZendDebuggerConfiguration_ZendDebuggerNotInstalledError;
+
public static String ZendDebuggerConfigurationDialog_client_host_ip;
public static String ZendDebuggerConfigurationDialog_debug_response_timeout;
@@ -168,6 +170,10 @@ public class PHPDebugCoreMessages extends NLS {
public static String XDebug_IDBGpModelConstants_0;
public static String XDebug_IDBGpModelConstants_1;
+ public static String XDebugDebuggerConfiguration_XDebugNotEnabledError;
+
+ public static String XDebugDebuggerConfiguration_XDebugNotInstalledError;
+
static {
// load message values from bundle file
NLS.initializeMessages(BUNDLE_NAME, PHPDebugCoreMessages.class);
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.properties b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.properties
index 9e29fba..a06b9a2 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.properties
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugCoreMessages.properties
@@ -48,6 +48,7 @@ PHPLaunchUtilities_terminate=Terminate
PHPLaunchUtilities_waitingForDebugger=Waiting for the debugger's response...
PHPWebPageLaunchDelegate_0=Debug Error
PHPWebPageLaunchDelegate_serverNotFound=The selected launch uses a nonexistent PHP server ''{0}''. Configure the server from the PHP Servers preferences page (PHP|PHP Servers).
+ZendDebuggerConfiguration_ZendDebuggerNotInstalledError=Zend Debugger extension is not installed.
ZendDebuggerConfigurationDialog_client_host_ip=Client Host/IP:
ZendDebuggerConfigurationDialog_debug_response_timeout=Debug Response Timeout (ms):
ZendDebuggerConfigurationDialog_invalid_response_time=Debug response time must be greater than {0} ms.
@@ -117,3 +118,5 @@ XDebug_DBGpVariable_0=setValue called, but verifyValue failed
XDebug_DBGpVariable_1=program under debug rejected value change
XDebug_IDBGpModelConstants_0=<Invalid>
XDebug_IDBGpModelConstants_1=<Uninitialized>
+XDebugDebuggerConfiguration_XDebugNotEnabledError=XDebug is not enabled. Please add xdebug.remote_enable=1 to php.ini configuration file.
+XDebugDebuggerConfiguration_XDebugNotInstalledError=XDebug extension is not installed. Please visit http://xdebug.org/docs/install to see how to install it.
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/AbstractDebuggerConfiguration.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/AbstractDebuggerConfiguration.java
index 67acfa7..a7bb6b0 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/AbstractDebuggerConfiguration.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/debugger/AbstractDebuggerConfiguration.java
@@ -14,11 +14,15 @@
*/
package org.eclipse.php.internal.debug.core.debugger;
+import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.php.debug.daemon.communication.ICommunicationDaemon;
import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
+import org.eclipse.php.internal.debug.core.preferences.PHPexeItem;
/**
* An abstract implementation of the IDebuggerConfiguration.
@@ -160,4 +164,32 @@ public abstract class AbstractDebuggerConfiguration implements
* Note that the changes affecting the PDT immediately.
*/
public abstract void applyDefaults();
+
+ /**
+ * Validate debugger configuration for specified {@link PHPexeItem}
+ * instance.
+ *
+ * @return validation status
+ */
+ public abstract IStatus validate(PHPexeItem item);
+
+ protected boolean isInstalled(PHPexeItem exeItem, String extensionId) {
+ try {
+ String output = null;
+ File iniFile = exeItem.getINILocation();
+ if (iniFile != null) {
+ output = PHPexeItem.exec(exeItem.getExecutable()
+ .getAbsolutePath(), "-c", iniFile //$NON-NLS-1$
+ .getAbsolutePath(), "--re", extensionId); //$NON-NLS-1$
+ } else {
+ output = PHPexeItem.exec(exeItem.getExecutable()
+ .getAbsolutePath(), "--re", extensionId); //$NON-NLS-1$
+ }
+ return output != null && !output.trim().startsWith("Exception"); //$NON-NLS-1$
+ } catch (IOException e) {
+ PHPDebugPlugin.log(e);
+ }
+ return false;
+ }
+
}
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPexeItem.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPexeItem.java
index 477d797..a3e584c 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPexeItem.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/preferences/PHPexeItem.java
@@ -21,9 +21,12 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
+import org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration;
import org.eclipse.php.internal.debug.core.launching.PHPLaunchUtilities;
import org.eclipse.php.internal.debug.core.phpIni.PHPINIUtil;
@@ -340,6 +343,17 @@ public class PHPexeItem {
phpexes.setItemDefaultForPHPVersion(this, phpVersion);
}
+ public IStatus validateDebugger() {
+ AbstractDebuggerConfiguration[] debuggers = PHPDebuggersRegistry
+ .getDebuggersConfigurations();
+ for (AbstractDebuggerConfiguration debugger : debuggers) {
+ if (getDebuggerID().equals(debugger.getDebuggerId())) {
+ return debugger.validate(this);
+ }
+ }
+ return Status.OK_STATUS;
+ }
+
void addPHPVersionToDefaultList(PHPVersion phpVersion) {
defaultForPHPVersionList.add(phpVersion);
}
@@ -449,7 +463,7 @@ public class PHPexeItem {
* Command array
* @throws IOException
*/
- private static String exec(String... cmd) throws IOException {
+ public static String exec(String... cmd) throws IOException {
String[] envParams = null;
String env = PHPLaunchUtilities
.getLibrarySearchPathEnv(new File(cmd[0]).getParentFile());
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/XDebugDebuggerConfiguration.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/XDebugDebuggerConfiguration.java
index 580e8f3..6ee0ef7 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/XDebugDebuggerConfiguration.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/XDebugDebuggerConfiguration.java
@@ -11,9 +11,18 @@
*******************************************************************************/
package org.eclipse.php.internal.debug.core.xdebug.dbgp;
+import java.io.File;
+import java.io.IOException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.php.internal.debug.core.PHPDebugCoreMessages;
+import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
import org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration;
import org.eclipse.php.internal.debug.core.launching.XDebugExeLaunchConfigurationDelegate;
import org.eclipse.php.internal.debug.core.launching.XDebugWebLaunchConfigurationDelegate;
+import org.eclipse.php.internal.debug.core.preferences.PHPexeItem;
+import org.eclipse.php.internal.debug.core.preferences.PHPexes;
import org.eclipse.php.internal.debug.core.xdebug.XDebugPreferenceMgr;
import org.eclipse.swt.widgets.Shell;
@@ -25,6 +34,9 @@ import org.eclipse.swt.widgets.Shell;
*/
public class XDebugDebuggerConfiguration extends AbstractDebuggerConfiguration {
+ private static final String REMOTE_ENABLE = "remote_enable"; //$NON-NLS-1$
+ private static final String EXTENSION_ID = "xdebug"; //$NON-NLS-1$
+
/**
* Constructs a new XDebugDebuggerConfiguration.
*/
@@ -94,4 +106,56 @@ public class XDebugDebuggerConfiguration extends AbstractDebuggerConfiguration {
XDebugPreferenceMgr.applyDefaults(preferences);
save();
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration
+ * #validate()
+ */
+ public IStatus validate(PHPexeItem item) {
+ File executable = item.getExecutable();
+ try {
+ PHPexes.changePermissions(executable);
+ if (isInstalled(item, EXTENSION_ID)) {
+ String output = null;
+ File iniFile = item.getINILocation();
+ if (iniFile != null) {
+ output = PHPexeItem.exec(executable.getAbsolutePath(),
+ "-c", iniFile.getAbsolutePath(), "--ri", //$NON-NLS-1$ //$NON-NLS-2$
+ EXTENSION_ID);
+ } else {
+ output = PHPexeItem.exec(executable.getAbsolutePath(),
+ "--ri", EXTENSION_ID); //$NON-NLS-1$
+ }
+ if (output != null) {
+ String[] properties = output.split("\n"); //$NON-NLS-1$
+ for (String property : properties) {
+ String[] columns = property.split("=>"); //$NON-NLS-1$
+ if (columns.length == 3
+ && (EXTENSION_ID + '.' + REMOTE_ENABLE)
+ .equals(columns[0].trim())) {
+ String value = columns[1].trim();
+ if (!"on".equalsIgnoreCase(value)) { //$NON-NLS-1$
+ return new Status(
+ IStatus.WARNING,
+ PHPDebugPlugin.ID,
+ PHPDebugCoreMessages.XDebugDebuggerConfiguration_XDebugNotEnabledError);
+ }
+ }
+ }
+ }
+ } else {
+ return new Status(
+ IStatus.WARNING,
+ PHPDebugPlugin.ID,
+ PHPDebugCoreMessages.XDebugDebuggerConfiguration_XDebugNotInstalledError);
+ }
+ } catch (IOException e) {
+ PHPDebugPlugin.log(e);
+ }
+ return Status.OK_STATUS;
+ }
+
} \ No newline at end of file
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ZendDebuggerConfiguration.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ZendDebuggerConfiguration.java
index 3ceec06..b6e7dad 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ZendDebuggerConfiguration.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/zend/debugger/ZendDebuggerConfiguration.java
@@ -14,10 +14,18 @@
*/
package org.eclipse.php.internal.debug.core.zend.debugger;
+import java.io.File;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.php.internal.debug.core.PHPDebugCoreMessages;
+import org.eclipse.php.internal.debug.core.PHPDebugPlugin;
import org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration;
import org.eclipse.php.internal.debug.core.launching.PHPExecutableLaunchDelegate;
import org.eclipse.php.internal.debug.core.launching.PHPWebPageLaunchDelegate;
import org.eclipse.php.internal.debug.core.preferences.PHPDebugCorePreferenceNames;
+import org.eclipse.php.internal.debug.core.preferences.PHPexeItem;
+import org.eclipse.php.internal.debug.core.preferences.PHPexes;
import org.eclipse.swt.widgets.Shell;
/**
@@ -28,6 +36,8 @@ import org.eclipse.swt.widgets.Shell;
*/
public class ZendDebuggerConfiguration extends AbstractDebuggerConfiguration {
+ private static final String EXTENSION_ID = "zend_debugger"; //$NON-NLS-1$
+
/**
* Constructs a new ZendDebuggerConfiguration.
*/
@@ -111,4 +121,24 @@ public class ZendDebuggerConfiguration extends AbstractDebuggerConfiguration {
.getDefaultBoolean(PHPDebugCorePreferenceNames.RUN_WITH_DEBUG_INFO));
save();
}
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.php.internal.debug.core.debugger.AbstractDebuggerConfiguration
+ * #validate()
+ */
+ public IStatus validate(PHPexeItem item) {
+ File executable = item.getExecutable();
+ PHPexes.changePermissions(executable);
+ if (!isInstalled(item, EXTENSION_ID)) {
+ return new Status(
+ IStatus.WARNING,
+ PHPDebugPlugin.ID,
+ PHPDebugCoreMessages.ZendDebuggerConfiguration_ZendDebuggerNotInstalledError);
+ }
+ return Status.OK_STATUS;
+ }
+
}
diff --git a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeCompositeFragment.java b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeCompositeFragment.java
index 5a36c67..48236d3 100644
--- a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeCompositeFragment.java
+++ b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeCompositeFragment.java
@@ -16,6 +16,7 @@ import java.util.LinkedList;
import java.util.List;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IMessageProvider;
@@ -333,7 +334,8 @@ public class PHPExeCompositeFragment extends CompositeFragment implements
IMessageProvider.ERROR);
return;
}
- if (!executableLocation.getName().toLowerCase().contains("php")) { //$NON-NLS-1$
+ if (!executableLocation.getName().toLowerCase().contains("php") //$NON-NLS-1$
+ || executableLocation.isDirectory()) {
setMessage(PHPDebugUIMessages.PHPExeCompositeFragment_13,
IMessageProvider.ERROR);
return;
@@ -398,13 +400,23 @@ public class PHPExeCompositeFragment extends CompositeFragment implements
phpExeItem.setINILocation(iniFile);
phpExeItem.setSapiType(sapiType);
- setMessage(getDescription(), IMessageProvider.NONE);
+ IStatus status = phpExeItem.validateDebugger();
+ if (status.getSeverity() != IStatus.OK) {
+ if (status.getSeverity() == IStatus.ERROR) {
+ setMessage(status.getMessage(), IMessageProvider.ERROR);
+ return;
+ } else {
+ setMessage(status.getMessage(), IMessageProvider.WARNING);
+ }
+ } else {
+ setMessage(getDescription(), IMessageProvider.NONE);
+ }
controlHandler.update();
}
protected void setMessage(String message, int type) {
controlHandler.setMessage(message, type);
- setComplete(type == IMessageProvider.NONE);
+ setComplete(type != IMessageProvider.ERROR);
controlHandler.update();
}
diff --git a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeEditDialog.java b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeEditDialog.java
index b57c96f..6226ddd 100644
--- a/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeEditDialog.java
+++ b/plugins/org.eclipse.php.debug.ui/src/org/eclipse/php/internal/debug/ui/wizards/PHPExeEditDialog.java
@@ -97,7 +97,6 @@ public class PHPExeEditDialog extends TitleAreaDialog implements
CompositeFragment fragment = (CompositeFragment) item
.getControl();
setTitle(fragment.getTitle());
- setDescription(fragment.getDescription());
}
});
return tabs;