Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349360

Summary: [local][shells] app output is lost while debugging it via gdbserver
Product: [Tools] Target Management Reporter: Anna Dushistova <anna.dushistova>
Component: RSEAssignee: dsdp.tm.rse-inbox <tm.rse-inbox>
Status: NEW --- QA Contact: Martin Oberhuber <mober.at+eclipse>
Severity: normal    
Priority: P3 CC: dmcknigh
Version: 3.3   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:
Bug Depends on:    
Bug Blocks: 349345    

Description Anna Dushistova CLA 2011-06-14 14:46:10 EDT
I created a simple Hello World app that prints "Hello World" 10 times.
Created 2 local shells in RSE: one for gdb, another one for gdbserver.
The application output shows up only after the child was terminated:

Process /tmp/test created; pid = 7010
Listening on port 2345
Remote debugging from host 127.0.0.1
!!!Hello World!!!

Child exited with status 0
!!!Hello World!!!
GDBserver exiting
!!!Hello World!!!
!!!Hello World!!!

It works fine in my normal Linux terminal and it works fine if gdbserver is launched in a SSH shell.
Comment 1 David McKnight CLA 2011-06-14 14:48:15 EDT
This is probably because the local shell is not a real tty shell, so programs running under it don't return output until completion.
Comment 2 Anna Dushistova CLA 2011-06-14 14:55:53 EDT
(In reply to comment #1)
> This is probably because the local shell is not a real tty shell, so programs
> running under it don't return output until completion.

Do you think it's possible to change this behavior or maybe we should just disable the "Local" connections in the remote launcher?
Comment 3 David McKnight CLA 2011-06-14 15:17:32 EDT
(In reply to comment #2)
> (In reply to comment #1)
> > This is probably because the local shell is not a real tty shell, so programs
> > running under it don't return output until completion.
> 
> Do you think it's possible to change this behavior or maybe we should just
> disable the "Local" connections in the remote launcher?

I guess that's up to you.  For now, this will still work for launches where users don't care about the standard IO.  This can be alleviated by providing a pseudo-terminal.  In fact, LocalShellThread does allow you to hook that in if an "rse.pty" JVM property is specified:

                 ...
		// if pty exists for this client
		// then the rse.pty property will have been set
		// by the contributor of the pty exectuable
		// on linux client this is a likely scenario
		PSEUDO_TERMINAL = System.getProperty("rse.pty"); //$NON-NLS-1$
		if (PSEUDO_TERMINAL != null) {
			try {
				PSEUDO_TERMINAL = FileLocator.resolve(new URL(PSEUDO_TERMINAL)).getPath();
			} catch (Exception e) {
				/* ignore, no pty available */
			}
		}
                ...
Comment 4 Anna Dushistova CLA 2011-06-15 18:29:39 EDT
Dave, can you please explain a bit more how this is supposed to work?
Thanks!
Comment 5 David McKnight CLA 2011-06-16 10:58:37 EDT
(In reply to comment #4)
> Dave, can you please explain a bit more how this is supposed to work?
> Thanks!

Anna, you can find out more by looking at the 'pty' man pages.

Here's one pulled off the web:
http://linux.die.net/man/7/pty

From RSE, a pseudo terminal executable would be used to launch the shell.  This makes the programs in the shell behave as though they were launched in a tty session, allowing the output to come back interactively rather than after program completion.