From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16721 invoked by alias); 10 Jun 2010 20:55:06 -0000 Received: (qmail 16710 invoked by uid 22791); 10 Jun 2010 20:55:05 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 10 Jun 2010 20:54:55 +0000 Received: from wpaz17.hot.corp.google.com (wpaz17.hot.corp.google.com [172.24.198.81]) by smtp-out.google.com with ESMTP id o5AKspD8027832 for ; Thu, 10 Jun 2010 13:54:52 -0700 Received: from pvc21 (pvc21.prod.google.com [10.241.209.149]) by wpaz17.hot.corp.google.com with ESMTP id o5AKsSdY000543 for ; Thu, 10 Jun 2010 13:54:51 -0700 Received: by pvc21 with SMTP id 21so199330pvc.23 for ; Thu, 10 Jun 2010 13:54:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.4.31 with SMTP id 31mr526792wfd.255.1276203290628; Thu, 10 Jun 2010 13:54:50 -0700 (PDT) Received: by 10.141.125.8 with HTTP; Thu, 10 Jun 2010 13:54:49 -0700 (PDT) In-Reply-To: References: Date: Thu, 10 Jun 2010 20:55:00 -0000 Message-ID: Subject: Re: RFA: add to_string argument to gdb.execute From: Doug Evans To: Tom Tromey Cc: gdb-patches@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-06/txt/msg00253.txt.bz2 On Thu, Jun 10, 2010 at 1:26 PM, Tom Tromey wrote: > I plan to check this in. =A0It needs a doc review. > > This adds a to_string argument to gdb.execute, so you can capture > command output in a python string. > > I've gone back and forth on how I wanted to implement this idea, but in > the end I settled on this approach as very simple and useful. > > This patch also adds keyword arguments to gdb.execute. =A0I think our rule > should be that any function with 2 or more arguments should take keyword > arguments; we violate this in a couple of places. > > There is still room for a bigger change, involving structured output > from gdb. =A0My plan there is to expose MI commands to Python, and make a > new kind of ui_out that creates Python objects. =A0I think this approach > has several nice points: we know it will be fairly complete (because MI > is), and we already have documentation. This feels like a with-output-to-string kind-of-problem. i.e. the wrapping of collecting the output to a string belongs at a higher level. Scheme example: (define x (with-output-to-string (lambda () (display "foo")))) That way one can wrap anything and have all the gdb output collected without having to modify all the individual gdb.execute calls inside. Dunno if it's as easy to implement though.