This is the mail archive of the 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: RFC: gdb_test_multiple

On Sun, Jan 05, 2003 at 10:53:57AM -0600, Michael Elizabeth Chastain wrote:
> Hi Daniel,
> > This isn't a style thing, though.  Let me point out the actual
> > syntactic difference between the two above: the strings are
> > expanded/substituted at the time of the call to gdb_test_multiple
> > instead of at the time of the actual expect {}, down the call chain.
> I don't understand.  Are you saying that:
>   set msg "breakpoint on Foo::Bar"
>   gdb_test_multiple "break Foo::Bar" $msg {
>     -re "foo" {
>       ... fail $msg ...
>     }
>   }
> requires something gross in gdb_test_multiple in order to work?

No, but this similar construct:

   set teststr "foo"
   gdb_test_multiple "break Foo::Bar" $msg {
     -re "$teststr" {
       ... fail $msg ...

does.  And that idiom is all over the testsuite, for readability
purposes; see $hex, etc.

> I guess my question is: when does the "$msg" in "fail $msg" get
> expanded.  If the caller expands it before calling gdb_test_multiple
> then I don't see the problem.  If the caller passes "{ ... fail $msg ... }"
> without expanding $msg then I do see the problem.

{ } quoting in TCL completely disables expansion.  Variables inside a
"proc name { args } { vars $here } are not expanded until the procedure
is called; similarly for the {} construct above.

If you think about it, this is logical.  Consider
$expect_out(0,string), which is based on the regular expression match.
Its value isn't known when gdb_test_multiple is called, so it can't be
expanded until after the matching is done.

Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer

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