summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Bozeman2012-10-30 16:18:01 (EDT)
committer Marc Khouzam2012-10-31 10:28:45 (EDT)
commit2c49273e16be7c8f36dbf4b31515069932ccd474 (patch)
tree1e4bff2ecbeb5280454054ed896ebc77919d62ca
parent4d02730830a61dbf5178db62807eaa465cb18e6b (diff)
downloadorg.eclipse.cdt-2c49273e16be7c8f36dbf4b31515069932ccd474.zip
org.eclipse.cdt-2c49273e16be7c8f36dbf4b31515069932ccd474.tar.gz
org.eclipse.cdt-2c49273e16be7c8f36dbf4b31515069932ccd474.tar.bz2
Bug: 376203 Launch job never completes if GDB terminates on start.
- Added check to report error (with information from stderr if available) if initial GDB prompt is not read. Change-Id: I48ec3cbe8061bc3dc5e3bcb37296e2fc3de0cf61 Reviewed-on: https://git.eclipse.org/r/8401 Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java45
1 files changed, 38 insertions, 7 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java
index 1a679dc..9cb79fa 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GDBBackend.java
@@ -10,6 +10,7 @@
* Wind River System
* Ericsson
* Marc Khouzam (Ericsson) - Use the new IMIBackend2 interface (Bug 350837)
+ * Mark Bozeman (Mentor Graphics) - Report GDB start failures (Bug 376203)
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.service;
@@ -19,7 +20,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
-import java.io.Reader;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.List;
@@ -561,22 +561,53 @@ public class GDBBackend extends AbstractDsfService implements IGDBBackend, IMIBa
return Status.OK_STATUS;
}
+ BufferedReader inputReader = null;
+ BufferedReader errorReader = null;
+ boolean success = false;
try {
- Reader r = new InputStreamReader(getMIInputStream());
- BufferedReader reader = new BufferedReader(r);
+ // Read initial GDB prompt
+ inputReader = new BufferedReader(new InputStreamReader(getMIInputStream()));
String line;
- while ((line = reader.readLine()) != null) {
+ while ((line = inputReader.readLine()) != null) {
line = line.trim();
if (line.endsWith("(gdb)")) { //$NON-NLS-1$
+ success = true;
break;
}
}
+
+ // Failed to read initial prompt, check for error
+ if (!success) {
+ errorReader = new BufferedReader(new InputStreamReader(getMIErrorStream()));
+ String errorInfo = errorReader.readLine();
+ if (errorInfo == null) {
+ errorInfo = "GDB prompt not read"; //$NON-NLS-1$
+ }
+ gdbLaunchRequestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, errorInfo, null));
+ }
} catch (IOException e) {
- gdbLaunchRequestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Error reading GDB STDOUT", e)); //$NON-NLS-1$
- gdbLaunchRequestMonitor.done();
- return Status.OK_STATUS;
+ success = false;
+ gdbLaunchRequestMonitor.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, -1, "Error reading GDB output", e)); //$NON-NLS-1$
}
+ // In the case of failure, close the MI streams so
+ // they are not leaked.
+ if (!success)
+ {
+ if (inputReader != null) {
+ try {
+ inputReader.close();
+ } catch (IOException e) {
+ }
+ }
+ if (errorReader != null) {
+ try {
+ errorReader.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
gdbLaunchRequestMonitor.done();
return Status.OK_STATUS;
}