From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9505 invoked by alias); 21 Jun 2010 21:40:00 -0000 Received: (qmail 9495 invoked by uid 22791); 21 Jun 2010 21:39:59 -0000 X-SWARE-Spam-Status: No, hits=-5.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 21 Jun 2010 21:39:55 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5LLdILK006199 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 21 Jun 2010 17:39:18 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o5LLdIVq019703; Mon, 21 Jun 2010 17:39:18 -0400 Received: from opsy.redhat.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o5LLdGco007997; Mon, 21 Jun 2010 17:39:17 -0400 Received: by opsy.redhat.com (Postfix, from userid 500) id 7827B3792C6; Mon, 21 Jun 2010 15:39:16 -0600 (MDT) From: Tom Tromey To: Hui Zhu Cc: Joel Brobecker , Stan Shebs , Stan Shebs , Michael Snyder , gdb-patches ml , Eli Zaretskii Subject: Re: [RFC] Let "gcore" command accept a suffix argument References: <4B3BEDCC.9040103@earthlink.net> <20100106075757.GF24777@adacore.com> <20100109105557.GA2007@adacore.com> <20100110054328.GD2007@adacore.com> <20100110140029.GF2007@adacore.com> Reply-To: tromey@redhat.com Date: Mon, 21 Jun 2010 21:40:00 -0000 In-Reply-To: (Hui Zhu's message of "Mon, 21 Jun 2010 23:04:30 +0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/msg00465.txt.bz2 >>>>> ">" == Hui Zhu writes: >> static void >> -printf_command (char *arg, int from_tty) >> +ui_printf_maybe_filtered (char *arg, struct ui_file *stream, int filter) I don't think you really need the 'filter' argument. fprintf_filtered will actually work unfiltered unless printing to gdb_stdout. (One of several bad things about this API -- but we already rely on it.) I think this argument uglifies the code quite a bit. >> +static void >> +eval_command (char *arg, int from_tty) >> +{ >> + struct ui_file *ui_out = mem_fileopen (); >> + char *expanded; >> + struct cleanup *old_chain; >> + >> + ui_printf_maybe_filtered (arg, ui_out, 0); >> + expanded = ui_file_xstrdup (ui_out, NULL); >> + old_chain = make_cleanup (xfree, expanded); >> + execute_command (expanded, from_tty); >> + do_cleanups (old_chain); You need a cleanup in there to destroy the new ui_out. >> + add_com ("eval", no_class, eval_command, _("\ >> +Call command with variable.")); >> } This needs a better doc string. I think this approach is good overall. It needs a documentation patch, a NEWS entry, and some tests. Tom