* [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
@ 2001-10-18 22:52 Keith Seitz
2001-10-19 8:28 ` Andrew Cagney
2001-10-19 12:36 ` Michael Snyder
0 siblings, 2 replies; 8+ messages in thread
From: Keith Seitz @ 2001-10-18 22:52 UTC (permalink / raw)
To: gdb-patches
Hi,
I will be submitting some additional tests to ref-types.exp in the next
day or so, and I thought that it would be nice to clean up ref-types.exp a
little beforehand.
The following "patch" (which is bigger than the file) uses gdb_test and
gdb_test_exact when appropriate, and it cleans up some common tcl "errors"
(not really syntax errors, but common syntax usages which are, umm,
offensive).
I think this is much easier to read than the "normal" things that are done
in the testsuite.
I have only tested this on linux native and solaris native. If more are
required, just name them.
What do others think?
Keith
ChangeLog
2001-10-18 Keith Seitz <keiths@redhat.com>
* gdb.c++/ref-types.exp: Cleanup.
Use gdb_test and gdb_test_exact where appropriate.
Insert braces around expressions, whack the "then" from
"if" statements and other tcl-style nicities (which also
speed up the execution of the code).
Rewrite regular expressions to avoid escaping and re-escaping
regexps because of gdb_test whackiness.
Update copyright.
Patch
Index: ref-types.exp
===================================================================
RCS file: /cvs/src/src/gdb/testsuite/gdb.c++/ref-types.exp,v
retrieving revision 1.5
diff -u -p -r1.5 ref-types.exp
--- ref-types.exp 2001/03/16 17:59:58 1.5
+++ ref-types.exp 2001/10/19 03:51:58
@@ -1,5 +1,5 @@
# Tests for reference types with short type variables in GDB.
-# Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+# Copyright 1998, 1999, 2000, 2001 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
@@ -20,9 +20,10 @@
# written by Elena Zannoni (ezannoni@cygnus.com)
-if $tracelevel then {
- strace $tracelevel
- }
+if {$tracelevel} {
+ strace $tracelevel
+}
+
#
# test running programs
@@ -49,12 +50,12 @@ gdb_load ${binfile}
#
# set it up at a breakpoint so we can play with the variable values
#
-if ![runto_main] then {
+if {![runto_main]} {
perror "couldn't run to breakpoint"
continue
}
-if ![runto 'marker1'] then {
+if {![runto "marker1"]} {
perror "couldn't run to marker1"
continue
}
@@ -77,12 +78,12 @@ proc gdb_start_again {} {
#
# set it up at a breakpoint so we can play with the variable values
#
- if ![runto_main] then {
+ if {![runto_main]} {
perror "couldn't run to breakpoint"
continue
}
- if ![runto 'marker1'] then {
+ if {![runto "marker1"]} {
perror "couldn't run to marker1"
continue
}
@@ -90,574 +91,164 @@ proc gdb_start_again {} {
gdb_test "up" ".*main.*" "up from marker1 2"
}
-
-
-send_gdb "print s\n"
-gdb_expect {
- -re ".\[0-9\]* = -1.*$gdb_prompt $" {
- pass "print value of s"
- }
- -re ".*$gdb_prompt $" { fail "print value of s" }
- timeout { fail "(timeout) print value of s" }
- }
-
-
-send_gdb "ptype s\n"
-gdb_expect {
- -re "type = short.*$gdb_prompt $" { pass "ptype s" }
- -re ".*$gdb_prompt $" { fail "ptype s" }
- timeout { fail "(timeout) ptype s" }
-}
+gdb_test {print s} {.[0-9]* = -1} {print value of s}
-send_gdb "print *ps\n"
-gdb_expect {
- -re ".\[0-9\]* = -1.*$gdb_prompt $" {
- pass "print value of ps"
- }
- -re ".*$gdb_prompt $" { fail "print value of ps" }
- timeout { fail "(timeout) print value of ps" }
- }
+gdb_test {ptype s} {type = short (int)?} {ptype s}
+gdb_test {print *ps} {.[0-9]* = -1} {print value of ps}
-send_gdb "ptype ps\n"
-gdb_expect {
- -re "type = short \*.*$gdb_prompt $" { pass "ptype ps" }
- -re ".*$gdb_prompt $" { fail "ptype ps" }
- timeout { fail "(timeout) ptype ps" }
-}
+gdb_test {ptype ps} {type = short (int)? \*} {ptype ps}
-send_gdb "print as\[0\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 0.*$gdb_prompt $" {
- pass "print value of as\[0\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of as\[0\]" }
- timeout { fail "(timeout) print value of as\[0\]" }
- }
+gdb_test {print as[0]} {.[0-9]* = 0} {print value of as[0]}
+gdb_test {ptype as} {type = short (int)? \[4\]} {ptype as}
-send_gdb "ptype as\n"
-gdb_expect {
- -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
- -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
- -re ".*$gdb_prompt $" { fail "ptype as" }
- timeout { fail "(timeout) ptype as" }
-}
+gdb_test {print as[1]} {.[0-9]* = 1} {print value of as[1]}
-send_gdb "print as\[1\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 1.*$gdb_prompt $" {
- pass "print value of as\[1\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of as\[1\]" }
- timeout { fail "(timeout) print value of as\[1\]" }
- }
+gdb_test {print as[2]} {.[0-9]* = 2} {print value of as[2]}
-send_gdb "print as\[2\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 2.*$gdb_prompt $" {
- pass "print value of as\[2\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of as\[2\]" }
- timeout { fail "(timeout) print value of as\[2\]" }
- }
+gdb_test {print as[3]} {.[0-9]* = 3} {print value of as[3]}
-send_gdb "print as\[3\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 3.*$gdb_prompt $" {
- pass "print value of as\[3\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of as\[3\]" }
- timeout { fail "(timeout) print value of as\[3\]" }
- }
-
+set pattern {.[0-9]* = \(short (int)? &\) @}
+append pattern "$hex: -1"
send_gdb "print rs\n"
gdb_expect {
- -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
- pass "print value of rs"
- }
- -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
- pass "print value of rs"
- }
- -re ".*$gdb_prompt $" { fail "print value of rs" }
- timeout { fail "(timeout) print value of rs" }
- eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
-
+ -re $pattern {
+ pass "print value of rs"
}
-
-send_gdb "ptype rs\n"
-gdb_expect {
- -re "type = short &.*$gdb_prompt $" { pass "ptype rs" }
- -re "type = short int &.*$gdb_prompt $" { pass "ptype rs" }
- -re ".*$gdb_prompt $" { fail "ptype rs" }
- timeout { fail "(timeout) ptype rs" }
+ -re ".*$gdb_prompt $" { fail "print value of rs" }
+ timeout { fail "(timeout) print value of rs" }
+ eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
}
+gdb_test {ptype rs} {type = short (int)? &} {ptype rs}
-send_gdb "print *rps\n"
-gdb_expect {
- -re ".\[0-9\]* = -1.*$gdb_prompt $" {
- pass "print value of *rps"
- }
- -re ".*$gdb_prompt $" { fail "print value of *rps" }
- timeout { fail "(timeout) print value of *rps" }
- }
+gdb_test {print *rps} {.[0-9]* = -1} {print value of *rps}
+gdb_test {ptype rps} {type = short (int)? \*&} {ptype rps}
-send_gdb "ptype rps\n"
-gdb_expect {
- -re "type = short \\*&.*$gdb_prompt $" { pass "ptype rps" }
- -re "type = short int \\*&.*$gdb_prompt $" { pass "ptype rps" }
- -re ".*$gdb_prompt $" { fail "ptype rps" }
- timeout { fail "(timeout) ptype rps" }
-}
+gdb_test {print ras[0]} {.[0-9]* = 0} {print value of ras[0]}
+gdb_test {ptype ras} {type = short (int)? \(&\)\[4\]} {ptype ras}
+gdb_test {print ras[1]} {.[0-9]* = 1} {print value of ras[1]}
-send_gdb "print ras\[0\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 0.*$gdb_prompt $" {
- pass "print value of ras\[0\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of ras\[0\]" }
- timeout { fail "(timeout) print value of ras\[0\]" }
- }
+gdb_test {print ras[2]} {.[0-9]* = 2} {print value of ras[2]}
-
-send_gdb "ptype ras\n"
-gdb_expect {
- -re "type = short \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
- -re "type = short int \\\(&\\\)\\\[4\\\].*$gdb_prompt $" { pass "ptype ras" }
- -re ".*$gdb_prompt $" { fail "ptype ras" }
- timeout { fail "(timeout) ptype ras" }
-}
-
-send_gdb "print ras\[1\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 1.*$gdb_prompt $" {
- pass "print value of ras\[1\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of ras\[1\]" }
- timeout { fail "(timeout) print value of ras\[1\]" }
- }
-
-send_gdb "print ras\[2\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 2.*$gdb_prompt $" {
- pass "print value of ras\[2\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of ras\[2\]" }
- timeout { fail "(timeout) print value of ras\[2\]" }
- }
-
-send_gdb "print ras\[3\]\n"
-gdb_expect {
- -re ".\[0-9\]* = 3.*$gdb_prompt $" {
- pass "print value of ras\[3\]"
- }
- -re ".*$gdb_prompt $" { fail "print value of ras\[3\]" }
- timeout { fail "(timeout) print value of ras\[3\]" }
- }
+gdb_test {print ras[3]} {.[0-9]* = 3} {print value of ras[3]}
-if ![runto 'f'] then {
+if {![runto "f"]} {
perror "couldn't run to f"
continue
}
gdb_test "up" ".main2.*" "up from f"
-
-send_gdb "print C\n"
-gdb_expect {
- -re ".\[0-9\]* = 65 \'A\'.*$gdb_prompt $" {
- pass "print value of C"
- }
- -re ".*$gdb_prompt $" { fail "print value of C" }
- timeout { fail "(timeout) print value of C" }
- }
+gdb_test {print C} {.[0-9]* = 65 'A'} {print value of C}
-send_gdb "ptype C\n"
-gdb_expect {
- -re "type = char.*$gdb_prompt $" { pass "ptype C" }
- -re ".*$gdb_prompt $" { fail "ptype C" }
- timeout { fail "(timeout) ptype C" }
-}
+gdb_test_exact {ptype C} {type = char} {ptype C}
+gdb_test {print UC} {.[0-9]* = 21 '\\025'} {print value of UC}
-send_gdb "print UC\n"
-gdb_expect {
- -re ".\[0-9\]* = 21 '\.025'\.*$gdb_prompt $" {
- pass "print value of UC"
- }
- -re ".*$gdb_prompt $" { fail "print value of UC" }
- timeout { fail "(timeout) print value of UC" }
- }
+gdb_test_exact {ptype UC} {type = unsigned char} {ptype UC}
+gdb_test {print S} {.[0-9]* = -14} {print value of S}
-send_gdb "ptype UC\n"
-gdb_expect {
- -re "type = unsigned char.*$gdb_prompt $" { pass "ptype UC" }
- -re ".*$gdb_prompt $" { fail "ptype UC" }
- timeout { fail "(timeout) ptype UC" }
-}
+gdb_test {ptype S} {type = short (int)?} {ptype S}
+gdb_test {print US} {.[0-9]* = 7} {print value of US}
-send_gdb "print S\n"
-gdb_expect {
- -re ".\[0-9\]* = -14.*$gdb_prompt $" {
- pass "print value of S"
- }
- -re ".*$gdb_prompt $" { fail "print value of S" }
- timeout { fail "(timeout) print value of S" }
- }
+gdb_test {ptype US} {type = (unsigned short (int)?|short unsigned (int)?)} {ptype US}
+gdb_test {print I} {.[0-9]* = 102} {print value of I}
-send_gdb "ptype S\n"
-gdb_expect {
- -re "type = short.*$gdb_prompt $" { pass "ptype S" }
- -re ".*$gdb_prompt $" { fail "ptype S" }
- timeout { fail "(timeout) ptype S" }
-}
+gdb_test_exact {ptype I} {type = int} {ptype I}
+gdb_test {print UI} {.[0-9]* = 1002} {print value of UI}
-send_gdb "print US\n"
-gdb_expect {
- -re ".\[0-9\]* = 7.*$gdb_prompt $" {
- pass "print value of US"
- }
- -re ".*$gdb_prompt $" { fail "print value of US" }
- timeout { fail "(timeout) print value of US" }
- }
+gdb_test_exact {ptype UI} {type = unsigned int} {ptype UI}
+gdb_test {print L} {.[0-9]* = -234} {print value of L}
-send_gdb "ptype US\n"
-gdb_expect {
- -re "type = unsigned short.*$gdb_prompt $" { pass "ptype US" }
- -re "type = short unsigned.*$gdb_prompt $" { pass "ptype US" }
- -re ".*$gdb_prompt $" { fail "ptype US" }
- timeout { fail "(timeout) ptype US" }
-}
+gdb_test {ptype L} {type = long (int)?} {ptype L}
+gdb_test {print UL} {.[0-9]* = 234} {print value of UL}
-send_gdb "print I\n"
-gdb_expect {
- -re ".\[0-9\]* = 102.*$gdb_prompt $" {
- pass "print value of I"
- }
- -re ".*$gdb_prompt $" { fail "print value of I" }
- timeout { fail "(timeout) print value of I" }
- }
+gdb_test {ptype UL} {type = (unsigned long (int)?|long unsigned (int)?)} {ptype UL}
+gdb_test {print F} {.[0-9]* = 1.2[0-9]*e\+10} {print value of F}
-send_gdb "ptype I\n"
-gdb_expect {
- -re "type = int.*$gdb_prompt $" { pass "ptype I" }
- -re ".*$gdb_prompt $" { fail "ptype I" }
- timeout { fail "(timeout) ptype I" }
-}
+gdb_test_exact {ptype F} {type = float} {ptype F}
+gdb_test {print D} {.[0-9]* = -1.375e-123} {print value of D}
-send_gdb "print UI\n"
-gdb_expect {
- -re ".\[0-9\]* = 1002.*$gdb_prompt $" {
- pass "print value of UI"
- }
- -re ".*$gdb_prompt $" { fail "print value of UI" }
- timeout { fail "(timeout) print value of UI" }
- }
+gdb_test_exact {ptype D} {type = double} {ptype D}
-send_gdb "ptype UI\n"
-gdb_expect {
- -re "type = unsigned int.*$gdb_prompt $" { pass "ptype UI" }
- -re ".*$gdb_prompt $" { fail "ptype UI" }
- timeout { fail "(timeout) ptype UI" }
-}
-
-
-send_gdb "print L\n"
-gdb_expect {
- -re ".\[0-9\]* = -234.*$gdb_prompt $" {
- pass "print value of L"
- }
- -re ".*$gdb_prompt $" { fail "print value of L" }
- timeout { fail "(timeout) print value of L" }
- }
-
-
-send_gdb "ptype L\n"
-gdb_expect {
- -re "type = long.*$gdb_prompt $" { pass "ptype L" }
- -re ".*$gdb_prompt $" { fail "ptype L" }
- timeout { fail "(timeout) ptype L" }
-}
-
-
-send_gdb "print UL\n"
-gdb_expect {
- -re ".\[0-9\]* = 234.*$gdb_prompt $" {
- pass "print value of UL"
- }
- -re ".*$gdb_prompt $" { fail "print value of UL" }
- timeout { fail "(timeout) print value of UL" }
- }
-
-
-send_gdb "ptype UL\n"
-gdb_expect {
- -re "type = unsigned long.*$gdb_prompt $" { pass "ptype UL" }
- -re "type = long unsigned.*$gdb_prompt $" { pass "ptype UL" }
- -re ".*$gdb_prompt $" { fail "ptype UL" }
- timeout { fail "(timeout) ptype UL" }
-}
-
-
-send_gdb "print F\n"
-gdb_expect {
- -re ".\[0-9\]* = 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
- pass "print value of F"
- }
- -re ".*$gdb_prompt $" { fail "print value of F" }
- timeout { fail "(timeout) print value of F" }
- }
-
-
-
-send_gdb "ptype F\n"
-gdb_expect {
- -re "type = float.*$gdb_prompt $" { pass "ptype F" }
- -re ".*$gdb_prompt $" { fail "ptype F" }
- timeout { fail "(timeout) ptype F" }
-}
-
-
-send_gdb "print D\n"
-gdb_expect {
- -re ".\[0-9\]* = -1.375e-123.*$gdb_prompt $" {
- pass "print value of D"
- }
- -re ".*$gdb_prompt $" { fail "print value of D" }
- timeout { fail "(timeout) print value of D" }
- }
-
-
-send_gdb "ptype D\n"
-gdb_expect {
- -re "type = double.*$gdb_prompt $" { pass "ptype D" }
- -re ".*$gdb_prompt $" { fail "ptype D" }
- timeout { fail "(timeout) ptype D" }
-}
-
-
-
#
# test reference types
#
+gdb_test_exact {ptype rC} {type = char &} {ptype rC}
+gdb_test_exact {ptype rUC} {type = unsigned char &} {ptype rUC}
+gdb_test {ptype rS} {type = short (int)? &} {ptype rS}
+gdb_test {ptype rUS} {type = (unsigned short (int)?|short unsigned (int)?) &} \
+ {ptype rUS}
-send_gdb "ptype rC\n"
-gdb_expect {
- -re "type = char &.*$gdb_prompt $" { pass "ptype rC" }
- -re ".*$gdb_prompt $" { fail "ptype rC" }
- timeout { fail "(timeout) ptype rC" }
-}
+gdb_test_exact {ptype rI} {type = int &} {ptype rI}
+gdb_test_exact {ptype rUI} {type = unsigned int &} {ptype rUI}
+gdb_test {ptype rL} {type = long (int)? &} {ptype rL}
+gdb_test {ptype rUL} {type = (unsigned long (int)?)|(long unsigned (int)?) &} \
+ {ptype rUL}
-send_gdb "ptype rUC\n"
-gdb_expect {
- -re "type = unsigned char &.*$gdb_prompt $" { pass "ptype rUC" }
- -re ".*$gdb_prompt $" { fail "ptype rUC" }
- timeout { fail "(timeout) ptype rUC" }
-}
+gdb_test_exact {ptype rF} {type = float &} {ptype rF}
+gdb_test_exact {ptype rD} {type = double &} {ptype rD}
+set pattern {.[0-9]* = \(char &\) @}
+append pattern "$hex: 65 'A'"
+gdb_test {print rC} $pattern {print value of rC}
-send_gdb "ptype rS\n"
-gdb_expect {
- -re "type = short &.*$gdb_prompt $" { pass "ptype rS" }
- -re "type = short int &.*$gdb_prompt $" { pass "ptype rS" }
- -re ".*$gdb_prompt $" { fail "ptype rS" }
- timeout { fail "(timeout) ptype rS" }
-}
+set pattern {.[0-9]* = \(unsigned char &\) @}
+append pattern $hex {: 21 '\\025'}
+gdb_test {print rUC} $pattern {print value of rUC}
+set pattern {.[0-9]* = \(short (int)? &\) @}
+append pattern "$hex: -14"
+gdb_test {print rS} $pattern {print value of rS}
+set pattern {.[0-9]* = \((unsigned short (int)?|short unsigned (int)?) &\) @}
+append pattern "$hex: 7"
+gdb_test {print rUS} $pattern {print value of rUS}
-send_gdb "ptype rUS\n"
-gdb_expect {
- -re "type = unsigned short &.*$gdb_prompt $" { pass "ptype rUS" }
- -re "type = short unsigned int &.*$gdb_prompt $" { pass "ptype rUS" }
- -re ".*$gdb_prompt $" { fail "ptype rUS" }
- timeout { fail "(timeout) ptype rUS" }
-}
+set pattern {.[0-9]* = \(int &\) @}
+append pattern "$hex: 102"
+gdb_test {print rI} $pattern {print value of rI}
+set pattern {.[0-9]* = \(unsigned int &\) @}
+append pattern "$hex: 1002"
+gdb_test {print rUI} $pattern {print value of UI}
-send_gdb "ptype rI\n"
-gdb_expect {
- -re "type = int &.*$gdb_prompt $" { pass "ptype rI" }
- -re ".*$gdb_prompt $" { fail "ptype rI" }
- timeout { fail "(timeout) ptype rI" }
-}
-
-
-
-send_gdb "ptype rUI\n"
-gdb_expect {
- -re "type = unsigned int &.*$gdb_prompt $" { pass "ptype rUI" }
- -re ".*$gdb_prompt $" { fail "ptype rUI" }
- timeout { fail "(timeout) ptype rUI" }
-}
+set pattern {.[1-9]* = \(long (int)? &\) @}
+append pattern "$hex: -234"
+gdb_test {print rL} $pattern "print value of rL"
+set pattern {.[0-9]* = \((unsigned long|long unsigned int) &\) @}
+append pattern "$hex: 234"
+gdb_test {print rUL} $pattern {print value of rUL}
+set pattern {.[0-9]* = \(float &\) @}
+append pattern "$hex: 1.2" {[0-9]*e\+10}
+gdb_test {print rF} $pattern {print value of rF}
-send_gdb "ptype rL\n"
-gdb_expect {
- -re "type = long &.*$gdb_prompt $" { pass "ptype rL" }
- -re "type = long int &.*$gdb_prompt $" { pass "ptype rL" }
- -re ".*$gdb_prompt $" { fail "ptype rL" }
- timeout { fail "(timeout) ptype rL" }
-}
-
-
-send_gdb "ptype rUL\n"
-gdb_expect {
- -re "type = unsigned long &.*$gdb_prompt $" { pass "ptype rUL" }
- -re "type = long unsigned int &.*$gdb_prompt $" { pass "ptype rUL" }
- -re ".*$gdb_prompt $" { fail "ptype rUL" }
- timeout { fail "(timeout) ptype rUL" }
-}
-
-
-send_gdb "ptype rF\n"
-gdb_expect {
- -re "type = float &.*$gdb_prompt $" { pass "ptype rF" }
- -re ".*$gdb_prompt $" { fail "ptype rF" }
- timeout { fail "(timeout) ptype rF" }
-}
-
-
-send_gdb "ptype rD\n"
-gdb_expect {
- -re "type = double &.*$gdb_prompt $" { pass "ptype rD" }
- -re ".*$gdb_prompt $" { fail "ptype rD" }
- timeout { fail "(timeout) ptype rD" }
-}
-
-
-send_gdb "print rC\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(char &\\) @$hex: 65 \'A\'.*$gdb_prompt $" {
- pass "print value of rC"
- }
- -re ".*$gdb_prompt $" { fail "print value of rC" }
- timeout { fail "(timeout) print value of rC" }
- }
-
-
-send_gdb "print rUC\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(unsigned char &\\) @$hex: 21 \'.025\'.*$gdb_prompt $" {
- pass "print value of rUC"
- }
- -re ".*$gdb_prompt $" { fail "print value of rUC" }
- timeout { fail "(timeout) print value of rUC" }
- }
-
-
-send_gdb "print rS\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(short &\\) @$hex: -14.*$gdb_prompt $" {
- pass "print value of rS"
- }
- -re ".\[0-9\]* = \\(short int &\\) @$hex: -14.*$gdb_prompt $" {
- pass "print value of rS"
- }
- -re ".*$gdb_prompt $" { fail "print value of rS" }
- timeout { fail "(timeout) print value of rS" }
- }
-
-
-send_gdb "print rUS\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(unsigned short &\\) @$hex: 7.*$gdb_prompt $" {
- pass "print value of rUS"
- }
- -re ".\[0-9\]* = \\(short unsigned int &\\) @$hex: 7.*$gdb_prompt $" {
- pass "print value of rUS"
- }
- -re ".*$gdb_prompt $" { fail "print value of rUS" }
- timeout { fail "(timeout) print value of rUS" }
- }
-
-
-send_gdb "print rI\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(int &\\) @$hex: 102.*$gdb_prompt $" {
- pass "print value of rI"
- }
- -re ".*$gdb_prompt $" { fail "print value of rI" }
- timeout { fail "(timeout) print value of rI" }
- }
-
-
-send_gdb "print rUI\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(unsigned int &\\) @$hex: 1002.*$gdb_prompt $" {
- pass "print value of UI"
- }
- -re ".*$gdb_prompt $" { fail "print value of rUI" }
- timeout { fail "(timeout) print value of rUI" }
- }
-
-
-send_gdb "print rL\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(long &\\) @$hex: -234.*$gdb_prompt $" {
- pass "print value of rL"
- }
- -re ".\[0-9\]* = \\(long int &\\) @$hex: -234.*$gdb_prompt $" {
- pass "print value of rL"
- }
- -re ".*$gdb_prompt $" { fail "print value of rL" }
- timeout { fail "(timeout) print value of rL" }
- }
-
-
-
-send_gdb "print rUL\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(unsigned long &\\) @$hex: 234.*$gdb_prompt $" {
- pass "print value of rUL"
- }
- -re ".\[0-9\]* = \\(long unsigned int &\\) @$hex: 234.*$gdb_prompt $" {
- pass "print value of rUL"
- }
- -re ".*$gdb_prompt $" { fail "print value of rUL" }
- timeout { fail "(timeout) print value of rUL" }
- }
-
-
-send_gdb "print rF\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(float &\\) @$hex: 1.2\[0-9\]*e\\+10.*$gdb_prompt $" {
- pass "print value of rF"
- }
- -re ".*$gdb_prompt $" { fail "print value of rF" }
- timeout { fail "(timeout) print value of rF" }
- }
-
-
-send_gdb "print rD\n"
-gdb_expect {
- -re ".\[0-9\]* = \\(double &\\) @$hex: -1.375e-123.*$gdb_prompt $" {
- pass "print value of rD"
- }
- -re ".*$gdb_prompt $" { fail "print value of rD" }
- timeout { fail "(timeout) print value of rD" }
- }
+set pattern {.[0-9]* = \(double &\) @}
+append pattern "$hex: -1.375e-123"
+gdb_test {print rD} $pattern {print value of rD}
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-18 22:52 [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup" Keith Seitz
@ 2001-10-19 8:28 ` Andrew Cagney
2001-10-19 11:29 ` Keith Seitz
2001-10-19 12:36 ` Michael Snyder
1 sibling, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2001-10-19 8:28 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
> +set pattern {.[0-9]* = \(short (int)? &\) @}
> +append pattern "$hex: -1"
Is there another way of doing this bit? I'm finding it more confusing
then all the escape characters?
enjoy,
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-19 8:28 ` Andrew Cagney
@ 2001-10-19 11:29 ` Keith Seitz
2001-10-19 15:12 ` Andrew Cagney
0 siblings, 1 reply; 8+ messages in thread
From: Keith Seitz @ 2001-10-19 11:29 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Fri, 19 Oct 2001, Andrew Cagney wrote:
> > +set pattern {.[0-9]* = \(short (int)? &\) @}
> > +append pattern "$hex: -1"
>
> Is there another way of doing this bit? I'm finding it more confusing
> then all the escape characters?
Well, there is, but I don't think anyone would like it any better:
gdb_test {print foo} [format {%s %s} {.[0-9]* = \(short( int?) &\)} "@$hex: -1"] \
{print foo test}
This is a common tcl thing to do, but, well, I'm not sure it's any better
for, how did someone put it? "beginners". (IMO, the "beginner" thing is a
cop out.)
Well, whatever. Let me know, and I will make any appropriate change
requested. Or I'll drop the whole thing and submit my additions without
the "cleanup".
Keith
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-19 11:29 ` Keith Seitz
@ 2001-10-19 15:12 ` Andrew Cagney
2001-10-21 12:15 ` Keith Seitz
0 siblings, 1 reply; 8+ messages in thread
From: Andrew Cagney @ 2001-10-19 15:12 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
> On Fri, 19 Oct 2001, Andrew Cagney wrote:
>
>
>> > +set pattern {.[0-9]* = \(short (int)? &\) @}
>> > +append pattern "$hex: -1"
>
>>
>> Is there another way of doing this bit? I'm finding it more confusing
>> then all the escape characters?
>
>
> Well, there is, but I don't think anyone would like it any better:
>
> gdb_test {print foo} [format {%s %s} {.[0-9]* = \(short( int?) &\)} "@$hex: -1"] \
> {print foo test}
There has to be something better. Look at some of the patters in MI.
They read ``blah $hex more blah $hex even more blah $hex even more blah
$hex''. While all those escape characters are bad I think this
construct a pattern bit by bit approach is worse.
> This is a common tcl thing to do, but, well, I'm not sure it's any better
> for, how did someone put it? "beginners". (IMO, the "beginner" thing is a
> cop out.)
Think of it more as making the testsuite contributor friendly. People
create test cases by cloning existing code. People don't create test
cases by reading the TCL manual.
Can functions like gdb_expect_list and the like be changed to convert
their ``string'' into a fixed pattern before passing things on?
Andrew
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-19 15:12 ` Andrew Cagney
@ 2001-10-21 12:15 ` Keith Seitz
0 siblings, 0 replies; 8+ messages in thread
From: Keith Seitz @ 2001-10-21 12:15 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
On Fri, 19 Oct 2001, Andrew Cagney wrote:
> There has to be something better. Look at some of the patters in MI.
> They read ``blah $hex more blah $hex even more blah $hex even more blah
> $hex''. While all those escape characters are bad I think this
> construct a pattern bit by bit approach is worse.
Unfortunately, there is nothing better that I've found. All the MI tests
use strings and escape all the special characters. We could introduce
something which would concat all the arguments together, but I don't think
this is any more readable.
> Think of it more as making the testsuite contributor friendly. People
> create test cases by cloning existing code. People don't create test
> cases by reading the TCL manual.
I don't have a problem making the testsuite more user-friendly. That's
exactly why I have submitted this rfc/a to begin with. I don't buy the
whole "knowing tcl is not a requirement of writing tests" any more than
"knowing C is not a requirement of writing gdb code". Gdb and its
testsuite are equally important parts of a system. You cannot modify
the program "gdb" without knowing C. Likewise, IMO, you cannt write tests
without knowing Tcl. [Let the flames begin.]
I also think that it is a mistake to do cut-n-paste programming, even
(especially?) in the testsuite. <flame>I admit, that as someone who knows
Tcl fairly well, I find dejagnu and our testsuites, ummm, pathetic.
They are all obviously someone's first use of tcl. I know this is
going to upset people, but, well, just look at how they're
written! No one who even uses tcl a little would ever write vararg
procedures for everything. You wouldn't do it in C, you shouldn't
do it in tcl.</flame> Let's face it: the testsuite is a self-propagating
mess.
> Can functions like gdb_expect_list and the like be changed to convert
> their ``string'' into a fixed pattern before passing things on?
Yes, this could be done. We would have to write our own string parser
which would only do variable substitutions. (Actually, with tcl this is
very easy.)
Ok, let me make sure what it is about the testsuite that I find more
contributor-unfriendly than anything else. We say that we don't want to
make people read the tcl manual, but there is an implicit assumption in
the testsuite that presumes that people understand the only undocumented
"feaeture" of tcl: evaluation.
Without looking at the testsuite, which of these are correct? Knowing Tcl
fairly well, I can tell which of these is correct just by looking at them
(most of the time :-). I'll bet very few could figure this out without
looking at the testsuite for guidance.
1. gdb_test "print foo" ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $"
2. gdb_test "print foo" ".\\[0-\\]* = \\\(short &\\) @$hex: -1.*gdb_prompt $"
3. gdb_test "print foo" ".\[0-9\]* = \\\(short &\\\) @$hex: -1.*$gdb_prompt $"
4. send_gdb {print foo
}
gdb_expect {
-re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" { pass }
...
}
5. send_gdb "print foo\n"
gdb_expect {
-re ".[0-9]* = \(short &\) @$hex: -1.*$gdb_prompt $" { pass }
...
}
6. send_gdb "print foo\n"
gdb_expect {
-re {.[0-9]* = \(short &\) @0x[0-9a-fA-F]+: -1.*(gdb) $} { pass }
...
}
In any case, we're just trading tit-for-tat. Let's face it, our testsuite
requires SOME understanding of tcl and how it works.
So, all of this being said (and maybe I should have just submitted my
additions to the testsuite instead of massaging it), let me summarize what
our options are:
1. Write a new proc (or modify existing ones) so that the pattern argument
would get any variables substituted. Thus we would have:
gdb_test "print f" {.[0-9]* = $hex" "print f"
This would get changed (by gdb_test or some new proc) to the equivalent
of:
gdb_test "print f" {.[0-9]* = 0x[0-9a-fA-F]+} "print f"
2. Add new gdb_test_concat procedure which would look like:
gdb_test_concat "print f" "print value of f" {.[0-9]* = } $hex
(i.e., proc gdb_test_concat {gdb_cmd test_name args}, args
concat'ed before being sent to expect)
3. Revert change to "set pattern PAT1; append pattern PAT2" to original
patterns ("PAT1PAT2").
Just let me know what is desired, and I shall embark down that road.
(Maybe I should just submit #3 until something is decided?)
Well, now I have to go into apology mode, because I am undoubtedly
stepping on several feet. I am sorry.
Keith
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-18 22:52 [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup" Keith Seitz
2001-10-19 8:28 ` Andrew Cagney
@ 2001-10-19 12:36 ` Michael Snyder
2001-10-19 12:58 ` Keith Seitz
1 sibling, 1 reply; 8+ messages in thread
From: Michael Snyder @ 2001-10-19 12:36 UTC (permalink / raw)
To: Keith Seitz; +Cc: gdb-patches
Keith Seitz wrote:
>
> Hi,
>
> I will be submitting some additional tests to ref-types.exp in the next
> day or so, and I thought that it would be nice to clean up ref-types.exp a
> little beforehand.
>
> The following "patch" (which is bigger than the file) uses gdb_test and
> gdb_test_exact when appropriate, and it cleans up some common tcl "errors"
> (not really syntax errors, but common syntax usages which are, umm,
> offensive).
>
> I think this is much easier to read than the "normal" things that are done
> in the testsuite.
>
> I have only tested this on linux native and solaris native. If more are
> required, just name them.
>
> What do others think?
Oh boy! Nit pick fest! ;-)
[Thanks for doing this, Keith, you probably know more about
Tcl than the rest of us put together.]
> +gdb_test {print s} {.[0-9]* = -1} {print value of s}
> +gdb_test {ptype s} {type = short (int)?} {ptype s}
I'm just curious why these would not be:
gdb_test "print s" ".[0-9]* = -1" "print value of s"
gdb_test "ptype s" "type = short (int?)" "ptype s"
Seems like the use of quotes in this context is ubiquitous
throughout the rest of the testsuite. Is there any reason
for switching to curly braces here? Is consistancy good?
Also I agree with the suggestion by Fernando to make the pattern
"short( int)?".
> +set pattern {.[0-9]* = \(short (int)? &\) @}
> +append pattern "$hex: -1"
> send_gdb "print rs\n"
> gdb_expect {
> - -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
> - pass "print value of rs"
> - }
> - -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
> - pass "print value of rs"
> - }
> - -re ".*$gdb_prompt $" { fail "print value of rs" }
> - timeout { fail "(timeout) print value of rs" }
> - eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
> -
> + -re $pattern {
> + pass "print value of rs"
> }
Would it be possible to accomplish the same thing by
combining the two "pass" regexps thusly?
-re ".\[0-9\]* = \\(short( int)? &\) @$hex: -1.*$gdb_prompt $" {
Michael
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
2001-10-19 12:36 ` Michael Snyder
@ 2001-10-19 12:58 ` Keith Seitz
0 siblings, 0 replies; 8+ messages in thread
From: Keith Seitz @ 2001-10-19 12:58 UTC (permalink / raw)
To: Michael Snyder; +Cc: gdb-patches
On Fri, 19 Oct 2001, Michael Snyder wrote:
> > +gdb_test {print s} {.[0-9]* = -1} {print value of s}
> > +gdb_test {ptype s} {type = short (int)?} {ptype s}
>
> I'm just curious why these would not be:
>
> gdb_test "print s" ".[0-9]* = -1" "print value of s"
> gdb_test "ptype s" "type = short (int?)" "ptype s"
Aha! I was hoping someone would ask. The difference is that in tcl,
strings are evaluated, lists are not. Consider:
tclsh> set a 3
3
tclsh> puts "a is $a"
a is 3
tclsh> puts {a is $a}
a is $a
> Seems like the use of quotes in this context is ubiquitous
> throughout the rest of the testsuite. Is there any reason
> for switching to curly braces here? Is consistancy good?
The use of quotes is not incorrect, but when I start thinking about
regexps (which, I admit, usually make my head hurt), I like to think
[0-9]\(foo\)\*, not \[0-9\]\\\(foo\\\)\\\*. It's just easier to read (for
me, I guess).
> Also I agree with the suggestion by Fernando to make the pattern
> "short( int)?".
Already done. My bad.
> > +set pattern {.[0-9]* = \(short (int)? &\) @}
> > +append pattern "$hex: -1"
> > send_gdb "print rs\n"
> > gdb_expect {
> > - -re ".\[0-9\]* = \\(short &\\) @$hex: -1.*$gdb_prompt $" {
> > - pass "print value of rs"
> > - }
> > - -re ".\[0-9\]* = \\(short int &\\) @$hex: -1.*$gdb_prompt $" {
> > - pass "print value of rs"
> > - }
> > - -re ".*$gdb_prompt $" { fail "print value of rs" }
> > - timeout { fail "(timeout) print value of rs" }
> > - eof { fail "print rs ($GDB dumped core) (FIXME)" ; gdb_start_again ; }
> > -
> > + -re $pattern {
> > + pass "print value of rs"
> > }
>
> Would it be possible to accomplish the same thing by
> combining the two "pass" regexps thusly?
>
> -re ".\[0-9\]* = \\(short( int)? &\) @$hex: -1.*$gdb_prompt $" {
Close (now you see why I like to use {} instead of "" for regular
expressions):
-re ".\[0-9\]* = \\\(short( int)? &\\\) @$hex: -1.*gdb_prompt $" {
When this is passed to expect, tcl will evaluate the special characters.
So ".\[0-9\]" will turn into '.[0-9]" (which is the range atom used by
regexp) and "\\\(" will become '\(' (which is the literal character '('
to expect), $hex will get substituted (and become another regexp atom to
expect), and so on.
Like I said, maybe it's just style, but I find the _real_ regular
expressions easier to read than all the "\\\(", "\\\[", "\\\$", and such,
and there is no ambiguity about how many "\" are needed. It's never more
than one (unless you mean literally mean '\', in which case it's "\\").
You could also think of it as {} being more like a C-string, whereas "..."
is more like a shell (a la bash) string.
Keith
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup"
@ 2001-10-19 9:08 Keith Seitz
0 siblings, 0 replies; 8+ messages in thread
From: Keith Seitz @ 2001-10-19 9:08 UTC (permalink / raw)
To: gdb-patches
On Fri, 19 Oct 2001, Fernando Nasser wrote:
> > +gdb_test {ptype as} {type = short (int)? \[4\]} {ptype as}
> >
> > -send_gdb "ptype as\n"
> > -gdb_expect {
> > - -re "type = short \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
> > - -re "type = short int \\\[4\\\].*$gdb_prompt $" { pass "ptype as" }
> > - -re ".*$gdb_prompt $" { fail "ptype as" }
> > - timeout { fail "(timeout) ptype as" }
> > -}
>
> I wonder if the extra space in the new pattern would not make it fail.
Oops. Late night braindeath. I actually wrote it this way to begin with,
then noticed that changing it from "( int)?" to " (int)?" had no effect on
linux and solaris deduced that it didn't make a difference. Of course it
doesn't! Both machines print out "short int [4]"! I will change these from
"short (int)?" to "short( int)?":
expect1.23> regexp {type = short (int)? \[4\].*(gdb)} {type = short int [4] (gdb)}
1
expect1.24> regexp {type = short (int)? \[4\].*(gdb)} {type = short [4] (gdb)}
0
expect1.25> regexp {type = short( int)? \[4\].*(gdb)} {type = short [4]
(gdb)}
1
expect1.26> regexp {type = short( int)? \[4\].*(gdb)} {type = short int [4] (gdb)}
1
> Of course you could make it "( int)?", but with the size of the change
> it is hard to find all these cases or to inspect them visually and not
> miss anything.
That's why we've got emacs! ;-)
Thanks for keeping me honest!
Keith
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2001-10-21 12:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-18 22:52 [RFC/A] testsuite/gdb.c++/ref-types.exp "cleanup" Keith Seitz
2001-10-19 8:28 ` Andrew Cagney
2001-10-19 11:29 ` Keith Seitz
2001-10-19 15:12 ` Andrew Cagney
2001-10-21 12:15 ` Keith Seitz
2001-10-19 12:36 ` Michael Snyder
2001-10-19 12:58 ` Keith Seitz
2001-10-19 9:08 Keith Seitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox