From: Elena Zannoni <ezannoni@redhat.com>
To: David Carlton <carlton@math.stanford.edu>
Cc: gdb-patches@sources.redhat.com, Jim Blandy <jimb@redhat.com>,
Elena Zannoni <ezannoni@redhat.com>
Subject: Re: PING [RFA] DWARF-2, static data members
Date: Thu, 05 Dec 2002 12:28:00 -0000 [thread overview]
Message-ID: <15855.46570.409897.896793@localhost.redhat.com> (raw)
In-Reply-To: <ro1ptt1kq5z.fsf@jackfruit.Stanford.EDU>
David Carlton writes:
> Could somebody look at this patch? If possible, I'd like it to get
> into GDB 5.3, because the sooner that I can submit a corresponding
> patch to GCC, the better. The problem that this refers to is
> discussed in a thread entitled "DWARF-2, static data members" from the
> first half of August. (In gdb, not gdb-patches.) And, unfortunately,
> it's about to make my life unhappy; there's nothing I can do about
> that, given that GCC is generating the wrong debugging information,
> but the faster GCC generates the right debugging information, the more
> likely it is that I'll be happier in the future...
>
> On 20 Aug 2002 16:17:16 -0700, David Carlton
> <carlton@math.Stanford.EDU> said:
> > In article <15700.15818.829204.767503@jackfruit.Stanford.EDU>, David
> > Carlton <carlton@math.Stanford.EDU> writes:
>
> >> It seems to me that the safe thing to do would be to modify GDB so
> >> that it treats members that either are DW_TAG_variable or
> >> DW_TAG_member + DW_AT_declaration as static data members; that way
> >> it will be safe both with code compiled by current versions of GCC
> >> and by code compiled with hypothetical future versions of GCC that
> >> have this misinterpretation fixed (as well as other compilers out
> >> there that might do the right thing).
>
> > Here's a patch that does that. I tried to modify GDB's behavior as
> > little as possible: so it uses the current code for adding non-static
> > and static data members, but it calls the former if the member is a
> > DW_TAG_member that isn't a declaration and calls the latter if the
> > member is either a DW_TAG_member that is a declaration or a
> > DW_TAG_variable. (As opposed to the current situation that calls the
> > former if it's a DW_TAG_member and the latter if it's a
> > DW_TAG_variable.)
>
> > I'm also include a patch to GCC's dwarf2out.c that, I think, gets GCC
> > to tag static data members with DW_TAG_member instead of
> > DW_TAG_variable; I've tried compiling and debugging files with this,
> > and GCC seems to be generating the correct debugging information that
> > and GDB seems to be handling it appropriately. I'll try to submit
> > that patch to the GCC folks once this patch gets accepted for GDB
>
> David Carlton
> carlton@math.stanford.edu
>
> 2002-08-20 David Carlton <carlton@math.stanford.edu>
>
> * dwarf2read.c (dwarf2_add_field): Treat a field that is a
> DW_TAG_member as well as a declaration as being a C++ static data
> member.
> (read_structure_scope): Combine tests for DW_TAG_member and
> DW_TAG_variable.
>
> Index: dwarf2read.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/dwarf2read.c,v
> retrieving revision 1.65
> diff -u -p -r1.65 dwarf2read.c
> --- dwarf2read.c 20 Aug 2002 18:45:30 -0000 1.65
> +++ dwarf2read.c 20 Aug 2002 22:37:07 -0000
> @@ -2049,7 +2049,9 @@ dwarf2_add_field (struct field_info *fip
> new_field->virtuality = DW_UNSND (attr);
>
> fp = &new_field->field;
> - if (die->tag == DW_TAG_member)
> +
> + /* Data member other than a C++ static data member. */
> + if (die->tag == DW_TAG_member && ! die_is_declaration (die))
> {
> /* Get type of field. */
> fp->type = die_type (die, objfile, cu_header);
> @@ -2133,12 +2135,14 @@ dwarf2_add_field (struct field_info *fip
> fip->non_public_fields = 1;
> }
> }
> - else if (die->tag == DW_TAG_variable)
> + /* C++ static member. It should be a DW_TAG_member that is a
> + declaration, but G++ currently incorrectly generates
> + DW_TAG_variable tags. */
> + else if (die->tag == DW_TAG_member || die->tag == DW_TAG_variable)
> {
> char *physname;
>
> - /* C++ static member.
> - Get name of field. */
> + /* Get name of field. */
> attr = dwarf_attr (die, DW_AT_name);
> if (attr && DW_STRING (attr))
> fieldname = DW_STRING (attr);
> @@ -2503,13 +2507,11 @@ read_structure_scope (struct die_info *d
>
> while (child_die && child_die->tag)
> {
> - if (child_die->tag == DW_TAG_member)
> - {
> - dwarf2_add_field (&fi, child_die, objfile, cu_header);
> - }
> - else if (child_die->tag == DW_TAG_variable)
> + /* G++ can incorrectly tag static member variables with
> + DW_TAG_variable. */
> + if (child_die->tag == DW_TAG_member
> + || child_die->tag == DW_TAG_variable)
> {
> - /* C++ static member. */
> dwarf2_add_field (&fi, child_die, objfile, cu_header);
> }
> else if (child_die->tag == DW_TAG_subprogram)
>
Makes sense. Hoever, could you leave the comments inside the 'then' bodies?
Like
if (blah)
{
/* C++ static member. */
[...]
}
I think it would be useful to add a g++ version number or a date in
the comments, because at some point down the road we may want to
obsolete the old form.
Was the patch to gcc submitted, or the gcc PR fixed otherwise?
Elena
>
> Here's the patch for GCC's dwarf2out.c:
>
> --- dwarf2out.c.orig Wed Aug 14 14:05:05 2002
> +++ dwarf2out.c Tue Aug 20 15:08:32 2002
> @@ -10460,12 +10460,19 @@ gen_variable_die (decl, context_die)
> dw_die_ref context_die;
> {
> tree origin = decl_ultimate_origin (decl);
> - dw_die_ref var_die = new_die (DW_TAG_variable, context_die, decl);
> -
> + dw_die_ref var_die;
> dw_die_ref old_die = lookup_decl_die (decl);
> int declaration = (DECL_EXTERNAL (decl)
> || class_scope_p (context_die));
>
> + /* Declarations of C++ static data members within the declaration of
> + their enclosing class should be tagged as DW_TAG_member. */
> + if (class_scope_p (context_die))
> + var_die = new_die (DW_TAG_member, context_die, decl);
> + else
> + var_die = new_die (DW_TAG_variable, context_die, decl);
> +
> +
> if (origin != NULL)
> add_abstract_origin_attribute (var_die, origin);
>
next prev parent reply other threads:[~2002-12-05 20:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-11-19 17:04 David Carlton
2002-12-05 12:28 ` Elena Zannoni [this message]
2002-12-05 14:44 ` David Carlton
2002-12-05 15:45 ` Elena Zannoni
2002-12-05 16:16 ` David Carlton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=15855.46570.409897.896793@localhost.redhat.com \
--to=ezannoni@redhat.com \
--cc=carlton@math.stanford.edu \
--cc=gdb-patches@sources.redhat.com \
--cc=jimb@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox