From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13673 invoked by alias); 18 Aug 2009 18:18:12 -0000 Received: (qmail 13662 invoked by uid 22791); 18 Aug 2009 18:18:11 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL,BAYES_05,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 18 Aug 2009 18:18:00 +0000 Received: from spaceape11.eur.corp.google.com (spaceape11.eur.corp.google.com [172.28.16.145]) by smtp-out.google.com with ESMTP id n7IIHu8W017307 for ; Tue, 18 Aug 2009 11:17:57 -0700 Received: from yxe9 (yxe9.prod.google.com [10.190.2.9]) by spaceape11.eur.corp.google.com with ESMTP id n7IIGjYw025261 for ; Tue, 18 Aug 2009 11:17:54 -0700 Received: by yxe9 with SMTP id 9so4617323yxe.30 for ; Tue, 18 Aug 2009 11:17:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.150.80.15 with SMTP id d15mr8571796ybb.28.1250619473422; Tue, 18 Aug 2009 11:17:53 -0700 (PDT) In-Reply-To: <200908171816.n7HIGd2j014563@d12av02.megacenter.de.ibm.com> References: <200908171308.n7HD8dwb023540@d12av02.megacenter.de.ibm.com> <200908171816.n7HIGd2j014563@d12av02.megacenter.de.ibm.com> Date: Tue, 18 Aug 2009 18:44:00 -0000 Message-ID: Subject: Re: [RFA] Fix crash of convenience vars with typedefs. From: Doug Evans To: Ulrich Weigand Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-System-Of-Record: true X-IsSubscribed: yes 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: 2009-08/txt/msg00287.txt.bz2 On Mon, Aug 17, 2009 at 11:16 AM, Ulrich Weigand wrote: > I wrote: >> Maybe it would be best to split the INTERNALVAR_SCALAR state into two >> distinct states INTERNALVAL_INTEGER and INTERNAL_POINTER; the decision >> can be make in set_internalvar, where we already call check_typedef, >> and then used subsequentially. > > Like so. =A0Does this fix your problem? Almost. gdb now crashes in a different place. [from testsuite/gdb.log] print /x $prog_var ../../../src/gdb/findvar.c:246: internal-error: store_typed_address: type is not a pointer or reference A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) FAIL: gdb.base/gdbvars.exp: Print contents of new convenience variable of program variable (GDB internal error) n ../../../src/gdb/findvar.c:246: internal-error: store_typed_address: type is not a pointer or reference A problem internal to GDB has been detected, further debugging may prove unreliable. Can you run the testcase included in my patch? If that passes I'm happy. > > Bye, > Ulrich > > > ChangeLog: > > =A0 =A0 =A0 =A0* value.c (enum internalvar_kind): Replace INTERNALVAR_SCA= LAR by > =A0 =A0 =A0 =A0INTERNALVAR_INTEGER and INTERNALVAR_POINTER. > =A0 =A0 =A0 =A0(union internalvar_data): Replace "scalar" member by "inte= ger" > =A0 =A0 =A0 =A0and "pointer". > =A0 =A0 =A0 =A0(value_of_internalvar): Handle INTERNALVAR_INTEGER and > =A0 =A0 =A0 =A0INTERNALVAR_POINTER instead of INTERNALVAR_SCALAR. > =A0 =A0 =A0 =A0(get_internalvar_integer): Likewise. > =A0 =A0 =A0 =A0(set_internalvar): Likewise. > =A0 =A0 =A0 =A0(set_internalvar_integer): Likewise. > =A0 =A0 =A0 =A0(preserve_one_internalvar): Likewise. > > > Index: gdb/value.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > RCS file: /cvs/src/src/gdb/value.c,v > retrieving revision 1.92 > diff -u -p -r1.92 value.c > --- gdb/value.c 13 Aug 2009 18:39:20 -0000 =A0 =A0 =A01.92 > +++ gdb/value.c 17 Aug 2009 17:06:30 -0000 > @@ -920,8 +920,11 @@ struct internalvar > =A0 =A0 =A0 /* The internal variable holds a GDB internal convenience fun= ction. =A0*/ > =A0 =A0 =A0 INTERNALVAR_FUNCTION, > > - =A0 =A0 =A0/* The variable holds a simple scalar value. =A0*/ > - =A0 =A0 =A0INTERNALVAR_SCALAR, > + =A0 =A0 =A0/* The variable holds an integer value. =A0*/ > + =A0 =A0 =A0INTERNALVAR_INTEGER, > + > + =A0 =A0 =A0/* The variable holds a pointer value. =A0*/ > + =A0 =A0 =A0INTERNALVAR_POINTER, > > =A0 =A0 =A0 /* The variable holds a GDB-provided string. =A0*/ > =A0 =A0 =A0 INTERNALVAR_STRING, > @@ -944,19 +947,22 @@ struct internalvar > =A0 =A0 =A0 =A0 =A0int canonical; > =A0 =A0 =A0 =A0} fn; > > - =A0 =A0 =A0/* A scalar value used with INTERNALVAR_SCALAR. =A0*/ > + =A0 =A0 =A0/* An integer value used with INTERNALVAR_INTEGER. =A0*/ > =A0 =A0 =A0 struct > =A0 =A0 =A0 =A0 { > =A0 =A0 =A0 =A0 =A0/* If type is non-NULL, it will be used as the type to= generate > =A0 =A0 =A0 =A0 =A0 =A0 a value for this internal variable. =A0If type is= NULL, a default > =A0 =A0 =A0 =A0 =A0 =A0 integer type for the architecture is used. =A0*/ > =A0 =A0 =A0 =A0 =A0struct type *type; > - =A0 =A0 =A0 =A0 union > - =A0 =A0 =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 =A0 =A0 LONGEST l; =A0 =A0/* Used with TYPE_CODE_INT an= d NULL types. =A0*/ > - =A0 =A0 =A0 =A0 =A0 =A0 CORE_ADDR a; =A0/* Used with TYPE_CODE_PTR type= s. =A0*/ > - =A0 =A0 =A0 =A0 =A0 } val; > - =A0 =A0 =A0 =A0} scalar; > + =A0 =A0 =A0 =A0 LONGEST val; > + =A0 =A0 =A0 =A0} integer; > + > + =A0 =A0 =A0/* A pointer value used with INTERNALVAR_POINTER. =A0*/ > + =A0 =A0 =A0struct > + =A0 =A0 =A0 =A0{ > + =A0 =A0 =A0 =A0 struct type *type; > + =A0 =A0 =A0 =A0 CORE_ADDR val; > + =A0 =A0 =A0 =A0} pointer; > > =A0 =A0 =A0 /* A string value used with INTERNALVAR_STRING. =A0*/ > =A0 =A0 =A0 char *string; > @@ -1082,16 +1088,16 @@ value_of_internalvar (struct gdbarch *gd > =A0 =A0 =A0 val =3D allocate_value (builtin_type (gdbarch)->internal_fn); > =A0 =A0 =A0 break; > > - =A0 =A0case INTERNALVAR_SCALAR: > - =A0 =A0 =A0if (!var->u.scalar.type) > + =A0 =A0case INTERNALVAR_INTEGER: > + =A0 =A0 =A0if (!var->u.integer.type) > =A0 =A0 =A0 =A0val =3D value_from_longest (builtin_type (gdbarch)->builti= n_int, > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 var->u.= scalar.val.l); > - =A0 =A0 =A0else if (TYPE_CODE (var->u.scalar.type) =3D=3D TYPE_CODE_INT) > - =A0 =A0 =A0 val =3D value_from_longest (var->u.scalar.type, var->u.scal= ar.val.l); > - =A0 =A0 =A0else if (TYPE_CODE (var->u.scalar.type) =3D=3D TYPE_CODE_PTR) > - =A0 =A0 =A0 val =3D value_from_pointer (var->u.scalar.type, var->u.scal= ar.val.a); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 var->u.= integer.val); > =A0 =A0 =A0 else > - =A0 =A0 =A0 =A0internal_error (__FILE__, __LINE__, "bad type"); > + =A0 =A0 =A0 val =3D value_from_longest (var->u.integer.type, var->u.int= eger.val); > + =A0 =A0 =A0break; > + > + =A0 =A0case INTERNALVAR_POINTER: > + =A0 =A0 =A0val =3D value_from_pointer (var->u.pointer.type, var->u.poin= ter.val); > =A0 =A0 =A0 break; > > =A0 =A0 case INTERNALVAR_STRING: > @@ -1145,14 +1151,9 @@ get_internalvar_integer (struct internal > =A0{ > =A0 switch (var->kind) > =A0 =A0 { > - =A0 =A0case INTERNALVAR_SCALAR: > - =A0 =A0 =A0if (var->u.scalar.type =3D=3D NULL > - =A0 =A0 =A0 =A0 || TYPE_CODE (var->u.scalar.type) =3D=3D TYPE_CODE_INT) > - =A0 =A0 =A0 { > - =A0 =A0 =A0 =A0 *result =3D var->u.scalar.val.l; > - =A0 =A0 =A0 =A0 return 1; > - =A0 =A0 =A0 } > - =A0 =A0 =A0/* Fall through. =A0*/ > + =A0 =A0case INTERNALVAR_INTEGER: > + =A0 =A0 =A0*result =3D var->u.integer.val; > + =A0 =A0 =A0return 1; > > =A0 =A0 default: > =A0 =A0 =A0 return 0; > @@ -1224,15 +1225,15 @@ set_internalvar (struct internalvar *var > =A0 =A0 =A0 break; > > =A0 =A0 case TYPE_CODE_INT: > - =A0 =A0 =A0new_kind =3D INTERNALVAR_SCALAR; > - =A0 =A0 =A0new_data.scalar.type =3D value_type (val); > - =A0 =A0 =A0new_data.scalar.val.l =3D value_as_long (val); > + =A0 =A0 =A0new_kind =3D INTERNALVAR_INTEGER; > + =A0 =A0 =A0new_data.integer.type =3D value_type (val); > + =A0 =A0 =A0new_data.integer.val =3D value_as_long (val); > =A0 =A0 =A0 break; > > =A0 =A0 case TYPE_CODE_PTR: > - =A0 =A0 =A0new_kind =3D INTERNALVAR_SCALAR; > - =A0 =A0 =A0new_data.scalar.type =3D value_type (val); > - =A0 =A0 =A0new_data.scalar.val.a =3D value_as_address (val); > + =A0 =A0 =A0new_kind =3D INTERNALVAR_POINTER; > + =A0 =A0 =A0new_data.pointer.type =3D value_type (val); > + =A0 =A0 =A0new_data.pointer.val =3D value_as_address (val); > =A0 =A0 =A0 break; > > =A0 =A0 default: > @@ -1269,9 +1270,9 @@ set_internalvar_integer (struct internal > =A0 /* Clean up old contents. =A0*/ > =A0 clear_internalvar (var); > > - =A0var->kind =3D INTERNALVAR_SCALAR; > - =A0var->u.scalar.type =3D NULL; > - =A0var->u.scalar.val.l =3D l; > + =A0var->kind =3D INTERNALVAR_INTEGER; > + =A0var->u.integer.type =3D NULL; > + =A0var->u.integer.val =3D l; > =A0} > > =A0void > @@ -1426,10 +1427,16 @@ preserve_one_internalvar (struct interna > =A0{ > =A0 switch (var->kind) > =A0 =A0 { > - =A0 =A0case INTERNALVAR_SCALAR: > - =A0 =A0 =A0if (var->u.scalar.type && TYPE_OBJFILE (var->u.scalar.type) = =3D=3D objfile) > - =A0 =A0 =A0 var->u.scalar.type > - =A0 =A0 =A0 =A0 =3D copy_type_recursive (objfile, var->u.scalar.type, c= opied_types); > + =A0 =A0case INTERNALVAR_INTEGER: > + =A0 =A0 =A0if (var->u.integer.type && TYPE_OBJFILE (var->u.integer.type= ) =3D=3D objfile) > + =A0 =A0 =A0 var->u.integer.type > + =A0 =A0 =A0 =A0 =3D copy_type_recursive (objfile, var->u.integer.type, = copied_types); > + =A0 =A0 =A0break; > + > + =A0 =A0case INTERNALVAR_POINTER: > + =A0 =A0 =A0if (TYPE_OBJFILE (var->u.pointer.type) =3D=3D objfile) > + =A0 =A0 =A0 var->u.pointer.type > + =A0 =A0 =A0 =A0 =3D copy_type_recursive (objfile, var->u.pointer.type, = copied_types); > =A0 =A0 =A0 break; > > =A0 =A0 case INTERNALVAR_VALUE: > > -- > =A0Dr. Ulrich Weigand > =A0GNU Toolchain for Linux on System z and Cell BE > =A0Ulrich.Weigand@de.ibm.com >