Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-debug-dev] MI: obtaining GDB's stderr

Mikhail,

I think I have found why I cannot get to GDB's stderr. In MISession#setup:

	gdbProcess.exitValue();
	InputStream err = gdbProcess.getErrorStream();
	BufferedReader reader = new BufferedReader(new InputStreamReader(err));
	String line = null;
	try {
		line = reader.readLine();
		reader.close();
	} catch (Exception e) {
		// the reader may throw a NPE.
	}

This is done before the txThread and rxThread are start()ed.

So, it opens the error stream as a BufferedReader, reads and discards whatever it finds, and then closes it.

Q: When the BufferedReader closes, will it also close the err InputStream? i.e. when i try to open the ErrorStream later on, will it always be empty?

Q: Do you know why it might do this?

Thanks,

--
Derek


Mikhail Khodjaiants wrote:
Hi Derek,

In most cases the process returned by "getGDBProcess" is not a process
that runs gdb. There is a class called Spawner that starts a gdb process
and creates the pipes for stdin, stdout and stderr. The Spawner's native
code is located in the "library" directory of the
org.eclipse.cdt.core.<os> plugins. It may be a bug, I don't know if we
have ever used the error stream from gdb.

It would be very useful if you and other "monitor" users come up with
the requirements on how to improve the support for "monitor" in general.
My personal experience with it is very limited.

Regards,
Mikhail

-----Original Message-----
From: cdt-debug-dev-bounces@xxxxxxxxxxx
[mailto:cdt-debug-dev-bounces@xxxxxxxxxxx] On Behalf Of Derek Morris
Sent: 13 November 2006 16:59
To: CDT Debug developers list
Subject: [cdt-debug-dev] MI: obtaining GDB's stderr

Hi,

How can I get access to GDB's stderr? I am trying to obtain additional
(error) information that is returned from a "monitor" command.

I am using the following code but reader.ready() always returns false.

MIProcess gdbProcess = miSession.getGDBProcess(); InputStream err =
gdbProcess.getErrorStream(); BufferedReader reader = new
BufferedReader(new InputStreamReader(
		err));
String line = null;
try {
	while (reader.ready()) {
		line = reader.readLine();
		errors.add(line) ;
	}
	reader.close();
} catch (Exception e) {
	e.printStackTrace() ;// the reader may throw a NPE.
}

I know that data is being written to stderr - I just can't get it!

TIA
--
Derek
_______________________________________________
cdt-debug-dev mailing list
cdt-debug-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-debug-dev



Back to the top