Re: Is there a way to unset inferior-tty?

Bob Rossi
2016-07-26T19:32:47Z

On Tue, Jul 26, 2016 at 07:22:34PM +0000, Marc Khouzam wrote:
> > On Sat, Jul 02, 2016 at 02:04:39PM +0000, Marc Khouzam wrote:
> > > > > I think this should just be fixed to work.
> > > > >
> > > > > The fix should be very similar to this:
> > > > >
> > > > >
> > > > > https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=811a659a779fdf93293fe1105d99e9db171a8b68
> > > > >
> > > > > Thanks,
> > > > > Pedro Alves
> > > >
> > > > Hi Marc,
> > > >
> > > > Here's a patch. If you like it I'll submit it to gdb-patches with
> > > > ChangeLog and all.
> > >
> > > Thanks! Might as well submit it.
> > >
> > > 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.
> >
> > I do the same thing in CGDB.
>
> Great, that helps confirm this is a good approach.
>
> Do you handle the output of a second inferior?
> If the user does 'add-inferior' and then runs it,
> I was planning on redirecting that new output to a
> new Eclipse console. This is causing me some
> trouble though because when the new inferior
> starts, I don't know if it was due to a 'run' or
> an 'attach', so I'm not sure if I should be expecting
> some output or not.
>
> Have you seen this too?

Here's how I solved it, it's sort of ugly.

I create a pty in CGDB and tell GDB to assign the inferior to it, using
tty /dev/...
The inferior then writes to one end of the pty, and CGDB has a select
loop which reads from the other end.

If GDB or the inferior closes the file handle, I'll read an EOF in the
select loop. In that case, I simply create a new pty and rerun the tty command.

With that approach in mind, i'm not sure who closed the handle or why.
I just open a new one and assign it.

I didn't know, until today, that multiple inferiors could exist!
Does GDB even support one /tty per inferior in that case?
CGDB certainly doesn't support this mode.

Good Luck!

Thanks,
Bob Rossi