Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* RE: MI testsuite to use PTY for inferior
@ 2005-07-30  5:54 Nick Roberts
  2005-07-30 17:39 ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Nick Roberts @ 2005-07-30  5:54 UTC (permalink / raw)
  To: Bob Rossi; +Cc: gdb-patches


Bob,

I've looked at your patch and have some comments.  I'm not very familiar
with expect so some of what I say might be wrong.


> +# INFERIOR_PTY should be set to TRUE to have the inferior work with it's
> +# own PTY. If set to FALSE, the inferior shares GDB's PTY.
>  #
>  # When running over NFS, particularly if running many simultaneous
>  # tests on different hosts all using the same server, things can
>  # get really slow.  Give gdb at least 3 minutes to start up.
>  #
> -proc mi_gdb_start { } {
> +proc mi_gdb_start { args } {
>      global verbose
>      global GDB
>      global GDBFLAGS
> @@ -99,6 +105,10 @@
>  
>      gdb_stop_suppressing_tests;
>  
> +    if { [llength $args] == 1} {
> +	set inferior_pty [lindex $args 0]
> +    }
> +
>      # Start SID.
>      if { [info procs sid_start] != "" } {
>  	verbose "Spawning SID"
> @@ -117,6 +127,16 @@
>  	    exit 1
>  	}
>      }
> +
> +    # spawn off the new pty for the inferior process

Open a new pty for the inferior process? (spawn means new process?)

> +    if { [ info exists inferior_pty ] } {
> +	spawn -pty
> +	global mi_inferior_spawn_id
> +	global mi_inferior_tty_name
> +	set mi_inferior_spawn_id $spawn_id
> +	set mi_inferior_tty_name $spawn_out(slave,name)
> +    }
> +

This seems to try to open a new pty even if inferior_pty is false.  Shouldn't
the condition, here and elsewhere, be:

if { $inferior_pty } {

> -# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
> +# mi_gdb_test COMMAND PATTERN IPATTERN MESSAGE -- send a command to gdb; test the result.
>  #
>  # COMMAND is the command to execute, send to GDB with send_gdb.  If
>  #   this is the null string no command is sent.
>  # PATTERN is the pattern to match for a PASS, and must NOT include
>  #   the \r\n sequence immediately before the gdb prompt.
> +# IPATTERN is the pattern to match for the inferior's output. This will not 
> +#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
>  # MESSAGE is an optional message to be printed.  If this is
>  #   omitted, then the pass/fail messages use the command string as the
>  #   message.  (If this is the empty string, then sometimes we don't
> @@ -533,14 +568,20 @@

With these arguments, you can't discriminate between

mi_gdb_test COMMAND PATTERN MESSAGE

and

mi_gdb_test COMMAND PATTERN IPATTERN

(MESSAGE is optional).

Re your ChangeLog entry,

> +	* gdb.mi/mi-console.exp: Ditto.
> +	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.

47-exec-next isn't a procedure.  I would just do:

* gdb.mi/mi-console.exp: Use mi_gdb_test to get GDB and Inferior output.

I know that "Ditto." and "Likewise." are used often in GDB but I prefer:

	* gdb.mi/gdb669.exp, gdb.mi/gdb680.exp, gdb.mi/gdb701.exp,
	gdb.mi/gdb792.exp, gdb.mi/mi-break.exp, gdb.mi/mi-disassemble.exp,
	gdb.mi/mi-eval.exp: Tell mi_gdb_start to use a PTY for inferior.
	Update Copyright.

I can't really comment yet on the essence of what you are doing yet, but it
looks sound to me.

Nick


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30  5:54 MI testsuite to use PTY for inferior Nick Roberts
@ 2005-07-30 17:39 ` Bob Rossi
  2005-07-30 18:08   ` Daniel Jacobowitz
  2005-07-30 22:47   ` Nick Roberts
  0 siblings, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-07-30 17:39 UTC (permalink / raw)
  To: Nick Roberts; +Cc: gdb-patches

> I've looked at your patch and have some comments.  I'm not very familiar
> with expect so some of what I say might be wrong.

Nick, thanks for taking the time.

> > +# INFERIOR_PTY should be set to TRUE to have the inferior work with it's
> > +# own PTY. If set to FALSE, the inferior shares GDB's PTY.
> >  #
> >  # When running over NFS, particularly if running many simultaneous
> >  # tests on different hosts all using the same server, things can
> >  # get really slow.  Give gdb at least 3 minutes to start up.
> >  #
> > -proc mi_gdb_start { } {
> > +proc mi_gdb_start { args } {
> >      global verbose
> >      global GDB
> >      global GDBFLAGS
> > @@ -99,6 +105,10 @@
> >  
> >      gdb_stop_suppressing_tests;
> >  
> > +    if { [llength $args] == 1} {
> > +	set inferior_pty [lindex $args 0]
> > +    }
> > +
> >      # Start SID.
> >      if { [info procs sid_start] != "" } {
> >  	verbose "Spawning SID"
> > @@ -117,6 +127,16 @@
> >  	    exit 1
> >  	}
> >      }
> > +
> > +    # spawn off the new pty for the inferior process
> 
> Open a new pty for the inferior process? (spawn means new process?)

I used the verb "spawn" because in order to get a new pty you have to
call 'spawn pty'. If it is prefered to say "Create the new pty ...", I
can change that.

> > +    if { [ info exists inferior_pty ] } {
> > +	spawn -pty
> > +	global mi_inferior_spawn_id
> > +	global mi_inferior_tty_name
> > +	set mi_inferior_spawn_id $spawn_id
> > +	set mi_inferior_tty_name $spawn_out(slave,name)
> > +    }
> > +
> 
> This seems to try to open a new pty even if inferior_pty is false.  Shouldn't
> the condition, here and elsewhere, be:
> 
> if { $inferior_pty } {

I think this could be a style issue, but I'm not sure. I only create the
inferior_pty variable if mi_gdb_start's INFERIOR_PTY is true. Then I
check in later calls to see if the variable inferior_pty exists via
'info exists inferior_pty'. 

I'm pretty sure this is equivalent to always creating the variable
inferior_pty and always assigning it a true/false value based on
INFERIOR_PTY. Then I could do an if on it's value, instead of simply
it's existence.

Is one of these approaches prefered over the other in GDB's testsuite or
in TCL programming?

> > -# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
> > +# mi_gdb_test COMMAND PATTERN IPATTERN MESSAGE -- send a command to gdb; test the result.
> >  #
> >  # COMMAND is the command to execute, send to GDB with send_gdb.  If
> >  #   this is the null string no command is sent.
> >  # PATTERN is the pattern to match for a PASS, and must NOT include
> >  #   the \r\n sequence immediately before the gdb prompt.
> > +# IPATTERN is the pattern to match for the inferior's output. This will not 
> > +#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
> >  # MESSAGE is an optional message to be printed.  If this is
> >  #   omitted, then the pass/fail messages use the command string as the
> >  #   message.  (If this is the empty string, then sometimes we don't
> > @@ -533,14 +568,20 @@
> 
> With these arguments, you can't discriminate between
> 
> mi_gdb_test COMMAND PATTERN MESSAGE
> 
> and
> 
> mi_gdb_test COMMAND PATTERN IPATTERN
> 
> (MESSAGE is optional).

Yeah, this does look like a problem. Thanks. Is there a good way to work
around this in TCL? Or should I make the IPATTERN parameter necessary?
Force the user to put "" for IPATTERN? 

Or rather, should I make the MESSAGE parameter necessary? I have a feeling 
that all of the MI tests use the MESSAGE parameter. If I do that, I can
make the IPATTERN parameter optional, and last.

> Re your ChangeLog entry,
> > +	* gdb.mi/mi-console.exp: Ditto.
> > +	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
> 
> 47-exec-next isn't a procedure.  I would just do:
> 
> * gdb.mi/mi-console.exp: Use mi_gdb_test to get GDB and Inferior output.
> 
> I know that "Ditto." and "Likewise." are used often in GDB but I prefer:
> 
> 	* gdb.mi/gdb669.exp, gdb.mi/gdb680.exp, gdb.mi/gdb701.exp,
> 	gdb.mi/gdb792.exp, gdb.mi/mi-break.exp, gdb.mi/mi-disassemble.exp,
> 	gdb.mi/mi-eval.exp: Tell mi_gdb_start to use a PTY for inferior.
> 	Update Copyright.

I will gladly change my ChangeLog sytle if either Daneil or Eli agree
with your assessment. I have currently built up my ChangeLog style as a
repetitive response from Daneil and Eli in order to comply with there
style, in order to get faster patch review time.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 17:39 ` Bob Rossi
@ 2005-07-30 18:08   ` Daniel Jacobowitz
  2005-07-30 22:47     ` Nick Roberts
  2005-07-30 22:47   ` Nick Roberts
  1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-07-30 18:08 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches

I haven't had time to look at the whole patch yet; I'll do that later
today or tomorrow, I had a couple of comments.  But let me respond to a
couple of things here first...

On Sat, Jul 30, 2005 at 01:38:56PM -0400, Bob Rossi wrote:
> > > +
> > > +    # spawn off the new pty for the inferior process
> > 
> > Open a new pty for the inferior process? (spawn means new process?)
> 
> I used the verb "spawn" because in order to get a new pty you have to
> call 'spawn pty'. If it is prefered to say "Create the new pty ...", I
> can change that.

Either way, formatting - capitals and periods.  I would recommend
"create the new pty", because you can't spawn off a PTY; it's not
something which runs on its own.

> > > -# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
> > > +# mi_gdb_test COMMAND PATTERN IPATTERN MESSAGE -- send a command to gdb; test the result.
> > >  #
> > >  # COMMAND is the command to execute, send to GDB with send_gdb.  If
> > >  #   this is the null string no command is sent.
> > >  # PATTERN is the pattern to match for a PASS, and must NOT include
> > >  #   the \r\n sequence immediately before the gdb prompt.
> > > +# IPATTERN is the pattern to match for the inferior's output. This will not 
> > > +#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
> > >  # MESSAGE is an optional message to be printed.  If this is
> > >  #   omitted, then the pass/fail messages use the command string as the
> > >  #   message.  (If this is the empty string, then sometimes we don't
> > > @@ -533,14 +568,20 @@
> > 
> > With these arguments, you can't discriminate between
> > 
> > mi_gdb_test COMMAND PATTERN MESSAGE
> > 
> > and
> > 
> > mi_gdb_test COMMAND PATTERN IPATTERN
> > 
> > (MESSAGE is optional).
> 
> Yeah, this does look like a problem. Thanks. Is there a good way to work
> around this in TCL? Or should I make the IPATTERN parameter necessary?
> Force the user to put "" for IPATTERN? 
> 
> Or rather, should I make the MESSAGE parameter necessary? I have a feeling 
> that all of the MI tests use the MESSAGE parameter. If I do that, I can
> make the IPATTERN parameter optional, and last.

You're adding a new parameter; having it optional is fine, as long as
you add it after all existing optional parameters.  COMMAND PATTERN
IPATTERN MESSAGE is more intuitive, but I think that's less important
than correctness, so I would recommend COMMAND PATTERN [MESSAGE
[IPATTERN]].  Make sense?

> > I know that "Ditto." and "Likewise." are used often in GDB but I prefer:
> > 
> > 	* gdb.mi/gdb669.exp, gdb.mi/gdb680.exp, gdb.mi/gdb701.exp,
> > 	gdb.mi/gdb792.exp, gdb.mi/mi-break.exp, gdb.mi/mi-disassemble.exp,
> > 	gdb.mi/mi-eval.exp: Tell mi_gdb_start to use a PTY for inferior.
> > 	Update Copyright.
> 
> I will gladly change my ChangeLog sytle if either Daneil or Eli agree
> with your assessment. I have currently built up my ChangeLog style as a
> repetitive response from Daneil and Eli in order to comply with there
> style, in order to get faster patch review time.

I don't much care which of these you use.  You don't need to mention
updating the copyright year in the changelog unless you're doing
archaeology, though - if you're just adding the current year, don't
bother.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 17:39 ` Bob Rossi
  2005-07-30 18:08   ` Daniel Jacobowitz
@ 2005-07-30 22:47   ` Nick Roberts
  2005-07-30 23:03     ` Bob Rossi
  1 sibling, 1 reply; 62+ messages in thread
From: Nick Roberts @ 2005-07-30 22:47 UTC (permalink / raw)
  To: Bob Rossi; +Cc: gdb-patches

Bob Rossi writes:
 > > This seems to try to open a new pty even if inferior_pty is false.  Shouldn't
 > > the condition, here and elsewhere, be:
 > > 
 > > if { $inferior_pty } {
 > 
 > I think this could be a style issue, but I'm not sure. I only create the
 > inferior_pty variable if mi_gdb_start's INFERIOR_PTY is true. Then I
 > check in later calls to see if the variable inferior_pty exists via
 > 'info exists inferior_pty'. 

Perhaps I've not understood the context but what if somenone uses:

if {[mi_gdb_start false]} {

as a condition for a test?

Nick


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 18:08   ` Daniel Jacobowitz
@ 2005-07-30 22:47     ` Nick Roberts
  2005-07-31  1:19       ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Nick Roberts @ 2005-07-30 22:47 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: gdb-patches

 > > > With these arguments, you can't discriminate between
 > > > 
 > > > mi_gdb_test COMMAND PATTERN MESSAGE
 > > > 
 > > > and
 > > > 
 > > > mi_gdb_test COMMAND PATTERN IPATTERN
 > > > 
 > > > (MESSAGE is optional).
 > > 
 > > Yeah, this does look like a problem. Thanks. Is there a good way to work
 > > around this in TCL? Or should I make the IPATTERN parameter necessary?
 > > Force the user to put "" for IPATTERN? 
 > > 
 > > Or rather, should I make the MESSAGE parameter necessary? I have a feeling 
 > > that all of the MI tests use the MESSAGE parameter. If I do that, I can
 > > make the IPATTERN parameter optional, and last.
 > 
 > You're adding a new parameter; having it optional is fine, as long as
 > you add it after all existing optional parameters.  COMMAND PATTERN
 > IPATTERN MESSAGE is more intuitive, but I think that's less important
 > than correctness, so I would recommend COMMAND PATTERN [MESSAGE
 > [IPATTERN]].  Make sense?

That seems to imply that if IPATTERN is present, MESSAGE can't be omitted.
How about:

# mi_gdb_test COMMAND PATTERN-LIST [MESSAGE]
...
# PATTERN-LIST is the list {PATTERN [IPATTERN]} where:
# PATTERN is the pattern to match for a PASS, and must NOT include
#   the \r\n sequence immediately before the gdb prompt.
# IPATTERN is the pattern to match for the inferior's output. This will not 
#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.

    if {[llength $PATTERN-LIST] == 1} {
 	...
    } elseif {[llength $PATTERN-LIST] == 2} {
        ...

  This seems to be compatible with existing arguments as scalars seem to be
considered as lists of length 1.  But perhaps you can't have lists within
argument lists in TCL.

Nick


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 22:47   ` Nick Roberts
@ 2005-07-30 23:03     ` Bob Rossi
  2005-07-31  1:21       ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-07-30 23:03 UTC (permalink / raw)
  To: Nick Roberts; +Cc: gdb-patches

On Sun, Jul 31, 2005 at 10:16:31AM +1200, Nick Roberts wrote:
> Bob Rossi writes:
>  > > This seems to try to open a new pty even if inferior_pty is false.  Shouldn't
>  > > the condition, here and elsewhere, be:
>  > > 
>  > > if { $inferior_pty } {
>  > 
>  > I think this could be a style issue, but I'm not sure. I only create the
>  > inferior_pty variable if mi_gdb_start's INFERIOR_PTY is true. Then I
>  > check in later calls to see if the variable inferior_pty exists via
>  > 'info exists inferior_pty'. 
> 
> Perhaps I've not understood the context but what if somenone uses:
> 
> if {[mi_gdb_start false]} {
> 
> as a condition for a test?

Hi Nick,

Now I see your point, sorry I didn't see it earlier.

The code in mi_gdb_start,

    if { [llength $args] == 1} {
        set inferior_pty [lindex $args 0]
    }   

does not really do what I intended. Probably this would be closer.

    if { [llength $args] == 1} {
       if { [lindex $args 0] } {
        set inferior_pty true
       }
    }   

However, since that's pretty ugly, I'll take your suggestion and always
create and assign inferior_pty a value. Then I'll check it for the value
of "true" before executing any code.

Thanks again,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 22:47     ` Nick Roberts
@ 2005-07-31  1:19       ` Daniel Jacobowitz
  0 siblings, 0 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-07-31  1:19 UTC (permalink / raw)
  To: Nick Roberts; +Cc: gdb-patches

On Sun, Jul 31, 2005 at 10:27:59AM +1200, Nick Roberts wrote:
> That seems to imply that if IPATTERN is present, MESSAGE can't be omitted.

Yes.  If this bugs you, you could make a message of "" be handled like
an omitted message.

> How about:
> 
> # mi_gdb_test COMMAND PATTERN-LIST [MESSAGE]
> ...
> # PATTERN-LIST is the list {PATTERN [IPATTERN]} where:
> # PATTERN is the pattern to match for a PASS, and must NOT include
> #   the \r\n sequence immediately before the gdb prompt.
> # IPATTERN is the pattern to match for the inferior's output. This will not 
> #   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
> 
>     if {[llength $PATTERN-LIST] == 1} {
>  	...
>     } elseif {[llength $PATTERN-LIST] == 2} {
>         ...
> 
>   This seems to be compatible with existing arguments as scalars seem to be
> considered as lists of length 1.  But perhaps you can't have lists within
> argument lists in TCL.

No, that won't work correctly.  TCL quoting is funny.  Look at this:

% set a "a"
a
% llength $a
1
% set a "a b"
a b
% llength $a
2

It reparses the string, textually, as a list.  Most patterns will be
more than one "item".  This would be easy in Python, but is a bit of a
bear in TCL.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-30 23:03     ` Bob Rossi
@ 2005-07-31  1:21       ` Daniel Jacobowitz
  2005-07-31 13:16         ` Bob Rossi
  2005-08-03  2:07         ` Bob Rossi
  0 siblings, 2 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-07-31  1:21 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches

On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> However, since that's pretty ugly, I'll take your suggestion and always
> create and assign inferior_pty a value. Then I'll check it for the value
> of "true" before executing any code.

I recommend doing something different.  Make the argument a flag, i.e.
"mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
default to be.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31  1:21       ` Daniel Jacobowitz
@ 2005-07-31 13:16         ` Bob Rossi
  2005-07-31 15:31           ` Daniel Jacobowitz
  2005-07-31 21:35           ` Nick Roberts
  2005-08-03  2:07         ` Bob Rossi
  1 sibling, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-07-31 13:16 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches

On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > However, since that's pretty ugly, I'll take your suggestion and always
> > create and assign inferior_pty a value. Then I'll check it for the value
> > of "true" before executing any code.
> 
> I recommend doing something different.  Make the argument a flag, i.e.
> "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> default to be.

If it would be OK, I'd prefer to just have the TTY work with all MI
tests, not making it optional. I'd like to repost the patch with all of
the problems found already, and with that additional change. Is this OK?

My theory is that no FE can/should use MI with out separating the inferior
output via a pty. So, it's OK to test GDB under these assumptions.

Here is the original patch with Andrew's comments on this, from a while back,
   http://sources.redhat.com/ml/gdb-patches/2005-02/msg00085.html

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 13:16         ` Bob Rossi
@ 2005-07-31 15:31           ` Daniel Jacobowitz
  2005-07-31 21:20             ` Bob Rossi
  2005-07-31 21:35           ` Nick Roberts
  1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-07-31 15:31 UTC (permalink / raw)
  To: gdb-patches; +Cc: Nick Roberts

On Sun, Jul 31, 2005 at 09:16:53AM -0400, Bob Rossi wrote:
> On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > However, since that's pretty ugly, I'll take your suggestion and always
> > > create and assign inferior_pty a value. Then I'll check it for the value
> > > of "true" before executing any code.
> > 
> > I recommend doing something different.  Make the argument a flag, i.e.
> > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > default to be.
> 
> If it would be OK, I'd prefer to just have the TTY work with all MI
> tests, not making it optional. I'd like to repost the patch with all of
> the problems found already, and with that additional change. Is this OK?
> 
> My theory is that no FE can/should use MI with out separating the inferior
> output via a pty. So, it's OK to test GDB under these assumptions.

Well, first, let me ask you a question.  What is the intended fate of
the old mechanism for interleaved output?  The new TTY method has at
least two limitations:

  - As far as I know, native Win32 targets can't use PTYs:
      http://world.std.com/~jmhart/critcom.htm#UNIX%20Pseudoterminal
    So, they'll probably need something different.

  - Remote targets that provide output currently aren't redirected onto
    the PTY; instead they'll appear interleaved, just like before.

Also, Andrew pretty specifically asked you to leave the mi2-* tests
alone for this change.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 15:31           ` Daniel Jacobowitz
@ 2005-07-31 21:20             ` Bob Rossi
  2005-08-01  1:53               ` Daniel Jacobowitz
  2005-08-01  3:56               ` Eli Zaretskii
  0 siblings, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-07-31 21:20 UTC (permalink / raw)
  To: gdb-patches, Nick Roberts

On Sun, Jul 31, 2005 at 11:30:52AM -0400, Daniel Jacobowitz wrote:
> On Sun, Jul 31, 2005 at 09:16:53AM -0400, Bob Rossi wrote:
> > On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > > However, since that's pretty ugly, I'll take your suggestion and always
> > > > create and assign inferior_pty a value. Then I'll check it for the value
> > > > of "true" before executing any code.
> > > 
> > > I recommend doing something different.  Make the argument a flag, i.e.
> > > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > > default to be.
> > 
> > If it would be OK, I'd prefer to just have the TTY work with all MI
> > tests, not making it optional. I'd like to repost the patch with all of
> > the problems found already, and with that additional change. Is this OK?
> > 
> > My theory is that no FE can/should use MI with out separating the inferior
> > output via a pty. So, it's OK to test GDB under these assumptions.
> 
> Well, first, let me ask you a question.  What is the intended fate of
> the old mechanism for interleaved output?  The new TTY method has at
> least two limitations:

This is very interesting. This branches into 2 areas, the testsuite and
FE's). As far as the testsuite is concerned, if we add this patch
optional (currently the way it is), then everything is fine for target's
that don't support any TTY mechanism. If we add the patch unconditionally, 
then I would say that the target's that don't support TTY's are
unsupported by GDB/MI.

What is GDB's stance on supporting target's via GDB/MI that can not support
creating TTY's? Off the top of my head, I don't think it makes sense to
support these targets. You can not write a reliable FE under theses
circumstances. The inferior can spew out anything it chooses, including
partial MI fragments (if inferior == GDB).

>   - As far as I know, native Win32 targets can't use PTYs:
>       http://world.std.com/~jmhart/critcom.htm#UNIX%20Pseudoterminal
>     So, they'll probably need something different.

In this scenario, I think Cygwin is the answer. Or use GDB/MI with an
inferior program that doesn't output anything to the terminal.

>   - Remote targets that provide output currently aren't redirected onto
>     the PTY; instead they'll appear interleaved, just like before.

In this scenario, I'm guessing from the sound of it that GDB just hasn't
added support for this yet. So it's a GDB bug, right? I could look into
this if I had some direction.

> Also, Andrew pretty specifically asked you to leave the mi2-* tests
> alone for this change.

Well, he definatly was against it at first, and then I thought maybe he
was changing his mind,

   http://sources.redhat.com/ml/gdb-patches/2005-02/msg00110.html

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 13:16         ` Bob Rossi
  2005-07-31 15:31           ` Daniel Jacobowitz
@ 2005-07-31 21:35           ` Nick Roberts
  2005-07-31 21:37             ` Daniel Jacobowitz
  1 sibling, 1 reply; 62+ messages in thread
From: Nick Roberts @ 2005-07-31 21:35 UTC (permalink / raw)
  To: Bob Rossi; +Cc: gdb-patches

 > If it would be OK, I'd prefer to just have the TTY work with all MI
 > tests, not making it optional. I'd like to repost the patch with all of
 > the problems found already, and with that additional change. Is this OK?
 > 
 > My theory is that no FE can/should use MI with out separating the inferior
 > output via a pty. So, it's OK to test GDB under these assumptions.

 I think you should at least test for ptys first, so that the old tests are
run if/when they are not available.  More generally I think its wrong to force
the frontend to separate the output.  Currently, I get reasonable behaviour
with Emacs without doing this and would always include interleaved output as a
user option.

Nick


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 21:35           ` Nick Roberts
@ 2005-07-31 21:37             ` Daniel Jacobowitz
  2005-07-31 23:32               ` Nick Roberts
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-07-31 21:37 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Bob Rossi, gdb-patches

On Mon, Aug 01, 2005 at 09:36:29AM +1200, Nick Roberts wrote:
>  > If it would be OK, I'd prefer to just have the TTY work with all MI
>  > tests, not making it optional. I'd like to repost the patch with all of
>  > the problems found already, and with that additional change. Is this OK?
>  > 
>  > My theory is that no FE can/should use MI with out separating the inferior
>  > output via a pty. So, it's OK to test GDB under these assumptions.
> 
>  I think you should at least test for ptys first, so that the old tests are
> run if/when they are not available.

Won't do any good - expect relies on PTYs.  If the system the tests are
run on does not have PTYs, it won't have the testsuite either.

>  More generally I think its wrong to force
> the frontend to separate the output.  Currently, I get reasonable behaviour
> with Emacs without doing this and would always include interleaved output as a
> user option.

Would it hurt you to stitch them back together, though?  The fewer
interfaces we have to support, the better...

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 21:37             ` Daniel Jacobowitz
@ 2005-07-31 23:32               ` Nick Roberts
  2005-08-01  1:51                 ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Nick Roberts @ 2005-07-31 23:32 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Bob Rossi, gdb-patches

 > >  I think you should at least test for ptys first, so that the old tests are
 > > run if/when they are not available.
 > 
 > Won't do any good - expect relies on PTYs.  If the system the tests are
 > run on does not have PTYs, it won't have the testsuite either.

I see.

 > >  More generally I think its wrong to force
 > > the frontend to separate the output.  Currently, I get reasonable behaviour
 > > with Emacs without doing this and would always include interleaved output as a
 > > user option.
 > 
 > Would it hurt you to stitch them back together, though?  The fewer
 > interfaces we have to support, the better...

I guess it would even be safer in cases where the inferior has similar output
e.g debugging GDB itself.  However, I thought there were systems where ptys
weren't available (w32?).  Even if you can't run the testsuite, you might
still want to run GDB there (actually, I thought FSF GDB *is* being ported to
w32 - how is it tested?).

Nick


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 23:32               ` Nick Roberts
@ 2005-08-01  1:51                 ` Daniel Jacobowitz
  0 siblings, 0 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01  1:51 UTC (permalink / raw)
  To: Nick Roberts; +Cc: Bob Rossi, gdb-patches

On Mon, Aug 01, 2005 at 11:25:03AM +1200, Nick Roberts wrote:
>  > >  More generally I think its wrong to force
>  > > the frontend to separate the output.  Currently, I get reasonable behaviour
>  > > with Emacs without doing this and would always include interleaved output as a
>  > > user option.
>  > 
>  > Would it hurt you to stitch them back together, though?  The fewer
>  > interfaces we have to support, the better...
> 
> I guess it would even be safer in cases where the inferior has similar output
> e.g debugging GDB itself.  However, I thought there were systems where ptys

Yes, I agree.

> weren't available (w32?).  Even if you can't run the testsuite, you might
> still want to run GDB there (actually, I thought FSF GDB *is* being ported to
> w32 - how is it tested?).

Yes.  And, there, we are going to need a different solution.  Probably,
we would declare applications that use the console IO routines directly
unsupported, and run other applications via a pipe, allowing GDB to
capture input and output separately.  Lots of people are interested in
native Windows debugging - but not so many are interested in console
apps!

Speaking for CodeSourcery, we're only porting GDB to Windows _host_. So
it doesn't need much testing besides making sure the CLI works OK.  And
you can run expect under Cygwin to test a mingw32 GDB, which I hadn't
thought about in my previous message.  But we don't do that at the
moment.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 21:20             ` Bob Rossi
@ 2005-08-01  1:53               ` Daniel Jacobowitz
  2005-08-01  2:05                 ` Bob Rossi
  2005-08-01  3:56               ` Eli Zaretskii
  1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01  1:53 UTC (permalink / raw)
  To: gdb-patches

On Sun, Jul 31, 2005 at 05:20:21PM -0400, Bob Rossi wrote:
> What is GDB's stance on supporting target's via GDB/MI that can not support
> creating TTY's? Off the top of my head, I don't think it makes sense to
> support these targets. You can not write a reliable FE under theses
> circumstances. The inferior can spew out anything it chooses, including
> partial MI fragments (if inferior == GDB).
> 
> >   - As far as I know, native Win32 targets can't use PTYs:
> >       http://world.std.com/~jmhart/critcom.htm#UNIX%20Pseudoterminal
> >     So, they'll probably need something different.
> 
> In this scenario, I think Cygwin is the answer. Or use GDB/MI with an
> inferior program that doesn't output anything to the terminal.

That's probably what usually happens.  I don't know.  I can't say it's
a priority for me.

> >   - Remote targets that provide output currently aren't redirected onto
> >     the PTY; instead they'll appear interleaved, just like before.
> 
> In this scenario, I'm guessing from the sound of it that GDB just hasn't
> added support for this yet. So it's a GDB bug, right? I could look into
> this if I had some direction.

I don't know.  What do you want it to do?  GDB to set up a fake
terminal and push output to it?  Might make sense, might not, haven't
thought about it.

> > Also, Andrew pretty specifically asked you to leave the mi2-* tests
> > alone for this change.
> 
> Well, he definatly was against it at first, and then I thought maybe he
> was changing his mind,
> 
>    http://sources.redhat.com/ml/gdb-patches/2005-02/msg00110.html

I don't think Andrew's concern in that message is related, but you
could ask him.  In any case I think that this is yet another way in
which we ought to leave the MI2 tests alone.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01  1:53               ` Daniel Jacobowitz
@ 2005-08-01  2:05                 ` Bob Rossi
  2005-08-01  2:15                   ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-01  2:05 UTC (permalink / raw)
  To: gdb-patches

> > >   - Remote targets that provide output currently aren't redirected onto
> > >     the PTY; instead they'll appear interleaved, just like before.
> > 
> > In this scenario, I'm guessing from the sound of it that GDB just hasn't
> > added support for this yet. So it's a GDB bug, right? I could look into
> > this if I had some direction.
> 
> I don't know.  What do you want it to do?  GDB to set up a fake
> terminal and push output to it?  Might make sense, might not, haven't
> thought about it.

Why doesn't GDB open a pty and simply give the FE the name of the device
it can read the inferior I/O from? This would simplify a lot of things.

Although, it still would not work nativly on Windows. However, if GDB
doesn't support inferior I/O on the host, it wouldn't be expected to
when using the remote target. The only difference is that only a Cygwin
port of GDB to windows would be able to support this feature, not a
Windows's part of GDB.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01  2:05                 ` Bob Rossi
@ 2005-08-01  2:15                   ` Daniel Jacobowitz
  2005-08-01 11:32                     ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01  2:15 UTC (permalink / raw)
  To: gdb-patches

On Sun, Jul 31, 2005 at 10:05:25PM -0400, Bob Rossi wrote:
> > > >   - Remote targets that provide output currently aren't redirected onto
> > > >     the PTY; instead they'll appear interleaved, just like before.
> > > 
> > > In this scenario, I'm guessing from the sound of it that GDB just hasn't
> > > added support for this yet. So it's a GDB bug, right? I could look into
> > > this if I had some direction.
> > 
> > I don't know.  What do you want it to do?  GDB to set up a fake
> > terminal and push output to it?  Might make sense, might not, haven't
> > thought about it.
> 
> Why doesn't GDB open a pty and simply give the FE the name of the device
> it can read the inferior I/O from? This would simplify a lot of things.

Didn't we go through this already and decide it was better for the user
to provide the TTY and tell GDB where to send the user?  Just like we
do now for set inferior-tty?

It wouldn't be a big stretch to make this go for remote targets; GDB
would do the writing instead of the inferior.  There'd be no input.

For Windows, if someone cared to implement it, you could probably pass
a pipe to GDB in some fashion.  I do not know enough about Windows to
know how, or care enough about native Windows use of MI to figure it
out myself.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31 21:20             ` Bob Rossi
  2005-08-01  1:53               ` Daniel Jacobowitz
@ 2005-08-01  3:56               ` Eli Zaretskii
  2005-08-01 11:30                 ` Bob Rossi
  1 sibling, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-01  3:56 UTC (permalink / raw)
  To: gdb-patches

> Date: Sun, 31 Jul 2005 17:20:21 -0400
> From: Bob Rossi <bob@brasko.net>
> 
> What is GDB's stance on supporting target's via GDB/MI that can not support
> creating TTY's? Off the top of my head, I don't think it makes sense to
> support these targets.

Please don't jump to such far-fetched conclusions.  The fact that some
obscure feature is not available on some platform does not mean GDB
should drop support for that platform.  I would object to removing
support for any platform on such feeble grounds.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01  3:56               ` Eli Zaretskii
@ 2005-08-01 11:30                 ` Bob Rossi
  2005-08-01 13:00                   ` Daniel Jacobowitz
  2005-08-01 18:45                   ` Eli Zaretskii
  0 siblings, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 11:30 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Mon, Aug 01, 2005 at 06:56:28AM +0300, Eli Zaretskii wrote:
> > Date: Sun, 31 Jul 2005 17:20:21 -0400
> > From: Bob Rossi <bob@brasko.net>
> > 
> > What is GDB's stance on supporting target's via GDB/MI that can not support
> > creating TTY's? Off the top of my head, I don't think it makes sense to
> > support these targets.
> 
> Please don't jump to such far-fetched conclusions.  The fact that some
> obscure feature is not available on some platform does not mean GDB
> should drop support for that platform.  I would object to removing
> support for any platform on such feeble grounds.

Hi Eli,

I am claiming that a reliable FE can not be written if the inferior writes 
data to the same output stream as GDB/MI's output stream. So, on native 
windows, if the inferior I/O and GDB/MI I/O can not be separated, it 
wouldn't be worth while to write an FE on that platform.

Nick, does Emacs port natively to windows? Does GDB/MI work reliably for
you there?

Currently, native windows can not use the already crucial feature of the
PTY for separating inferior I/O and GDB/MI I/O. The precedent has
already been set. I don't think GDB should stop the use of PTY's in any
feature of MI in order to improve itself because some platform's don't
support the feature.

With that said, I don't think GDB should "drop support" for native 
windows either. I just think it's OK to use PTY's and assume platforms
that don't support it are kind of screwed.

Are there any other routes to go down here? Should we have an
alternative mode where GDB reads the output of the inferior and writes
it to a named pipe? or simply writes it encoded in the MI output stream?
This functionality could work in both UNIX/windows. However, it wouldn't
give terminal semantics.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01  2:15                   ` Daniel Jacobowitz
@ 2005-08-01 11:32                     ` Bob Rossi
  0 siblings, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 11:32 UTC (permalink / raw)
  To: gdb-patches

On Sun, Jul 31, 2005 at 10:15:13PM -0400, Daniel Jacobowitz wrote:
> On Sun, Jul 31, 2005 at 10:05:25PM -0400, Bob Rossi wrote:
> > > > >   - Remote targets that provide output currently aren't redirected onto
> > > > >     the PTY; instead they'll appear interleaved, just like before.
> > > > 
> > > > In this scenario, I'm guessing from the sound of it that GDB just hasn't
> > > > added support for this yet. So it's a GDB bug, right? I could look into
> > > > this if I had some direction.
> > > 
> > > I don't know.  What do you want it to do?  GDB to set up a fake
> > > terminal and push output to it?  Might make sense, might not, haven't
> > > thought about it.
> > 
> > Why doesn't GDB open a pty and simply give the FE the name of the device
> > it can read the inferior I/O from? This would simplify a lot of things.
> 
> Didn't we go through this already and decide it was better for the user
> to provide the TTY and tell GDB where to send the user?  Just like we
> do now for set inferior-tty?

Well, the previous discussion was a little different, but if you don't
like the idea, that's fine.

> It wouldn't be a big stretch to make this go for remote targets; GDB
> would do the writing instead of the inferior.  There'd be no input.
> 
> For Windows, if someone cared to implement it, you could probably pass
> a pipe to GDB in some fashion.  I do not know enough about Windows to
> know how, or care enough about native Windows use of MI to figure it
> out myself.

Yeah, so you think it would make sense to have GDB simply encode the
remote output into the GDB/MI output stream the way the documentation
says it should. That makes much more sense.

Is it as simple to do as it sounds?

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 11:30                 ` Bob Rossi
@ 2005-08-01 13:00                   ` Daniel Jacobowitz
  2005-08-01 13:16                     ` Bob Rossi
  2005-08-01 18:45                   ` Eli Zaretskii
  1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01 13:00 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches

On Mon, Aug 01, 2005 at 07:30:02AM -0400, Bob Rossi wrote:
> Hi Eli,
> 
> I am claiming that a reliable FE can not be written if the inferior writes 
> data to the same output stream as GDB/MI's output stream. So, on native 
> windows, if the inferior I/O and GDB/MI I/O can not be separated, it 
> wouldn't be worth while to write an FE on that platform.

That's a very strange judgement call:

 (A) The huge majority of Windows programs don't even write to the
console.

 (B) The huge majority of programs which write to stdout, on Windows
or otherwise, couldn't possibly be confused with GDB/MI output.

> Nick, does Emacs port natively to windows? Does GDB/MI work reliably for
> you there?

Not relevant, since his Emacs port doesn't use a separate TTY at the
moment.  It works just fine with interleaved I/O in fact.

> Are there any other routes to go down here? Should we have an
> alternative mode where GDB reads the output of the inferior and writes
> it to a named pipe? or simply writes it encoded in the MI output stream?
> This functionality could work in both UNIX/windows. However, it wouldn't
> give terminal semantics.

Windows doesn't _HAVE_ terminal semantics!  If it did, it'd probably
have pseudo-ttys too.

I've already suggested pipes; I don't know if there are named pipes on
Windows or unnamed ones.  Currently we encode writes in the output
stream.  My question upthread is whether we should continue to do so.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 13:00                   ` Daniel Jacobowitz
@ 2005-08-01 13:16                     ` Bob Rossi
  2005-08-01 13:23                       ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 13:16 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches

On Mon, Aug 01, 2005 at 09:00:24AM -0400, Daniel Jacobowitz wrote:
> On Mon, Aug 01, 2005 at 07:30:02AM -0400, Bob Rossi wrote:
> > Hi Eli,
> > 
> > I am claiming that a reliable FE can not be written if the inferior writes 
> > data to the same output stream as GDB/MI's output stream. So, on native 
> > windows, if the inferior I/O and GDB/MI I/O can not be separated, it 
> > wouldn't be worth while to write an FE on that platform.
> 
> That's a very strange judgement call:
> 
>  (A) The huge majority of Windows programs don't even write to the
> console.

Yes, well these would work just fine, of course.

>  (B) The huge majority of programs which write to stdout, on Windows
> or otherwise, couldn't possibly be confused with GDB/MI output.

This is the scenario that really stinks for the FE. Currently the way
things stand on UNIX, a FE can be written nicely, and work in all
case's. However, in windows, no longer can a FE have a clean
implementation. It needs to begin guessing what output is from GDB and
what output is from the inferior.

Is there an easy and clean way to solve this problem? Maybe this problem
is easier to solve than I think it is. Any suggestions?

Honestly, I don't care if someone writes an FE that does this kind of
processing, the only reason I really care about this topic is because I
would prefer to use the TTY option in the testsuite to ensure the I/O is
separated. Doing this though, leaves target's without TTY's
semi-untested.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 13:16                     ` Bob Rossi
@ 2005-08-01 13:23                       ` Daniel Jacobowitz
  2005-08-01 13:31                         ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01 13:23 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches

On Mon, Aug 01, 2005 at 09:16:27AM -0400, Bob Rossi wrote:
> Is there an easy and clean way to solve this problem? Maybe this problem
> is easier to solve than I think it is. Any suggestions?

No, but the heuristics are easier than you think they are.

> Honestly, I don't care if someone writes an FE that does this kind of
> processing, the only reason I really care about this topic is because I
> would prefer to use the TTY option in the testsuite to ensure the I/O is
> separated. Doing this though, leaves target's without TTY's
> semi-untested.

As already written, expect requires a TTY anyway.  No TTY, no
testsuite.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 13:23                       ` Daniel Jacobowitz
@ 2005-08-01 13:31                         ` Bob Rossi
  2005-08-01 14:00                           ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 13:31 UTC (permalink / raw)
  To: Eli Zaretskii, gdb-patches

On Mon, Aug 01, 2005 at 09:23:51AM -0400, Daniel Jacobowitz wrote:
> On Mon, Aug 01, 2005 at 09:16:27AM -0400, Bob Rossi wrote:
> > Is there an easy and clean way to solve this problem? Maybe this problem
> > is easier to solve than I think it is. Any suggestions?
> 
> No, but the heuristics are easier than you think they are.
> 
> > Honestly, I don't care if someone writes an FE that does this kind of
> > processing, the only reason I really care about this topic is because I
> > would prefer to use the TTY option in the testsuite to ensure the I/O is
> > separated. Doing this though, leaves target's without TTY's
> > semi-untested.
> 
> As already written, expect requires a TTY anyway.  No TTY, no
> testsuite.

I aggree with the above. However, my point is that the testsuite
will no longer test interleaved output. It would only test GDB under the
assumption that the tty command works.

Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 13:31                         ` Bob Rossi
@ 2005-08-01 14:00                           ` Daniel Jacobowitz
  2005-08-01 14:07                             ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01 14:00 UTC (permalink / raw)
  To: gdb-patches

[Sorry for the duplicate; sourceware hiccupped.]

On Mon, Aug 01, 2005 at 09:30:56AM -0400, Bob Rossi wrote:
> On Mon, Aug 01, 2005 at 09:23:51AM -0400, Daniel Jacobowitz wrote:
> > On Mon, Aug 01, 2005 at 09:16:27AM -0400, Bob Rossi wrote:
> > > Is there an easy and clean way to solve this problem? Maybe this problem
> > > is easier to solve than I think it is. Any suggestions?
> > 
> > No, but the heuristics are easier than you think they are.
> > 
> > > Honestly, I don't care if someone writes an FE that does this kind of
> > > processing, the only reason I really care about this topic is because I
> > > would prefer to use the TTY option in the testsuite to ensure the I/O is
> > > separated. Doing this though, leaves target's without TTY's
> > > semi-untested.
> > 
> > As already written, expect requires a TTY anyway.  No TTY, no
> > testsuite.
> 
> I aggree with the above. However, my point is that the testsuite
> will no longer test interleaved output. It would only test GDB under the
> assumption that the tty command works.

These are tests of a frontend's ability to handle unexpected output,
not tests of GDB itself; I don't see GDB needing much in the way of
tests for them.  I pick my things to worry about :-)

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 14:00                           ` Daniel Jacobowitz
@ 2005-08-01 14:07                             ` Bob Rossi
  0 siblings, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 14:07 UTC (permalink / raw)
  To: gdb-patches

On Mon, Aug 01, 2005 at 10:00:17AM -0400, Daniel Jacobowitz wrote:
> [Sorry for the duplicate; sourceware hiccupped.]
> 
> On Mon, Aug 01, 2005 at 09:30:56AM -0400, Bob Rossi wrote:
> > On Mon, Aug 01, 2005 at 09:23:51AM -0400, Daniel Jacobowitz wrote:
> > > On Mon, Aug 01, 2005 at 09:16:27AM -0400, Bob Rossi wrote:
> > > > Is there an easy and clean way to solve this problem? Maybe this problem
> > > > is easier to solve than I think it is. Any suggestions?
> > > 
> > > No, but the heuristics are easier than you think they are.
> > > 
> > > > Honestly, I don't care if someone writes an FE that does this kind of
> > > > processing, the only reason I really care about this topic is because I
> > > > would prefer to use the TTY option in the testsuite to ensure the I/O is
> > > > separated. Doing this though, leaves target's without TTY's
> > > > semi-untested.
> > > 
> > > As already written, expect requires a TTY anyway.  No TTY, no
> > > testsuite.
> > 
> > I aggree with the above. However, my point is that the testsuite
> > will no longer test interleaved output. It would only test GDB under the
> > assumption that the tty command works.
> 
> These are tests of a frontend's ability to handle unexpected output,
> not tests of GDB itself; I don't see GDB needing much in the way of
> tests for them.  I pick my things to worry about :-)

OK, So I'm assuming the wise thing to do would be to go ahead with my
patch and drop the discussion of support on native windows.

I'll provide the already given changes needed, and repost.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 11:30                 ` Bob Rossi
  2005-08-01 13:00                   ` Daniel Jacobowitz
@ 2005-08-01 18:45                   ` Eli Zaretskii
  2005-08-01 19:01                     ` Mark Kettenis
  1 sibling, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-01 18:45 UTC (permalink / raw)
  To: gdb-patches

> Date: Mon, 1 Aug 2005 07:30:02 -0400
> From: Bob Rossi <bob@brasko.net>
> Cc: gdb-patches@sources.redhat.com
> 
> I am claiming that a reliable FE can not be written if the inferior writes 
> data to the same output stream as GDB/MI's output stream. So, on native 
> windows, if the inferior I/O and GDB/MI I/O can not be separated, it 
> wouldn't be worth while to write an FE on that platform.

IMHO, you are again jumping to conclusions.  The problem was that
Windows doesn't support PTYs, not that it's impossible to separate the
two output streams there.

> Nick, does Emacs port natively to windows?

Of course, it does.  I'm writing this mail in such a port ;-)

> Are there any other routes to go down here?

(Shrug) What about redirecting one of the streams to another file
handle?  I think any modern platform will support this.  We could, for
example, make this an option (it could be on by default if PTYs aren't
supported).

In fact, doesn't GDB already use a different standard output stream?
I thought it did.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 18:45                   ` Eli Zaretskii
@ 2005-08-01 19:01                     ` Mark Kettenis
  2005-08-01 19:25                       ` Daniel Jacobowitz
  2005-08-01 20:45                       ` Eli Zaretskii
  0 siblings, 2 replies; 62+ messages in thread
From: Mark Kettenis @ 2005-08-01 19:01 UTC (permalink / raw)
  To: eliz; +Cc: gdb-patches

   Date: Mon, 01 Aug 2005 21:45:18 +0300
   From: Eli Zaretskii <eliz@gnu.org>

   (Shrug) What about redirecting one of the streams to another file
   handle?  I think any modern platform will support this.  We could, for
   example, make this an option (it could be on by default if PTYs aren't
   supported).

Terminals are quite different from "normal" pipes.  For example stdio
is line buffered for (pseudo) terminals but normally buffered for
other streams.  So this affects basically any program.

Mark


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 19:01                     ` Mark Kettenis
@ 2005-08-01 19:25                       ` Daniel Jacobowitz
  2005-08-01 19:34                         ` Mark Kettenis
  2005-08-01 20:48                         ` Eli Zaretskii
  2005-08-01 20:45                       ` Eli Zaretskii
  1 sibling, 2 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01 19:25 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: eliz, gdb-patches

On Mon, Aug 01, 2005 at 09:01:44PM +0200, Mark Kettenis wrote:
>    Date: Mon, 01 Aug 2005 21:45:18 +0300
>    From: Eli Zaretskii <eliz@gnu.org>
> 
>    (Shrug) What about redirecting one of the streams to another file
>    handle?  I think any modern platform will support this.  We could, for
>    example, make this an option (it could be on by default if PTYs aren't
>    supported).
> 
> Terminals are quite different from "normal" pipes.  For example stdio
> is line buffered for (pseudo) terminals but normally buffered for
> other streams.  So this affects basically any program.

Yes, but I think Eli's still basically right here: if you don't have
PTYs, then preserving terminal semantics isn't terribly important.

The buffering gets annoying on Windows because some applications use
Windows library calls to detect a console and control buffering
accordingly.  But we can't handle that, so I wouldn't fret about it too
much.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 19:25                       ` Daniel Jacobowitz
@ 2005-08-01 19:34                         ` Mark Kettenis
  2005-08-01 19:43                           ` Bob Rossi
  2005-08-01 20:48                         ` Eli Zaretskii
  1 sibling, 1 reply; 62+ messages in thread
From: Mark Kettenis @ 2005-08-01 19:34 UTC (permalink / raw)
  To: drow; +Cc: eliz, gdb-patches

   Date: Mon, 1 Aug 2005 15:25:45 -0400
   From: Daniel Jacobowitz <drow@false.org>

   On Mon, Aug 01, 2005 at 09:01:44PM +0200, Mark Kettenis wrote:
   >    Date: Mon, 01 Aug 2005 21:45:18 +0300
   >    From: Eli Zaretskii <eliz@gnu.org>
   > 
   >    (Shrug) What about redirecting one of the streams to another file
   >    handle?  I think any modern platform will support this.  We could, for
   >    example, make this an option (it could be on by default if PTYs aren't
   >    supported).
   > 
   > Terminals are quite different from "normal" pipes.  For example stdio
   > is line buffered for (pseudo) terminals but normally buffered for
   > other streams.  So this affects basically any program.

   Yes, but I think Eli's still basically right here: if you don't have
   PTYs, then preserving terminal semantics isn't terribly important.

Oh, yes.  As long as it isn't the default, this certainly makes sense.
So anyone who cares about windows, feel free to implement this ;-).

Mark


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 19:34                         ` Mark Kettenis
@ 2005-08-01 19:43                           ` Bob Rossi
  0 siblings, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-01 19:43 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: drow, eliz, gdb-patches

On Mon, Aug 01, 2005 at 09:34:22PM +0200, Mark Kettenis wrote:
>    Date: Mon, 1 Aug 2005 15:25:45 -0400
>    From: Daniel Jacobowitz <drow@false.org>
> 
>    On Mon, Aug 01, 2005 at 09:01:44PM +0200, Mark Kettenis wrote:
>    >    Date: Mon, 01 Aug 2005 21:45:18 +0300
>    >    From: Eli Zaretskii <eliz@gnu.org>
>    > 
>    >    (Shrug) What about redirecting one of the streams to another file
>    >    handle?  I think any modern platform will support this.  We could, for
>    >    example, make this an option (it could be on by default if PTYs aren't
>    >    supported).
>    > 
>    > Terminals are quite different from "normal" pipes.  For example stdio
>    > is line buffered for (pseudo) terminals but normally buffered for
>    > other streams.  So this affects basically any program.
> 
>    Yes, but I think Eli's still basically right here: if you don't have
>    PTYs, then preserving terminal semantics isn't terribly important.
> 
> Oh, yes.  As long as it isn't the default, this certainly makes sense.
> So anyone who cares about windows, feel free to implement this ;-).

