This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: Patch to C++ nested class printing
- To: Jason Merrill <jason at cygnus dot com>
- Subject: Re: Patch to C++ nested class printing
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Sat, 12 Feb 2000 17:07:54 +1100
- CC: gdb-patches at sourceware dot cygnus dot com
- Organization: Cygnus Solutions
- References: <199911240947.BAA18697@yorick.cygnus.com> <u9iu0yhh9j.fsf@yorick.cygnus.com>
Jason Merrill wrote:
>
> Ping?
Pong :-(
I'll be checking this in monday.
Andrew
>
> >>>>> Jason Merrill <jason@cygnus.com> writes:
>
> > Currently, printing of methods which take arguments of nested class type
> > (often, methods of nested classes themselves) is badly broken; for
> > instance, in gdb.c++/local.cc,
>
> > (gdb) ptype InnerLocal
> > type = class InnerLocal {
> > public:
> > char ilc;
> > int *ip;
> > NestedInnerLocal nest1;
>
> > InnerLocal & InnerLocal const &); <-- should be "operator="
> > InnerLocal const &); <-- should be a constructor
> > InnerLocal(void);
> > int il_foo(unsigned char const &);
> > }
>
> > This happens because the demangled name is
>
> > main.1::InnerLocal::operator=(main.1::InnerLocal const &);
>
> > and c_type_print_base blithely strips away everything up to the last ::,
> > including the name of the method. Oops. This patch causes us to stop at
> > the (.
>
> > 1999-11-24 Jason Merrill <jason@casey.cygnus.com>
>
> > * c-typeprint.c (c_type_print_base): Only strip the initial
> > Class:: qualification.
>
> > Index: c-typeprint.c
> > ===================================================================
> > RCS file: /cvs/cvsfiles/devo/gdb/c-typeprint.c,v
> > retrieving revision 2.39
> > diff -c -p -r2.39 c-typeprint.c
> > *** c-typeprint.c 1999/07/07 23:51:03 2.39
> > --- c-typeprint.c 1999/11/24 09:38:13
> > *************** c_type_print_base (type, stream, show, l
> > *** 923,932 ****
> > }
> > else
> > {
> > ! char *p;
> > char *demangled_no_class = demangled_name;
>
> > ! while ((p = strchr (demangled_no_class, ':')))
> > {
> > demangled_no_class = p;
> > if (*++demangled_no_class == ':')
> > --- 923,939 ----
> > }
> > else
> > {
> > ! char *p, *q;
> > char *demangled_no_class = demangled_name;
>
> > ! /* Only strip the initial Class:: qualification;
> > ! if we don't stop at the (, we end up throwing
> > ! away the name of the function. */
> > ! q = strchr (demangled_name, '(');
> > ! if (q == NULL)
> > ! q = demangled_name + strlen (demangled_name);
> > ! while ((p = strchr (demangled_no_class, ':'))
> > ! && p < q)
> > {
> > demangled_no_class = p;
> > if (*++demangled_no_class == ':')