Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* how canonical are template names?
@ 2003-01-10 21:19 David Carlton
  2003-01-10 21:21 ` David Carlton
  0 siblings, 1 reply; 10+ messages in thread
From: David Carlton @ 2003-01-10 21:19 UTC (permalink / raw)
  To: gdb; +Cc: Daniel Jacobowitz

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


^ permalink raw reply	[flat|nested] 10+ messages in thread
* how canonical are template names?
@ 2003-01-10 21:42 David Carlton
  2003-01-10 21:55 ` Daniel Jacobowitz
  2003-01-10 23:34 ` Stan Shebs
  0 siblings, 2 replies; 10+ messages in thread
From: David Carlton @ 2003-01-10 21:42 UTC (permalink / raw)
  To: gdb; +Cc: Daniel Jacobowitz

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<volatile char*> {
  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<char volatile*> {
  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<volatile char *>::foo
No symbol "Foo<volatile char *>" in current context.
(gdb) FAIL: gdb.c++/templates.exp: print Foo<volatile char *>::foo

* Branch:

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

* 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<int,33> {
  public:
    int x;
    int t;

    int bar(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Bar

* Branch:

ptype Bar
type = class Bar<int, 33> {
  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<int,'s'> {
  public:
    int x;
    int t;

    int baz(int, int);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Baz

* Branch:

ptype Baz
type = class Baz<int, 115> {
  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<char,&string> {
  public:
    int x;
    char t;

    char qux(int, char);
}
(gdb) XFAIL: gdb.c++/templates.exp: ptype Qux

* Branch:

ptype Qux
type = class Qux<char, &(string)> {
  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


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: how canonical are template names?
@ 2003-01-11  0:59 Michael Elizabeth Chastain
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-11  0:59 UTC (permalink / raw)
  To: carlton, gdb; +Cc: drow

David C writes:
> 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.

templates.exp has issues.  :(  I'm working on a rewrite but it's on
the back burner right now.  You'll have to hand-analyze the results,
which I see you've done.

In fact, I'd like to just write a brand new templates test file,
include all the useful testing from the old one, and then strangle
the old one.

> Here, the new output switches the 'char' and 'volatile'.  It's still
> the same type.

GDB is okay here.

> type = class Baz<int, 115> {

GDB is incorrect here.  sz is of type 'char' so it should be printed
like that.

* Current:

> type = class Qux<char, &(string)> {

This is probably a judgement call.  My opinion is that it's legal for
gdb to emit this.  It's annoying but we have much worse problems to fix,
so just eat it and go on to the other 570 open PR's.  I would like to
accept the parens for another 3-5 years, and we can revisit them once
gcc 2 is no longer supported, stabs is dead, and so on.

I would file a PR about the '115' that should be a character 's'
and let the others go.  My two cents.

Michael C


^ permalink raw reply	[flat|nested] 10+ messages in thread
* Re: how canonical are template names?
@ 2003-01-11  1:07 Michael Elizabeth Chastain
  2003-01-11  3:42 ` Daniel Jacobowitz
  0 siblings, 1 reply; 10+ messages in thread
From: Michael Elizabeth Chastain @ 2003-01-11  1:07 UTC (permalink / raw)
  To: carlton, shebs; +Cc: drow, gdb

Since a C++ parser is a bitch of a thing to write, is there any chance
that Mark Mitchell's new C++ parser can be re-used in gdb?

The interesting part would be doing name resolution out of the
symbol table information rather than internal compiler information.

Michael C


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-01-11  3:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-10 21:19 how canonical are template names? David Carlton
2003-01-10 21:21 ` David Carlton
2003-01-10 21:42 David Carlton
2003-01-10 21:55 ` Daniel Jacobowitz
2003-01-10 22:44   ` David Carlton
2003-01-10 23:34 ` Stan Shebs
2003-01-10 23:47   ` David Carlton
2003-01-11  0:59 Michael Elizabeth Chastain
2003-01-11  1:07 Michael Elizabeth Chastain
2003-01-11  3:42 ` Daniel Jacobowitz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox