From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21418 invoked by alias); 10 Jan 2010 14:16:37 -0000 Received: (qmail 21402 invoked by uid 22791); 10 Jan 2010 14:16:36 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail-px0-f175.google.com (HELO mail-px0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 10 Jan 2010 14:16:32 +0000 Received: by pxi5 with SMTP id 5so15329908pxi.12 for ; Sun, 10 Jan 2010 06:16:31 -0800 (PST) MIME-Version: 1.0 Received: by 10.142.56.7 with SMTP id e7mr3559042wfa.191.1263132991120; Sun, 10 Jan 2010 06:16:31 -0800 (PST) In-Reply-To: <20100110140029.GF2007@adacore.com> References: <20100106075757.GF24777@adacore.com> <20100109105557.GA2007@adacore.com> <20100110054328.GD2007@adacore.com> <20100110140029.GF2007@adacore.com> From: Hui Zhu Date: Sun, 10 Jan 2010 14:16:00 -0000 Message-ID: Subject: Re: [RFC] Let "gcore" command accept a suffix argument To: Joel Brobecker Cc: Stan Shebs , Tom Tromey , Stan Shebs , Michael Snyder , gdb-patches ml , Eli Zaretskii 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-01/txt/msg00225.txt.bz2 You are good on it. Make a new patch is more easy than make me clear with this idea. :) Thanks, Hui On Sun, Jan 10, 2010 at 22:00, Joel Brobecker wrote: >> But I think we have know the type of the val that we want output, the >> string we want it as string, the number we want it to be number. >> Are you sure we need point out the type of val to be output? >> >> And this idea is out of my ability. =A0Sorry about it. > > If you could have a look at how the "printf" command is implemented, > you might be surprised as to how easy this task might be. =A0For someone > who tackled the really complex project of grafting process record onto > GDB, I sincerely think that this should nearly be a no-brainer for you: > > =A01. Extract out the entire contents of the printf_command implementation > =A0 =A0 into a separate function. Let's call it ui_printf: > > =A0 =A0 =A0 void > =A0 =A0 =A0 ui_printf (char *args, ui_file *stream) > > =A02. Adjust the body so that all the printf/puts, etc, basically anything > =A0 =A0 printing on stdout, are replace by equivalent calls that print in > =A0 =A0 the given ui_file *stream; > > =A03. Implement the body of printf_command by simply calling this new > =A0 =A0 function with gdb_stdout as the ui_file; > > =A0 =A0 =A0 printf_command (char *args, int from_tty) > =A0 =A0 =A0 { > =A0 =A0 =A0 =A0 ui_printf (args, gdb_stout); > =A0 =A0 =A0 } > > =A04. Implement the eval function roughly like so: > > =A0 =A0 =A0 =A0eval_command (char *args, int from_tty) > =A0 =A0 =A0 =A0{ > =A0 =A0 =A0 =A0 =A0struct ui_file *ui_out =3D mem_fileopen (); > =A0 =A0 =A0 =A0 =A0char *expanded; > =A0 =A0 =A0 =A0 =A0struct cleanup *old_chain; > > =A0 =A0 =A0 =A0 =A0ui_printf (args, ui_out); =A0// That's the new functio= n extracted > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /= / from printf_command, which prints > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /= / in a ui_file instead of stdout. > =A0 =A0 =A0 =A0 =A0expanded =3D ui_file_xstrdup (ui_out, NULL); > =A0 =A0 =A0 =A0 =A0old_chain =3D make_cleanup (xfree, expanded); > =A0 =A0 =A0 =A0 =A0execute_command (expanded, from_tty); > =A0 =A0 =A0 =A0 =A0do_cleanups (old_chain); > =A0 =A0 =A0 =A0} > > -- > Joel >