aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry BLIND2018-05-04 04:54:52 -0400
committerThierry BLIND2018-05-11 17:17:55 -0400
commitefeae5c7aac8dd7c6ace1f13fd1b8fb4372384e0 (patch)
tree0c5d12f09d80713bff93ac1b6dfa602f769a0db7
parent06369fb0ea3d484a80ae5390b2faa0df093d9e70 (diff)
downloadorg.eclipse.pdt-efeae5c7aac8dd7c6ace1f13fd1b8fb4372384e0.tar.gz
org.eclipse.pdt-efeae5c7aac8dd7c6ace1f13fd1b8fb4372384e0.tar.xz
org.eclipse.pdt-efeae5c7aac8dd7c6ace1f13fd1b8fb4372384e0.zip
Bug 534323 - [XDebug] deadlock while stopping/starting a debug session
Signed-off-by: Thierry BLIND <thierryblind@msn.com>
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugUtil.java47
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpMultiSessionTarget.java4
-rw-r--r--plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpTarget.java4
3 files changed, 44 insertions, 11 deletions
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugUtil.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugUtil.java
index 441e93fcd..033476c0b 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugUtil.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/PHPDebugUtil.java
@@ -59,6 +59,26 @@ public final class PHPDebugUtil {
* @throws MalformedURLException
*/
public static void openLaunchURL(final String launchURL) throws DebugException {
+ openLaunchURL(launchURL, true);
+ }
+
+ /**
+ * Opens URL from debug/run launch configuration, through a synchronous or an
+ * asynchronous UI thread call. When the UI thread is unavailable, the URL is
+ * always handled synchronously in a non-graphical way. Users of this method
+ * should handle exceptions that might be thrown but without need to log the
+ * exception info (it is already handled by this implementation). <b>Note that
+ * exceptions are only thrown when parameter doSyncExec is set to true or when
+ * the UI thread is unavailable.</b>
+ *
+ * @param launchURL
+ * @param doSyncExec
+ * opens URL synchronously when true, asynchronously
+ * otherwise
+ * @throws DebugException
+ * @throws MalformedURLException
+ */
+ public static void openLaunchURL(final String launchURL, final boolean doSyncExec) throws DebugException {
// If no display is available, it means eclipse is shutting down,
// try then to call the URL in a non-graphical way
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=517792
@@ -86,10 +106,9 @@ public final class PHPDebugUtil {
return;
}
- final SyncObject<DebugException> e = new SyncObject<>();
+ final SyncObject<DebugException> e = doSyncExec ? new SyncObject<>() : null;
- // Run synchronously to pass exception if any
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ Runnable r = new Runnable() {
@Override
public void run() {
try {
@@ -117,14 +136,24 @@ public final class PHPDebugUtil {
launchURL),
t);
String errorMessage = PHPDebugCoreMessages.Debugger_Unexpected_Error_1;
- e.set(new DebugException(new Status(IStatus.ERROR, PHPDebugPlugin.getID(),
- IPHPDebugConstants.INTERNAL_ERROR, errorMessage, t)));
+ if (e != null) {
+ e.set(new DebugException(new Status(IStatus.ERROR, PHPDebugPlugin.getID(),
+ IPHPDebugConstants.INTERNAL_ERROR, errorMessage, t)));
+ }
}
}
- });
- DebugException ex = e.get();
- if (ex != null) {
- throw ex;
+ };
+
+ if (doSyncExec) {
+ // Run synchronously to pass exception if any
+ PlatformUI.getWorkbench().getDisplay().syncExec(r);
+ @SuppressWarnings("null")
+ DebugException ex = e.get();
+ if (ex != null) {
+ throw ex;
+ }
+ } else {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(r);
}
}
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpMultiSessionTarget.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpMultiSessionTarget.java
index ab6957a4b..6cb53701a 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpMultiSessionTarget.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpMultiSessionTarget.java
@@ -491,7 +491,9 @@ public class DBGpMultiSessionTarget extends DBGpElement
}
DBGpLogger.debug("browser is not null, sending " + stopDebugURL); //$NON-NLS-1$
try {
- PHPDebugUtil.openLaunchURL(stopDebugURL);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=534323
+ // launch asynchronously
+ PHPDebugUtil.openLaunchURL(stopDebugURL, false);
} catch (DebugException e) {
DBGpLogger.logException("Failed to send stop XDebug session URL: " + stopDebugURL, //$NON-NLS-1$
this, e);
diff --git a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpTarget.java b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpTarget.java
index 50bbd633d..f6a0b6b15 100644
--- a/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpTarget.java
+++ b/plugins/org.eclipse.php.debug.core/src/org/eclipse/php/internal/debug/core/xdebug/dbgp/model/DBGpTarget.java
@@ -712,7 +712,9 @@ public class DBGpTarget extends DBGpElement
}
DBGpLogger.debug("browser is not null, sending " + stopDebugURL); //$NON-NLS-1$
try {
- PHPDebugUtil.openLaunchURL(stopDebugURL);
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=534323
+ // launch asynchronously
+ PHPDebugUtil.openLaunchURL(stopDebugURL, false);
} catch (DebugException e) {
DBGpLogger.logException("Failed to send stop XDebug session URL: " + stopDebugURL, this, e); //$NON-NLS-1$
}