From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8372 invoked by alias); 3 May 2006 23:05:07 -0000 Received: (qmail 8364 invoked by uid 22791); 3 May 2006 23:05:06 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 03 May 2006 23:05:01 +0000 Received: from farnswood.snap.net.nz (p202-124-115-103.snap.net.nz [202.124.115.103]) by viper.snap.net.nz (Postfix) with ESMTP id 827CD755BF7; Thu, 4 May 2006 11:04:58 +1200 (NZST) Received: by farnswood.snap.net.nz (Postfix, from userid 500) id 9B254627ED; Thu, 4 May 2006 00:05:14 +0100 (BST) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17497.14121.225320.477428@farnswood.snap.net.nz> Date: Wed, 03 May 2006 23:05:00 -0000 To: Vladimir Prus Cc: gdb-patches@sources.redhat.com Subject: Re: Variable objects: references formatting X-Mailer: VM 7.19 under Emacs 22.0.50.43 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00024.txt.bz2 > At the moment, when using variable objects to display a struct or a class, > the result of -data-evaluate-expression is "...". However, when displaying > a reference to a class, the result of -data-evaluate-expression is > {}-enclosed list of members and their values. > This disparity does not seem to be reasonable, the attached patch fixes it: > Changelog: > 2006-05-03 Vladimir Prus > varobj.c (c_value_of_variable): Ignore top-level references. > Patch attached. > Thanks, > Volodya There are som many things about this patch that I don't understand: > Index: varobj.c > =================================================================== > RCS file: /cvs/src/src/gdb/varobj.c,v > retrieving revision 1.58 Version 1.59 has been in the repository for over a month, so how come this patch is against 1.58? > diff -u -r1.58 varobj.c > @@ -2055,8 +2219,14 @@ I'm not used to unified diffs, but as insertion appears to be done at the same place why is it not something like: @@ -2055,8 +2055,14 @@ > { > /* BOGUS: if val_print sees a struct/class, it will print out its > children instead of "{...}" */ > + struct type* type = get_type (var); > + /* Strip top-level references. */ > + while (TYPE_CODE (type) == TYPE_CODE_REF) > + { > + type = TYPE_TARGET_TYPE (type); > + } > > - switch (TYPE_CODE (get_type (var))) > + switch (TYPE_CODE (type)) > { > case TYPE_CODE_STRUCT: > case TYPE_CODE_UNION: Most importantly, however, the preamble is about -data-evaluate-expression but AFAICS this doesn't call c_value_of_variable. I have tested the output of -data-evaluate-expression on pointers to typedeffed structures and found that with the latter I get a {}-enclosed list of members with gcc 3.2 and {...} with gcc 4.1. More generally, I have found that gcc 4.1 treats typedefs differently, which leads to errors with variable objects. So clearly I also don't understand how Jim can think that the patch looks good and he'll apply it. -- Nick http://www.inet.net.nz/~nickrob