List Info

Thread: Re: stdin




Re: stdin
country flaguser name
Israel
2007-03-14 17:27:19
Joel Brobecker wrote:
>> after launching "gdb program", how may I
invoke the program as if I
>> was actually executing "echo wibble |
program".
>>     
>
> Not tested, but would you be able to put the text you
want to pipe
> into a file, and then do "run <
your_file"?
>
>   
That will work only if

   1. your_file is small enough. I sometimes pipe GBs of
data through pipes.
   2. You don't mind that the behavior of pipes and files is
different
      in some cases. The bug that you hunt might go away due
to this
      difference (like it might disappear by changing an
unrelated
      environment variable - yes I have seen such bugs).
      Also, a program such as 'less' might behave
differently, on
      purpose, when reading from a pipe and not a file.

Another solution:
in (T)CSH: setenv SHELL /bin/zsh
or in (BA)SH: export SHELL=/bin/zsh
Then:
=> gdb /bin/cat
....
(gdb) r < <(echo ok)
ok

What happens here is that <(some command) means that the
command is run, 
its output is written to a pipe. The pipe gets a name (named
pipe or 
through /dev/fd/[0-9]), and that name is used in
(gdb) r < the_name_of_the_pipe

Actual implementation may be different (because '<' does
not require a 
name), but the main idea remains. Anyway, this is a
work-around, not a 
true solution.

Michael


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )