This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA: patch to fix gdb/1680
- From: Jim Ingham <jingham at apple dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Sun, 20 Jun 2004 15:37:13 -0700
- Subject: Re: RFA: patch to fix gdb/1680
- References: <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