Re: [PATCH] An implementation of pipe to make I/O communication between gdb and shell.

Abhijit Halder
2011-08-02T08:52:46Z

On Tue, Aug 2, 2011 at 12:24 PM, Jan Kratochvil
<jan.kratochvil@redhat.com> wrote:
> On Fri, 29 Jul 2011 15:35:10 +0200, Abhijit Halder wrote:
> On Fri, Jul 29, 2011 at 6:45 PM, Abhijit Halder <abhijit.k.halder@gmail.com> wrote:
>> This is the implementation of a new gdb command, named 'pipe', to make
>> ease of I/O communication between gdb and shell.
>> The syntax of this command is shown as follows:
>> (gdb) pipe [option] <dlim> gdb-cmd <dlim> shell-cmd
>> List of options go with pipe command:
>>  -r   gdb reads output of shell-command from pipe
>>  -w  gdb passes output of a command to shell to process.
>
> When is useful to feed input of a GDB command from some file/process?
> It is IMO useful only for `run' but that will not work this way.
>
Yes. I made this option (-r) available just to make the code
futuristic. To feed input to `run' command, we still need to make
changes in the `run' command interface itself.
>
>>  -    end of gdb option list
>> dlim (delimiter) is a single ASCII character from the set below:
>> {|/\'"`#@!$%^} (We actually can remove this restriction).
>
> I would prefer first to agree on the proper syntax.  I do not find
>
> (gdb) pipe | print 1 | less
>
> to be something a new user will ever try whether it does not work.
>
Can't we introduce a new command and make the user educated to use
that (using documentation and all)? Introducing a new command instead
of using some meta-character (like '|') will give us more flexibility
and that will be ease of maintenance. At the same time this will be
more futuristic.
Pedro Alves mentioned in a similar line: "I think I like this better
than comming up with some syntax that we need to make sure works not
just with C, but all supported languages. (and hope no future
supported language adds a conflict)." I also do think that the
introduction of a new command will be a better approach.
> The original idea of:
>
> (gdb) print 1 | less
>
> looks fine to me as in normal cases one never uses `|' in the GDB commands.
> Still for example for the `echo' GDB command one may use `|' as both the
> `echo' argument and also one may want to pass the output to some shell.
>
We can still support inline pipe (print 1 | less) along with pipe
command. But the question of maintainability will appear.
> If there is pipe `|' GDB could support also redirections '>', '>>', '2>&1',
> '&>', '|&' besides '|' etc.
>
The same can still be very much possible with pipe command in place. For e.g.
(gdb) pipe | thread apply all bt | grep "foobar" 2>&1 | tee myLog.txt

> There could be some disable of the option being enabled by default:
>
> (gdb) set shell-metachars off
>
>
> Thanks,
> Jan
>