Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2012-01-27 11:34:04 -0500
committerMarc Khouzam2012-01-27 11:45:03 -0500
commit55e8d9f684deae4dcc13a28b0513bac5db7f927a (patch)
treef7e6d483a785e4e9489efe27d8364893727ff9f1
parent13d3bad2dec3762cc90d7380749328be51a63164 (diff)
downloadorg.eclipse.cdt-55e8d9f684deae4dcc13a28b0513bac5db7f927a.tar.gz
org.eclipse.cdt-55e8d9f684deae4dcc13a28b0513bac5db7f927a.tar.xz
org.eclipse.cdt-55e8d9f684deae4dcc13a28b0513bac5db7f927a.zip
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/launch/remote/launching/RemoteGdbLaunchDelegate.java28
-rw-r--r--cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/launching/RemoteRunLaunchDelegate.java26
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java3
3 files changed, 27 insertions, 30 deletions
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 db6e3e6725..04f188d68f 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
@@ -49,8 +49,6 @@ import org.eclipse.rse.services.shells.IHostShellOutputListener;
public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
- private boolean gdbserverReady = false;
-
@Override
public void launch(ILaunchConfiguration config, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException {
@@ -95,6 +93,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
if (arguments != null && !arguments.equals("")) //$NON-NLS-1$
commandArguments += " " + arguments; //$NON-NLS-1$
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9);
+
// extending HostShellProcessAdapter here
final GdbLaunch l = (GdbLaunch)launch;
IHostShell remoteShell = null;
@@ -107,6 +106,14 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
+
+ // We cannot use a global variable because multiple launches
+ // could access them at the same time. We need a different
+ // variable for each launch, but we also need it be final.
+ // Use a final array to do that.
+ final boolean gdbServerReady[] = new boolean[1];
+ gdbServerReady[0] = false;
+
final Object lock = new Object();
if (remoteShell != null) {
remoteShell.addOutputListener(new IHostShellOutputListener() {
@@ -115,7 +122,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
for (IHostOutput line : event.getLines()) {
if (line.getString().contains("Listening on port")) { //$NON-NLS-1$
synchronized (lock) {
- setGdbserverReady(true);
+ gdbServerReady[0] = true;
lock.notifyAll();
}
break;
@@ -165,15 +172,14 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
// Now wait until gdbserver is up and running on the remote host
synchronized (lock) {
- while (!isGdbserverReady()) {
+ while (gdbServerReady[0] == false) {
if (monitor.isCanceled() || iProcess.isTerminated()) {
//gdbserver launch failed
if (remoteShellProcess != null) {
remoteShellProcess.destroy();
}
- abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage,
- null,
- ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ RSEHelper.abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null,
+ ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
}
try {
lock.wait(300);
@@ -225,12 +231,4 @@ 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 f843bfc7d4..cff7acee2a 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
@@ -64,7 +64,6 @@ import org.eclipse.rse.services.shells.IHostShellOutputListener;
public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
private ICDISession dsession;
- private boolean gdbserverReady;
/*
* (non-Javadoc)
@@ -147,6 +146,13 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
+ // We cannot use a global variable because multiple launches
+ // could access them at the same time. We need a different
+ // variable for each launch, but we also need it be final.
+ // Use a final array to do that.
+ final boolean gdbServerReady[] = new boolean[1];
+ gdbServerReady[0] = false;
+
final Object lock = new Object();
if (remoteShell != null) {
remoteShell
@@ -159,7 +165,7 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
if (line.getString().contains(
"Listening on port")) { //$NON-NLS-1$
synchronized (lock) {
- setGdbserverReady(true);
+ gdbServerReady[0] = true;
lock.notifyAll();
}
break;
@@ -199,12 +205,11 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
// Now wait until gdbserver is up and running on the
// remote host
synchronized (lock) {
- while (!isGdbserverReady()) {
+ while (gdbServerReady[0] == false) {
if (monitor.isCanceled()
|| rsProcess.isTerminated()) {
- abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage,
- null,
- ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
+ RSEHelper.abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null,
+ ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
}
try {
lock.wait(300);
@@ -323,13 +328,4 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDISession getSession(){
return dsession;
}
-
- protected boolean isGdbserverReady() {
- return gdbserverReady;
- }
-
- protected void setGdbserverReady(boolean gdbserverReady) {
- this.gdbserverReady = gdbserverReady;
- }
-
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java
index 7f7a125658..d718f56475 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java
@@ -84,6 +84,8 @@ public class ShutdownSequence extends Sequence {
ServiceReference<?>[] serviceRefs = GdbPlugin.getBundleContext().getServiceReferences(
IDsfService.class.getName(),
String.format( "(%s=%s)", IDsfService.PROP_SESSION_ID, fSessionId ).intern() ); //$NON-NLS-1$
+
+ if (serviceRefs != null) {
List<IDsfService> services = new ArrayList<IDsfService>( serviceRefs.length );
for ( ServiceReference<?> ref : serviceRefs ) {
Object serviceObj = GdbPlugin.getBundleContext().getService( ref );
@@ -100,6 +102,7 @@ public class ShutdownSequence extends Sequence {
} );
result = services.toArray( new IDsfService[services.size()] );
}
+ }
catch( InvalidSyntaxException e ) {
// Shouldn't happen
}

Back to the top