Is there a way to unset inferior-tty?

Pedro Alves palves@redhat.com
Thu Aug 11 17:16:00 GMT 2016


On 07/02/2016 03:04 PM, Marc Khouzam wrote:

> In the end I moved to a more complete solution for eclipse.   Right
> after an inferior starts, eclipse will reset the tty to a new and
> valid value; that way, if the user does a 'run', the tty will already
> be properly set _and_ will direct inferior output to a valid eclipse
> console.
> 
> FWIW, this also led me to automatically set the tty for an inferior
> that is created using the GDB console with the 'add-inferior' command
> (thanks to the =thread-group-added event). I think this will make for
> an improved user experience with the GDB console in eclipse.

Sounds to me like this will end up causing trouble.

E.g., if you follow a big tree of processes (e.g., debug "make check"
with "set detach-on-fork off"), you'll end up creating a useless tty
for each of the thousands of short lived children spawned, right?

It's also racy.  E.g., a script can do:

 add-inferior ..
 inferior 2
 run

And before you managed to handle the =thread-group-added event,
"run" has already run, so you can no longer change the inferior's
tty.

Unless you're pointing all inferiors to the same tty?
In that case, why are you destroying the original tty in
the first place?

I wonder whether what we need is a "set default-inferior-tty TTY" command,
that makes inferiors created with "add-inferior" inherit that
TTY automatically?  With that, a frontend would have (or could give the 
user the) choice of making inferiors created in the console with
add-inferior output to a separate console.  If that setting is clear,
then output of new inferiors created on the console goes to
gdb's console by default or to wherever the user forced with
"set inferior-tty", just like when running gdb outside Eclipse.

In sum:

 #1 - If "set inferior-tty" is explicitly set in the inferior, use that.
 #2 - Otherwise, if "set default-inferior-tty" is explicitly set, use that.
 #3 - Otherwise, use gdb's tty.

Thanks,
Pedro Alves



More information about the Gdb mailing list