From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Received: (qmail 16911 invoked from network); 10 Jan 2003 21:42:19 -0000 Received: from unknown (HELO jackfruit.Stanford.EDU) (171.64.38.136) by 209.249.29.67 with SMTP; 10 Jan 2003 21:42:19 -0000 Received: (from carlton@localhost) by jackfruit.Stanford.EDU (8.11.6/8.11.6) id h0ALg7u24143; Fri, 10 Jan 2003 13:42:07 -0800 X-Authentication-Warning: jackfruit.Stanford.EDU: carlton set sender to carlton@math.stanford.edu using -f To: gdb Cc: Daniel Jacobowitz Subject: how canonical are template names? From: David Carlton Date: Fri, 10 Jan 2003 21:42:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2003-01/txt/msg00174.txt.bz2 I'm testing a patch on my branch that tries to figure out when a class lives inside a namespace by looking at the demangled names of the methods of the classes. When I tested the patch, I saw some regressions in gdb.c++/templates.exp. But, on looking at the situation further, I'm not sure that they qualify as regressions. Basically, there are different ways to write the same types; it turns out that G++'s debug info and the demangler choose different ways in some circumstances. In an ideal world, maybe GDB would always print types in one canonical way and allow users as much flexibility as possible in how they input types. But, for now, it seems quite reasonable to allow GDB to print types however it wishes and to require users to input types the same way that GDB outputs them in some circumstances. Usually, users can figure out what name GDB thinks a templated class has by calling 'ptype' on a variable of the appropriate type. Here's the differences in question, taken from gdb.logs in testsuite runs. I'll show the differences test by test, marking the current output with "* Current:" my new output with "* Branch:", and my discussion of differences with "* Discussion:". * Current: ptype fvpchar type = class Foo { public: int x; volatile char *t; volatile char * foo(int, char volatile*); } (gdb) PASS: gdb.c++/templates.exp: ptype fvpchar * Branch: ptype fvpchar type = class Foo { public: int x; volatile char *t; volatile char * foo(int, char volatile*); } (gdb) FAIL: gdb.c++/templates.exp: ptype fvpchar * Discussion: Here, the new output switches the 'char' and 'volatile'. It's still the same type. * Current: print Foo::foo No symbol "Foo" in current context. (gdb) FAIL: gdb.c++/templates.exp: print Foo::foo * Branch: print Foo::foo $4 = {volatile char *(Foo * const, int, volatile char *)} 0x80493be ::foo(int, char volatile*)> (gdb) FAIL: gdb.c++/templates.exp: print Foo::foo * Discussion: I have no idea what bizarre interaction between the parser and templates is causing the new version to print something useful in this situation even though the current version doesn't. (For what it's worth, the current version does print something useful if you omit the space in 'char *'.) * Current: ptype Bar type = class Bar { public: int x; int t; int bar(int, int); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Bar * Branch: ptype Bar type = class Bar { public: int x; int t; int bar(int, int); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Bar * Discussion: Here, the new output puts spaces between template arguments. (I have no idea what's up with the XFAIL: I haven't looked into that yet.) There are a few more examples that differ only by spaces (some of which turn PASS into FAIL rather than maintaining an XFAIL); I'll skip them. * Current: ptype Baz type = class Baz { public: int x; int t; int baz(int, int); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Baz * Branch: ptype Baz type = class Baz { public: int x; int t; int baz(int, int); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Baz * Discussion: Here, not only is there an extra space, but the character constant is printed using its numerical value. There are a few more examples like this. * Current: ptype Qux type = class Qux { public: int x; char t; char qux(int, char); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Qux * Branch: ptype Qux type = class Qux { public: int x; char t; char qux(int, char); } (gdb) XFAIL: gdb.c++/templates.exp: ptype Qux * Discussion: Besides the space difference, there are parens around 'string'. There are more examples like this, too. Those are the differences that the testsuite reveals. Any opinions as to which of these should be considered serious, if any? I'm leaning towards not worrying about any of them, but filing a low-priority PR about it just to get it into the database. (The main reason for the latter is because it would be nice if input were a bit more flexible; I don't care so much about variations in GDB's output.) David Carlton carlton@math.stanford.edu