mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 270369 Display stderr from the debugger in the console log
This commit is contained in:
parent
5110ac05c1
commit
542c3b2137
2 changed files with 82 additions and 1 deletions
|
@ -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 */}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -74,10 +74,12 @@ public class MISession extends Observable {
|
||||||
Process sessionProcess;
|
Process sessionProcess;
|
||||||
MIProcess gdbProcess;
|
MIProcess gdbProcess;
|
||||||
InputStream inChannel;
|
InputStream inChannel;
|
||||||
|
InputStream inErrChannel;
|
||||||
OutputStream outChannel;
|
OutputStream outChannel;
|
||||||
|
|
||||||
TxThread txThread;
|
TxThread txThread;
|
||||||
RxThread rxThread;
|
RxThread rxThread;
|
||||||
|
ErrorThread errorThread;
|
||||||
EventThread eventThread;
|
EventThread eventThread;
|
||||||
|
|
||||||
CommandQueue txQueue;
|
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 {
|
public MISession(MIProcess process, IMITTY tty, int type, CommandFactory commandFactory, int commandTimeout, int launchTimeout, IProgressMonitor monitor) throws MIException {
|
||||||
gdbProcess = process;
|
gdbProcess = process;
|
||||||
inChannel = process.getInputStream();
|
inChannel = process.getInputStream();
|
||||||
|
inErrChannel = process.getErrorStream();
|
||||||
outChannel = process.getOutputStream();
|
outChannel = process.getOutputStream();
|
||||||
|
|
||||||
factory = commandFactory;
|
factory = commandFactory;
|
||||||
|
@ -162,6 +165,7 @@ public class MISession extends Observable {
|
||||||
|
|
||||||
txThread = new TxThread(this);
|
txThread = new TxThread(this);
|
||||||
rxThread = new RxThread(this);
|
rxThread = new RxThread(this);
|
||||||
|
errorThread = new ErrorThread(this);
|
||||||
eventThread = new EventThread(this);
|
eventThread = new EventThread(this);
|
||||||
|
|
||||||
// initialize/setup
|
// 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 {
|
public MISession(MIProcess process, IMITTY tty, int type, CommandFactory commandFactory, int commandTimeout) throws MIException {
|
||||||
gdbProcess = process;
|
gdbProcess = process;
|
||||||
inChannel = process.getInputStream();
|
inChannel = process.getInputStream();
|
||||||
|
inErrChannel = process.getErrorStream();
|
||||||
outChannel = process.getOutputStream();
|
outChannel = process.getOutputStream();
|
||||||
|
|
||||||
factory = commandFactory;
|
factory = commandFactory;
|
||||||
|
@ -199,12 +204,14 @@ public class MISession extends Observable {
|
||||||
|
|
||||||
txThread = new TxThread(this);
|
txThread = new TxThread(this);
|
||||||
rxThread = new RxThread(this);
|
rxThread = new RxThread(this);
|
||||||
|
errorThread = new ErrorThread(this);
|
||||||
eventThread = new EventThread(this);
|
eventThread = new EventThread(this);
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
|
|
||||||
txThread.start();
|
txThread.start();
|
||||||
rxThread.start();
|
rxThread.start();
|
||||||
|
errorThread.start();
|
||||||
eventThread.start();
|
eventThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,6 +258,10 @@ public class MISession extends Observable {
|
||||||
if (rxThread.isAlive()) {
|
if (rxThread.isAlive()) {
|
||||||
rxThread.interrupt();
|
rxThread.interrupt();
|
||||||
}
|
}
|
||||||
|
// Kill the Error reading Thread.
|
||||||
|
if (errorThread.isAlive()) {
|
||||||
|
errorThread.interrupt();
|
||||||
|
}
|
||||||
// Kill the event Thread.
|
// Kill the event Thread.
|
||||||
if (eventThread.isAlive()) {
|
if (eventThread.isAlive()) {
|
||||||
eventThread.interrupt();
|
eventThread.interrupt();
|
||||||
|
@ -291,6 +302,7 @@ public class MISession extends Observable {
|
||||||
|
|
||||||
txThread.start();
|
txThread.start();
|
||||||
rxThread.start();
|
rxThread.start();
|
||||||
|
errorThread.start();
|
||||||
eventThread.start();
|
eventThread.start();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -308,6 +320,10 @@ public class MISession extends Observable {
|
||||||
if (rxThread.isAlive()) {
|
if (rxThread.isAlive()) {
|
||||||
rxThread.interrupt();
|
rxThread.interrupt();
|
||||||
}
|
}
|
||||||
|
// Kill the Error Thread.
|
||||||
|
if (errorThread.isAlive()) {
|
||||||
|
errorThread.interrupt();
|
||||||
|
}
|
||||||
// Kill the event Thread.
|
// Kill the event Thread.
|
||||||
if (eventThread.isAlive()) {
|
if (eventThread.isAlive()) {
|
||||||
eventThread.interrupt();
|
eventThread.interrupt();
|
||||||
|
@ -740,7 +756,14 @@ public class MISession extends Observable {
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} 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.
|
// Kill the event Thread ... if it is not us.
|
||||||
if (!eventThread.equals(Thread.currentThread())) {
|
if (!eventThread.equals(Thread.currentThread())) {
|
||||||
// Kill the event Thread.
|
// Kill the event Thread.
|
||||||
|
@ -802,6 +825,10 @@ public class MISession extends Observable {
|
||||||
return inChannel;
|
return inChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputStream getChannelErrorStream() {
|
||||||
|
return inErrChannel;
|
||||||
|
}
|
||||||
|
|
||||||
OutputStream getChannelOutputStream() {
|
OutputStream getChannelOutputStream() {
|
||||||
return outChannel;
|
return outChannel;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue