From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 557 invoked by alias); 30 Sep 2010 08:29:47 -0000 Received: (qmail 547 invoked by uid 22791); 30 Sep 2010 08:29:45 -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-yx0-f169.google.com (HELO mail-yx0-f169.google.com) (209.85.213.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 30 Sep 2010 08:29:40 +0000 Received: by yxk8 with SMTP id 8so884555yxk.0 for ; Thu, 30 Sep 2010 01:29:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.37.130 with SMTP id x2mr2087965qcd.194.1285835378744; Thu, 30 Sep 2010 01:29:38 -0700 (PDT) Received: by 10.229.19.19 with HTTP; Thu, 30 Sep 2010 01:29:38 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Sep 2010 08:29: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-09/txt/msg00160.txt.bz2 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 like= 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 { int flags; clazz *cls; u8 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 that 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 return 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' :) Cheers /Joel