From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17579 invoked by alias); 12 Oct 2010 11:58:43 -0000 Received: (qmail 17564 invoked by uid 22791); 12 Oct 2010 11:58:42 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-qy0-f169.google.com (HELO mail-qy0-f169.google.com) (209.85.216.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Oct 2010 11:58:37 +0000 Received: by qyk7 with SMTP id 7so755172qyk.0 for ; Tue, 12 Oct 2010 04:58:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.228.15 with SMTP id jc15mr6261763qcb.31.1286884715510; Tue, 12 Oct 2010 04:58:35 -0700 (PDT) Received: by 10.229.19.19 with HTTP; Tue, 12 Oct 2010 04:58:35 -0700 (PDT) In-Reply-To: References: Date: Tue, 12 Oct 2010 11:58:00 -0000 Message-ID: Subject: Re: Extending gdb.Value From: =?ISO-8859-1?Q?Joel_Borggr=E9n=2DFranck?= To: Tom Tromey Cc: gdb@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2010-10/txt/msg00036.txt.bz2 On Thu, Sep 30, 2010 at 10:29 AM, Joel Borggr=E9n-Franck wrote: > On Wed, Sep 29, 2010 at 11:23 PM, Tom Tromey wrote: >>>>>>> "Joel" =3D=3D Joel Borggr=E9n-Franck writes: >> >> Joel> So I noticed today that I cant extend gdb.Value: >> >> Joel> The fix for this is trivial: >> [...] >> >> Joel> I'm convinced this is a good idea. I got lots of stuff I would lik= e to >> Joel> add on top of gdb.Value that only makes sense in the context of >> Joel> specific applications. >> >> Joel> So how can I test that this doesn't break anything? And which other >> Joel> python types are suitable for being bases. Why not add all of them? >> >> I think the reason things are the way they are is due to a mix of >> ignorance and conservatism. =A0That is, we probably didn't think about it >> early on (I know I didn't), and also we've generally tried to reduce our >> exposure to "weird stuff" in case we need to make changes. >> >> Could you elaborate on the uses to which you intend to put this? >> That would be helpful. >> > > The first use case is while debugging a virtual machine for a class-based > language. There are a lot of data on the heap of the target language that > to gdb looks like: > > struct heapObj { > =A0int flags; > =A0clazz *cls; > =A0u8 first_byte_of_fields[1]; > } > > concatenated with a chunk of fields that only make sense with help from > data stored in cls. For example, the length of this object can't be > determined without looking it up through cls. > > I would like to abstract over this by creating a subclass of gdb.Value th= at > overrides __getitem__ to do the lookup in the vm's datastructures so that > the heap-objects behaves just the same as regular gdb.Values. IE > my_heap_obj['foo'] should lookup the offset of 'foo' through cls, and ret= urn > a new HeapObject that represents the field 'foo'. > > Further, this VM doesn't follow the same stack layout conventions as gcc, > so I can easily see the need to extend gdb.Frame to build a bt and frame > iterator that works. But I'll get back to that later. > > Also, why not? Closed/final classes should IMO be avoided in favor of > saying 'hey you can do this, but I wont clean up the mess you create' =A0= :) > Tom, Was this the kind of use case you wanted? Cheers /Joel