1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-20 07:25:23 +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 { public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
private boolean gdbserverReady = false;
@Override @Override
public void launch(ILaunchConfiguration config, String mode, public void launch(ILaunchConfiguration config, String mode,
ILaunch launch, IProgressMonitor monitor) throws CoreException { ILaunch launch, IProgressMonitor monitor) throws CoreException {
@ -95,6 +93,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
if (arguments != null && !arguments.equals("")) //$NON-NLS-1$ if (arguments != null && !arguments.equals("")) //$NON-NLS-1$
commandArguments += " " + arguments; //$NON-NLS-1$ commandArguments += " " + arguments; //$NON-NLS-1$
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9); monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9);
// extending HostShellProcessAdapter here // extending HostShellProcessAdapter here
final GdbLaunch l = (GdbLaunch)launch; final GdbLaunch l = (GdbLaunch)launch;
IHostShell remoteShell = null; IHostShell remoteShell = null;
@ -107,6 +106,14 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); 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(); final Object lock = new Object();
if (remoteShell != null) { if (remoteShell != null) {
remoteShell.addOutputListener(new IHostShellOutputListener() { remoteShell.addOutputListener(new IHostShellOutputListener() {
@ -115,7 +122,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
for (IHostOutput line : event.getLines()) { for (IHostOutput line : event.getLines()) {
if (line.getString().contains("Listening on port")) { //$NON-NLS-1$ if (line.getString().contains("Listening on port")) { //$NON-NLS-1$
synchronized (lock) { synchronized (lock) {
setGdbserverReady(true); gdbServerReady[0] = true;
lock.notifyAll(); lock.notifyAll();
} }
break; break;
@ -165,15 +172,14 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
// Now wait until gdbserver is up and running on the remote host // Now wait until gdbserver is up and running on the remote host
synchronized (lock) { synchronized (lock) {
while (!isGdbserverReady()) { while (gdbServerReady[0] == false) {
if (monitor.isCanceled() || iProcess.isTerminated()) { if (monitor.isCanceled() || iProcess.isTerminated()) {
//gdbserver launch failed //gdbserver launch failed
if (remoteShellProcess != null) { if (remoteShellProcess != null) {
remoteShellProcess.destroy(); remoteShellProcess.destroy();
} }
abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, RSEHelper.abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null,
null, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
} }
try { try {
lock.wait(300); lock.wait(300);
@ -225,12 +231,4 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
protected String getPluginID() { protected String getPluginID() {
return Activator.PLUGIN_ID; 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 { public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
private ICDISession dsession; private ICDISession dsession;
private boolean gdbserverReady;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -147,6 +146,13 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR); 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(); final Object lock = new Object();
if (remoteShell != null) { if (remoteShell != null) {
remoteShell remoteShell
@ -159,7 +165,7 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
if (line.getString().contains( if (line.getString().contains(
"Listening on port")) { //$NON-NLS-1$ "Listening on port")) { //$NON-NLS-1$
synchronized (lock) { synchronized (lock) {
setGdbserverReady(true); gdbServerReady[0] = true;
lock.notifyAll(); lock.notifyAll();
} }
break; break;
@ -199,12 +205,11 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
// Now wait until gdbserver is up and running on the // Now wait until gdbserver is up and running on the
// remote host // remote host
synchronized (lock) { synchronized (lock) {
while (!isGdbserverReady()) { while (gdbServerReady[0] == false) {
if (monitor.isCanceled() if (monitor.isCanceled()
|| rsProcess.isTerminated()) { || rsProcess.isTerminated()) {
abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, RSEHelper.abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null,
null, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
} }
try { try {
lock.wait(300); lock.wait(300);
@ -323,13 +328,4 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
ICDISession getSession(){ ICDISession getSession(){
return dsession; 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( ServiceReference<?>[] serviceRefs = GdbPlugin.getBundleContext().getServiceReferences(
IDsfService.class.getName(), IDsfService.class.getName(),
String.format( "(%s=%s)", IDsfService.PROP_SESSION_ID, fSessionId ).intern() ); //$NON-NLS-1$ String.format( "(%s=%s)", IDsfService.PROP_SESSION_ID, fSessionId ).intern() ); //$NON-NLS-1$
if (serviceRefs != null) {
List<IDsfService> services = new ArrayList<IDsfService>( serviceRefs.length ); List<IDsfService> services = new ArrayList<IDsfService>( serviceRefs.length );
for ( ServiceReference<?> ref : serviceRefs ) { for ( ServiceReference<?> ref : serviceRefs ) {
Object serviceObj = GdbPlugin.getBundleContext().getService( ref ); Object serviceObj = GdbPlugin.getBundleContext().getService( ref );
@ -100,6 +102,7 @@ public class ShutdownSequence extends Sequence {
} ); } );
result = services.toArray( new IDsfService[services.size()] ); result = services.toArray( new IDsfService[services.size()] );
} }
}
catch( InvalidSyntaxException e ) { catch( InvalidSyntaxException e ) {
// Shouldn't happen // Shouldn't happen
} }