mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 368597: [remote debug] if gdbserver fails to launch on target, launch doesn't get terminated
This commit is contained in:
parent
ccd531c177
commit
13d3bad2de
4 changed files with 120 additions and 7 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* 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) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||||
* Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
* 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
|
* 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;
|
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_Location;
|
||||||
public static String RemoteCMainTab_Properties_Skip_default;
|
public static String RemoteCMainTab_Properties_Skip_default;
|
||||||
|
|
||||||
|
public static String RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage;
|
||||||
|
|
||||||
public static String RemoteRunLaunchDelegate_0;
|
public static String RemoteRunLaunchDelegate_0;
|
||||||
|
|
||||||
public static String RemoteRunLaunchDelegate_RemoteShell;
|
public static String RemoteRunLaunchDelegate_RemoteShell;
|
||||||
|
|
|
@ -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
|
# All rights reserved. This program and the accompanying materials
|
||||||
# are made available under the terms of the Eclipse Public License v1.0
|
# are made available under the terms of the Eclipse Public License v1.0
|
||||||
# which accompanies this distribution, and is available at
|
# 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) - [244173][remotecdt][nls] Externalize Strings in RemoteRunLaunchDelegate
|
||||||
# Anna Dushistova (MontaVista) - [181517][usability] Specify commands to be run before remote application launch
|
# 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
|
# 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
|
# NLS_MESSAGEFORMAT_VAR
|
||||||
|
@ -49,3 +50,4 @@ RemoteCMainTab_Properties=Properties...
|
||||||
RemoteCMainTab_Properties_title=Properties
|
RemoteCMainTab_Properties_title=Properties
|
||||||
RemoteCMainTab_Properties_Location=Remote workspace location:
|
RemoteCMainTab_Properties_Location=Remote workspace location:
|
||||||
RemoteCMainTab_Properties_Skip_default=Skip download to target path by default
|
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.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Anna Dushistova (Mentor Graphics) - initial API and implementation
|
* Anna Dushistova (Mentor Graphics) - initial API and implementation
|
||||||
* Anna Dushistova (Mentor Graphics) - moved to org.eclipse.cdt.launch.remote.launching
|
* 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) - [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;
|
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.ILaunch;
|
||||||
import org.eclipse.debug.core.ILaunchConfiguration;
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.eclipse.debug.core.model.IProcess;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
|
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.IHostShell;
|
||||||
|
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
|
||||||
|
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,
|
||||||
|
@ -100,6 +107,23 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
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 {
|
try {
|
||||||
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
|
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
|
||||||
|
|
||||||
|
@ -136,9 +160,28 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPlugin.newProcess(launch, remoteShellProcess,
|
IProcess iProcess = DebugPlugin.newProcess(launch, remoteShellProcess,
|
||||||
Messages.RemoteRunLaunchDelegate_RemoteShell);
|
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
|
// 3. Let debugger know how gdbserver was started on the remote
|
||||||
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
||||||
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP,
|
wc.setAttribute(IGDBLaunchConfigurationConstants.ATTR_REMOTE_TCP,
|
||||||
|
@ -163,6 +206,7 @@ public class RemoteGdbLaunchDelegate extends GdbLaunchDelegate {
|
||||||
} finally {
|
} finally {
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getProgramArguments(ILaunchConfiguration config)
|
protected String getProgramArguments(ILaunchConfiguration config)
|
||||||
|
@ -181,4 +225,12 @@ 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
* Anna Dushistova (Mentor Graphics) - [314659]Fixed deprecated methods
|
* Anna Dushistova (Mentor Graphics) - [314659]Fixed deprecated methods
|
||||||
* Anna Dushistova (Mentor Graphics) - moved to org.eclipse.cdt.launch.remote.launching
|
* 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) - [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;
|
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.osgi.util.NLS;
|
||||||
import org.eclipse.rse.core.RSECorePlugin;
|
import org.eclipse.rse.core.RSECorePlugin;
|
||||||
import org.eclipse.rse.services.shells.HostShellProcessAdapter;
|
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.IHostShell;
|
||||||
|
import org.eclipse.rse.services.shells.IHostShellChangeEvent;
|
||||||
|
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)
|
||||||
|
@ -141,7 +146,28 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
RSEHelper.abort(e1.getMessage(), e1,
|
RSEHelper.abort(e1.getMessage(), e1,
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
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 {
|
try {
|
||||||
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
|
remoteShellProcess = new HostShellProcessAdapter(remoteShell) {
|
||||||
|
|
||||||
|
@ -164,8 +190,28 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
RSEHelper.abort(Messages.RemoteRunLaunchDelegate_7, e,
|
RSEHelper.abort(Messages.RemoteRunLaunchDelegate_7, e,
|
||||||
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
|
||||||
}
|
}
|
||||||
DebugPlugin.newProcess(launch, remoteShellProcess,
|
IProcess rsProcess = DebugPlugin
|
||||||
Messages.RemoteRunLaunchDelegate_RemoteShell);
|
.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
|
// Pre-set configuration constants for the
|
||||||
// GDBSERVERCDIDebugger to indicate how the gdbserver
|
// GDBSERVERCDIDebugger to indicate how the gdbserver
|
||||||
|
@ -223,6 +269,7 @@ public class RemoteRunLaunchDelegate extends AbstractCLaunchDelegate {
|
||||||
iprocess, exeFile, true, false, stopSymbol,
|
iprocess, exeFile, true, false, stopSymbol,
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
try {
|
try {
|
||||||
if (dsession != null)
|
if (dsession != null)
|
||||||
|
@ -276,4 +323,13 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue