Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jim Ingham <jingham@apple.com>
To: gdb-patches@sources.redhat.com
Subject: Re: RFA: patch to fix gdb/1680
Date: Sun, 20 Jun 2004 22:37:00 -0000	[thread overview]
Message-ID: <602841F8-C30A-11D8-9047-00039379E320@apple.com> (raw)
In-Reply-To: <1087626323.4926.ezmlm@sources.redhat.com>

Note, this duplication of the regexp engine is what I wrote about a 
couple of weeks ago when removing expect first came up...

In order not to have to change the Testsuites when Ian imported Tcl  
8.4 into the sourceware repository, he took an old copy of Tcl's regexp 
engine & stuffed it into expect.  This is not the way things work in 
the real versions of Tcl & Expect, needless to say.

The ChangeLog entry was:

2001-07-09  Ian Roxborough  <irox@redhat.com>

         * tclParse-compat.c: New file.
         * tcl_regexp.c:
         * tcl_regexp.h: New file.  Contains Tcl8.0's regexp.
         * Makefile.in: Added new files to be compiled and linked.
         * exp_clib.c (exp_expectl, exp_fexpectl):
         * exp_inter.c (in_keymap, Exp_InteractCmd ):
         * exp_regexp.c (regtry, regdump, regprop):
         * expect.c (parse_expect_args, eval_case_string,
           exp_background_filehandler, Exp_ExpectCmd):
         * expect.h:
         * expect_comm.h:
         * Dbg.c (breakpoint_test, cmdBreak): Use newly built in
           regexp, not external Tcl regexp.
         * exp_tty.c (exec_stty):
         * exp_command.c (Exp_CloseCmd, Tcl_CloseCmd): Handle Tcl API
           changes in Tcl8.3.

If you are going to use the net Tcl & Expect, you won't be able to do 
this hack, and are going to have to change the testsuite instead, as 
this thread is pointing out...

BTW, the regexp man page in the Tcl distro is quite exhaustive, for 
instance:

http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm

This is a good reference for the 8.3 & above regexp syntax.

Note, also, if you don't need to substitute in variables, then it is 
MUCH easier to write the regexp expressions with {} around them that 
using "'s - since you don't have to worry about backslashing everything 
in sight...

And if you have a gnarly regexp you are trying to write that does need 
variables substituted, it can be easier to use the format command:

   foreach r {0 1 2 3 4 5 6 7} {
       set result_regex [format {.. = {%d, %d.25, %d.5, %d.75}.*} $r $r 
$r $r]
       gdb_test "print \$xmm$r.v4_float" \
          $result_regex \
           "check contents of %xmm$r"
   }

or if there are enough instances of one substituted value that it gets 
tedious to do the format, you can do:

   foreach r {0 1 2 3 4 5 6 7} {
       regsub -all {.. = {VAR, VAR.25, VAR.5, VAR.75}.*} VAR $r 
result_regexp
       gdb_test "print \$xmm$r.v4_float" \
          $result_regex \
           "check contents of %xmm$r"
   }

As I said, in this case the expression is pretty simple so the 
backslashing is not so onerous, but if you are doing something complex, 
either of these tricks can make the code much more readable...

Finally, note that if you need to see the result regexp as it ACTUALLY 
gets to dejagnu, pass the --debug flag in RUNTESTFLAGS, and it will 
spit out a file named dbg.log in build/gdb/testsuite which shows among 
much other stuff the actual regexp that dejagnu is trying to match.

Jim

On Jun 18, 2004, at 11:25 PM, Michael Elizabeth Chastain wrote:

> The problem is not with tcl, but with expect.
>
> I built two stacks of tcl+expect+dejagnu:
>
>   'released stack' -- all the packages from their ftp sites.
>   This is what I normally use.
>
>   'sourceware stack' -- the versions from sourceware.
>   This is what Jim B normally uses.
>
> Here is a version table:
>
> 	    released  sourceware
>   tcl       8.4.6     8.4.1 (nearly)
>   expect    5.41      5.26 + patches, dated 1998-06-15
>   dejagnu   1.4.4     1.4.3 (nearly)
>
> Both TCL and Expect have their own copies of the Henry Spencer regular
> expression code ("HSREC" for short).  You can see this coming: 
> "re-usable
> code re-used to hell".
>
>
_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
Jim Ingham                                                           
jingham@apple.com
Developer Tools - gdb


       reply	other threads:[~2004-06-20 22:37 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1087626323.4926.ezmlm@sources.redhat.com>
2004-06-20 22:37 ` Jim Ingham [this message]
2004-06-21  2:44 Michael Elizabeth Chastain
  -- strict thread matches above, loose matches on Subject: below --
2004-06-19  6:31 Michael Elizabeth Chastain
2004-06-21  5:00 ` Jim Blandy
2004-06-19  2:44 Michael Elizabeth Chastain
2004-06-19  6:25 ` Joel Brobecker
2004-06-18 23:38 Michael Elizabeth Chastain
2004-06-18 20:25 Michael Elizabeth Chastain
2004-06-18 20:33 ` Daniel Jacobowitz
2004-06-18 19:43 Michael Elizabeth Chastain
2004-06-18 19:18 Michael Elizabeth Chastain
2004-06-18 19:35 ` Andrew Cagney
2004-06-18 19:42 ` Daniel Jacobowitz
2004-06-18 19:56   ` Andrew Cagney
2004-06-18 20:00     ` Daniel Jacobowitz
2004-06-18 22:20   ` Jim Blandy
2004-06-18 22:51     ` Andreas Schwab
2004-06-19  6:15       ` Jim Blandy
2004-06-18 18:25 Michael Elizabeth Chastain
2004-06-18 18:10 Jim Blandy
2004-06-18 18:42 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=602841F8-C30A-11D8-9047-00039379E320@apple.com \
    --to=jingham@apple.com \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox