From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6831 invoked by alias); 25 Nov 2008 08:48:30 -0000 Received: (qmail 6764 invoked by uid 22791); 25 Nov 2008 08:48:30 -0000 X-Spam-Check-By: sourceware.org Received: from mx2.redhat.com (HELO mx2.redhat.com) (66.187.237.31) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 25 Nov 2008 08:47:54 +0000 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id mAP8lQZ1010614; Tue, 25 Nov 2008 03:47:26 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id mAP8lPSA015861; Tue, 25 Nov 2008 03:47:25 -0500 Received: from opsy.redhat.com (vpn-12-223.rdu.redhat.com [10.11.12.223]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id mAP8lKRq020514; Tue, 25 Nov 2008 03:47:25 -0500 Received: by opsy.redhat.com (Postfix, from userid 500) id 4E43D482B4; Tue, 25 Nov 2008 01:47:20 -0700 (MST) To: Jerome Guitton Cc: gdb-patches@sourceware.org Subject: Re: [RFC] "lazily" allocate the raw content of lazy values References: <20081124144810.GA90681@adacore.com> From: Tom Tromey Reply-To: tromey@redhat.com Date: Tue, 25 Nov 2008 17:59:00 -0000 In-Reply-To: <20081124144810.GA90681@adacore.com> (Jerome Guitton's message of "Mon\, 24 Nov 2008 15\:48\:10 +0100") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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-11/txt/msg00685.txt.bz2 >>>>> "Jerome" == Jerome Guitton writes: Jerome> Here, an elegant solution would be to manipulate lazy values instead Jerome> of references [...] Very nice background explanation, thanks. Jerome> +/* Actual contents of the value. For use of this value; setting it Jerome> + uses the stuff defined in struct value. Target byte-order. We force it Jerome> + to be aligned properly for any possible value. Note that a value therefore Jerome> + extends beyond what is declared here. */ Jerome> + Jerome> +union value_aligner Jerome> +{ Jerome> + gdb_byte contents[1]; Jerome> + DOUBLEST force_doublest_align; Jerome> + LONGEST force_longest_align; Jerome> + CORE_ADDR force_core_addr_align; Jerome> + void *force_pointer_align; Jerome> +}; The purpose of this union is just to force alignment of the 'contents' field, so that we can stuff any data type into it without worrying. Once we're no longer using the struct hack to store the bits, there is no need for this union. Jerome> + union value_aligner *content; I think you might as well make this "gdb_byte *contents" now. I think it would be nice to have a test case showing the Ada problem. This would help prevent mistakes if we ever want to change the value representation again. Would this be hard to do? After that I only have nits. Jerome> +void Jerome> +value_free (struct value *val) Jerome> +{ Jerome> + if (val && val->content) No need to check val->content, xfree does that. Jerome> struct value * Jerome> value_change_enclosing_type (struct value *val, struct type *new_encl_type) You were right, value_change_enclosing_type is much simpler now :-) Jerome> if (value_lazy (arg1)) Jerome> - set_value_lazy (v, 1); Jerome> + { Jerome> + v = allocate_value_lazy (value_enclosing_type (arg1)); Jerome> + } In the GNU style, a single statement like this does not have braces around it. There are a few instances of this in the patch. Tom