Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-03-12 11:42:07 +0000
committerAnton Leherbauer2015-03-12 11:42:45 +0000
commit62e3fd571366b7f78903d2baf6690a60a06b4946 (patch)
treee8f0e5c8a32aefeca657a12603b9e04df93bb388 /target_explorer
parent51f1be2dc75d2b887e182c089f6b5d1c65b96678 (diff)
downloadorg.eclipse.tcf-62e3fd571366b7f78903d2baf6690a60a06b4946.tar.gz
org.eclipse.tcf-62e3fd571366b7f78903d2baf6690a60a06b4946.tar.xz
org.eclipse.tcf-62e3fd571366b7f78903d2baf6690a60a06b4946.zip
Target Explorer: Fix handling of gdbserver port already in use
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java42
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties4
3 files changed, 41 insertions, 10 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java
index 0e65d329a..71d843de2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/launching/TEGdbLaunchDelegate.java
@@ -17,6 +17,7 @@ package org.eclipse.tcf.te.tcf.launch.cdt.launching;
import java.io.IOException;
import java.util.concurrent.RejectedExecutionException;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@@ -82,6 +83,7 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
commandArguments += " " + arguments; //$NON-NLS-1$
monitor.setTaskName(Messages.RemoteRunLaunchDelegate_9);
+ final AtomicBoolean gdbServerStarted = new AtomicBoolean(false);
final GdbLaunch l = (GdbLaunch) launch;
final Callback callback = new Callback() {
@Override
@@ -100,7 +102,8 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
catch (RejectedExecutionException e) {
// Session disposed.
}
-
+ } else {
+ gdbServerStarted.set(true);
}
super.internalDone(caller, status);
}
@@ -115,17 +118,19 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
final Object lock = new Object();
+ final StringBuilder gdbServerOutput = new StringBuilder();
StreamsDataReceiver.Listener listener = new StreamsDataReceiver.Listener() {
@Override
public void dataReceived(String data) {
+ gdbServerOutput.append(data);
if (data.contains("Listening on port")) { //$NON-NLS-1$
gdbServerReady.set(true);
synchronized (lock) {
lock.notifyAll();
}
}
- else if (data.contains("GDBserver exiting")) { //$NON-NLS-1$
+ else if (data.contains("GDBserver exiting") || data.contains("Exiting")) { //$NON-NLS-1$ //$NON-NLS-2$
gdbServerExited.set(true);
synchronized (lock) {
lock.notifyAll();
@@ -143,7 +148,11 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
// gdbserver launch failed
// Need to shutdown the DSF launch session because it is
// partially started already.
- shutdownSession(l);
+ shutdownSession(l, Messages.TEGdbLaunchDelegate_canceledMsg);
+ }
+ if (gdbServerStarted.get() && launcher.getChannel() == null) {
+ // gdbserver died
+ shutdownSession(l, gdbServerOutput.toString());
}
synchronized (lock) {
try {
@@ -156,7 +165,7 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
// If the gdbserver exited, also shutdown the DSF launch session
if (gdbServerExited.get()) {
- shutdownSession(l);
+ shutdownSession(l, gdbServerOutput.toString());
}
// 3. Let debugger know how gdbserver was started on the remote
@@ -188,9 +197,20 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
* @throws CoreException If the GDB debug session shutdown failed.
*/
protected void shutdownSession(final GdbLaunch launch) throws CoreException {
+ shutdownSession(launch, null);
+ }
+
+ /**
+ * Shutdown the GDB debug session.
+ *
+ * @param launch The GDB launch. Must not be <code>null</code>.
+ * @param details Error message, may be <code>null</code>
+ * @throws CoreException If the GDB debug session shutdown failed.
+ */
+ protected void shutdownSession(final GdbLaunch launch, String details) throws CoreException {
Assert.isNotNull(launch);
try {
- launch.getSession().getExecutor().execute(new DsfRunnable() {
+ launch.getSession().getExecutor().submit(new DsfRunnable() {
@Override
public void run() {
// Avoid an NPE while running the shutdown
@@ -198,13 +218,19 @@ public class TEGdbLaunchDelegate extends GdbLaunchDelegate {
launch.shutdownSession(new ImmediateRequestMonitor());
}
}
- });
+ }).get(1000, TimeUnit.MILLISECONDS);
}
catch (RejectedExecutionException e) {
// Session disposed.
}
-
- abort(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage, null, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
+ catch (Exception e) {
+ // Ignore exceptions during shutdown.
+ }
+
+ String msg = Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage;
+ if (details != null && details.length() > 0)
+ msg = NLS.bind(Messages.RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorWithDetails, details);
+ abort(msg, null, ICDTLaunchConfigurationConstants.ERR_DEBUGGER_NOT_INSTALLED);
}
protected String getProgramArguments(ILaunchConfiguration config) throws CoreException {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java
index 3620a1bbb..33e482575 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
+ * Copyright (c) 2006, 2015 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
@@ -50,6 +50,7 @@ public class Messages extends NLS {
public static String RemoteGdbLaunchDelegate_filetransferFailed;
public static String RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage;
+ public static String RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorWithDetails;
public static String RemoteRunLaunchDelegate_0;
@@ -74,6 +75,8 @@ public class Messages extends NLS {
public static String TCFPeerSelector_0;
+ public static String TEGdbLaunchDelegate_canceledMsg;
+
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties
index 28b60b874..fd99857b6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/nls/Messages.properties
@@ -1,5 +1,5 @@
################################################################################
-# Copyright (c) 2006, 2014 Wind River Systems, Inc. and others.
+# Copyright (c) 2006, 2015 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
@@ -54,4 +54,6 @@ RemoteCMainTab_Properties_Location=Remote workspace location:
RemoteCMainTab_Properties_Skip_default=Skip download to target path by default
RemoteGdbLaunchDelegate_filetransferFailed=Failed to download application image to target. Possibly caused by: {0}
RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorMessage=Could not start gdbserver on the remote host. See console output for more details.
+RemoteGdbLaunchDelegate_gdbserverFailedToStartErrorWithDetails=Could not start gdbserver on the remote host. Possibly caused by:\n{0}
TCFPeerSelector_0=Connection:
+TEGdbLaunchDelegate_canceledMsg=Canceled by user

Back to the top