From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82104 invoked by alias); 27 May 2019 13:12:51 -0000 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 Received: (qmail 82096 invoked by uid 89); 27 May 2019 13:12:50 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=tee, sends, launches, some_command X-HELO: mail-wm1-f47.google.com Received: from mail-wm1-f47.google.com (HELO mail-wm1-f47.google.com) (209.85.128.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 May 2019 13:12:49 +0000 Received: by mail-wm1-f47.google.com with SMTP id z23so11740102wma.4 for ; Mon, 27 May 2019 06:12:48 -0700 (PDT) Return-Path: Received: from ?IPv6:2001:8a0:f913:f700:4eeb:42ff:feef:f164? ([2001:8a0:f913:f700:4eeb:42ff:feef:f164]) by smtp.gmail.com with ESMTPSA id s15sm5816110wrn.68.2019.05.27.06.12.44 (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 06:12:45 -0700 (PDT) Subject: Re: [RFAv2 4/6] Implement | (pipe) command. To: Philippe Waroquiers , gdb-patches@sourceware.org References: <20190426201108.7489-1-philippe.waroquiers@skynet.be> <20190426201108.7489-5-philippe.waroquiers@skynet.be> <1556951051.1511.14.camel@skynet.be> From: Pedro Alves Message-ID: Date: Mon, 27 May 2019 13:12:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <1556951051.1511.14.camel@skynet.be> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2019-05/txt/msg00588.txt.bz2 On 5/4/19 7:24 AM, Philippe Waroquiers wrote: > On Fri, 2019-05-03 at 19:59 +0100, Pedro Alves wrote: >> On 4/26/19 9:11 PM, Philippe Waroquiers wrote: >>> The pipe command allows to run a GDB command, and pipe its output >>> to a shell command: >>> (gdb) help pipe >>> Send the output of a gdb command to a shell command. >>> Usage: pipe [COMMAND] | SHELL_COMMAND >>> Usage: | [COMMAND] | SHELL_COMMAND >>> Usage: pipe -dX COMMAND X SHELL_COMMAND >>> Usage: | -dX COMMAND X SHELL_COMMAND >>> Executes COMMAND and sends its output to SHELL_COMMAND. >>> If COMMAND contains a | character, the option -dX indicates >>> to use the character X to separate COMMAND from SHELL_COMMAND. >>> With no COMMAND, repeat the last executed command >>> and send its output to SHELL_COMMAND. >>> (gdb) >> >> I think that making "-dX" a single character is a mistake. I'd rather >> make that "-d STRING", so you can use use a string that is much less >> likely to conflict. Like bash herestrings. So a user would be able >> to do: >> >> pipe -d XXXYYYXXX $command | $shell_command >> >> I also think "-dX" without a space in between is very non-gdb-ish. >> In gdb, you kind of either have "-OPT X", or "/OX", which is kind of >> double "--" vs "-" with getopt, except with different leading >> tokens. > > Ok, will change to -d STRING. > Thanks. >>> For example: >>> (gdb) pipe print some_data_structure | grep -B3 -A3 something >>> >>> The pipe character is defined as an alias for pipe command, so that >>> the above can be typed as: >>> (gdb) | print some_data_structure | grep -B3 -A3 something >>> >> >> I get that "it makes sense", but do you see yourself using the "|" command >> in preference to "pipe"? "pipe" can be typed as "pi", which is two >> key strokes as well. Kind of wondering whether the character could be >> saved for something else in the future. I don't have a use in mind, >> just thinking out loud. > Yes, I always use "|" (I even just checked the test to be sure that I > also tested "pipe" and not only "|"). > pip must be used, as pi launches an interactive python. > > Also, "|" allows to do: > (gdb) some_command > ... > (gdb) ||grep something_in_some_command_output > (gdb) ||tee save_some_command_output > > which is better than > (gdb) pip|grep something_in_some_command_output Alright, that does sound clever. Thanks, Pedro Alves