From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10032 invoked by alias); 5 Dec 2002 20:28:36 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 10001 invoked from network); 5 Dec 2002 20:28:35 -0000 Received: from unknown (HELO mx1.redhat.com) (66.187.233.31) by sources.redhat.com with SMTP; 5 Dec 2002 20:28:35 -0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.11.6/8.11.6) with ESMTP id gB5K3PP25401 for ; Thu, 5 Dec 2002 15:03:25 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gB5KSYD31223 for ; Thu, 5 Dec 2002 15:28:34 -0500 Received: from localhost.redhat.com (romulus-int.sfbay.redhat.com [172.16.27.46]) by pobox.corp.redhat.com (8.11.6/8.11.6) with ESMTP id gB5KSW913933; Thu, 5 Dec 2002 15:28:33 -0500 Received: by localhost.redhat.com (Postfix, from userid 469) id 9AC33FF79; Thu, 5 Dec 2002 15:24:10 -0500 (EST) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15855.46570.409897.896793@localhost.redhat.com> Date: Thu, 05 Dec 2002 12:28:00 -0000 To: David Carlton Cc: gdb-patches@sources.redhat.com, Jim Blandy , Elena Zannoni Subject: Re: PING [RFA] DWARF-2, static data members In-Reply-To: References: X-SW-Source: 2002-12/txt/msg00173.txt.bz2 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 > said: > > In article <15700.15818.829204.767503@jackfruit.Stanford.EDU>, David > > Carlton 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 > > * 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); >