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]

Re: RFC: Formatting of type output


On Thu, Dec 06, 2001 at 10:42:22PM +0200, Eli Zaretskii wrote:
> > Date: Thu, 6 Dec 2001 12:02:05 -0500
> > From: Daniel Jacobowitz <drow@mvista.com>
> > 
> > That means that, regrettably, they are formatted differently; it is closer
> > to the v2 demangler than to the v3 demangler, but different from both
> > (classes get prefixed by "class" even in C++, for example).
> 
> Could you please post a few examples how they are different?  It's
> hard to reason about this without seeing some live examples; I guess
> I don't know enough about this problem to figure this out myself.

Well, here's an example.  v2/stabs:
type = class Class {
  private:
    int xxx;

  public:
    Class & operator=(Class const &);
    Class(Class const &);
    Class(void);
}

v3/stabs (after some patches not yet submitted to eliminate duplicate
constructors):
(gdb) ptype Class
type = class Class {
  private:
    int xxx;

  public:
    Class & operator=(Class const&);
    void Class(Class const&);
    void Class();
}


Notice "const &" becomes "const&" and "(void)" becomes "()".

For v3/dwarf, though:
(gdb) ptype Class
type = class Class {
  private:
    int xxx;

  public:
    Class & operator=(Class const&);
    Class(class Class &);
    Class(void);
}

See the "class Class &"?  That's because Class::Class does not have a
DW_AT_mips_linkage_name, so we use the method argument printer.  class Class
is opaque when the constructor is defined (a bug causes us to have lost
"const" here, I'll fix it).  operator= is still going through the v3
demangler.

Worse, do it a second time in the same GDB session:
type = class Class {
  private:
    int xxx;

  public:
    Class & operator=(Class const&);
    Class(Class &);
    Class(void);
}

And now it matches some combination of the other two.  I'm still trying
to figure out how to suppress "class" properly.

And what I'm proposing is to use the method argument printer all the
time.  If we do that, as it stands now:

(gdb) ptype Class
type = class Class {
  private:
    int xxx;

  public:
    Class & operator=(class Class &);
    Class(Class &);
    Class(void);
}

Now the "class Class" bug shows up earlier, and had the qualifiers not
been trampled we would have gained a space in front of the & for
operator=.

> > Does anything mechanical depend on the format of type output, besides our
> > testsuite?
> 
> The documentation might include some examples which could need to be
> changed.  Obviously, this is not a grave problem, but since you
> asked...

I'll keep it in mind.

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


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