From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30127 invoked by alias); 9 Sep 2003 04:51:45 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 30119 invoked from network); 9 Sep 2003 04:51:43 -0000 Received: from unknown (HELO localhost.redhat.com) (65.49.0.121) by sources.redhat.com with SMTP; 9 Sep 2003 04:51:43 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id BC5972B8B; Tue, 9 Sep 2003 00:51:41 -0400 (EDT) Message-ID: <3F5D5C5D.4070809@redhat.com> Date: Tue, 09 Sep 2003 04:51:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jim Blandy Cc: Daniel Jacobowitz , Mark Kettenis , gdb@sources.redhat.com Subject: Re: [RFC] Register sets References: <200308232249.h7NMnvhh090154@elgar.kettenis.dyndns.org> <20030824164347.GA17520@nevyn.them.org> <200308252234.h7PMYqFu001245@elgar.kettenis.dyndns.org> <3F4B8173.1000302@redhat.com> <20030826165547.GA22836@nevyn.them.org> <86he3xrkjb.fsf@elgar.kettenis.dyndns.org> <20030904125514.GA2577@nevyn.them.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-09/txt/msg00110.txt.bz2 > Daniel Jacobowitz writes: > >> struct regset >> { >> void (*supply_regset)(struct regcache *, const void *, size_t, int); >> void (*read_regset)(struct regcache *, void *, size_t, int); >> }; > > > If you want to allow people to define regset formats via the CLI, it > seems to me you probably want some kind of closure argument in there, > like this: > > struct regset > { > /* Always pass this to the supply_regset and read_regset > functions below as their first argument. */ > void *closure; > void (*supply_regset)(void *closure, > struct regcache *, const void *, size_t, int); > void (*read_regset)(void *closure, > struct regcache *, void *, size_t, int); > }; > > This gives you the hook you need to have a single function for all > CLI-defined regsets, interpreting the layout the user supplies to the > CLI command. Er, this isn't a closure (at least not in the sense specified on bfd@). Rather this is an object and so might as well be implemented in more of an object style - pass the "struct regset" as the first parameter. enjoy, Andrew