This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I get regexp from expect at gdb_expect?


On Mon, Jan 31, 2005 at 04:10:42PM -0500, Bob Rossi wrote:
> > You've left out your pattern, and the context.  I recommend using
> > "exp_internal 1" to debug this sort of problem; that will show you what
> > expect is doing.
> 
> OK, here's an example of the problem, here's the output for 2
> consecutive commands given to GDB. 
> 
> First, 200-break-delete is sent. The '200-break-delete' is in the
> 'expect_out(buffer)' output, which leads me to believe the testsuite is 
> echoing the input command. This in itself is probably wrong. However, the
> '200-break-delete' is not in the matched regular expression
> 'expect_out(0,string)'. 

  expect: does "200-break-delete\r\n200^done\r\n(gdb) \r\n" (spawn_id exp11) match regular expression "\*\*\* DOSEXIT code.*"? no

  "([\r\n]*((\^done)[\r\n]+[(]gdb[)] \r\n[ ]*$))"? yes

It's not in your $expect_out(0,string) because it didn't match your
first parenthesized bit.  It's in expect_out(buffer) at this point.

> The next command, '200-break-list' is in both the 'expect_out(buffer)'
> and in the 'expect_out(0,string)'. This leads me to believe that there
> is something wrong with the regular expression matching. It can match
> things that it shouldn't, which could mask problems.
> 
> I don't really understand what you are saying about 'GDB is echoing
> commands'. I do understand that when you are at the terminal running
> GDB, GDB allows the terminal to 'echo' the char's typed. However, if you
> fork/exec GDB, and send it a command, it will not 'echo' the data back
> to your process. Isn't this the way Expect works?

Expect works on a terminal.  It's not instrumenting GDB to find out
what GDB is writing; it's accepting whatever input comes to its side of
the terminal.  Which includes things echoed by the terminal.  In
readline mode GDB turns off echo and provides the echo manually; in MI
mode, it does not touch the terminal, which echoes by default.

It's just your patterns that are producing a difference.

-- 
Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]