From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41625) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAdrh-0004ld-8u for qemu-devel@nongnu.org; Thu, 22 Mar 2012 04:59:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAdrf-0007V3-Fx for qemu-devel@nongnu.org; Thu, 22 Mar 2012 04:59:24 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:52099) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAdrf-0007Up-7T for qemu-devel@nongnu.org; Thu, 22 Mar 2012 04:59:23 -0400 Received: by wibhn6 with SMTP id hn6so391959wib.10 for ; Thu, 22 Mar 2012 01:59:20 -0700 (PDT) Date: Thu, 22 Mar 2012 08:07:53 +0000 From: Stefan Hajnoczi Message-ID: <20120322080753.GA10233@stefanha-thinkpad.localdomain> References: <20120313200235.24179.63987.stgit@ginnungagap.bsc.es> <20120313200332.24179.78152.stgit@ginnungagap.bsc.es> <87obrrgyoc.fsf@ginnungagap.bsc.es> <87pqc79km7.fsf@ginnungagap.bsc.es> <87pqc6ujrq.fsf@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87pqc6ujrq.fsf@ginnungagap.bsc.es> Subject: Re: [Qemu-devel] [PATCH 10/12] trace: [tracetool] Automatically establish available backends and formats List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?Llu=EDs?= Vilanova Cc: harsh@linux.vnet.ibm.com, qemu-devel@nongnu.org, aneesh.kumar@linux.vnet.ibm.com On Wed, Mar 21, 2012 at 03:10:49PM +0100, Lluís Vilanova wrote: > Stefan Hajnoczi writes: > [...] > >> Maybe this would work nice for everybody: > >> > >> tracetool.py                  # main program (just parse cmdline opts and call tracetool module) > >> tracetool/__init__.py         # common boilerplate code (e.g., event parsing and call dispatching) > >> tracetool/format/__init__.py  # format auto-registration/lookup code > >> tracetool/format/h.py         # code for the 'h' format > >>                              # __doc__           [mandatory, format description] > >>                              # def begin(events) [optional] > >>                              # def end(events)   [optional] > >> tracetool/backend/__init__.py # backend auto-registration/lookup code > >> tracetool/backend/simple.py   # code for the 'simple' backend > >>                              # __doc__            [mandatory, backend description] > >>                              # PUBLIC = [True|False] [optional, > >>                              #                        defaults to False, > >>                              #                        indicates it's listed on --list-backends] > >>                              # def format(events) [optional, > >>                              #                     backend-specific code for given format, > >>                              #                     implicitly indicates format compatibility] > > > Let's call this function backend.generate(events) instead of "format" > > since we already use that term and it's a Python builtin too. This is > > a code generation function. > > Maybe I wasn't clear. I meant that for tracetool/backend/simple.py to work with > the format 'h', it must have the following routine: > > def h (events): > ... > > That is, there must exist a routine with the same name of the format (with '-' > replaced with '_', when necessary) for the backend to be compatible with that > format. Ah, yes. That makes sense, I misunderstood. Stefan