Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug')
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/ErrorThread.java54
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java29
2 files changed, 82 insertions, 1 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/ErrorThread.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/ErrorThread.java
new file mode 100644
index 00000000000..dd6f1e1254a
--- /dev/null
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/ErrorThread.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Broadcom Corporation 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * James Blackburn (Broadcom Corp.)
+ *******************************************************************************/
+package org.eclipse.cdt.debug.mi.core;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+
+/**
+ * Receiving, and printing to the console, stderr output
+ * @since 6.1
+ * @noextend This class is not intended to be subclassed by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class ErrorThread extends Thread {
+
+ final MISession session;
+
+ public ErrorThread(MISession s) {
+ super("MI Error Thread"); //$NON-NLS-1$
+ session = s;
+ }
+
+ /*
+ * Sit on the error stream output, and append to the GDB console
+ */
+ public void run() {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(session.getChannelErrorStream()));
+ try {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ OutputStream console = session.getLogPipe();
+ if (console != null) {
+ console.write((line + "\n").getBytes()); //$NON-NLS-1$
+ console.flush();
+ }
+ }
+ } catch (IOException e) {
+ try {
+ reader.close();
+ } catch (IOException e1) {/* closing anyway */}
+ }
+ }
+
+}
diff --git a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java
index 2db2cc60c4d..c4c7b54ecd5 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/mi/org/eclipse/cdt/debug/mi/core/MISession.java
@@ -74,10 +74,12 @@ public class MISession extends Observable {
Process sessionProcess;
MIProcess gdbProcess;
InputStream inChannel;
+ InputStream inErrChannel;
OutputStream outChannel;
TxThread txThread;
RxThread rxThread;
+ ErrorThread errorThread;
EventThread eventThread;
CommandQueue txQueue;
@@ -145,6 +147,7 @@ public class MISession extends Observable {
public MISession(MIProcess process, IMITTY tty, int type, CommandFactory commandFactory, int commandTimeout, int launchTimeout, IProgressMonitor monitor) throws MIException {
gdbProcess = process;
inChannel = process.getInputStream();
+ inErrChannel = process.getErrorStream();
outChannel = process.getOutputStream();
factory = commandFactory;
@@ -162,6 +165,7 @@ public class MISession extends Observable {
txThread = new TxThread(this);
rxThread = new RxThread(this);
+ errorThread = new ErrorThread(this);
eventThread = new EventThread(this);
// initialize/setup
@@ -182,6 +186,7 @@ public class MISession extends Observable {
public MISession(MIProcess process, IMITTY tty, int type, CommandFactory commandFactory, int commandTimeout) throws MIException {
gdbProcess = process;
inChannel = process.getInputStream();
+ inErrChannel = process.getErrorStream();
outChannel = process.getOutputStream();
factory = commandFactory;
@@ -199,12 +204,14 @@ public class MISession extends Observable {
txThread = new TxThread(this);
rxThread = new RxThread(this);
+ errorThread = new ErrorThread(this);
eventThread = new EventThread(this);
setup();
txThread.start();
rxThread.start();
+ errorThread.start();
eventThread.start();
}
@@ -251,6 +258,10 @@ public class MISession extends Observable {
if (rxThread.isAlive()) {
rxThread.interrupt();
}
+ // Kill the Error reading Thread.
+ if (errorThread.isAlive()) {
+ errorThread.interrupt();
+ }
// Kill the event Thread.
if (eventThread.isAlive()) {
eventThread.interrupt();
@@ -291,6 +302,7 @@ public class MISession extends Observable {
txThread.start();
rxThread.start();
+ errorThread.start();
eventThread.start();
try {
@@ -308,6 +320,10 @@ public class MISession extends Observable {
if (rxThread.isAlive()) {
rxThread.interrupt();
}
+ // Kill the Error Thread.
+ if (errorThread.isAlive()) {
+ errorThread.interrupt();
+ }
// Kill the event Thread.
if (eventThread.isAlive()) {
eventThread.interrupt();
@@ -740,7 +756,14 @@ public class MISession extends Observable {
}
} catch (InterruptedException e) {
}
-
+ // Kill the Error Thread.
+ try {
+ if (errorThread.isAlive()) {
+ errorThread.interrupt();
+ errorThread.join(cmdTimeout);
+ }
+ } catch (InterruptedException e) {
+ }
// Kill the event Thread ... if it is not us.
if (!eventThread.equals(Thread.currentThread())) {
// Kill the event Thread.
@@ -802,6 +825,10 @@ public class MISession extends Observable {
return inChannel;
}
+ InputStream getChannelErrorStream() {
+ return inErrChannel;
+ }
+
OutputStream getChannelOutputStream() {
return outChannel;
}

Back to the top