To me, it's more or less to hear a public profession of how GDB should
work on windows. This allows me to change the way GDB works involving
TTY's and not feel so bad.

Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 19:01                     ` Mark Kettenis
  2005-08-01 19:25                       ` Daniel Jacobowitz
@ 2005-08-01 20:45                       ` Eli Zaretskii
  2005-08-01 20:52                         ` Daniel Jacobowitz
  1 sibling, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-01 20:45 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> Date: Mon, 1 Aug 2005 21:01:44 +0200 (CEST)
> From: Mark Kettenis <mark.kettenis@xs4all.nl>
> CC: gdb-patches@sources.redhat.com
> 
> Terminals are quite different from "normal" pipes.  For example stdio
> is line buffered for (pseudo) terminals but normally buffered for
> other streams.

I'm quite sure I've heard this once or twice before ;-)

Seriously, though: buffering and other aspects of I/O relevant to
terminals can be fixed by suitable calls to termios or similar
functions.

In addition, a file handle redirected to the pipe vis-a-vis a FE
doesn't necessarily need to be line buffered.

So I don't see this as a big problem.  (At least in theory; I don't
think I will have enough free time to work on this for the Windows
port anytime soon.)


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 19:25                       ` Daniel Jacobowitz
  2005-08-01 19:34                         ` Mark Kettenis
