From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3724 invoked by alias); 13 Dec 2007 17:05:37 -0000 Received: (qmail 3703 invoked by uid 22791); 13 Dec 2007 17:05:35 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 13 Dec 2007 17:05:25 +0000 Received: (qmail 1414 invoked from network); 13 Dec 2007 17:05:23 -0000 Received: from unknown (HELO 172.16.unknown.plus.ru) (vladimir@127.0.0.2) by mail.codesourcery.com with ESMTPA; 13 Dec 2007 17:05:23 -0000 From: Vladimir Prus To: Jim Blandy Subject: Re: Support constants for DW_AT_data_member_location Date: Thu, 13 Dec 2007 17:57:00 -0000 User-Agent: KMail/1.9.6 Cc: gdb-patches@sources.redhat.com References: <200711291254.14423.vladimir@codesourcery.com> <200711292317.53967.vladimir@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200712132005.17970.vladimir@codesourcery.com> Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-12/txt/msg00175.txt.bz2 On Saturday 01 December 2007 04:48:09 Jim Blandy wrote: > > So, DW_FORM_data4 used for DW_AT_data_member_location is never interepr= eted > > as constant. Maybe we should have "is_surely_constant" function? >=20 > Oh --- great catch, thanks. =A0(We don't support location lists for > DW_AT_data_member_location yet, but we certainly should warn, not > randomly misinterpret the value.) >=20 > How's this, then? >=20 > gdb/ChangeLog: > 2007-11-30 =A0Jim Blandy =A0 >=20 > =A0=A0=A0=A0=A0=A0=A0=A0* dwarf2read.c (attr_form_is_constant): New funct= ion. > =A0=A0=A0=A0=A0=A0=A0=A0(dwarf2_add_field): Use it and attr_form_is_secti= on_offset to > =A0=A0=A0=A0=A0=A0=A0=A0recognize DW_AT_data_member_location attributes. = =A0Use > =A0=A0=A0=A0=A0=A0=A0=A0dwarf2_get_attr_constant_value when the attribute= is a constant. >=20 > =A0=A0=A0=A0=A0=A0=A0=A0* dwarf2read.c (attr_form_is_section_offset): New= function. > =A0=A0=A0=A0=A0=A0=A0=A0(dwarf_add_member_fn, read_common_block, read_par= tial_die) > =A0=A0=A0=A0=A0=A0=A0=A0(dwarf2_symbol_mark_computed): Use it, instead of= writing it out. >=20 > diff -r c4f654de59cf gdb/dwarf2read.c > --- a/gdb/dwarf2read.c=A0=A0Thu Nov 29 11:28:59 2007 -0800 > +++ b/gdb/dwarf2read.c=A0=A0Fri Nov 30 17:32:46 2007 -0800 > @@ -1039,6 +1039,10 @@ static void dwarf_decode_macros (struct=20 > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 char = *, bfd *, struct dwarf2_cu *); > =A0 > =A0static int attr_form_is_block (struct attribute *); > + > +static int attr_form_is_section_offset (struct attribute *); > + > +static int attr_form_is_constant (struct attribute *); > =A0 > =A0static void dwarf2_symbol_mark_computed (struct attribute *attr, > =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 struct symbol *sym, > @@ -3380,8 +3384,16 @@ dwarf2_add_field (struct field_info *fip > =A0 =A0 =A0 =A0attr =3D dwarf2_attr (die, DW_AT_data_member_location, cu); > =A0 =A0 =A0 =A0if (attr) > =A0=A0=A0=A0=A0=A0=A0=A0{ > -=A0=A0=A0=A0=A0=A0=A0 =A0FIELD_BITPOS (*fp) =3D > -=A0=A0=A0=A0=A0=A0=A0 =A0 =A0decode_locdesc (DW_BLOCK (attr), cu) * bits= _per_byte; > + =A0 =A0 =A0 =A0 =A0if (attr_form_is_section_offset (attr)) > + =A0 =A0 =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 =A0 =A0 =A0dwarf2_complex_location_expr_complaint (); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0FIELD_BITPOS (*fp) =3D 0; > + =A0 =A0 =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0 =A0else if (attr_form_is_constant (attr)) > + =A0 =A0 =A0 =A0 =A0 =A0FIELD_BITPOS (*fp) =3D dwarf2_get_attr_constant_= value (attr, 0); You need "* 8" above, since the value of data_member_location is offset in bytes. > + =A0 =A0 =A0 =A0 =A0else > + =A0 =A0 =A0 =A0 =A0 =A0FIELD_BITPOS (*fp) =3D > + =A0 =A0 =A0 =A0 =A0 =A0 =A0decode_locdesc (DW_BLOCK (attr), cu) * bits_= per_byte; Or, if we really want GDB to support processors with 9-bit bytes, you need "* bits_per_byte". > +/* Return non-zero if ATTR's value is a section offset (classes > + =A0 lineptr, loclistptr, macptr or rangelistptr).=20 I'd also note here that in all cases, an attribute value may fall to only one class listed above. > In this case,=20 > + =A0 you may use DW_UNSND (attr) to retrieve the offset. =A0*/ > +static int > +attr_form_is_section_offset (struct attribute *attr) > +{ > + =A0return (attr->form =3D=3D DW_FORM_data4 > + =A0 =A0 =A0 =A0 =A0|| attr->form =3D=3D DW_FORM_data8); I'd probably add a comment here saying that in DWARF standand, those are only two forms that can encode those classes. Not being DWARF expert, it took me a bit of looking to verify that. If you explicitly mention this, then future readers can just trust the comment ;-) With the "* bits_per_byte" change, this patch fixes the problem I saw. Assuming there are no regressions, can you check it in? Thanks, Volodya