[cplus] An initial use of the canonicalizer

Michael Elizabeth Chastain mec.gnu@mindspring.com
Tue Dec 30 21:15:00 GMT 2003


Uh, I don't like parts of this.

  -   -re "type = (class |)Foo<volatile char ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char.* \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" }
  +   -re "type = (class |)Foo<.*char.* ?\\*> \\{\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*.*char.*\\*t;\r\n\r\n\[ \t\]*.*char.* \\* foo\\(int,.*char.*\\*\\);\r\n\\}\r\n$gdb_prompt $" { pass "ptype fvpchar" }

You dropped the "volatile" from the expected test pattern.
Can you do something like:

  (volatile char ?*|char volatile ?*)

  -    -re "\\$\[0-9\]* = \\{.*char \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }
  +    -re "\\$\[0-9\]* = \\{.*char.* \\*\\((class |)Foo<volatile char ?\\*> \\*(| const), int, .*char.* \\*\\)\\} $hex <Foo<.*char.*\\*>::foo\\(int, .*char.*\\*\\)>\r\n$gdb_prompt $" { pass "print Foo<volatile char *>::foo" }

This is okay.  The old version is gross with ".*char" so the new version
is no worse.

  +# Verify that we get the same results for Foo for some equivalent
  +# template arguments.
  +gdb_test "ptype Foo<volatile char*>::x" "type = int \\( Foo<.*char.*\\*>::&\\)"
  +gdb_test "ptype Foo<volatile char *>::x" "type = int \\( Foo<.*char.*\\*>::&\\)"
  +gdb_test "ptype Foo<char volatile *>::x" "type = int \\( Foo<.*char.*\\*>::&\\)"

I really want to see "volatile" in there.

  -    -re "ptype Bar\r\ntype = class Bar<int,33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $"
  +    -re "ptype Bar\r\ntype = class Bar<int, 33> {\r\n\[ \t\]*public:\r\n\[ \t\]*int x;\r\n\[ \t\]*int t;\r\n\r\n\[ \t\]*int bar\\(int, int\\);\r\n}\r\n$gdb_prompt $"

Please do this with "<int, ?33>" instead of "<int, 33>".

Here is why: sometimes, I need to run the current test suite with gdb 6.0,
because the 6.0 test suite no longer works with the current compiler.
So it helps me a lot if the current test suite accepts the output
of both gdb 6.0 and gdb HEAD.

Sometimes this is painful but in cases like this it's easy and cheap.

Michael C



More information about the Gdb-patches mailing list