@ 2005-08-01 20:48                         ` Eli Zaretskii
  1 sibling, 0 replies; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-01 20:48 UTC (permalink / raw)
  To: gdb-patches

> Date: Mon, 1 Aug 2005 15:25:45 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: eliz@gnu.org, gdb-patches@sources.redhat.com
> 
> The buffering gets annoying on Windows because some applications use
> Windows library calls to detect a console and control buffering
> accordingly.

Such programs are not suited for debugging by GDB.  One could attach
GDB from another command prompt window to try to alleviate the pain.
And, if GDB is very careful in how it uses another file handle for
terminal I/O, the Windows calls that fiddle with terminal settings
will not affect GDB, only the debuggee.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 20:45                       ` Eli Zaretskii
@ 2005-08-01 20:52                         ` Daniel Jacobowitz
  2005-08-02  3:45                           ` Eli Zaretskii
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-01 20:52 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: Mark Kettenis, gdb-patches

On Mon, Aug 01, 2005 at 11:45:03PM +0300, Eli Zaretskii wrote:
> Seriously, though: buffering and other aspects of I/O relevant to
> terminals can be fixed by suitable calls to termios or similar
> functions.
> 
> In addition, a file handle redirected to the pipe vis-a-vis a FE
> doesn't necessarily need to be line buffered.

FWIW, this bit is a real problem.  Not necessarily a big problem, but
definitely a real problem.

