This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

how canonical are template names?


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 (with control-M's stripped).  I'll do it test by test, listing
the current output first and my new output second.

ptype fvpchar
type = class Foo<volatile char*> {
  public:
    int x;
    volatile char *t;

    volatile char * foo(int, char volatile*);
}
(gdb) PASS: gdb.c++/templates.exp: ptype fvpchar

ptype fvpchar
type = class Foo<char volatile*> {
  public:
    int x;
    volatile char *t;

    volatile char * foo(int, char volatile*);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype fvpchar

**** Current

print Foo<volatile char *>::foo
No symbol "Foo<volatile char *>" in current context.
(gdb) FAIL: gdb.c++/templates.exp: print Foo<volatile char *>::foo
ptype Bar
type = class Bar<int,33> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Bar
ptype bint
type = class Bar<int,33> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype bint
ptype bint2
type = class Bar<int,1> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype bint2
ptype Baz
type = class Baz<int,'s'> {
  public:
    int x;
    int t;

    int baz(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Baz
ptype bazint
type = class Baz<int,'s'> {
  public:
    int x;
    int t;

    int baz(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype bazint
ptype bazint2
type = class Baz<char,'a'> {
  public:
    int x;
    char t;

    char baz(int, char);
}
(gdb) PASS: gdb.c++/templates.exp: ptype bazint2
ptype Qux
type = class Qux<char,&string> {
  public:
    int x;
    char t;

    char qux(int, char);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Qux
ptype quxint
type = class Qux<int,&string> {
  public:
    int x;
    int t;

    int qux(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype quxint
ptype Spec
type = class Spec<int,char> {
  public:
    int x;

    int spec(char);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Spec
ptype siip
type = class Spec<int,int*> {
  public:
    int x;

    int spec(int*);
}
(gdb) PASS: gdb.c++/templates.exp: ptype siip
ptype Garply<int>
type = class Garply<int> {
  public:
    int x;
    int t;

    int garply(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype Garply<int>
ptype Garply<Garply<char> >
type = class Garply<Garply<char> > {
  public:
    int x;
    Garply<char> t;

    Garply<char> garply(int, Garply<char>);
}
(gdb) PASS: gdb.c++/templates.exp: ptype Garply<Garply<char> >
print Garply<Garply<char> >::garply
$4 = {Garply<char> (Garply<Garply<char> > * const, int, Garply<char>)} 0x8049516 <Garply<Garply<char> >::garply(int, Garply<char>)>
(gdb) FAIL: gdb.c++/templates.exp: print Garply<Garply<char> >::garply
break Garply<Garply<char> >::garply
Breakpoint 5 at 0x8049528: file gdb.c++/templates.cc, line 696.
(gdb) PASS: gdb.c++/templates.exp: break Garply<Garply<char> >::garply
testcase ./gdb.c++/templates.exp completed in 7 seconds

		=== gdb Summary ===

# of expected passes		16
# of unexpected failures	6
# of expected failures		5
Executing on host: /extra/gdb/mirror/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd    (timeout = 300)
spawn /extra/gdb/mirror/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd 
GNU gdb 2003-01-09-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
/extra/gdb/mirror/src/gdb/testsuite/../../gdb/gdb version  2003-01-09-cvs -nx

runtest completed at Fri Jan 10 12:51:33 2003

**** New

print Foo<volatile char *>::foo
$4 = {volatile char *(Foo<volatile char*> * const, int, volatile char *)} 0x80493be <Foo<char volatile*>::foo(int, char volatile*)>
(gdb) FAIL: gdb.c++/templates.exp: print Foo<volatile char *>::foo
ptype Bar
type = class Bar<int, 33> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Bar
ptype bint
type = class Bar<int, 33> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype bint
ptype bint2
type = class Bar<int, 1> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype bint2
ptype Baz
type = class Baz<int, 115> {
  public:
    int x;
    int t;

    int baz(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Baz
ptype bazint
type = class Baz<int, 115> {
  public:
    int x;
    int t;

    int baz(int, int);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype bazint
ptype bazint2
type = class Baz<char, 97> {
  public:
    int x;
    char t;

    char baz(int, char);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype bazint2
ptype Qux
type = class Qux<char, &(string)> {
  public:
    int x;
    char t;

    char qux(int, char);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Qux
ptype quxint
type = class Qux<int, &(string)> {
  public:
    int x;
    int t;

    int qux(int, int);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype quxint
ptype Spec
type = class Spec<int, char> {
  public:
    int x;

    int spec(char);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Spec
ptype siip
type = class Spec<int, int*> {
  public:
    int x;

    int spec(int*);
}
(gdb) FAIL: gdb.c++/templates.exp: ptype siip
ptype Garply<int>
type = class Garply<int> {
  public:
    int x;
    int t;

    int garply(int, int);
}
(gdb) PASS: gdb.c++/templates.exp: ptype Garply<int>
ptype Garply<Garply<char> >
type = class Garply<Garply<char> > {
  public:
    int x;
    Garply<char> t;

    Garply<char> garply(int, Garply<char>);
}
(gdb) PASS: gdb.c++/templates.exp: ptype Garply<Garply<char> >
print Garply<Garply<char> >::garply
$5 = {Garply<char> (Garply<Garply<char> > * const, int, Garply<char>)} 0x8049516 <Garply<Garply<char> >::garply(int, Garply<char>)>
(gdb) FAIL: gdb.c++/templates.exp: print Garply<Garply<char> >::garply
break Garply<Garply<char> >::garply
Breakpoint 5 at 0x8049528: file gdb.c++/templates.cc, line 696.
(gdb) PASS: gdb.c++/templates.exp: break Garply<Garply<char> >::garply
testcase ./gdb.c++/templates.exp completed in 7 seconds

		=== gdb Summary ===

# of expected passes		9
# of unexpected failures	13
# of expected failures		5
Executing on host: /extra/gdb/dictionary/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd    (timeout = 300)
spawn /extra/gdb/dictionary/src/gdb/testsuite/../../gdb/gdb -nw --command gdb_cmd 
GNU gdb 2002-12-23-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu".
/extra/gdb/dictionary/src/gdb/testsuite/../../gdb/gdb version  2002-12-23-cvs -nx

runtest completed at Fri Jan 10 12:45:54 2003


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]