summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Dushistova2012-01-27 10:37:19 (EST)
committer Marc Khouzam2012-01-27 11:45:01 (EST)
commit13d3bad2dec3762cc90d7380749328be51a63164 (patch)
tree96d49b01df10bf419ae1ca953bb6a7ac7c663ee6
parentccd531c1775a8013cba813999e86e4250e6218d4 (diff)
downloadorg.eclipse.cdt-13d3bad2dec3762cc90d7380749328be51a63164.zip
org.eclipse.cdt-13d3bad2dec3762cc90d7380749328be51a63164.tar.gz
org.eclipse.cdt-13d3bad2dec3762cc90d7380749328be51a63164.tar.bz2
Bug 368597: [remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java5
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties4
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java56
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java62
4 files changed, 120 insertions, 7 deletions
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
index 254f492..da4da1a 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
* 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
@@ -12,6 +12,7 @@
* Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
* Nikita Shulga (EmbeddedAlley) - [265236][remotecdt] Wait for RSE to initialize before querying it for host list
+ * Anna Dushistova (MontaVista) - [368597][remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
*******************************************************************************/
package org.eclipse.cdt.internal.launch.remote;
@@ -45,6 +46,8 @@ public class Messages extends NLS {
public static String RemoteCMainTab_Properties_Location;
public static String RemoteCMainTab_Properties_Skip_default;
+ public static String RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage;
+
public static String RemoteRunLaunchDelegate_0;
public static String RemoteRunLaunchDelegate_RemoteShell;
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
index 3265450..18da69e 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/internal/launch/remote/messages.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
+# Copyright (c) 2006, 2012 Wind River Systems, Inc. and others.
# 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
@@ -12,6 +12,7 @@
# Anna Dushistova (MontaVista) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
# Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
# Nikita Shulga (EmbeddedAlley) - [265236][remotecdt] Wait for RSE to initialize before querying it for host list
+# Anna Dushistova (MontaVista) - [368597][remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
################################################################################
# NLS_MESSAGEFORMAT_VAR
@@ -49,3 +50,4 @@ RemoteCMainTab_Properties=Properties...
RemoteCMainTab_Properties_title=Properties
RemoteCMainTab_Properties_Location=Remote workspace location:
RemoteCMainTab_Properties_Skip_default=Skip download to target path by default
+RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage=Could not start gdbserver on the remote host. See console output for more details.
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java
index 600eac3..db6e3e6 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteGdbLaunchDelegate.java
@@ -9,6 +9,7 @@
* Anna Dushistova (Mentor Graphics) - initial API and implementation
* Anna Dushistova (Mentor Graphics) - moved to org.eclipse.cdt.launch.remote.launching
* Anna Dushistova (MontaVista) - [318051][remote debug] Terminating when "Remote shell" process is selected doesn't work
+ * Anna Dushistova (MontaVista) - [368597][remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
*******************************************************************************/
package org.eclipse.cdt.launch.remote.launching;
@@ -38,11 +39,17 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.model.IProcess;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IHostShellChangeEvent;
+import org.eclipse.rse.services.shells.IHostShellOutputListener;
public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
+
+ private boolean gdbserverReady = false;
@Override
public void launch(ILaunchConfiguration config, String mode,
@@ -100,6 +107,23 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
+ final Object lock = new Object();
+ if (remoteShell != null) {
+ remoteShell.addOutputListener(new IHostShellOutputListener() {
+
+ public void shellOutputChanged(IHostShellChangeEvent event) {
+ for (IHostOutput line : event.getLines()) {
+ if (line.getString().contains("Listening on port")) { //$NON-NLS-1$
+ synchronized (lock) {
+ setGdbserverReady(true);
+ lock.notifyAll();
+ }
+ break;
+ }
+ }
+ }
+ });
+
try {
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
@@ -136,9 +160,28 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
- DebugPlugin.newProcess(launch, remoteShellProcess,
+ IProcess iProcess = DebugPlugin.newProcess(launch, remoteShellProcess,
Messages.RemoteRunLaunchDelegate_RemoteShell);
-
+
+ // Now wait until gdbserver is up and running on the remote host
+ synchronized (lock) {
+ while (!isGdbserverReady()) {
+ if (monitor.isCanceled() || iProcess.isTerminated()) {
+ //gdbserver launch failed
+ if (remoteShellProcess != null) {
+ remoteShellProcess.destroy();
+ }
+ abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage,
+ null,
+ ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ }
+ try {
+ lock.wait(300);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
// 3. Let debugger know how gdbserver was started on the remote
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP,
@@ -163,6 +206,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
} finally {
monitor.done();
}
+ }
}
protected String getProgramArguments(ILaunchConfiguration config)
@@ -181,4 +225,12 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
protected String getPluginID() {
return Activator.PLUGIN_ID;
}
+
+ protected boolean isGdbserverReady() {
+ return gdbserverReady;
+ }
+
+ protected void setGdbserverReady(boolean gdbserverReady) {
+ this.gdbserverReady = gdbserverReady;
+ }
}
diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java
index 7feb832..f843bfc 100644
--- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java
+++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java
@@ -19,6 +19,7 @@
* Anna Dushistova (Mentor Graphics) - [314659]Fixed deprecated methods
* Anna Dushistova (Mentor Graphics) - moved to org.eclipse.cdt.launch.remote.launching
* Anna Dushistova (MontaVista) - [318051][remote debug] Terminating when "Remote shell" process is selected doesn't work
+ * Anna Dushistova (MontaVista) - [368597][remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
*******************************************************************************/
package org.eclipse.cdt.launch.remote.launching;
@@ -55,11 +56,15 @@ import org.eclipse.debug.core.model.IProcess;
import org.eclipse.osgi.util.NLS;
import org.eclipse.rse.core.RSECorePlugin;
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
+import org.eclipse.rse.services.shells.IHostOutput;
import org.eclipse.rse.services.shells.IHostShell;
+import org.eclipse.rse.services.shells.IHostShellChangeEvent;
+import org.eclipse.rse.services.shells.IHostShellOutputListener;
public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
private ICDISession dsession;
+ private boolean gdbserverReady;
/*
* (non-Javadoc)
@@ -141,7 +146,28 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
RSEHelper.abort(e1.getMessage(), e1,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
-
+
+ final Object lock = new Object();
+ if (remoteShell != null) {
+ remoteShell
+ .addOutputListener(new IHostShellOutputListener() {
+
+ public void shellOutputChanged(
+ IHostShellChangeEvent event) {
+ for (IHostOutput line : event
+ .getLines()) {
+ if (line.getString().contains(
+ "Listening on port")) { //$NON-NLS-1$
+ synchronized (lock) {
+ setGdbserverReady(true);
+ lock.notifyAll();
+ }
+ break;
+ }
+ }
+ }
+ });
+
try {
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
@@ -164,8 +190,28 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
RSEHelper.abort(Messages.RemoteRunLaunchDelegate_7, e,
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
- DebugPlugin.newProcess(launch, remoteShellProcess,
- Messages.RemoteRunLaunchDelegate_RemoteShell);
+ IProcess rsProcess = DebugPlugin
+ .newProcess(
+ launch,
+ remoteShellProcess,
+ Messages.RemoteRunLaunchDelegate_RemoteShell);
+
+ // Now wait until gdbserver is up and running on the
+ // remote host
+ synchronized (lock) {
+ while (!isGdbserverReady()) {
+ if (monitor.isCanceled()
+ || rsProcess.isTerminated()) {
+ abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage,
+ null,
+ ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ }
+ try {
+ lock.wait(300);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
// Pre-set configuration constants for the
// GDBSERVERCDIDebugger to indicate how the gdbserver
@@ -223,6 +269,7 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
iprocess, exeFile, true, false, stopSymbol,
true);
}
+ }
} catch (CoreException e) {
try {
if (dsession != null)
@@ -276,4 +323,13 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDISession getSession(){
return dsession;
}
+
+ protected boolean isGdbserverReady() {
+ return gdbserverReady;
+ }
+
+ protected void setGdbserverReady(boolean gdbserverReady) {
+ this.gdbserverReady = gdbserverReady;
+ }
+
}