You can't fix it via termios; it isn't a property of the terminal (and
we don't have a terminal, anyway).  It's set by the application startup
code based on the result of isatty() on fd 0, usually - at least both
mingw32 and GNU/Linux do it this way.

The default for non-terminals is block buffered, which if you're
waiting for output is really annoying.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-01 20:52                         ` Daniel Jacobowitz
@ 2005-08-02  3:45                           ` Eli Zaretskii
  2005-08-02  3:50                             ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-02  3:45 UTC (permalink / raw)
  To: gdb-patches

> Date: Mon, 1 Aug 2005 16:52:42 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sources.redhat.com
> 
> You can't fix it via termios; it isn't a property of the terminal (and
> we don't have a terminal, anyway).  It's set by the application startup
> code based on the result of isatty() on fd 0, usually - at least both
> mingw32 and GNU/Linux do it this way.

If this is the buffering you are worried with, it can be fixed with a
call to setvbuf, right?

> The default for non-terminals is block buffered, which if you're
> waiting for output is really annoying.

We could fflush and fsync the MI output stream, if this is the main
annoyance.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-02  3:45                           ` Eli Zaretskii
@ 2005-08-02  3:50                             ` Daniel Jacobowitz
  2005-08-02 20:46                               ` Eli Zaretskii
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-02  3:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

On Tue, Aug 02, 2005 at 06:45:28AM +0300, Eli Zaretskii wrote:
> > Date: Mon, 1 Aug 2005 16:52:42 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: Mark Kettenis <mark.kettenis@xs4all.nl>, gdb-patches@sources.redhat.com
> > 
> > You can't fix it via termios; it isn't a property of the terminal (and
> > we don't have a terminal, anyway).  It's set by the application startup
> > code based on the result of isatty() on fd 0, usually - at least both
> > mingw32 and GNU/Linux do it this way.
> 
> If this is the buffering you are worried with, it can be fixed with a
> call to setvbuf, right?

Yes, but the problem's that the buffering is in the program being
debugged.  It's not the buffering of the GDB MI stream that's the
problem, but the fact that the stdout of the program you're debugging
would suddenly become block buffered instead of line buffered, if you
fed it to a pipe when it expects a TTY.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-02  3:50                             ` Daniel Jacobowitz
@ 2005-08-02 20:46                               ` Eli Zaretskii
  2005-08-02 20:48                                 ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Eli Zaretskii @ 2005-08-02 20:46 UTC (permalink / raw)
  To: gdb-patches

> Date: Mon, 1 Aug 2005 23:50:20 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb-patches@sources.redhat.com
> 
> Yes, but the problem's that the buffering is in the program being
> debugged.  It's not the buffering of the GDB MI stream that's the
> problem, but the fact that the stdout of the program you're debugging
> would suddenly become block buffered instead of line buffered, if you
> fed it to a pipe when it expects a TTY.

This started as a discussion how to separate MI output from the
debuggee's.  For that, I suggested to redirect MI's output (_not_ the
debuggee's) to a different file handle.  That should not change the
buffering of the debuggee's stdout in any way.  While the problem you
mention is real, it has nothing to do with separation of these two
streams: if sending the program's output to a pipe changes its
buffering, we already have that annoyance on Windows.


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-02 20:46                               ` Eli Zaretskii
@ 2005-08-02 20:48                                 ` Daniel Jacobowitz
  2005-08-13 17:26                                   ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-02 20:48 UTC (permalink / raw)
  To: gdb-patches

On Tue, Aug 02, 2005 at 11:45:20PM +0300, Eli Zaretskii wrote:
> > Date: Mon, 1 Aug 2005 23:50:20 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: gdb-patches@sources.redhat.com
> > 
> > Yes, but the problem's that the buffering is in the program being
> > debugged.  It's not the buffering of the GDB MI stream that's the
> > problem, but the fact that the stdout of the program you're debugging
> > would suddenly become block buffered instead of line buffered, if you
> > fed it to a pipe when it expects a TTY.
> 
> This started as a discussion how to separate MI output from the
> debuggee's.  For that, I suggested to redirect MI's output (_not_ the
> debuggee's) to a different file handle.  That should not change the
> buffering of the debuggee's stdout in any way.  While the problem you
> mention is real, it has nothing to do with separation of these two
> streams: if sending the program's output to a pipe changes its
> buffering, we already have that annoyance on Windows.

Ah!  Thank you, I misunderstood your solution.  This is a very
interesting idea indeed.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-31  1:21       ` Daniel Jacobowitz
  2005-07-31 13:16         ` Bob Rossi
@ 2005-08-03  2:07         ` Bob Rossi
  2005-08-03 12:48           ` Bob Rossi
  2005-08-03 13:19           ` Daniel Jacobowitz
  1 sibling, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-03  2:07 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches; +Cc: Daniel Jacobowitz

On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > However, since that's pretty ugly, I'll take your suggestion and always
> > create and assign inferior_pty a value. Then I'll check it for the value
> > of "true" before executing any code.
> 
> I recommend doing something different.  Make the argument a flag, i.e.
> "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> default to be.

Here is an updated patch with all the suggestions made so far, except
for the ChangeLog suggestion Nick made. Nick, thanks for noticing the
problems with the original patch!

If preferred, I could add the separate-inferior-tty argument to
mi_gdb_start only in the tests that need that functionality to pass, 
instead of for all the mi-* tests. This would reduce the patch size
significantly.

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
+2005-08-02  Bob Rossi  <bob@brasko.net>
+
+	* gdb.mi/gdb669.exp: Tell mi_gdb_start to use a PTY for inferior.
+	* gdb.mi/gdb680.exp: Ditto.
+	* gdb.mi/gdb701.exp: Ditto.
+	* gdb.mi/gdb792.exp: Ditto.
+	* gdb.mi/mi-break.exp: Ditto.
+	* gdb.mi/mi-cli.exp: Ditto.
+	* gdb.mi/mi-disassemble.exp: Ditto.
+	* gdb.mi/mi-eval.exp: Ditto.
+	* gdb.mi/mi-file.exp: Ditto.
+	* gdb.mi/mi-hack-cli.exp: Ditto.
+	* gdb.mi/mi-pthreads.exp: Ditto.
+	* gdb.mi/mi-read-memory.exp: Ditto.
+	* gdb.mi/mi-regs.exp: Ditto.
+	* gdb.mi/mi-return.exp: Ditto.
+	* gdb.mi/mi-simplerun.exp: Ditto.
+	* gdb.mi/mi-stack.exp: Ditto.
+	* gdb.mi/mi-stepi.exp: Ditto.
+	* gdb.mi/mi-until.exp: Ditto.
+	* gdb.mi/mi-var-block.exp: Ditto.
+	* gdb.mi/mi-var-child.exp: Ditto.
+	* gdb.mi/mi-var-cmd.exp: Ditto.
+	* gdb.mi/mi-var-display.exp: Ditto.
+	* gdb.mi/mi-watch.exp: Ditto.
+	* gdb.mi/mi-basics.exp: Ditto.
+	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
+	(test_setshow_inferior_tty): Change tests to inferior-tty-set/show.
+	* gdb.mi/mi-console.exp: Ditto.
+	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
+	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use PTY for inferior.
+	(403-exec-continue): Use mi_gdb_test to get GDB and Inferior output.
+	(406-data-evaluate-expression have_a_very_merry_interrupt()): Ditto.
+	(410-data-evaluate-expression bar()): Ditto.
+	(408-exec-continue): Use mi_gdb_test to get GDB output.
+	* lib/mi-support.exp (mi_inferior_spawn_id): Add inferior PTY
+	descriptor.
+	(mi_inferior_tty_name): Add inferior PTY file name.
+	(mi_gdb_start): Add INFERIOR_PTY parameter.
+	(mi_gdb_test): Add IPATTERN parameter.

Index: gdb/testsuite/gdb.mi/gdb669.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb669.exp,v
retrieving revision 1.5
diff -u -r1.5 gdb669.exp
--- gdb/testsuite/gdb.mi/gdb669.exp	13 Jan 2004 17:08:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/gdb669.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start separate-inferior-tty]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb680.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb680.exp,v
retrieving revision 1.1
diff -u -r1.1 gdb680.exp
--- gdb/testsuite/gdb.mi/gdb680.exp	3 Sep 2002 16:37:00 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb680.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb701.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb701.exp,v
retrieving revision 1.1
diff -u -r1.1 gdb701.exp
--- gdb/testsuite/gdb.mi/gdb701.exp	16 Sep 2002 19:01:43 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb701.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb792.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb792.exp,v
retrieving revision 1.4
diff -u -r1.4 gdb792.exp
--- gdb/testsuite/gdb.mi/gdb792.exp	9 Aug 2004 16:32:44 -0000	1.4
+++ gdb/testsuite/gdb.mi/gdb792.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.10
diff -u -r1.10 mi-basics.exp
--- gdb/testsuite/gdb.mi/mi-basics.exp	6 Jul 2005 14:54:37 -0000	1.10
+++ gdb/testsuite/gdb.mi/mi-basics.exp	3 Aug 2005 02:02:20 -0000
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -238,6 +238,7 @@
 
 proc test_setshow_inferior_tty {} {
     global mi_gdb_prompt
+    global mi_inferior_tty_name
 
     # Test that the commands,
     #   -inferior-tty-set
@@ -245,8 +246,8 @@
     # are setting/getting the same data in GDB.
 
     mi_gdb_test "301-inferior-tty-show" \
-		"301\\\^done" \
-		"initial tty is empty"
+		"301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"initial tty is mi_inferior_tty_name"
 
     mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
 		"302\\\^done" \
@@ -262,7 +263,15 @@
 
     mi_gdb_test "305-inferior-tty-show" \
 		"305\\\^done" \
-		"final tty is empty"
+		"make sure tty is empty"
+
+    mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
+		"306\\\^done" \
+		"set tty to mi_inferior_tty_name (the way it was)"
+
+    mi_gdb_test "307-inferior-tty-show" \
+		"307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"verify tty is correct"
 }
 
 if [test_mi_interpreter_selection] {
Index: gdb/testsuite/gdb.mi/mi-break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-break.exp,v
retrieving revision 1.7
diff -u -r1.7 mi-break.exp
--- gdb/testsuite/gdb.mi/mi-break.exp	13 Aug 2004 16:21:29 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-break.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-cli.exp,v
retrieving revision 1.4
diff -u -r1.4 mi-cli.exp
--- gdb/testsuite/gdb.mi/mi-cli.exp	18 May 2005 03:41:58 -0000	1.4
+++ gdb/testsuite/gdb.mi/mi-cli.exp	3 Aug 2005 02:02:20 -0000
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.14
diff -u -r1.14 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	27 Apr 2005 16:35:15 -0000	1.14
+++ gdb/testsuite/gdb.mi/mi-console.exp	3 Aug 2005 02:02:20 -0000
@@ -36,7 +36,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -54,37 +54,10 @@
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
-gdb_expect {
-    -re "47\\^running\r\n$mi_gdb_prompt" {
-	pass "Started step over hello"
-    }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
-}
-
-if { ![target_info exists gdb,noinferiorio]}  {
-    gdb_expect {
-	-re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
-	    pass "Hello message"
-	}
-	-re "Hello" {
-
-	    # Probably a native system where GDB doesn't have direct #
-	    # control over the inferior console.  # For this to work,
-	    # GDB would need to run the inferior process # under a PTY
-	    # and then use the even-loops ability to wait on #
-	    # multiple event sources to channel the output back
-	    # through the # MI.
-
-	    kfail "gdb/623" "Hello message"
-	}
-	timeout {
-	    fail "Hello message (timeout)"
-	}
-    }
-}
+mi_gdb_test "47-exec-next" \
+	    "47\\^running" \
+	    "Testing console output" \
+	    "Hello \\\\\"!\[\r\n\]+"
     
 gdb_expect {
     -re "47\\*stopped.*$mi_gdb_prompt$" {
Index: gdb/testsuite/gdb.mi/mi-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-disassemble.exp,v
retrieving revision 1.13
diff -u -r1.13 mi-disassemble.exp
--- gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-disassemble.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-eval.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-eval.exp,v
retrieving revision 1.9
diff -u -r1.9 mi-eval.exp
--- gdb/testsuite/gdb.mi/mi-eval.exp	15 Aug 2004 10:15:58 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-eval.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
retrieving revision 1.5
diff -u -r1.5 mi-file.exp
--- gdb/testsuite/gdb.mi/mi-file.exp	8 May 2005 13:42:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-file.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-hack-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-hack-cli.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-hack-cli.exp
--- gdb/testsuite/gdb.mi/mi-hack-cli.exp	9 Aug 2004 16:32:44 -0000	1.6
+++ gdb/testsuite/gdb.mi/mi-hack-cli.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-pthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-pthreads.exp,v
retrieving revision 1.7
diff -u -r1.7 mi-pthreads.exp
--- gdb/testsuite/gdb.mi/mi-pthreads.exp	13 Jan 2004 17:08:03 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-pthreads.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start separate-inferior-tty]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-read-memory.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-read-memory.exp,v
retrieving revision 1.9
diff -u -r1.9 mi-read-memory.exp
--- gdb/testsuite/gdb.mi/mi-read-memory.exp	9 Aug 2004 16:32:44 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-read-memory.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-regs.exp,v
retrieving revision 1.12
diff -u -r1.12 mi-regs.exp
--- gdb/testsuite/gdb.mi/mi-regs.exp	9 Aug 2004 16:32:44 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-regs.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-return.exp,v
retrieving revision 1.12
diff -u -r1.12 mi-return.exp
--- gdb/testsuite/gdb.mi/mi-return.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-return.exp	3 Aug 2005 02:02:20 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-simplerun.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-simplerun.exp,v
retrieving revision 1.12
diff -u -r1.12 mi-simplerun.exp
--- gdb/testsuite/gdb.mi/mi-simplerun.exp	15 Aug 2004 10:15:58 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-simplerun.exp	3 Aug 2005 02:02:20 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.18
diff -u -r1.18 mi-stack.exp
--- gdb/testsuite/gdb.mi/mi-stack.exp	31 Jul 2005 21:24:25 -0000	1.18
+++ gdb/testsuite/gdb.mi/mi-stack.exp	3 Aug 2005 02:02:20 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stepi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stepi.exp,v
retrieving revision 1.11
diff -u -r1.11 mi-stepi.exp
--- gdb/testsuite/gdb.mi/mi-stepi.exp	18 May 2005 03:41:59 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-stepi.exp	3 Aug 2005 02:02:20 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.5
diff -u -r1.5 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	2 Aug 2005 14:21:01 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	3 Aug 2005 02:02:21 -0000
@@ -38,7 +38,7 @@
 set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
 
 mi_gdb_exit
-mi_gdb_start
+mi_gdb_start separate-inferior-tty
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -60,16 +60,10 @@
 #
 # Continue back to main()
 #
-
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+  "403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+  "testing exec continue" \
+  "hi in foo\[\r\n\]\+"
 
 mi_gdb_test "404-stack-list-frames 0 0" \
   "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -85,8 +79,9 @@
   "insert breakpoint subroutine"
 
 mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
-  "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
-  "evaluate expression have_a_very_merry_interrupt"
+  "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+  "data evaluate expression" \
+  "Waiting to get a signal\[\r\n\]+"
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
@@ -96,15 +91,8 @@
   "list stack frames"
 
 
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+  "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" \
   "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -114,7 +102,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+  "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+  "call inferior function which raises exception" \
+  "hi in bar\[\r\n\]+"
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: gdb/testsuite/gdb.mi/mi-until.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-until.exp,v
retrieving revision 1.9
diff -u -r1.9 mi-until.exp
--- gdb/testsuite/gdb.mi/mi-until.exp	18 May 2005 03:41:59 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-until.exp	3 Aug 2005 02:02:21 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-block.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-block.exp,v
retrieving revision 1.11
diff -u -r1.11 mi-var-block.exp
--- gdb/testsuite/gdb.mi/mi-var-block.exp	17 Aug 2004 09:38:29 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-var-block.exp	3 Aug 2005 02:02:21 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 #
 # This Program Is Free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-child.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-child.exp,v
retrieving revision 1.20
diff -u -r1.20 mi-var-child.exp
--- gdb/testsuite/gdb.mi/mi-var-child.exp	31 Jul 2005 22:10:53 -0000	1.20
+++ gdb/testsuite/gdb.mi/mi-var-child.exp	3 Aug 2005 02:02:21 -0000
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-cmd.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cmd.exp,v
retrieving revision 1.18
diff -u -r1.18 mi-var-cmd.exp
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp	14 Jan 2005 18:17:19 -0000	1.18
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp	3 Aug 2005 02:02:21 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.13
diff -u -r1.13 mi-var-display.exp
--- gdb/testsuite/gdb.mi/mi-var-display.exp	18 May 2005 03:41:59 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-var-display.exp	3 Aug 2005 02:02:21 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-watch.exp,v
retrieving revision 1.12
diff -u -r1.12 mi-watch.exp
--- gdb/testsuite/gdb.mi/mi-watch.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-watch.exp	3 Aug 2005 02:02:22 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.28
diff -u -r1.28 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	2 Aug 2005 14:21:01 -0000	1.28
+++ gdb/testsuite/lib/mi-support.exp	3 Aug 2005 02:02:23 -0000
@@ -28,6 +28,9 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
 set MIFLAGS "-i=mi"
 
 #
@@ -81,13 +84,17 @@
 }
 
 #
-# start gdb -- start gdb running, default procedure
+# start gdb INFERIOR_PTY -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work 
+# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY. 
+# The default value is same-inferior-tty.
 #
 # When running over NFS, particularly if running many simultaneous
 # tests on different hosts all using the same server, things can
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
-proc mi_gdb_start { } {
+proc mi_gdb_start { args } {
     global verbose
     global GDB
     global GDBFLAGS
@@ -98,6 +105,13 @@
     global MIFLAGS
 
     gdb_stop_suppressing_tests;
+    set inferior_pty no-tty
+
+    if { [llength $args] == 1} {
+	set inferior_pty [lindex $args 0]
+    }
+
+    set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
 
     # Start SID.
     if { [info procs sid_start] != "" } {
@@ -117,6 +131,16 @@
 	    exit 1
 	}
     }
+
+    # create the new pty for the inferior process
+    if { $separate_inferior_pty } {
+	spawn -pty
+	global mi_inferior_spawn_id
+	global mi_inferior_tty_name
+	set mi_inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+    }
+
     set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -189,6 +213,19 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # If allowing the inferior to have it's own PTY then assign the inferior
+    # it's own terminal device here
+    if { $separate_inferior_pty } {
+	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
+	gdb_expect 10 {
+	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "redirect inferior output to new terminal device."
+	    }
+	    timeout {
+	    	warning "Couldn't redirect inferior output." 2
+	    }
+    	}
+    }
 
     return 0;
 }
@@ -511,7 +548,8 @@
     return 0
 }
 
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN MESSAGE IPATTERN -- send a command to gdb; 
+#   test the result.
 #
 # COMMAND is the command to execute, send to GDB with send_gdb.  If
 #   this is the null string no command is sent.
@@ -520,6 +558,9 @@
 # MESSAGE is the message to be printed.  (If this is the empty string, 
 #   then sometimes we don't call pass or fail at all; I don't 
 #   understand this at all.)
+# IPATTERN is the pattern to match for the inferior's output.  This parameter
+#   is optional.  If present, it will produce a PASS if the match is 
+#   successful, and a FAIL if unsuccessful.
 #
 # Returns:
 #    1 if the test failed,
@@ -536,6 +577,10 @@
     set pattern [lindex $args 1]
     set message [lindex $args 2]
 
+    if [llength $args]==4 {
+	set ipattern [lindex $args 3]
+    }
+
     if [llength $args]==5 {
 	set question_string [lindex $args 3];
 	set response_string [lindex $args 4];
@@ -686,6 +731,23 @@
 	    set result 1
 	}
     }
