From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7525 invoked by alias); 13 Aug 2011 18:10:15 -0000 Received: (qmail 7511 invoked by uid 22791); 13 Aug 2011 18:10:13 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,TW_TD X-Spam-Check-By: sourceware.org Received: from mail-ey0-f169.google.com (HELO mail-ey0-f169.google.com) (209.85.215.169) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Aug 2011 18:09:59 +0000 Received: by eye22 with SMTP id 22so2655199eye.0 for ; Sat, 13 Aug 2011 11:09:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.105.207 with SMTP id u15mr740082ebo.140.1313258997751; Sat, 13 Aug 2011 11:09:57 -0700 (PDT) Received: by 10.213.31.202 with HTTP; Sat, 13 Aug 2011 11:09:57 -0700 (PDT) In-Reply-To: <20110813172342.GA22058@host1.jankratochvil.net> References: <201108041029.37721.pedro@codesourcery.com> <20110805082947.GA5020@host1.jankratochvil.net> <20110813172342.GA22058@host1.jankratochvil.net> Date: Sat, 13 Aug 2011 18:10:00 -0000 Message-ID: Subject: Re: [PATCH] An implementation of pipe to make I/O communication between gdb and shell. From: Abhijit Halder To: Jan Kratochvil Cc: Pedro Alves , gdb-patches@sourceware.org, Sergio Durigan Junior , Tom Tromey 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: 2011-08/txt/msg00275.txt.bz2 On Sat, Aug 13, 2011 at 10:53 PM, Jan Kratochvil wrote: > On Fri, 05 Aug 2011 11:41:09 +0200, Abhijit Halder wrote: >> On Fri, Aug 5, 2011 at 1:59 PM, Jan Kratochvil wrote: >> > I would prefer to also redirect gdb_stderr, gdb_stdlog, gdb_stdtarg and >> > gdb_stdtargerr like set_logging_redirect does. =A0This is like if one >> > uses |& instead of | . =A0I understand someone may have a different op= inion. >> > In such case there even may be some option of the command pipe for it. >> I understand your point here, but this will break out very basic >> assumption that delimiter is single character. >> Can we skip this at this point? Or simply we can redirect gdb_stderror >> to pipe as in most of the cases that will be equivalent to gdb_stdout. >> (My understanding was that the error from gdb can be captured anyway >> by error logging mechanism, the use-case of using pipe, I believe, is >> when the gdb output is huge and one wants to process that huge >> output.) Please suggest. > > The reason for redirecting also errors I find that when you type: > > $ ls /tmp bar|less > > you happilly see the content of /tmp but the message > > ls: cannot access bar: No such file or directory > > gets completely lost. =A0This is why I find |& safer for normal use cases. > > (One can argue also the other way, that standard shell pipe | also does n= ot > automatically redirect stderr, though.) > I have also redirected the gdb_stderr to pipe. + fp =3D stdio_fileopen (pipe->handle); + make_cleanup_ui_file_delete (fp); + make_cleanup_restore_ui_file (&gdb_stdout); + make_cleanup_restore_ui_file (&gdb_stderr); + make_cleanup_restore_ui_file (&gdb_stdlog); + make_cleanup_restore_ui_file (&gdb_stdtarg); + make_cleanup_restore_ui_file (&gdb_stdtargerr); + + if (ui_out_redirect (uiout, fp) < 0) + warning (_("Current output protocol does not support redirection")); + else + make_cleanup_ui_out_redirect_pop (uiout); + + gdb_stdout =3D fp; + gdb_stderr =3D fp; + gdb_stdlog =3D fp; + gdb_stdtarg =3D fp; + gdb_stdtargerr =3D fp; + execute_command (pipe->gdb_cmd, from_tty); But the error is still coming on screen. (gdb) pipe | print xxx | vim - Vim: Reading from stdin... No symbol table is loaded. Use the "file" command. (gdb) pipe | print 2 | vim - Vim: Reading from stdin... (gdb) > > Thanks, > Jan >