From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20751 invoked by alias); 19 Sep 2008 22:29:33 -0000 Received: (qmail 20743 invoked by uid 22791); 19 Sep 2008 22:29:33 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 19 Sep 2008 22:28:57 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 057D42A965C; Fri, 19 Sep 2008 18:28:55 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id eGWEV21AZplT; Fri, 19 Sep 2008 18:28:54 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id C0EA92A964B; Fri, 19 Sep 2008 18:28:54 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 9D08FE7ACD; Fri, 19 Sep 2008 15:28:52 -0700 (PDT) Date: Fri, 19 Sep 2008 22:29:00 -0000 From: Joel Brobecker To: Jan Kratochvil Cc: Tom Tromey , gdb-patches@sourceware.org Subject: Re: [patch] static_kind -> bit0, bit1 [Re: [gdb] Fortran dynamic arrays] Message-ID: <20080919222852.GB23372@adacore.com> References: <20080818111120.GE16894@adacore.com> <200808181553.m7IFrG3w005270@d12av02.megacenter.de.ibm.com> <48A59B3C.9050801@net-b.de> <20080818111120.GE16894@adacore.com> <20080907115637.GA12939@host0.dyn.jankratochvil.net> <20080908172701.GA18549@host0.dyn.jankratochvil.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080908172701.GA18549@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.4.2.2i 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: 2008-09/txt/msg00427.txt.bz2 > Both before and it gets a bit worse after. There should be a union with > fields for each very specific TYPE_CODE_*. I would tend to agree, but I haven't thought about it much. I might be biased by the fact that Ada's use of variant record is relatively common. For instance, our structure implemented in Ada might roughly look like this: type GDB_Type_Kind is (Type_Code_Enum, Type_Code_Range, Type_Code_Array, ... -- All possible kinds of types. type GDB_Type (Kind : GDB_Type_Kind) is Boolean : Stub; Boolean : Incomplete; -- ... Any other field that's common to all types case Kind is when Type_Code_Enum => Enumerates : List_Of_Enumerates; when Type_Code_Range | Type_Code_Int => Low, High : Bound_Type; when Type_Code_Array => Element_Type : GDB_Type_Pointer; Index : Range_Type_Pointer; when ... => [etc] As you suggest, this is easily achievable in C as well by using unions, with the one difference is that Ada does some access check and makes sure that we access fields that are consistent with the discriminant (field named "Kind" in the example above). I think that this would help clarify the whole structure, and tell us what is and what is not used for each kind of type. But I am not sure of the drawbacks... For sure this would be a pretty significant change througout GDB, but maybe an interesting one. (that was my windy way of saying: I think I agree) -- Joel