1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-19 15:05:36 +02:00

Bug 368597: [remote debug] if gdbserver fails to launch on target, launch doesn't get terminated

This commit is contained in:
Marc Khouzam 2012-01-27 11:34:04 -05:00
parent 13d3bad2de
commit 55e8d9f684
3 changed files with 27 additions and 30 deletions

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -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
}