From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20203 invoked by alias); 15 Nov 2006 17:21:11 -0000 Received: (qmail 20193 invoked by uid 22791); 15 Nov 2006 17:21:09 -0000 X-Spam-Check-By: sourceware.org Received: from mail-out3.apple.com (HELO mail-out3.apple.com) (17.254.13.22) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 15 Nov 2006 17:21:00 +0000 Received: from relay8.apple.com (a17-128-113-38.apple.com [17.128.113.38]) by mail-out3.apple.com (8.12.11/8.12.11) with ESMTP id kAFHKfvs026234; Wed, 15 Nov 2006 09:20:41 -0800 (PST) Received: from [17.201.22.244] (unknown [17.201.22.244]) by relay8.apple.com (Apple SCV relay) with ESMTP id 865E7183; Wed, 15 Nov 2006 09:20:41 -0800 (PST) Cc: gdb@sources.redhat.com Message-Id: <0F999BE0-8618-44C4-A924-EE55588784EC@apple.com> From: Jim Ingham To: Vladimir Prus In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes X-Smtp-Server: relay.apple.com Mime-Version: 1.0 (Apple Message framework v854) Subject: Re: MI and anonymous unions Content-Transfer-Encoding: 7bit Date: Wed, 15 Nov 2006 17:21:00 -0000 References: <200611151238.16778.vladimir@codesourcery.com> <20061115145405.GA25212@nevyn.them.org> X-Mailer: Apple Mail (2.854) X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-11/txt/msg00104.txt.bz2 Support for anonymous unions & structures is another of the "things we fixed but haven't submitted back"... We do pretty much what Vladimir suggests, though I use #anon#N for the varobj name: the choice doesn't much matter. We still return a blank expression (since that's really what the There's one other tricky bit 'caused by the fact that you might have more than one anonymous union or structure inside a structure. This wouldn't be a problem, but the varobj code tends to look up structure elements by name, which obviously won't work here. So you have to convert all the code that looks up structure elements to use the index rather than the name. Another of the things we do in our varobj code for C++ is that we look up the dynamic type of objects (the same mechanism that "set print object on" uses, and the value & children we return are based on the dynamic type. As soon as you do that, you really do need a "give me the expression that can recreate this varobj" for child varobj's. Otherwise the MI client needs to get all these dynamic casts right to get down to the proper child, which is a bit of a pain. But it's a generally useful command. We called it "var-info-path- expression" and given a varobj, it returns the expression that if evaluated would result in the same value. Xcode uses this for "show in separate window" actions in the debugger variable view. You can also use the to eliminate the "." for the anonymous structures or unions - though of course the MI client could do this too... Jim On Nov 15, 2006, at 6:58 AM, Vladimir Prus wrote: > > Daniel Jacobowitz wrote: > >> On Wed, Nov 15, 2006 at 12:38:16PM +0300, Vladimir Prus wrote: >>> Traversing it with MI eventually gives: >>> >>> -var-list-children V.public >>> > ^ > done > ,numchild="1",children=[child={name="V.public.",exp="",numchild="1", >>> type="union {...}"}] >>> (gdb) >>> -var-list-children V.public. >>> ^done,numchild="1",children=[ >>> child={name="V.public..public",exp="public",numchild="2"}] >>> (gdb) >>> -var-list-children V.public..public >>> ..... >>> >>> Although this kinda works, I'm pretty sure UI won't be happy about >>> empty >>> expression for a variable object, and if you have two anonymous >>> unions, >>> you can't even address them. >> >> I'm not sure what to do for the empty expression. There's nothing we >> can put there which would act like a named union, since you need one >> less period - hmm, we were just discussing an MI command to recreate >> expressions the other day... >> >> How do people use the exp="" result? Should it be ""? > > KDevelop uses it to construct the full expression, which will > obviously > break. I'm not sure about Eclipse, I think it does the same. > > But given that there's no way to put anything there that can be used > to > recreate expression, I don't see much difference. "" > would work > better if this is to be shown in some UI, I think. > >>> How about using some unique identifier for variable objects >>> corresponding >>> for anonymous unions? Say "@N"? >> >> That sounds reasonable. > > Ok. > > - Volodya >