+
+    # if the GDB output matched, compare the inferior output
+    if { $result == 0 } {
+	if [ info exists ipattern ] {
+	    global mi_inferior_spawn_id
+	    expect {
+		-i $mi_inferior_spawn_id -re "$ipattern" {
+		    pass "inferior_output:$message"
+		}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03  2:07         ` Bob Rossi
@ 2005-08-03 12:48           ` Bob Rossi
  2005-08-03 13:19           ` Daniel Jacobowitz
  1 sibling, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-03 12:48 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches, Daniel Jacobowitz

On Tue, Aug 02, 2005 at 10:06:53PM -0400, Bob Rossi wrote:
> On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > However, since that's pretty ugly, I'll take your suggestion and always
> > > create and assign inferior_pty a value. Then I'll check it for the value
> > > of "true" before executing any code.
> > 
> > I recommend doing something different.  Make the argument a flag, i.e.
> > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > default to be.
> 
> Here is an updated patch with all the suggestions made so far, except
> for the ChangeLog suggestion Nick made. Nick, thanks for noticing the
> problems with the original patch!
> 
> If preferred, I could add the separate-inferior-tty argument to
> mi_gdb_start only in the tests that need that functionality to pass, 
> instead of for all the mi-* tests. This would reduce the patch size
> significantly.

BTW, one other small note. If there is inferior data to match, and the
user pass's GDB's output and the inferior's output to gdb_mi_test, 2
PASS's will get generated, instead of one. I don't know if this is the
desirable way to do this.

Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03  2:07         ` Bob Rossi
  2005-08-03 12:48           ` Bob Rossi
@ 2005-08-03 13:19           ` Daniel Jacobowitz
  2005-08-03 18:22             ` Bob Rossi
  1 sibling, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-03 13:19 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches

On Tue, Aug 02, 2005 at 10:06:53PM -0400, Bob Rossi wrote:
> On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > However, since that's pretty ugly, I'll take your suggestion and always
> > > create and assign inferior_pty a value. Then I'll check it for the value
> > > of "true" before executing any code.
> > 
> > I recommend doing something different.  Make the argument a flag, i.e.
> > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > default to be.
> 
> Here is an updated patch with all the suggestions made so far, except
> for the ChangeLog suggestion Nick made. Nick, thanks for noticing the
> problems with the original patch!
> 
> If preferred, I could add the separate-inferior-tty argument to
> mi_gdb_start only in the tests that need that functionality to pass, 
> instead of for all the mi-* tests. This would reduce the patch size
> significantly.

How about mi-basics.exp (for the set tty tests) and mi-console.exp
only?  The other files mostly don't care, except for mi-syn-frame.exp,
and somewhere around here I have a patch that deletes the use of
inferior output from that test - it's just not relevant.


-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 13:19           ` Daniel Jacobowitz
@ 2005-08-03 18:22             ` Bob Rossi
  2005-08-03 18:23               ` Daniel Jacobowitz
  2005-08-03 18:24               ` Bob Rossi
  0 siblings, 2 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-03 18:22 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches

On Wed, Aug 03, 2005 at 09:19:00AM -0400, Daniel Jacobowitz wrote:
> On Tue, Aug 02, 2005 at 10:06:53PM -0400, Bob Rossi wrote:
> > On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > > However, since that's pretty ugly, I'll take your suggestion and always
> > > > create and assign inferior_pty a value. Then I'll check it for the value
> > > > of "true" before executing any code.
> > > 
> > > I recommend doing something different.  Make the argument a flag, i.e.
> > > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > > default to be.
> > 
> > Here is an updated patch with all the suggestions made so far, except
> > for the ChangeLog suggestion Nick made. Nick, thanks for noticing the
> > problems with the original patch!
> > 
> > If preferred, I could add the separate-inferior-tty argument to
> > mi_gdb_start only in the tests that need that functionality to pass, 
> > instead of for all the mi-* tests. This would reduce the patch size
> > significantly.
> 
> How about mi-basics.exp (for the set tty tests) and mi-console.exp
> only?  The other files mostly don't care, except for mi-syn-frame.exp,
> and somewhere around here I have a patch that deletes the use of
> inferior output from that test - it's just not relevant.

Hi Daniel,

I decided to keep mi-basics.exp simply because it would be complicated
for someone to turn on the separate-inferior-pty option, and know how to
re-write the tty tests. I kept the mi-console.exp test for obvious
reasons. I also kept the mi-syn-frame.exp tests for now. I don't care if
the results get deleted in the future, I just need to make sure that the
inferior I/O is separated from GDB/MI's I/O so that I can do a syntax
check on GDB/MI's I/O only.

The last known issue is to discuss if it matters that mi_gdb_test will
give 1 PASS if there is no inferior data, 2 PASS's if there is inferior
data and it matches, or 1 PASS and 1 FAIL if there is inferior data and
it doesn't match. (This assumes that the GDB data matches). Is this OK? 
I think it is.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 18:22             ` Bob Rossi
@ 2005-08-03 18:23               ` Daniel Jacobowitz
  2005-08-03 18:24               ` Bob Rossi
  1 sibling, 0 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-03 18:23 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 02:21:57PM -0400, Bob Rossi wrote:
> The last known issue is to discuss if it matters that mi_gdb_test will
> give 1 PASS if there is no inferior data, 2 PASS's if there is inferior
> data and it matches, or 1 PASS and 1 FAIL if there is inferior data and
> it doesn't match. (This assumes that the GDB data matches). Is this OK? 
> I think it is.

This is fine with me.  As long as it's a static property of the test,
rather than a dynamic property of the test results, I don't care how
many pass/fails it turns into.  Two is more expressive.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 18:22             ` Bob Rossi
  2005-08-03 18:23               ` Daniel Jacobowitz
@ 2005-08-03 18:24               ` Bob Rossi
  2005-08-03 18:32                 ` Daniel Jacobowitz
  1 sibling, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-03 18:24 UTC (permalink / raw)
  To: Nick Roberts, gdb-patches; +Cc: Daniel Jacobowitz

On Wed, Aug 03, 2005 at 02:21:57PM -0400, Bob Rossi wrote:
> On Wed, Aug 03, 2005 at 09:19:00AM -0400, Daniel Jacobowitz wrote:
> > On Tue, Aug 02, 2005 at 10:06:53PM -0400, Bob Rossi wrote:
> > > On Sat, Jul 30, 2005 at 09:21:11PM -0400, Daniel Jacobowitz wrote:
> > > > On Sat, Jul 30, 2005 at 07:03:09PM -0400, Bob Rossi wrote:
> > > > > However, since that's pretty ugly, I'll take your suggestion and always
> > > > > create and assign inferior_pty a value. Then I'll check it for the value
> > > > > of "true" before executing any code.
> > > > 
> > > > I recommend doing something different.  Make the argument a flag, i.e.
> > > > "mi_gdb_start use-tty".  Or "no-tty" depending on what you want the
> > > > default to be.
> > > 
> > > Here is an updated patch with all the suggestions made so far, except
> > > for the ChangeLog suggestion Nick made. Nick, thanks for noticing the
> > > problems with the original patch!
> > > 
> > > If preferred, I could add the separate-inferior-tty argument to
> > > mi_gdb_start only in the tests that need that functionality to pass, 
> > > instead of for all the mi-* tests. This would reduce the patch size
> > > significantly.
> > 
> > How about mi-basics.exp (for the set tty tests) and mi-console.exp
> > only?  The other files mostly don't care, except for mi-syn-frame.exp,
> > and somewhere around here I have a patch that deletes the use of
> > inferior output from that test - it's just not relevant.
> 
> Hi Daniel,
> 
> I decided to keep mi-basics.exp simply because it would be complicated
> for someone to turn on the separate-inferior-pty option, and know how to
> re-write the tty tests. I kept the mi-console.exp test for obvious
> reasons. I also kept the mi-syn-frame.exp tests for now. I don't care if
> the results get deleted in the future, I just need to make sure that the
> inferior I/O is separated from GDB/MI's I/O so that I can do a syntax
> check on GDB/MI's I/O only.
> 
> The last known issue is to discuss if it matters that mi_gdb_test will
> give 1 PASS if there is no inferior data, 2 PASS's if there is inferior
> data and it matches, or 1 PASS and 1 FAIL if there is inferior data and
> it doesn't match. (This assumes that the GDB data matches). Is this OK? 
> I think it is.

Sorry, I'm a little trigger happy, here's the patch.

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
+	* gdb.mi/mi-basics.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
+	(test_setshow_inferior_tty): Change tests to inferior-tty-set/show.
+	* gdb.mi/mi-console.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
+	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use a PTY for
+	inferior.
+	(403-exec-continue): Use mi_gdb_test to get GDB and Inferior output.
+	(406-data-evaluate-expression have_a_very_merry_interrupt()): Ditto.
+	(410-data-evaluate-expression bar()): Ditto.
+	(408-exec-continue): Use mi_gdb_test to get GDB output.
+	* lib/mi-support.exp (mi_inferior_spawn_id): Add inferior PTY
+	descriptor.
+	(mi_inferior_tty_name): Add inferior PTY file name.
+	(mi_gdb_start): Add INFERIOR_PTY parameter.
+	(mi_gdb_test): Add IPATTERN parameter.
   
Index: gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.10
diff -u -r1.10 mi-basics.exp
--- gdb/testsuite/gdb.mi/mi-basics.exp	6 Jul 2005 14:54:37 -0000	1.10
+++ gdb/testsuite/gdb.mi/mi-basics.exp	3 Aug 2005 16:09:11 -0000
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -238,6 +238,7 @@
 
 proc test_setshow_inferior_tty {} {
     global mi_gdb_prompt
+    global mi_inferior_tty_name
 
     # Test that the commands,
     #   -inferior-tty-set
@@ -245,8 +246,8 @@
     # are setting/getting the same data in GDB.
 
     mi_gdb_test "301-inferior-tty-show" \
-		"301\\\^done" \
-		"initial tty is empty"
+		"301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"initial tty is mi_inferior_tty_name"
 
     mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
 		"302\\\^done" \
@@ -262,7 +263,15 @@
 
     mi_gdb_test "305-inferior-tty-show" \
 		"305\\\^done" \
-		"final tty is empty"
+		"make sure tty is empty"
+
+    mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
+		"306\\\^done" \
+		"set tty to mi_inferior_tty_name (the way it was)"
+
+    mi_gdb_test "307-inferior-tty-show" \
+		"307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"verify tty is correct"
 }
 
 if [test_mi_interpreter_selection] {
Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.14
diff -u -r1.14 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	27 Apr 2005 16:35:15 -0000	1.14
+++ gdb/testsuite/gdb.mi/mi-console.exp	3 Aug 2005 16:09:11 -0000
@@ -36,7 +36,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -54,37 +54,10 @@
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
-gdb_expect {
-    -re "47\\^running\r\n$mi_gdb_prompt" {
-	pass "Started step over hello"
-    }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
-}
-
-if { ![target_info exists gdb,noinferiorio]}  {
-    gdb_expect {
-	-re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
-	    pass "Hello message"
-	}
-	-re "Hello" {
-
-	    # Probably a native system where GDB doesn't have direct #
-	    # control over the inferior console.  # For this to work,
-	    # GDB would need to run the inferior process # under a PTY
-	    # and then use the even-loops ability to wait on #
-	    # multiple event sources to channel the output back
-	    # through the # MI.
-
-	    kfail "gdb/623" "Hello message"
-	}
-	timeout {
-	    fail "Hello message (timeout)"
-	}
-    }
-}
+mi_gdb_test "47-exec-next" \
+	    "47\\^running" \
+	    "Testing console output" \
+	    "Hello \\\\\"!\[\r\n\]+"
     
 gdb_expect {
     -re "47\\*stopped.*$mi_gdb_prompt$" {
Index: gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.5
diff -u -r1.5 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	2 Aug 2005 14:21:01 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	3 Aug 2005 16:09:11 -0000
@@ -38,7 +38,7 @@
 set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
 
 mi_gdb_exit
-mi_gdb_start
+mi_gdb_start separate-inferior-tty
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -60,16 +60,10 @@
 #
 # Continue back to main()
 #
-
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+  "403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+  "testing exec continue" \
+  "hi in foo\[\r\n\]\+"
 
 mi_gdb_test "404-stack-list-frames 0 0" \
   "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -85,8 +79,9 @@
   "insert breakpoint subroutine"
 
 mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
-  "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
-  "evaluate expression have_a_very_merry_interrupt"
+  "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+  "data evaluate expression" \
+  "Waiting to get a signal\[\r\n\]+"
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
@@ -96,15 +91,8 @@
   "list stack frames"
 
 
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+  "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" \
   "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -114,7 +102,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+  "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+  "call inferior function which raises exception" \
+  "hi in bar\[\r\n\]+"
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.28
diff -u -r1.28 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	2 Aug 2005 14:21:01 -0000	1.28
+++ gdb/testsuite/lib/mi-support.exp	3 Aug 2005 16:09:11 -0000
@@ -28,6 +28,9 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
 set MIFLAGS "-i=mi"
 
 #
@@ -81,13 +84,17 @@
 }
 
 #
-# start gdb -- start gdb running, default procedure
+# start gdb INFERIOR_PTY -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work 
+# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY. 
+# The default value is same-inferior-tty.
 #
 # When running over NFS, particularly if running many simultaneous
 # tests on different hosts all using the same server, things can
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
-proc mi_gdb_start { } {
+proc mi_gdb_start { args } {
     global verbose
     global GDB
     global GDBFLAGS
@@ -98,6 +105,13 @@
     global MIFLAGS
 
     gdb_stop_suppressing_tests;
+    set inferior_pty no-tty
+
+    if { [llength $args] == 1} {
+	set inferior_pty [lindex $args 0]
+    }
+
+    set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
 
     # Start SID.
     if { [info procs sid_start] != "" } {
@@ -117,6 +131,16 @@
 	    exit 1
 	}
     }
+
+    # create the new pty for the inferior process
+    if { $separate_inferior_pty } {
+	spawn -pty
+	global mi_inferior_spawn_id
+	global mi_inferior_tty_name
+	set mi_inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+    }
+
     set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -189,6 +213,19 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # If allowing the inferior to have it's own PTY then assign the inferior
+    # it's own terminal device here
+    if { $separate_inferior_pty } {
+	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
+	gdb_expect 10 {
+	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "redirect inferior output to new terminal device."
+	    }
+	    timeout {
+	    	warning "Couldn't redirect inferior output." 2
+	    }
+    	}
+    }
 
     return 0;
 }
@@ -511,7 +548,8 @@
     return 0
 }
 
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN MESSAGE IPATTERN -- send a command to gdb; 
+#   test the result.
 #
 # COMMAND is the command to execute, send to GDB with send_gdb.  If
 #   this is the null string no command is sent.
@@ -520,6 +558,9 @@
 # MESSAGE is the message to be printed.  (If this is the empty string, 
 #   then sometimes we don't call pass or fail at all; I don't 
 #   understand this at all.)
+# IPATTERN is the pattern to match for the inferior's output.  This parameter
+#   is optional.  If present, it will produce a PASS if the match is 
+#   successful, and a FAIL if unsuccessful.
 #
 # Returns:
 #    1 if the test failed,
@@ -536,6 +577,10 @@
     set pattern [lindex $args 1]
     set message [lindex $args 2]
 
+    if [llength $args]==4 {
+	set ipattern [lindex $args 3]
+    }
+
     if [llength $args]==5 {
 	set question_string [lindex $args 3];
 	set response_string [lindex $args 4];
@@ -686,6 +731,23 @@
 	    set result 1
 	}
     }
+
+    # if the GDB output matched, compare the inferior output
+    if { $result == 0 } {
+	if [ info exists ipattern ] {
+	    global mi_inferior_spawn_id
+	    expect {
+		-i $mi_inferior_spawn_id -re "$ipattern" {
+		    pass "inferior_output:$message"
+		}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 18:24               ` Bob Rossi
@ 2005-08-03 18:32                 ` Daniel Jacobowitz
  2005-08-03 19:31                   ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-03 18:32 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> Sorry, I'm a little trigger happy, here's the patch.

Patch is OK with formatting corrections.

> Index: gdb/testsuite/ChangeLog
> +	* gdb.mi/mi-basics.exp: Tell mi_gdb_start to use a PTY for inferior.
> +	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
> +	(test_setshow_inferior_tty): Change tests to inferior-tty-set/show.

You shouldn't list the function name twice.

> +	* gdb.mi/mi-console.exp: Tell mi_gdb_start to use a PTY for inferior.
> +	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
> +	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use a PTY for
> +	inferior.
> +	(403-exec-continue): Use mi_gdb_test to get GDB and Inferior output.
> +	(406-data-evaluate-expression have_a_very_merry_interrupt()): Ditto.
> +	(410-data-evaluate-expression bar()): Ditto.
> +	(408-exec-continue): Use mi_gdb_test to get GDB output.

It's fine this way too, but like I think Nick said, you don't need to
mark individual tests in the ChangeLog.  We haven't been bothering and
no one seems to miss it.

> @@ -81,13 +84,17 @@
>  }
>  
>  #
> -# start gdb -- start gdb running, default procedure
> +# start gdb INFERIOR_PTY -- start gdb running, default procedure

Hmm, that doesn't look right.  Did you mean this?

# mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure

> +    # create the new pty for the inferior process

# Create the new PTY for the inferior process.


> +    # If allowing the inferior to have it's own PTY then assign the inferior
> +    # it's own terminal device here

# If allowing the inferior to have its own PTY then assign the inferior
# its own terminal device here.

(trailing period, no apostrophe in the possessive "its")

> -# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
> +# mi_gdb_test COMMAND PATTERN MESSAGE IPATTERN -- send a command to gdb; 
> +#   test the result.

Please say [IPATTERN] to indicate that it's optional.  Yes, I realize
it didn't do this before when MESSAGE was optional.

> +    # if the GDB output matched, compare the inferior output

# If the GDB output matched, compare the inferior output.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 18:32                 ` Daniel Jacobowitz
@ 2005-08-03 19:31                   ` Bob Rossi
  2005-08-04  2:23                     ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-03 19:31 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 02:32:11PM -0400, Daniel Jacobowitz wrote:
> On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> > Sorry, I'm a little trigger happy, here's the patch.
> 
> Patch is OK with formatting corrections.

Thanks Daniel,

All applied, here's the patch.

Bob Rossi

Index: gdb/testsuite/ChangeLog
+	* gdb.mi/mi-basics.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
+	Change tests to inferior-tty-set/show.
+	* gdb.mi/mi-console.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
+	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use a PTY for
+	inferior.  Use mi_gdb_test to get GDB and Inferior output.
+	* lib/mi-support.exp (mi_inferior_spawn_id): Add inferior PTY
+	descriptor.
+	(mi_inferior_tty_name): Add inferior PTY file name.
+	(mi_gdb_start): Add INFERIOR_PTY parameter.
+	(mi_gdb_test): Add IPATTERN parameter.

Index: gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.10
diff -u -r1.10 mi-basics.exp
--- gdb/testsuite/gdb.mi/mi-basics.exp	6 Jul 2005 14:54:37 -0000	1.10
+++ gdb/testsuite/gdb.mi/mi-basics.exp	3 Aug 2005 19:24:58 -0000
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -238,6 +238,7 @@
 
 proc test_setshow_inferior_tty {} {
     global mi_gdb_prompt
+    global mi_inferior_tty_name
 
     # Test that the commands,
     #   -inferior-tty-set
@@ -245,8 +246,8 @@
     # are setting/getting the same data in GDB.
 
     mi_gdb_test "301-inferior-tty-show" \
-		"301\\\^done" \
-		"initial tty is empty"
+		"301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"initial tty is mi_inferior_tty_name"
 
     mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
 		"302\\\^done" \
@@ -262,7 +263,15 @@
 
     mi_gdb_test "305-inferior-tty-show" \
 		"305\\\^done" \
-		"final tty is empty"
+		"make sure tty is empty"
+
+    mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
+		"306\\\^done" \
+		"set tty to mi_inferior_tty_name (the way it was)"
+
+    mi_gdb_test "307-inferior-tty-show" \
+		"307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"verify tty is correct"
 }
 
 if [test_mi_interpreter_selection] {
Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.14
diff -u -r1.14 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	27 Apr 2005 16:35:15 -0000	1.14
+++ gdb/testsuite/gdb.mi/mi-console.exp	3 Aug 2005 19:24:58 -0000
@@ -36,7 +36,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start separate-inferior-tty] {
     continue
 }
 
@@ -54,37 +54,10 @@
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
-gdb_expect {
-    -re "47\\^running\r\n$mi_gdb_prompt" {
-	pass "Started step over hello"
-    }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
-}
-
-if { ![target_info exists gdb,noinferiorio]}  {
-    gdb_expect {
-	-re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
-	    pass "Hello message"
-	}
-	-re "Hello" {
-
-	    # Probably a native system where GDB doesn't have direct #
-	    # control over the inferior console.  # For this to work,
-	    # GDB would need to run the inferior process # under a PTY
-	    # and then use the even-loops ability to wait on #
-	    # multiple event sources to channel the output back
-	    # through the # MI.
-
-	    kfail "gdb/623" "Hello message"
-	}
-	timeout {
-	    fail "Hello message (timeout)"
-	}
-    }
-}
+mi_gdb_test "47-exec-next" \
+	    "47\\^running" \
+	    "Testing console output" \
+	    "Hello \\\\\"!\[\r\n\]+"
     
 gdb_expect {
     -re "47\\*stopped.*$mi_gdb_prompt$" {
Index: gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.5
diff -u -r1.5 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	2 Aug 2005 14:21:01 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	3 Aug 2005 19:24:58 -0000
@@ -38,7 +38,7 @@
 set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
 
 mi_gdb_exit
-mi_gdb_start
+mi_gdb_start separate-inferior-tty
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -60,16 +60,10 @@
 #
 # Continue back to main()
 #
-
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+  "403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+  "testing exec continue" \
+  "hi in foo\[\r\n\]\+"
 
 mi_gdb_test "404-stack-list-frames 0 0" \
   "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -85,8 +79,9 @@
   "insert breakpoint subroutine"
 
 mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
-  "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
-  "evaluate expression have_a_very_merry_interrupt"
+  "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+  "data evaluate expression" \
+  "Waiting to get a signal\[\r\n\]+"
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
@@ -96,15 +91,8 @@
   "list stack frames"
 
 
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+  "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" \
   "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -114,7 +102,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+  "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+  "call inferior function which raises exception" \
+  "hi in bar\[\r\n\]+"
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.28
diff -u -r1.28 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	2 Aug 2005 14:21:01 -0000	1.28
+++ gdb/testsuite/lib/mi-support.exp	3 Aug 2005 19:24:58 -0000
@@ -28,6 +28,9 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
 set MIFLAGS "-i=mi"
 
 #
@@ -81,13 +84,17 @@
 }
 
 #
-# start gdb -- start gdb running, default procedure
+# mi_gdb_start [INFERIOR_PTY] -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to separate-inferior-tty to have the inferior work 
+# with it's own PTY. If set to same-inferior-tty, the inferior shares GDB's PTY. 
+# The default value is same-inferior-tty.
 #
 # When running over NFS, particularly if running many simultaneous
 # tests on different hosts all using the same server, things can
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
-proc mi_gdb_start { } {
+proc mi_gdb_start { args } {
     global verbose
     global GDB
     global GDBFLAGS
@@ -98,6 +105,13 @@
     global MIFLAGS
 
     gdb_stop_suppressing_tests;
+    set inferior_pty no-tty
+
+    if { [llength $args] == 1} {
+	set inferior_pty [lindex $args 0]
+    }
+
+    set separate_inferior_pty [string match $inferior_pty separate-inferior-tty]
 
     # Start SID.
     if { [info procs sid_start] != "" } {
@@ -117,6 +131,16 @@
 	    exit 1
 	}
     }
+
+    # Create the new PTY for the inferior process.
+    if { $separate_inferior_pty } {
+	spawn -pty
+	global mi_inferior_spawn_id
+	global mi_inferior_tty_name
+	set mi_inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+    }
+
     set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -189,6 +213,19 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # If allowing the inferior to have its own PTY then assign the inferior
+    # its own terminal device here.
+    if { $separate_inferior_pty } {
+	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
+	gdb_expect 10 {
+	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "redirect inferior output to new terminal device."
+	    }
+	    timeout {
+	    	warning "Couldn't redirect inferior output." 2
+	    }
+    	}
+    }
 
     return 0;
 }
@@ -511,7 +548,8 @@
     return 0
 }
 
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN MESSAGE [IPATTERN] -- send a command to gdb; 
+#   test the result.
 #
 # COMMAND is the command to execute, send to GDB with send_gdb.  If
 #   this is the null string no command is sent.
@@ -520,6 +558,9 @@
 # MESSAGE is the message to be printed.  (If this is the empty string, 
 #   then sometimes we don't call pass or fail at all; I don't 
 #   understand this at all.)
+# IPATTERN is the pattern to match for the inferior's output.  This parameter
+#   is optional.  If present, it will produce a PASS if the match is 
+#   successful, and a FAIL if unsuccessful.
 #
 # Returns:
 #    1 if the test failed,
@@ -536,6 +577,10 @@
     set pattern [lindex $args 1]
     set message [lindex $args 2]
 
+    if [llength $args]==4 {
+	set ipattern [lindex $args 3]
+    }
+
     if [llength $args]==5 {
 	set question_string [lindex $args 3];
 	set response_string [lindex $args 4];
@@ -686,6 +731,23 @@
 	    set result 1
 	}
     }
+
+    # If the GDB output matched, compare the inferior output.
+    if { $result == 0 } {
+	if [ info exists ipattern ] {
+	    global mi_inferior_spawn_id
+	    expect {
+		-i $mi_inferior_spawn_id -re "$ipattern" {
+		    pass "inferior_output:$message"
+		}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-03 19:31                   ` Bob Rossi
@ 2005-08-04  2:23                     ` Bob Rossi
  2005-08-04  2:27                       ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-04  2:23 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 03:31:22PM -0400, Bob Rossi wrote:
> On Wed, Aug 03, 2005 at 02:32:11PM -0400, Daniel Jacobowitz wrote:
> > On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> > > Sorry, I'm a little trigger happy, here's the patch.
> > 
> > Patch is OK with formatting corrections.
> 
> Thanks Daniel,
> 
> All applied, here's the patch.
> 
> Bob Rossi

Umm, I just reran the testsuite after I committed and I get,

   Running ../../../src/gdb/testsuite/gdb.mi/mi-syn-frame.exp ...
   FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
   FAIL: gdb.mi/mi-syn-frame.exp: list stack frames

it's most likely this was me, but I just want to make sure someone isn't
pulling my chaing.

Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-04  2:23                     ` Bob Rossi
@ 2005-08-04  2:27                       ` Bob Rossi
  2005-08-04  4:05                         ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-04  2:27 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 10:23:44PM -0400, Bob Rossi wrote:
> On Wed, Aug 03, 2005 at 03:31:22PM -0400, Bob Rossi wrote:
> > On Wed, Aug 03, 2005 at 02:32:11PM -0400, Daniel Jacobowitz wrote:
> > > On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> > > > Sorry, I'm a little trigger happy, here's the patch.
> > > 
> > > Patch is OK with formatting corrections.
> > 
> > Thanks Daniel,
> > 
> > All applied, here's the patch.
> > 
> > Bob Rossi
> 
> Umm, I just reran the testsuite after I committed and I get,
> 
>    Running ../../../src/gdb/testsuite/gdb.mi/mi-syn-frame.exp ...
>    FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
>    FAIL: gdb.mi/mi-syn-frame.exp: list stack frames
> 
> it's most likely this was me, but I just want to make sure someone isn't
> pulling my chaing.

Oops,        ^^^^^^, very bad typo. Of course you know what I meant.

Anyways, if I rerun this test, it pass's now. Is this another test that
has random results?

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-04  2:27                       ` Bob Rossi
@ 2005-08-04  4:05                         ` Daniel Jacobowitz
  2005-08-04 13:07                           ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-04  4:05 UTC (permalink / raw)
  To: gdb-patches

On Wed, Aug 03, 2005 at 10:26:59PM -0400, Bob Rossi wrote:
> On Wed, Aug 03, 2005 at 10:23:44PM -0400, Bob Rossi wrote:
> > On Wed, Aug 03, 2005 at 03:31:22PM -0400, Bob Rossi wrote:
> > > On Wed, Aug 03, 2005 at 02:32:11PM -0400, Daniel Jacobowitz wrote:
> > > > On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> > > > > Sorry, I'm a little trigger happy, here's the patch.
> > > > 
> > > > Patch is OK with formatting corrections.
> > > 
> > > Thanks Daniel,
> > > 
> > > All applied, here's the patch.
> > > 
> > > Bob Rossi
> > 
> > Umm, I just reran the testsuite after I committed and I get,
> > 
> >    Running ../../../src/gdb/testsuite/gdb.mi/mi-syn-frame.exp ...
> >    FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
> >    FAIL: gdb.mi/mi-syn-frame.exp: list stack frames
> > 
> > it's most likely this was me, but I just want to make sure someone isn't
> > pulling my chaing.
> 
> Oops,        ^^^^^^, very bad typo. Of course you know what I meant.
> 
> Anyways, if I rerun this test, it pass's now. Is this another test that
> has random results?

I've never seen it do that before; it's more likely that there's some
funny race condition in the new pty test code.  Can you reproduce it,
say, by running the test a couple times in a row?

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-04  4:05                         ` Daniel Jacobowitz
@ 2005-08-04 13:07                           ` Bob Rossi
  0 siblings, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-08-04 13:07 UTC (permalink / raw)
  To: gdb-patches

On Thu, Aug 04, 2005 at 12:05:26AM -0400, Daniel Jacobowitz wrote:
> On Wed, Aug 03, 2005 at 10:26:59PM -0400, Bob Rossi wrote:
> > On Wed, Aug 03, 2005 at 10:23:44PM -0400, Bob Rossi wrote:
> > > On Wed, Aug 03, 2005 at 03:31:22PM -0400, Bob Rossi wrote:
> > > > On Wed, Aug 03, 2005 at 02:32:11PM -0400, Daniel Jacobowitz wrote:
> > > > > On Wed, Aug 03, 2005 at 02:23:51PM -0400, Bob Rossi wrote:
> > > > > > Sorry, I'm a little trigger happy, here's the patch.
> > > > > 
> > > > > Patch is OK with formatting corrections.
> > > > 
> > > > Thanks Daniel,
> > > > 
> > > > All applied, here's the patch.
> > > > 
> > > > Bob Rossi
> > > 
> > > Umm, I just reran the testsuite after I committed and I get,
> > > 
> > >    Running ../../../src/gdb/testsuite/gdb.mi/mi-syn-frame.exp ...
> > >    FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
> > >    FAIL: gdb.mi/mi-syn-frame.exp: list stack frames
> > > 
> > > it's most likely this was me, but I just want to make sure someone isn't
> > > pulling my chaing.
> > 
> > Oops,        ^^^^^^, very bad typo. Of course you know what I meant.
> > 
> > Anyways, if I rerun this test, it pass's now. Is this another test that
> > has random results?
> 
> I've never seen it do that before; it's more likely that there's some
> funny race condition in the new pty test code.  Can you reproduce it,
> say, by running the test a couple times in a row?

No, it won't happen again for me, however, I'll keep an eye out for it, 
I run the tests often.

Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-02 20:48                                 ` Daniel Jacobowitz
@ 2005-08-13 17:26                                   ` Bob Rossi
  2005-08-13 21:41                                     ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-13 17:26 UTC (permalink / raw)
  To: gdb-patches

On Tue, Aug 02, 2005 at 04:47:50PM -0400, Daniel Jacobowitz wrote:
> On Tue, Aug 02, 2005 at 11:45:20PM +0300, Eli Zaretskii wrote:
> > > Date: Mon, 1 Aug 2005 23:50:20 -0400
> > > From: Daniel Jacobowitz <drow@false.org>
> > > Cc: gdb-patches@sources.redhat.com
> > > 
> > > Yes, but the problem's that the buffering is in the program being
> > > debugged.  It's not the buffering of the GDB MI stream that's the
> > > problem, but the fact that the stdout of the program you're debugging
> > > would suddenly become block buffered instead of line buffered, if you
> > > fed it to a pipe when it expects a TTY.
> > 
> > This started as a discussion how to separate MI output from the
> > debuggee's.  For that, I suggested to redirect MI's output (_not_ the
> > debuggee's) to a different file handle.  That should not change the
> > buffering of the debuggee's stdout in any way.  While the problem you
> > mention is real, it has nothing to do with separation of these two
> > streams: if sending the program's output to a pipe changes its
> > buffering, we already have that annoyance on Windows.
> 
> Ah!  Thank you, I misunderstood your solution.  This is a very
> interesting idea indeed.

This is a good solution. I just had yet another idea, that might be
worth while. It would be a simple way to allow the FE to separate the MI
output command and the inferior output data.

Currently, GDB works like this,

(gdb) 
-interpreter-exec console "b test.c:49"
~"Breakpoint 1 at 0x8048525: file test.c, line 49.\n"
^done
(gdb) 
-interpreter-exec console "r"
~"Starting program: /home/bob/cvs/cgdb/cgdb.readline/objdir/test \n"
OUTPUT FROM INFERIOR
~"\n"
~"Breakpoint 1, main (argc=1, argv=0xbffffb54) at test.c:49\n"
~"49\t   for ( i = 0; i < 100; i++)\n"
^done
(gdb) 

If we let GDB do what it does know, except change the MI output command
to allow something like,

(gdb) 
-interpreter-exec console "b test.c:49"
~"Breakpoint 1 at 0x8048525: file test.c, line 49.\n"
^done
(gdb) 
-interpreter-exec console "r"
~"Starting program: /home/bob/cvs/cgdb/cgdb.readline/objdir/test \n"
=inferior-starting unique-key
OUTPUT FROM INFERIOR
=inferior-stopped unique-key
~"\n"
~"Breakpoint 1, main (argc=1, argv=0xbffffb54) at test.c:49\n"
~"49\t   for ( i = 0; i < 100; i++)\n"
^done
(gdb) 

In this way, the FE can still break the output into lines, and it can
strcmp the line to determine if the output is from GDB or the inferior.
The "unique-key" takes care of the case where you are actually debugging
GDB, because once the FE get's the '=inferior-starting unique-key' line,
it doesn't care how many =inferior-started or =inferior-stopped lines
get sent out until the key matches.

This sounds like a very simple solution. What does everyone think?

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-13 17:26                                   ` Bob Rossi
@ 2005-08-13 21:41                                     ` Daniel Jacobowitz
  0 siblings, 0 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-13 21:41 UTC (permalink / raw)
  To: gdb-patches

On Sat, Aug 13, 2005 at 12:55:18PM -0400, Bob Rossi wrote:
> In this way, the FE can still break the output into lines, and it can
> strcmp the line to determine if the output is from GDB or the inferior.
> The "unique-key" takes care of the case where you are actually debugging
> GDB, because once the FE get's the '=inferior-starting unique-key' line,
> it doesn't care how many =inferior-started or =inferior-stopped lines
> get sent out until the key matches.
> 
> This sounds like a very simple solution. What does everyone think?

MI is supposed to (eventually at least) accept some commands while the
inferior is running.  I think this would break that, and add much
complexity.  They're different streams logically; we should separate
them, not invest more effort in interleaving them.

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-09-05 19:52           ` Bob Rossi
@ 2005-09-10  4:02             ` Daniel Jacobowitz
  0 siblings, 0 replies; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-09-10  4:02 UTC (permalink / raw)
  To: Mark Kettenis, gdb-patches

On Mon, Sep 05, 2005 at 03:51:47PM -0400, Bob Rossi wrote:
> Index: gdb/testsuite/ChangeLog
> 2005-08-31  Bob Rossi  <bob@brasko.net>
> +
> +	* lib/mi-support.exp (mi_gdb_test): Change -re to not be anchored.
> +	* gdb.mi/mi-syn-frame.exp: Call mi_gdb_test twice instead of once for 
> +	commands that return an MI output command and an asyncronous MI output
> +	command. This avoids race conditions.
> +	* gdb.mi/mi-console.exp: Ditto.

This is OK.  Please drop "This avoids race conditions"; GNU convention
is that only what goes in the changelog, not why.

Thanks a lot!


-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-09-01 22:12         ` Mark Kettenis
  2005-09-01 23:52           ` Bob Rossi
@ 2005-09-05 19:52           ` Bob Rossi
  2005-09-10  4:02             ` Daniel Jacobowitz
  1 sibling, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-09-05 19:52 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches, Daniel Jacobowitz

> Fixes the problems in mi-console.exp, but I still see the following:
> 
> 403-exec-continue
> 403^running
> (gdb) 
> FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
> 403*stopped
> (gdb) 
> 404-stack-list-frames 0 0
> 404^done,stack=[frame={level="0",addr="0x1c0006c8",func="main",file="../../../..
> /src/gdb/gdb/testsuite/gdb.mi/mi-syn-frame.c",fullname="/home/kettenis/src/gdb/g
> db/testsuite/gdb.mi/mi-syn-frame.c",line="14"}]
> (gdb) 
> PASS: gdb.mi/mi-syn-frame.exp: list stack frames

OK, I think I finally have a solution that will scale nicely to other
problems that pop up like this. The previous patch I posted is reposted
here, along with a patch that fixes the mi-syn-frame.exp testcase.

For an MI input command that can generate more than 1 MI output command
(the normal MI output command response + at least 1 asynchronous MI
output command), we can simply call mi_gdb_test multiple times, each
with an MI output command to match. Here's an example,

   mi_gdb_test "47-exec-next" \
               "47\\^running" \
               "Testing console output" \
               "Hello \\\\\"!\[\r\n\]+"

   mi_gdb_test "" "47\\*stopped.*" "Finished step over hello"

When the first parameter is "", mi_gdb_test still matches the MI output
command, even though no new data is sent to GDB.

The attached patch solves the current issues found by Mark and I.
What do you think?

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
2005-08-31  Bob Rossi  <bob@brasko.net>
+
+	* lib/mi-support.exp (mi_gdb_test): Change -re to not be anchored.
+	* gdb.mi/mi-syn-frame.exp: Call mi_gdb_test twice instead of once for 
+	commands that return an MI output command and an asyncronous MI output
+	command. This avoids race conditions.
+	* gdb.mi/mi-console.exp: Ditto.

Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.15
diff -u -r1.15 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	4 Aug 2005 01:52:31 -0000	1.15
+++ gdb/testsuite/gdb.mi/mi-console.exp	5 Sep 2005 19:43:55 -0000
@@ -58,15 +58,8 @@
 	    "47\\^running" \
 	    "Testing console output" \
 	    "Hello \\\\\"!\[\r\n\]+"
-    
-gdb_expect {
-    -re "47\\*stopped.*$mi_gdb_prompt$" {
-	pass "Finished step over hello"
-    }
-    timeout {
-	fail "Finished step over hello (timeout)"
-    }
-}
 
+mi_gdb_test "" "47\\*stopped.*" "Finished step over hello"
+    
 mi_gdb_exit
 return 0
Index: gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.6
diff -u -r1.6 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	4 Aug 2005 01:52:31 -0000	1.6
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	5 Sep 2005 19:43:55 -0000
@@ -35,8 +35,6 @@
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
-set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
-
 mi_gdb_exit
 mi_gdb_start separate-inferior-tty
 mi_delete_breakpoints
@@ -61,10 +59,12 @@
 # Continue back to main()
 #
 mi_gdb_test "403-exec-continue" \
-  "403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+  "403\\^running" \
   "testing exec continue" \
   "hi in foo\[\r\n\]\+"
 
+mi_gdb_test "" "403\\*stopped" "finished exec continue"
+
 mi_gdb_test "404-stack-list-frames 0 0" \
   "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
   "list stack frames"
@@ -91,8 +91,9 @@
   "list stack frames"
 
 
-mi_gdb_test "408-exec-continue" \
-  "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
+mi_gdb_test "408-exec-continue" "408\\^running"
+
+mi_gdb_test "" "408\\*stopped.*" "finished exec continue"
 
 mi_gdb_test "409-stack-list-frames 0 0" \
   "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.30
diff -u -r1.30 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	9 Aug 2005 19:00:16 -0000	1.30
+++ gdb/testsuite/lib/mi-support.exp	5 Sep 2005 19:43:55 -0000
@@ -659,7 +659,15 @@
 	    gdb_start
 	    set result -1
 	}
-	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
+	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*" {
+	    # NOTE, there is no trailing anchor because with GDB/MI, 
+	    # asynchronous responses can happen at any point, causing more 
+	    # data to be available.  Normally an anchor is used to make 
+	    # sure the end of the output is matched, however, $mi_gdb_prompt 
+	    # is just as good of an anchor since mi_gdb_test is meant to 
+	    # match a single mi output command. If a second GDB/MI output 
+	    # response is sent, it will be in the buffer for the next 
+	    # time mi_gdb_test is called.
 	    if ![string match "" $message] then {
 		pass "$message"
 	    }


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-09-01 22:12         ` Mark Kettenis
@ 2005-09-01 23:52           ` Bob Rossi
  2005-09-05 19:52           ` Bob Rossi
  1 sibling, 0 replies; 62+ messages in thread
From: Bob Rossi @ 2005-09-01 23:52 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> Fixes the problems in mi-console.exp, but I still see the following:
> 
> 403-exec-continue
> 403^running
> (gdb) 
> FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
> 403*stopped
> (gdb) 
> 404-stack-list-frames 0 0
> 404^done,stack=[frame={level="0",addr="0x1c0006c8",func="main",file="../../../..
> /src/gdb/gdb/testsuite/gdb.mi/mi-syn-frame.c",fullname="/home/kettenis/src/gdb/g
> db/testsuite/gdb.mi/mi-syn-frame.c",line="14"}]
> (gdb) 
> PASS: gdb.mi/mi-syn-frame.exp: list stack frames
> 
> Seems the attached patch solves those though.
> 
> Mark

O, great find Mark! I couldn't reproduce this, but now I see why the
testcase is failing. It's also a case where multiple MI output commands
were being matched in a single mi_gdb_test command.

I wonder how my changes effected the testsuite to cause these problems?
I'll take a look.

Thanks a lot!
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-09-01  0:52       ` Bob Rossi
@ 2005-09-01 22:12         ` Mark Kettenis
  2005-09-01 23:52           ` Bob Rossi
  2005-09-05 19:52           ` Bob Rossi
  0 siblings, 2 replies; 62+ messages in thread
From: Mark Kettenis @ 2005-09-01 22:12 UTC (permalink / raw)
  To: bob; +Cc: gdb-patches

> Date: Wed, 31 Aug 2005 20:52:00 -0400
> From: Bob Rossi <bob@brasko.net>
> 
> Index: gdb/testsuite/lib/mi-support.exp
> ===================================================================
> RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
> retrieving revision 1.30
> diff -u -r1.30 mi-support.exp
> --- gdb/testsuite/lib/mi-support.exp	9 Aug 2005 19:00:16 -0000	1.30
> +++ gdb/testsuite/lib/mi-support.exp	1 Sep 2005 00:46:01 -0000
> @@ -659,7 +659,15 @@
>  	    gdb_start
>  	    set result -1
>  	}
> -	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
> +	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*" {
> +	    # NOTE, there is no trailing anchor because with GDB/MI, 
> +	    # asynchronous responses can happen at any point, causing more 
> +	    # data to be available.  Normally an anchor is used to make 
> +	    # sure the end of the output is matched, however, $mi_gdb_prompt 
> +	    # is just as good of an anchor since mi_gdb_test is meant to 
> +	    # match a single mi output command. If a second GDB/MI output 
> +	    # response is sent, it will be in the buffer for the next 
> +	    # time mi_gdb_test is called.
>  	    if ![string match "" $message] then {
>  		pass "$message"
>  	    }
> 
> Basically, this passes the mi-console.exp testcase if the 'sleep 1' is
> there or not. Also, it didn't break any testcases. It changes
> mi_gdb_test to enforce the fact that only a single MI output command can
> be matched. What do you think?

Fixes the problems in mi-console.exp, but I still see the following:

403-exec-continue
403^running
(gdb) 
FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
403*stopped
(gdb) 
404-stack-list-frames 0 0
404^done,stack=[frame={level="0",addr="0x1c0006c8",func="main",file="../../../..
/src/gdb/gdb/testsuite/gdb.mi/mi-syn-frame.c",fullname="/home/kettenis/src/gdb/g
db/testsuite/gdb.mi/mi-syn-frame.c",line="14"}]
(gdb) 
PASS: gdb.mi/mi-syn-frame.exp: list stack frames

Seems the attached patch solves those though.

Mark


Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* gdb.mi/mi-syn-frame.exp (my_mi_gdb_prompt): Remove.  Split tests
	that were using this variable.

Index: gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.6
diff -u -p -r1.6 mi-syn-frame.exp
--- gdb.mi/mi-syn-frame.exp 4 Aug 2005 01:52:31 -0000 1.6
+++ gdb.mi/mi-syn-frame.exp 1 Sep 2005 22:10:47 -0000
@@ -35,8 +35,6 @@ if  { [gdb_compile "${srcdir}/${subdir}/
      gdb_suppress_entire_file "Testcase compile failed, so all tests in this file will automatically fail."
 }
 
-set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
-
 mi_gdb_exit
 mi_gdb_start separate-inferior-tty
 mi_delete_breakpoints
@@ -61,9 +59,18 @@ mi_gdb_test "402-stack-list-frames" "402
 # Continue back to main()
 #
 mi_gdb_test "403-exec-continue" \
-  "403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
-  "testing exec continue" \
-  "hi in foo\[\r\n\]\+"
+    "403\\^running" \
+    "testing exec continue" \
+    "hi in foo\[\r\n\]\+"
+
+gdb_expect {
+    -re "403\\*stopped.*$mi_gdb_prompt$" {
+	pass "finished exec continue"
+    }
+    timeout {
+	fail "finished exec continue (timeout)"
+    }
+}
 
 mi_gdb_test "404-stack-list-frames 0 0" \
   "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \
@@ -92,7 +99,16 @@ mi_gdb_test "407-stack-list-frames" \
 
 
 mi_gdb_test "408-exec-continue" \
-  "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
+  "408\\^running"
+
+gdb_expect {
+    -re "408\\*stopped.*$mi_gdb_prompt$" {
+	pass "finished exec continue"
+    }
+    timeout {
+	fail "finished exec continue (timeout)"
+    }
+}
 
 mi_gdb_test "409-stack-list-frames 0 0" \
   "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]" \


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-30  2:55     ` Daniel Jacobowitz
@ 2005-09-01  0:52       ` Bob Rossi
  2005-09-01 22:12         ` Mark Kettenis
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-09-01  0:52 UTC (permalink / raw)
  To: Mark Kettenis, gdb-patches

On Mon, Aug 29, 2005 at 10:52:03PM -0400, Daniel Jacobowitz wrote:
> On Fri, Aug 19, 2005 at 06:27:21PM -0400, Bob Rossi wrote:
> > > Funny thing is that if I run mi-console.exp alone, it usually
> > > (although not always) succeeds.
> > > 
> > > Attached are a gdb.log for a failing run and a passing run.
> > 
> > OK, I've tracked down why mi-console.exp breaks. Also, I can reproduce
> > it. The problem is slightly difficult to fix because of race conditions
> > so I was hoping to get some advice from people who might have had
> > similar experience with the testsuite.
> 
> Nice job tracking this down.

Hi Daniel,

The solution you sent in gave me an idea that might work out. It's
pretty simple. First look at the patch with it's comment,

Index: gdb/testsuite/ChangeLog
+	* lib/mi-support.exp (mi_gdb_test): Change -re to not be anchored.

Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.30
diff -u -r1.30 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	9 Aug 2005 19:00:16 -0000	1.30
+++ gdb/testsuite/lib/mi-support.exp	1 Sep 2005 00:46:01 -0000
@@ -659,7 +659,15 @@
 	    gdb_start
 	    set result -1
 	}
-	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
+	 -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*" {
+	    # NOTE, there is no trailing anchor because with GDB/MI, 
+	    # asynchronous responses can happen at any point, causing more 
+	    # data to be available.  Normally an anchor is used to make 
+	    # sure the end of the output is matched, however, $mi_gdb_prompt 
+	    # is just as good of an anchor since mi_gdb_test is meant to 
+	    # match a single mi output command. If a second GDB/MI output 
+	    # response is sent, it will be in the buffer for the next 
+	    # time mi_gdb_test is called.
 	    if ![string match "" $message] then {
 		pass "$message"
 	    }

Basically, this passes the mi-console.exp testcase if the 'sleep 1' is
there or not. Also, it didn't break any testcases. It changes
mi_gdb_test to enforce the fact that only a single MI output command can
be matched. What do you think?

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-20  9:07   ` Bob Rossi
@ 2005-08-30  2:55     ` Daniel Jacobowitz
  2005-09-01  0:52       ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Daniel Jacobowitz @ 2005-08-30  2:55 UTC (permalink / raw)
  To: Mark Kettenis, gdb-patches

On Fri, Aug 19, 2005 at 06:27:21PM -0400, Bob Rossi wrote:
> > Funny thing is that if I run mi-console.exp alone, it usually
> > (although not always) succeeds.
> > 
> > Attached are a gdb.log for a failing run and a passing run.
> 
> OK, I've tracked down why mi-console.exp breaks. Also, I can reproduce
> it. The problem is slightly difficult to fix because of race conditions
> so I was hoping to get some advice from people who might have had
> similar experience with the testsuite.

Nice job tracking this down.

> This splits up the regex matching into 2 commands, which makes sense.
> The problem is, in mi_gdb_test when it goes to match 47\\^running, it is
> possible that either just that has been outputted by GDB (Yay, match!),
> or that also the 47\\*stopped... output has also been output by GDB. In
> this case, the testcase fails because the regex in mi_gdb_test does not
> match the 'end anchor' of the output from GDB. Thus the race condition.
> 
> I'm still thinking of ways to fix this without totally hacking the
> testsuite, any ideas?
> 
> To reproduce this problem, put 'sleep 1' just before the gdb_expect line
> in mi-support.exp:mi_gdb_test.  That gives GDB enough time to output
> both items that need to be matched.

Well, let's see.  I'd recommend adding support for multiple prompts to
mi_gdb_test so that we don't lose the "unexpected output" case;
otherwise we get nasty timeouts.  I'm thinking of, roughly, this
control flow.

  gdb_expect {
    ....
    -re "^running\n$mi_gdb_prompt" {
      # Note the lack of a trailing anchor.
      # This will leave everything after that prompt in expect's
      # buffer, only consuming things before it.
      pass 1
    }
    -re ".*$mi_gdb_prompt$" {
      fail
      return
    }
  }

  gdb_expect {
    ....
    -re "\*stopped\n$mi_gdb_prompt" {
      pass 1
    }
    -re ".*$mi_gdb_prompt$" {
      fail
      return
    }
  }

I haven't tried it.  Does the idea make sense?

-- 
Daniel Jacobowitz
CodeSourcery, LLC


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-08-13 22:04 ` Mark Kettenis
@ 2005-08-20  9:07   ` Bob Rossi
  2005-08-30  2:55     ` Daniel Jacobowitz
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-08-20  9:07 UTC (permalink / raw)
  To: Mark Kettenis; +Cc: gdb-patches

> Funny thing is that if I run mi-console.exp alone, it usually
> (although not always) succeeds.
> 
> Attached are a gdb.log for a failing run and a passing run.

OK, I've tracked down why mi-console.exp breaks. Also, I can reproduce
it. The problem is slightly difficult to fix because of race conditions
so I was hoping to get some advice from people who might have had
similar experience with the testsuite.

For MI, the mi_gdb_test function is used to test the output of a
command. Only problem is, in mi_gdb_test there is this,

    gdb_expect $tmt {
        ...
         -re "\[\r\n\]*($pattern)\[\r\n\]+$mi_gdb_prompt\[ \]*$" {
            if ![string match "" $message] then {
                pass "$message"
            }
            set result 0
        }
        ...
        -re ".*$mi_gdb_prompt\[ \]*$" {
           if ![string match "" $message] then {
               fail "$message"
           }
           set result 1
       }
       ...
   }

So, if the pattern the user passes in matches the regex, then a pass
will get put out. However, if the pattern does not match, and a
mi_gdb_prompt is reached, then a fail will be issued. Only difference
is, the second case does not have to wait the full $tmt (which is 60 in
this case) seconds to complete the match.

So, the first problem is that $pattern can not consist of more than a
single gdb prompt output. In MI this means, you send,
   47-exec-next
and get back
   47^running^M
   (gdb) ^M
   47*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x080483e8",func="main",args=[],file
   (gdb) ^M

You can not expect to get back both of those in a single mi_gdb_test
command list so,
   mi_gdb_test "47-exec-next" \
               "47\\^running\[\r\n\]+${mi_gdb_prompt}47\\*stopped.*}" \
               "Testing console output" \
               "Hello \\\\\"!\[\r\n\]+"

With that in mind, the next obvious solution, which is the one used, is
to do what is currently in mi-console.exp,

   mi_gdb_test "47-exec-next" \
               "47\\^running" \
               "Testing console output" \
               "Hello \\\\\"!\[\r\n\]+"

   gdb_expect {
       -re "47\\*stopped.*$mi_gdb_prompt$" {
           pass "Finished step over hello"
       }
       timeout {
           fail "Finished step over hello (timeout)"
       }
   }

This splits up the regex matching into 2 commands, which makes sense.
The problem is, in mi_gdb_test when it goes to match 47\\^running, it is
possible that either just that has been outputted by GDB (Yay, match!),
or that also the 47\\*stopped... output has also been output by GDB. In
this case, the testcase fails because the regex in mi_gdb_test does not
match the 'end anchor' of the output from GDB. Thus the race condition.

I'm still thinking of ways to fix this without totally hacking the
testsuite, any ideas?

To reproduce this problem, put 'sleep 1' just before the gdb_expect line
in mi-support.exp:mi_gdb_test.  That gives GDB enough time to output
both items that need to be matched.

Thanks,
Bob Rossi


^ permalink raw reply	[flat|nested] 62+ messages in thread

* Re: MI testsuite to use PTY for inferior
  2005-07-27  3:18 Bob Rossi
@ 2005-08-13 22:04 ` Mark Kettenis
  2005-08-20  9:07   ` Bob Rossi
  0 siblings, 1 reply; 62+ messages in thread
From: Mark Kettenis @ 2005-08-13 22:04 UTC (permalink / raw)
  To: bob; +Cc: gdb-patches

[-- Attachment #1: Type: text/plain, Size: 468 bytes --]

Hmm, I consistently see 

FAIL: gdb.mi/mi-console.exp: Testing console output
FAIL: gdb.mi/mi-console.exp: Finished step over hello (timeout)

FAIL: gdb.mi/mi-syn-frame.exp: testing exec continue
FAIL: gdb.mi/mi-syn-frame.exp: list stack frames

if I run the complete testsuite, since this was checked in.

Funny thing is that if I run mi-console.exp alone, it usually
(although not always) succeeds.

Attached are a gdb.log for a failing run and a passing run.

Mark

[-- Attachment #2: gdb.log.fail --]
[-- Type: application/octet-stream, Size: 4766 bytes --]

Test Run By kettenis on Sat Aug 13 23:49:26 2005
Native configuration is i386-unknown-openbsd3.7

		=== gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/local/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/local/share/dejagnu/config/unix.exp as generic interface file for target.
Using ../../../../src/gdb/gdb/testsuite/config/unix.exp as tool-and-target-specific interface file.
Running ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.exp ...
~"GNU gdb 6.3.50.20050813-cvs\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
~"This GDB was configured as \"i386-unknown-openbsd3.7\"."
~"\n"
(gdb) 
100-gdb-set height 0
100^done
(gdb) 
101-gdb-set width 0
101^done
(gdb) 
102-inferior-tty-set /dev/ttyp9
102^done
(gdb) 
Executing on host: gcc ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c  -DFAKEARGV -g  -lm   -o /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console    (timeout = 300)
102-break-delete
102^done
(gdb) 
103-break-list
103^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb) 
104-environment-directory -r
104^done,source-path="$cdir:$cwd"
(gdb) 
105-environment-directory ../../../../src/gdb/gdb/testsuite/gdb.mi
105^done,source-path="/home/kettenis/obj/gdb/gdb/testsuite/../../../../src/gdb/gdb/testsuite/gdb.mi:$cdir:$cwd"
(gdb) 
105-file-exec-and-symbols /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console
105^done
(gdb) 
102-break-delete
102^done
(gdb) 
103-break-list
103^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb) 
104-environment-directory -r
104^done,source-path="$cdir:$cwd"
(gdb) 
105-environment-directory ../../../../src/gdb/gdb/testsuite/gdb.mi
105^done,source-path="/home/kettenis/obj/gdb/gdb/testsuite/../../../../src/gdb/gdb/testsuite/gdb.mi:$cdir:$cwd"
(gdb) 
105-file-exec-and-symbols /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console
105^done
(gdb) 
200-break-insert main
200^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x1c000638",func="main",file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="13",times="0"}
(gdb) 
PASS: gdb.mi/mi-console.exp: breakpoint at main
000-exec-run 
000^running
(gdb) 
000*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x1c000638",func="main",args=[],file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",fullname="/home/kettenis/src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="13"}
(gdb) 
PASS: gdb.mi/mi-console.exp: mi runto main
47-exec-next
47^running
(gdb) 
47*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x1c00063d",func="main",args=[],file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",fullname="/home/kettenis/src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="14"}
(gdb) 
FAIL: gdb.mi/mi-console.exp: Testing console output
FAIL: gdb.mi/mi-console.exp: Finished step over hello (timeout)
testcase ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.exp completed in 61 seconds

		=== gdb Summary ===

# of expected passes		2
# of unexpected failures	2
Executing on host: /home/kettenis/obj/gdb/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd    (timeout = 300)
GNU gdb 6.3.50.20050813-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-openbsd3.7".
/home/kettenis/obj/gdb/gdb/testsuite/../../gdb/gdb version  6.3.50.20050813-cvs -nx

runtest completed at Sat Aug 13 23:50:27 2005

[-- Attachment #3: gdb.log.pass --]
[-- Type: application/octet-stream, Size: 4806 bytes --]

Test Run By kettenis on Sat Aug 13 23:50:37 2005
Native configuration is i386-unknown-openbsd3.7

		=== gdb tests ===

Schedule of variations:
    unix

Running target unix
Using /usr/local/share/dejagnu/baseboards/unix.exp as board description file for target.
Using /usr/local/share/dejagnu/config/unix.exp as generic interface file for target.
Using ../../../../src/gdb/gdb/testsuite/config/unix.exp as tool-and-target-specific interface file.
Running ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.exp ...
~"GNU gdb 6.3.50.20050813-cvs\n"
~"Copyright 2004 Free Software Foundation, Inc.\n"
~"GDB is free software, covered by the GNU General Public License, and you are\n"
~"welcome to change it and/or distribute copies of it under certain conditions.\n"
~"Type \"show copying\" to see the conditions.\n"
~"There is absolutely no warranty for GDB.  Type \"show warranty\" for details.\n"
~"This GDB was configured as \"i386-unknown-openbsd3.7\"."
~"\n"
(gdb) 
100-gdb-set height 0
100^done
(gdb) 
101-gdb-set width 0
101^done
(gdb) 
102-inferior-tty-set /dev/ttyp9
102^done
(gdb) 
Executing on host: gcc ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c  -DFAKEARGV -g  -lm   -o /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console    (timeout = 300)
102-break-delete
102^done
(gdb) 
103-break-list
103^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb) 
104-environment-directory -r
104^done,source-path="$cdir:$cwd"
(gdb) 
105-environment-directory ../../../../src/gdb/gdb/testsuite/gdb.mi
105^done,source-path="/home/kettenis/obj/gdb/gdb/testsuite/../../../../src/gdb/gdb/testsuite/gdb.mi:$cdir:$cwd"
(gdb) 
105-file-exec-and-symbols /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console
105^done
(gdb) 
102-break-delete
102^done
(gdb) 
103-break-list
103^done,BreakpointTable={nr_rows="0",nr_cols="6",hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},{width="14",alignment="-1",col_name="type",colhdr="Type"},{width="4",alignment="-1",col_name="disp",colhdr="Disp"},{width="3",alignment="-1",col_name="enabled",colhdr="Enb"},{width="10",alignment="-1",col_name="addr",colhdr="Address"},{width="40",alignment="2",col_name="what",colhdr="What"}],body=[]}
(gdb) 
104-environment-directory -r
104^done,source-path="$cdir:$cwd"
(gdb) 
105-environment-directory ../../../../src/gdb/gdb/testsuite/gdb.mi
105^done,source-path="/home/kettenis/obj/gdb/gdb/testsuite/../../../../src/gdb/gdb/testsuite/gdb.mi:$cdir:$cwd"
(gdb) 
105-file-exec-and-symbols /home/kettenis/obj/gdb/gdb/testsuite/gdb.mi/mi-console
105^done
(gdb) 
200-break-insert main
200^done,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x1c000638",func="main",file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="13",times="0"}
(gdb) 
PASS: gdb.mi/mi-console.exp: breakpoint at main
000-exec-run 
000^running
(gdb) 
000*stopped,reason="breakpoint-hit",bkptno="1",thread-id="0",frame={addr="0x1c000638",func="main",args=[],file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",fullname="/home/kettenis/src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="13"}
(gdb) 
PASS: gdb.mi/mi-console.exp: mi runto main
47-exec-next
47^running
(gdb) 
PASS: gdb.mi/mi-console.exp: Testing console output
Hello \"!\rPASS: gdb.mi/mi-console.exp: inferior_output:Testing console output
47*stopped,reason="end-stepping-range",thread-id="0",frame={addr="0x1c00063d",func="main",args=[],file="../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.c",fullname="/home/kettenis/src/gdb/gdb/testsuite/gdb.mi/mi-console.c",line="14"}
(gdb) 
PASS: gdb.mi/mi-console.exp: Finished step over hello
testcase ../../../../src/gdb/gdb/testsuite/gdb.mi/mi-console.exp completed in 0 seconds

		=== gdb Summary ===

# of expected passes		5
Executing on host: /home/kettenis/obj/gdb/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd    (timeout = 300)
GNU gdb 6.3.50.20050813-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-unknown-openbsd3.7".
/home/kettenis/obj/gdb/gdb/testsuite/../../gdb/gdb version  6.3.50.20050813-cvs -nx

runtest completed at Sat Aug 13 23:50:37 2005

^ permalink raw reply	[flat|nested] 62+ messages in thread

* MI testsuite to use PTY for inferior
@ 2005-07-27  3:18 Bob Rossi
  2005-08-13 22:04 ` Mark Kettenis
  0 siblings, 1 reply; 62+ messages in thread
From: Bob Rossi @ 2005-07-27  3:18 UTC (permalink / raw)
  To: gdb-patches

Hi,

This patch is following the acceptance of the -inferior-tty-set command.
It basically changes the MI testsuite to use a pty for the inferior,
instead of mixing output from GDB and the inferior on the same console.
The function mi_gdb_test is now capable of checking the output of both
GDB and the inferior, without major headaches. In particular, look at
the difference to the mi-console.exp testcase.

If/Once this patch is accepted, I plan on fully anchoring GDB's output
in the MI testsuite. This will ensure that everything is being matched
correctly. It will also ensure I can capture the output of the MI
command and do a syntax check against the output of all the commands.

Currently, there is a parameter to mi_gdb_start. This tells the
lib/mi-support.exp that the testsuite is capable of dealing with a PTY
for the inferior.

I think that this parameter should go away, and I should test both mi-
and mi2- with the inferior PTY. However, Andrew was unsure at the time
that this was a good idea. I'm under the impression that MI is currently
useless without the assumption that FE's are using PTY's for the
inferior console. Is it OK if I resend this patch, which would effect
both mi- and mi2-?

One other note. If you call mi_gdb_test with GDB output to match, and
inferior output to match, then 2 tests are issued, not 1. You can get 2
passed, 1 pass/1 fail or 2 failed.

Thanks,
Bob Rossi

Index: gdb/testsuite/ChangeLog
+	* gdb.mi/gdb669.exp: Tell mi_gdb_start to use a PTY for inferior.
+	Update Copyright.
+	* gdb.mi/gdb680.exp: Ditto.
+	* gdb.mi/gdb701.exp: Ditto.
+	* gdb.mi/gdb792.exp: Ditto.
+	* gdb.mi/mi-break.exp: Ditto.
+	* gdb.mi/mi-disassemble.exp: Ditto.
+	* gdb.mi/mi-eval.exp: Ditto.
+	* gdb.mi/mi-file.exp: Ditto.
+	* gdb.mi/mi-hack-cli.exp: Ditto.
+	* gdb.mi/mi-pthreads.exp: Ditto.
+	* gdb.mi/mi-read-memory.exp: Ditto.
+	* gdb.mi/mi-regs.exp: Ditto.
+	* gdb.mi/mi-simplerun.exp: Ditto.
+	* gdb.mi/mi-var-block.exp: Ditto.
+	* gdb.mi/mi-var-child.exp: Ditto.
+	* gdb.mi/mi-basics.exp: Tell mi_gdb_start to use a PTY for inferior.
+	(test_setshow_inferior_tty): Add global mi_inferior_tty_name to scope.
+	(test_setshow_inferior_tty): Change tests to inferior-tty-set/show
+	* gdb.mi/mi-cli.exp: Tell mi_gdb_start to use a PTY for inferior.
+	* gdb.mi/mi-console.exp: Ditto.
+	(47-exec-next): Use mi_gdb_test to get GDB and Inferior output.
+	* gdb.mi/mi-return.exp: Ditto.
+	* gdb.mi/mi-stack.exp: Ditto.
+	* gdb.mi/mi-stepi.exp: Ditto.
+	* gdb.mi/mi-until.exp: Ditto.
+	* gdb.mi/mi-var-cmd.exp: Ditto.
+	* gdb.mi/mi-var-display.exp: Ditto.
+	* gdb.mi/mi-watch.exp: Ditto.
+	* gdb.mi/mi-syn-frame.exp: Tell mi_gdb_start to use PTY for inferior.
+	(403-exec-continue): Use mi_gdb_test to get GDB and Inferior output.
+	(406-data-evaluate-expression have_a_very_merry_interrupt()): Ditto.
+	(410-data-evaluate-expression bar()): Ditto.
+	(408-exec-continue): Use mi_gdb_test to get GDB output.
+	* lib/mi-support.exp (mi_inferior_spawn_id): Add inferior PTY
+	descriptor.
+	(mi_inferior_tty_name): Add inferior PTY file name.
+	(mi_gdb_start): Add INERIOR_PTY parameter, if TRUE, use PTY for
+	inferior, otherwise share GDB's PTY.
+	(mi_gdb_test): Add IPATTERN parameter, match inferior output from
+	the inferior's very own PTY.

Index: gdb/testsuite/gdb.mi/gdb669.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb669.exp,v
retrieving revision 1.5
diff -w -u -r1.5 gdb669.exp
--- gdb/testsuite/gdb.mi/gdb669.exp	13 Jan 2004 17:08:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/gdb669.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start true]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb680.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb680.exp,v
retrieving revision 1.1
diff -w -u -r1.1 gdb680.exp
--- gdb/testsuite/gdb.mi/gdb680.exp	3 Sep 2002 16:37:00 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb680.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb701.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb701.exp,v
retrieving revision 1.1
diff -w -u -r1.1 gdb701.exp
--- gdb/testsuite/gdb.mi/gdb701.exp	16 Sep 2002 19:01:43 -0000	1.1
+++ gdb/testsuite/gdb.mi/gdb701.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002 Free Software Foundation, Inc.
+# Copyright 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/gdb792.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/gdb792.exp,v
retrieving revision 1.4
diff -w -u -r1.4 gdb792.exp
--- gdb/testsuite/gdb.mi/gdb792.exp	9 Aug 2004 16:32:44 -0000	1.4
+++ gdb/testsuite/gdb.mi/gdb792.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-basics.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-basics.exp,v
retrieving revision 1.10
diff -w -u -r1.10 mi-basics.exp
--- gdb/testsuite/gdb.mi/mi-basics.exp	6 Jul 2005 14:54:37 -0000	1.10
+++ gdb/testsuite/gdb.mi/mi-basics.exp	27 Jul 2005 03:06:25 -0000
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
@@ -238,6 +238,7 @@
 
 proc test_setshow_inferior_tty {} {
     global mi_gdb_prompt
+    global mi_inferior_tty_name
 
     # Test that the commands,
     #   -inferior-tty-set
@@ -245,8 +246,8 @@
     # are setting/getting the same data in GDB.
 
     mi_gdb_test "301-inferior-tty-show" \
-		"301\\\^done" \
-		"initial tty is empty"
+		"301\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"initial tty is mi_inferior_tty_name"
 
     mi_gdb_test "302-inferior-tty-set /dev/pts/1" \
 		"302\\\^done" \
@@ -262,7 +263,15 @@
 
     mi_gdb_test "305-inferior-tty-show" \
 		"305\\\^done" \
-		"final tty is empty"
+		"make sure tty is empty"
+
+    mi_gdb_test "306-inferior-tty-set $mi_inferior_tty_name" \
+		"306\\\^done" \
+		"set tty to mi_inferior_tty_name (the way it was)"
+
+    mi_gdb_test "307-inferior-tty-show" \
+		"307\\\^done,inferior_tty_terminal=\"$mi_inferior_tty_name\"" \
+		"verify tty is correct"
 }
 
 if [test_mi_interpreter_selection] {
Index: gdb/testsuite/gdb.mi/mi-break.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-break.exp,v
retrieving revision 1.7
diff -w -u -r1.7 mi-break.exp
--- gdb/testsuite/gdb.mi/mi-break.exp	13 Aug 2004 16:21:29 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-break.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-cli.exp,v
retrieving revision 1.4
diff -w -u -r1.4 mi-cli.exp
--- gdb/testsuite/gdb.mi/mi-cli.exp	18 May 2005 03:41:58 -0000	1.4
+++ gdb/testsuite/gdb.mi/mi-cli.exp	27 Jul 2005 03:06:25 -0000
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-console.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-console.exp,v
retrieving revision 1.14
diff -w -u -r1.14 mi-console.exp
--- gdb/testsuite/gdb.mi/mi-console.exp	27 Apr 2005 16:35:15 -0000	1.14
+++ gdb/testsuite/gdb.mi/mi-console.exp	27 Jul 2005 03:06:25 -0000
@@ -36,7 +36,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
@@ -54,37 +54,10 @@
 mi_run_to_main
 
 # Next over the hello() call which will produce lots of output
-send_gdb "47-exec-next\n"
-gdb_expect {
-    -re "47\\^running\r\n$mi_gdb_prompt" {
-	pass "Started step over hello"
-    }
-    timeout {
-	fail "Started step over hello (timeout)"
-    }
-}
-
-if { ![target_info exists gdb,noinferiorio]}  {
-    gdb_expect {
-	-re "@\"H\"\r\n.*@\"e\"\r\n.*@\"l\"\r\n.*@\"l\"\r\n.*@\"o\"\r\n.*@\" \"\r\n.*@\"\\\\\\\\\"\r\n.*@\"\\\\\"\"\r\n.*@\"!\"\r\n.*@\"\\\\r\"\r\n.*@\"\\\\n\"\r\n" {
-	    pass "Hello message"
-	}
-	-re "Hello" {
-
-	    # Probably a native system where GDB doesn't have direct #
-	    # control over the inferior console.  # For this to work,
-	    # GDB would need to run the inferior process # under a PTY
-	    # and then use the even-loops ability to wait on #
-	    # multiple event sources to channel the output back
-	    # through the # MI.
-
-	    kfail "gdb/623" "Hello message"
-	}
-	timeout {
-	    fail "Hello message (timeout)"
-	}
-    }
-}
+mi_gdb_test "47-exec-next" \
+	    "47\\^running" \
+	    "Hello \\\\\"!\[\r\n\]+" \
+	    "Testing console output"
     
 gdb_expect {
     -re "47\\*stopped.*$mi_gdb_prompt$" {
Index: gdb/testsuite/gdb.mi/mi-disassemble.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-disassemble.exp,v
retrieving revision 1.13
diff -w -u -r1.13 mi-disassemble.exp
--- gdb/testsuite/gdb.mi/mi-disassemble.exp	15 Aug 2004 10:15:58 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-disassemble.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-eval.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-eval.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-eval.exp
--- gdb/testsuite/gdb.mi/mi-eval.exp	15 Aug 2004 10:15:58 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-eval.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-file.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-file.exp,v
retrieving revision 1.5
diff -w -u -r1.5 mi-file.exp
--- gdb/testsuite/gdb.mi/mi-file.exp	8 May 2005 13:42:03 -0000	1.5
+++ gdb/testsuite/gdb.mi/mi-file.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-hack-cli.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-hack-cli.exp,v
retrieving revision 1.6
diff -w -u -r1.6 mi-hack-cli.exp
--- gdb/testsuite/gdb.mi/mi-hack-cli.exp	9 Aug 2004 16:32:44 -0000	1.6
+++ gdb/testsuite/gdb.mi/mi-hack-cli.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2001 Free Software Foundation, Inc.
+# Copyright 1999, 2001, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-pthreads.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-pthreads.exp,v
retrieving revision 1.7
diff -w -u -r1.7 mi-pthreads.exp
--- gdb/testsuite/gdb.mi/mi-pthreads.exp	13 Jan 2004 17:08:03 -0000	1.7
+++ gdb/testsuite/gdb.mi/mi-pthreads.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 2002, 2003, 2004 Free Software Foundation, Inc.
+# Copyright 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -32,7 +32,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if {[mi_gdb_start]} {
+if {[mi_gdb_start true]} {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-read-memory.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-read-memory.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-read-memory.exp
--- gdb/testsuite/gdb.mi/mi-read-memory.exp	9 Aug 2004 16:32:44 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-read-memory.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -33,7 +33,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-regs.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-regs.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-regs.exp
--- gdb/testsuite/gdb.mi/mi-regs.exp	9 Aug 2004 16:32:44 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-regs.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-return.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-return.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-return.exp
--- gdb/testsuite/gdb.mi/mi-return.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-return.exp	27 Jul 2005 03:06:25 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-simplerun.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-simplerun.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-simplerun.exp
--- gdb/testsuite/gdb.mi/mi-simplerun.exp	15 Aug 2004 10:15:58 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-simplerun.exp	27 Jul 2005 03:06:25 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,7 +29,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stack.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stack.exp,v
retrieving revision 1.16
diff -w -u -r1.16 mi-stack.exp
--- gdb/testsuite/gdb.mi/mi-stack.exp	20 Jun 2005 03:38:20 -0000	1.16
+++ gdb/testsuite/gdb.mi/mi-stack.exp	27 Jul 2005 03:06:26 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-stepi.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-stepi.exp,v
retrieving revision 1.11
diff -w -u -r1.11 mi-stepi.exp
--- gdb/testsuite/gdb.mi/mi-stepi.exp	18 May 2005 03:41:59 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-stepi.exp	27 Jul 2005 03:06:26 -0000
@@ -27,7 +27,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-syn-frame.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-syn-frame.exp,v
retrieving revision 1.4
diff -w -u -r1.4 mi-syn-frame.exp
--- gdb/testsuite/gdb.mi/mi-syn-frame.exp	13 Jun 2005 02:41:51 -0000	1.4
+++ gdb/testsuite/gdb.mi/mi-syn-frame.exp	27 Jul 2005 03:06:26 -0000
@@ -38,7 +38,7 @@
 set my_mi_gdb_prompt "\\(gdb\\)\[ \]*\[\r\n\]*"
 
 mi_gdb_exit
-mi_gdb_start
+mi_gdb_start true
 mi_delete_breakpoints
 mi_gdb_reinitialize_dir $srcdir/$subdir
 mi_gdb_load ${binfile}
@@ -58,16 +58,10 @@
 #
 # Continue back to main()
 #
-
-send_gdb "403-exec-continue\n"
-gdb_expect {
-  -re "403\\^running\[\r\n\]+${my_mi_gdb_prompt}hi in foo\[\r\n\]+403\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "403-exec-continue"
-  }
-  timeout {
-    fail "403-exec-continue"
-  }
-}
+mi_gdb_test "403-exec-continue" \
+			"403\\^running\[\r\n\]+${my_mi_gdb_prompt}403\\\*stopped" \
+			"hi in foo\[\r\n\]\+" \
+			"testing exec continue"
 
 mi_gdb_test "404-stack-list-frames 0 0" "404\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]"
 
@@ -78,7 +72,11 @@
 
 mi_gdb_test "405-break-insert subroutine" "405\\^done,bkpt=\{number=\"3\",type=\"breakpoint\",disp=\"keep\",enabled=\"y\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",line=\"$decimal\",times=\"0\"\}"
 
-mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" "Waiting to get a signal\[\r\n\]+\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\""
+mi_gdb_test "406-data-evaluate-expression have_a_very_merry_interrupt()" \
+            "\\&\"The program being debugged stopped while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"When the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\n\"\[\r\n\]+\\&\"stop \\(instead of continuing to evaluate the expression containing\\\\n\"\[\r\n\]+\\&\"the function call\\).\\\\n\"\[\r\n\]+406\\^error,msg=\"The program being debugged stopped while in a function called from GDB.\\\\nWhen the function \\(have_a_very_merry_interrupt\\) is done executing, GDB will silently\\\\nstop \\(instead of continuing to evaluate the expression containing\\\\nthe function call\\).\"" \
+			"Waiting to get a signal\[\r\n\]+" \
+			"data evaluate expression"
+
 
 # We should have both a signal handler and a call dummy frame
 # in this next output.
@@ -86,15 +84,8 @@
 mi_gdb_test "407-stack-list-frames" "407\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"subroutine\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"1\",addr=\"$hex\",func=\"handler\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"<signal handler called>\"\},.*frame=\{level=\"$decimal\",addr=\"$hex\",func=\"have_a_very_merry_interrupt\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"$decimal\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]"
 
 
-send_gdb "408-exec-continue\n"
-gdb_expect {
-  -re "408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped\[\r\n\]+${my_mi_gdb_prompt}$" {
-    pass "408-exec-continue"
-  }
-  timeout {
-    fail "408-exec-continue"
-  }
-}
+mi_gdb_test "408-exec-continue" \
+			"408\\^running\[\r\n\]+${my_mi_gdb_prompt}408\\\*stopped"
 
 mi_gdb_test "409-stack-list-frames 0 0" "409\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"\}.*\\\]"
 
@@ -102,7 +93,10 @@
 # Call bar() by hand, which should get an exception while running.
 # 
 
-mi_gdb_test "410-data-evaluate-expression bar()" "hi in bar\[\r\n\]+\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" "call inferior function which raises exception"
+mi_gdb_test "410-data-evaluate-expression bar()" \
+            "\\&\"The program being debugged was signaled while in a function called from GDB.\\\\n\"\[\r\n\]+\\&\"GDB remains in the frame where the signal was received.\\\\n\"\[\r\n\]+\\&\"To change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\n\"\[\r\n\]+\\&\"Evaluation of the expression containing the function \\(bar\\) will be abandoned.\\\\n\"\[\r\n\]+410\\^error,msg=\"The program being debugged was signaled while in a function called from GDB.\\\\nGDB remains in the frame where the signal was received.\\\\nTo change this behavior use \\\\\"set unwindonsignal on\\\\\"\\\\nEvaluation of the expression containing the function \\(bar\\) will be abandoned.\"" \
+			"hi in bar\[\r\n\]+" \
+			"call inferior function which raises exception" 
 
 mi_gdb_test "411-stack-list-frames" "411\\^done,stack=\\\[frame=\{level=\"0\",addr=\"$hex\",func=\"bar\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"},frame=\{level=\"1\",addr=\"$hex\",func=\"<function called from gdb>\"\},frame=\{level=\"2\",addr=\"$hex\",func=\"main\",file=\".*mi-syn-frame.c\",fullname=\"${fullname_syntax}${srcfile}\",line=\"$decimal\"}.*\\\]" "backtrace from inferior function at exception"
 
Index: gdb/testsuite/gdb.mi/mi-until.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-until.exp,v
retrieving revision 1.9
diff -w -u -r1.9 mi-until.exp
--- gdb/testsuite/gdb.mi/mi-until.exp	18 May 2005 03:41:59 -0000	1.9
+++ gdb/testsuite/gdb.mi/mi-until.exp	27 Jul 2005 03:06:26 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-block.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-block.exp,v
retrieving revision 1.11
diff -w -u -r1.11 mi-var-block.exp
--- gdb/testsuite/gdb.mi/mi-var-block.exp	17 Aug 2004 09:38:29 -0000	1.11
+++ gdb/testsuite/gdb.mi/mi-var-block.exp	27 Jul 2005 03:06:26 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation, Inc.
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation, Inc.
 #
 # This Program Is Free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-child.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-child.exp,v
retrieving revision 1.17
diff -w -u -r1.17 mi-var-child.exp
--- gdb/testsuite/gdb.mi/mi-var-child.exp	17 Aug 2004 09:38:29 -0000	1.17
+++ gdb/testsuite/gdb.mi/mi-var-child.exp	27 Jul 2005 03:06:26 -0000
@@ -1,4 +1,4 @@
-# Copyright 1999, 2000, 2001, 2002, 2004 Free Software Foundation
+# Copyright 1999, 2000, 2001, 2002, 2004, 2005 Free Software Foundation
 
 # This Program Is Free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -24,7 +24,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-cmd.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-cmd.exp,v
retrieving revision 1.18
diff -w -u -r1.18 mi-var-cmd.exp
--- gdb/testsuite/gdb.mi/mi-var-cmd.exp	14 Jan 2005 18:17:19 -0000	1.18
+++ gdb/testsuite/gdb.mi/mi-var-cmd.exp	27 Jul 2005 03:06:26 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-var-display.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-var-display.exp,v
retrieving revision 1.13
diff -w -u -r1.13 mi-var-display.exp
--- gdb/testsuite/gdb.mi/mi-var-display.exp	18 May 2005 03:41:59 -0000	1.13
+++ gdb/testsuite/gdb.mi/mi-var-display.exp	27 Jul 2005 03:06:26 -0000
@@ -25,7 +25,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/gdb.mi/mi-watch.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.mi/mi-watch.exp,v
retrieving revision 1.12
diff -w -u -r1.12 mi-watch.exp
--- gdb/testsuite/gdb.mi/mi-watch.exp	18 May 2005 03:41:59 -0000	1.12
+++ gdb/testsuite/gdb.mi/mi-watch.exp	27 Jul 2005 03:06:26 -0000
@@ -30,7 +30,7 @@
 set MIFLAGS "-i=mi"
 
 gdb_exit
-if [mi_gdb_start] {
+if [mi_gdb_start true] {
     continue
 }
 
Index: gdb/testsuite/lib/mi-support.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/lib/mi-support.exp,v
retrieving revision 1.27
diff -w -u -r1.27 mi-support.exp
--- gdb/testsuite/lib/mi-support.exp	18 May 2005 03:41:59 -0000	1.27
+++ gdb/testsuite/lib/mi-support.exp	27 Jul 2005 03:06:26 -0000
@@ -28,6 +28,9 @@
     set mi_gdb_prompt "\[(\]gdb\[)\] \r\n"
 }
 
+global mi_inferior_spawn_id
+global mi_inferior_tty_name
+
 set MIFLAGS "-i=mi"
 
 #
@@ -81,13 +84,16 @@
 }
 
 #
-# start gdb -- start gdb running, default procedure
+# start gdb INFERIOR_PTY -- start gdb running, default procedure
+#
+# INFERIOR_PTY should be set to TRUE to have the inferior work with it's
+# own PTY. If set to FALSE, the inferior shares GDB's PTY.
 #
 # When running over NFS, particularly if running many simultaneous
 # tests on different hosts all using the same server, things can
 # get really slow.  Give gdb at least 3 minutes to start up.
 #
-proc mi_gdb_start { } {
+proc mi_gdb_start { args } {
     global verbose
     global GDB
     global GDBFLAGS
@@ -99,6 +105,10 @@
 
     gdb_stop_suppressing_tests;
 
+    if { [llength $args] == 1} {
+	set inferior_pty [lindex $args 0]
+    }
+
     # Start SID.
     if { [info procs sid_start] != "" } {
 	verbose "Spawning SID"
@@ -117,6 +127,16 @@
 	    exit 1
 	}
     }
+
+    # spawn off the new pty for the inferior process
+    if { [ info exists inferior_pty ] } {
+	spawn -pty
+	global mi_inferior_spawn_id
+	global mi_inferior_tty_name
+	set mi_inferior_spawn_id $spawn_id
+	set mi_inferior_tty_name $spawn_out(slave,name)
+    }
+
     set res [remote_spawn host "$GDB -nw $GDBFLAGS $MIFLAGS [host_info gdb_opts]"];
     if { $res < 0 || $res == "" } {
 	perror "Spawning $GDB failed."
@@ -189,6 +209,19 @@
 	    warning "Couldn't set the width to 0."
 	}
     }
+    # If allowing the inferior to have it's own PTY then assign the inferior
+    # it's own terminal device here
+    if { [ info exists inferior_pty ] } {
+	send_gdb "102-inferior-tty-set $mi_inferior_tty_name\n"
+	gdb_expect 10 {
+	    -re ".*102\\\^done\r\n$mi_gdb_prompt$" {
+		verbose "redirect inferior output to new terminal device."
+	    }
+	    timeout {
+	    	warning "Couldn't redirect inferior output." 2
+	    }
+    	}
+    }
 
     return 0;
 }
@@ -511,12 +544,14 @@
     return 0
 }
 
-# mi_gdb_test COMMAND PATTERN MESSAGE -- send a command to gdb; test the result.
+# mi_gdb_test COMMAND PATTERN IPATTERN MESSAGE -- send a command to gdb; test the result.
 #
 # COMMAND is the command to execute, send to GDB with send_gdb.  If
 #   this is the null string no command is sent.
 # PATTERN is the pattern to match for a PASS, and must NOT include
 #   the \r\n sequence immediately before the gdb prompt.
+# IPATTERN is the pattern to match for the inferior's output. This will not 
+#   produce a PASS if successfull, but will produce a FAIL if unsuccessful.
 # MESSAGE is an optional message to be printed.  If this is
 #   omitted, then the pass/fail messages use the command string as the
 #   message.  (If this is the empty string, then sometimes we don't
@@ -533,14 +568,20 @@
     global GDB expect_out
     upvar timeout timeout
 
-    if [llength $args]>2 then {
+    if { [llength $args] == 3} {
 	set message [lindex $args 2]
+    } elseif {[llength $args] == 4 } {
+	set message [lindex $args 3]
     } else {
 	set message [lindex $args 0]
     }
     set command [lindex $args 0]
     set pattern [lindex $args 1]
 
+    if [llength $args]==4 {
+	set ipattern [lindex $args 2]
+    }
+
     if [llength $args]==5 {
 	set question_string [lindex $args 3];
 	set response_string [lindex $args 4];
@@ -691,6 +732,23 @@
 	    set result 1
 	}
     }
+
+    # if the GDB output matched, compare the inferior output
+    if { $result == 0 } {
+	if [ info exists ipattern ] {
+	    global mi_inferior_spawn_id
+	    expect {
+		-i $mi_inferior_spawn_id -re "$ipattern" {
+		    pass "inferior_output:$message"
+		}
+		timeout {
+		    fail "inferior output timeout"
+		    set result 1
+		}
+	    }
+        }
+    }
+
     return $result
 }
 


^ permalink raw reply	[flat|nested] 62+ messages in thread

end of thread, other threads:[~2005-09-10  4:02 UTC | newest]

Thread overview: 62+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-30  5:54 MI testsuite to use PTY for inferior Nick Roberts
2005-07-30 17:39 ` Bob Rossi
2005-07-30 18:08   ` Daniel Jacobowitz
2005-07-30 22:47     ` Nick Roberts
2005-07-31  1:19       ` Daniel Jacobowitz
2005-07-30 22:47   ` Nick Roberts
2005-07-30 23:03     ` Bob Rossi
2005-07-31  1:21       ` Daniel Jacobowitz
2005-07-31 13:16         ` Bob Rossi
2005-07-31 15:31           ` Daniel Jacobowitz
2005-07-31 21:20             ` Bob Rossi
2005-08-01  1:53               ` Daniel Jacobowitz
2005-08-01  2:05                 ` Bob Rossi
2005-08-01  2:15                   ` Daniel Jacobowitz
2005-08-01 11:32                     ` Bob Rossi
2005-08-01  3:56               ` Eli Zaretskii
2005-08-01 11:30                 ` Bob Rossi
2005-08-01 13:00                   ` Daniel Jacobowitz
2005-08-01 13:16                     ` Bob Rossi
2005-08-01 13:23                       ` Daniel Jacobowitz
2005-08-01 13:31                         ` Bob Rossi
2005-08-01 14:00                           ` Daniel Jacobowitz
2005-08-01 14:07                             ` Bob Rossi
2005-08-01 18:45                   ` Eli Zaretskii
2005-08-01 19:01                     ` Mark Kettenis
2005-08-01 19:25                       ` Daniel Jacobowitz
2005-08-01 19:34                         ` Mark Kettenis
2005-08-01 19:43                           ` Bob Rossi
2005-08-01 20:48                         ` Eli Zaretskii
2005-08-01 20:45                       ` Eli Zaretskii
2005-08-01 20:52                         ` Daniel Jacobowitz
2005-08-02  3:45                           ` Eli Zaretskii
2005-08-02  3:50                             ` Daniel Jacobowitz
2005-08-02 20:46                               ` Eli Zaretskii
2005-08-02 20:48                                 ` Daniel Jacobowitz
2005-08-13 17:26                                   ` Bob Rossi
2005-08-13 21:41                                     ` Daniel Jacobowitz
2005-07-31 21:35           ` Nick Roberts
2005-07-31 21:37             ` Daniel Jacobowitz
2005-07-31 23:32               ` Nick Roberts
2005-08-01  1:51                 ` Daniel Jacobowitz
2005-08-03  2:07         ` Bob Rossi
2005-08-03 12:48           ` Bob Rossi
2005-08-03 13:19           ` Daniel Jacobowitz
2005-08-03 18:22             ` Bob Rossi
2005-08-03 18:23               ` Daniel Jacobowitz
2005-08-03 18:24               ` Bob Rossi
2005-08-03 18:32                 ` Daniel Jacobowitz
2005-08-03 19:31                   ` Bob Rossi
2005-08-04  2:23                     ` Bob Rossi
2005-08-04  2:27                       ` Bob Rossi
2005-08-04  4:05                         ` Daniel Jacobowitz
2005-08-04 13:07                           ` Bob Rossi
  -- strict thread matches above, loose matches on Subject: below --
2005-07-27  3:18 Bob Rossi
2005-08-13 22:04 ` Mark Kettenis
2005-08-20  9:07   ` Bob Rossi
2005-08-30  2:55     ` Daniel Jacobowitz
2005-09-01  0:52       ` Bob Rossi
2005-09-01 22:12         ` Mark Kettenis
2005-09-01 23:52           ` Bob Rossi
2005-09-05 19:52           ` Bob Rossi
2005-09-10  4:02             ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox