From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21182 invoked by alias); 8 Jan 2008 23:54:55 -0000 Received: (qmail 21174 invoked by uid 22791); 8 Jan 2008 23:54:54 -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; Tue, 08 Jan 2008 23:54:25 +0000 Received: (qmail 22617 invoked from network); 8 Jan 2008 23:54:23 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 8 Jan 2008 23:54:23 -0000 To: Thiago Jung Bauermann Cc: luisgpm@linux.vnet.ibm.com, gdb-patches@sourceware.org Subject: Re: [PATCH] Improve printf DFP support References: <1199798856.22083.9.camel@gargoyle> <1199805546.15225.8.camel@localhost.localdomain> <20080108152919.GA21337@caradoc.them.org> From: Jim Blandy Date: Tue, 08 Jan 2008 23:54:00 -0000 In-Reply-To: <20080108152919.GA21337@caradoc.them.org> (Daniel Jacobowitz's message of "Tue, 8 Jan 2008 10:29:19 -0500") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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: 2008-01/txt/msg00168.txt.bz2 Daniel Jacobowitz writes: > On Tue, Jan 08, 2008 at 01:19:06PM -0200, Thiago Jung Bauermann wrote: >> param_ptr should be a const gdb_byte *, and the cast here should be >> removed. In addition, I believe the use of value_offset here is wrong. >> Other uses of value_offset are to obtain a memory address in the >> inferior address space, not in GDB's. Also, I think that value_contents >> should be used intead of value_contents_all so that the value's >> embedded_offset can be taken into account. > > I believe that you are correct. The value handling is another area of > GDB that could do with some cleaning up; I am not convinced the > multiple offsets dance is necessary... I think the origin of GDB's confusion is that we didn't follow through with any consistent decision about whether a value should act like an instance of its static type or its dynamic type. So value_type (v) is v's static type, but value_address (v) returns the address of the instance of the dynamic type --- thus the need to add value_embedded_offset to it. So, if I were going to take a shot at it, here are the decisions I think would make sense: 1) Use the C++ terminology --- 'static type' and 'dynamic type' --- whereever the distinction needs to be made, instead of 'embedded' and 'enclosing'. For example, value_enclosing_type should be value_dynamic_type. 2) Use the static type as the default for most value_ operations within GDB: - value_type should return the static type. - value_contents should return the contents of the portion of the object corresponding to the static type (i.e. it should have value_embedded_offset added in) - value_contents_all should be called value_dynamic_type_contents 3) Use the dynamic type by default when printing objects. objectprint should be 1 by default. We can count on run-time type information nowadays, right? I don't know how much of this still applies, but this is what I wrote on the topic a long time ago: http://sourceware.org/ml/gdb/2001-05/msg00306.html