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

A short comment. Did you try to set a breakpoint in this code? If
exitValue for some reason doesn't throw an exception (a bug in the
spawner) and there is no error message the error stream will be closed,
but the session will continue. 

-----Original Message-----
From: cdt-debug-dev-bounces@xxxxxxxxxxx
[mailto:cdt-debug-dev-bounces@xxxxxxxxxxx] On Behalf Of Mikhail
Khodjaiants
Sent: 17 November 2006 14:34
To: CDT Debug developers list
Subject: RE: [cdt-debug-dev] MI: obtaining GDB's stderr

Derek,

This code checks if the gdb process has terminated. "exitValue()"
returns a value if the process has terminated, otherwise throws
IllegalThreadStateException. The process can terminate at the startup
for many reason. In this case this code reads the error message, closes
the error stream and throws Miexception to inform the client. 
If the process is running (normal situation) this code does nothing
(catch IllegalThreadStateException).

Mikhail

-----Original Message-----
From: cdt-debug-dev-bounces@xxxxxxxxxxx
[mailto:cdt-debug-dev-bounces@xxxxxxxxxxx] On Behalf Of Derek Morris
Sent: 16 November 2006 14:37
To: CDT Debug developers list
Subject: 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
> 
_______________________________________________
cdt-debug-dev mailing list
cdt-debug-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/cdt-debug-dev

--
IMPORTANT NOTICE: The contents of this email and any attachments are
confidential and may also be privileged. If you are not the intended
recipient, please notify the sender immediately and do not disclose the
contents to any other person, use it for any purpose, or store or copy
the information in any medium.  Thank you.


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


Back to the top