This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: CYGWIN file input redirection
On 10/24/2016 02:24 PM, Eli Zaretskii wrote:
> I'm not sure I see the problem. If you debug GDB's redirection code,
> you will probably not redirect that GDB's standard streams, right?
> IOW, you would
>
> > gdb ./gdb.exe
> (top-gdb) run foo.exe
> (gdb) run < bar > baz
>
> Right? Or did you mean something else?
OK. I guess I was confused. So let's just forget my comment.
>
>> It'd be nice to add comments mentioning what syntax works and doesn't
>> work. Is there something users should know about syntax, that
>> should be added to the manual?
>
> The code is supposed to support everything cmd.exe supports, and
> nothing else. Ah, I see I didn't implement the likes of "2>&1". Will
> do.
>
> The only thing beyond what cmd.exe supports is that one can use
> Unix-style forward slashes in redirected file names, which comes in
> handy because GDB's file-name completion helps. Not sure if this
> should be in the manual. WDYT?
Seems fine not to mention that, since gdb supports forward slashes
throughout, anyway. If it didn't support them here probably someone
would call it a bug.
>
>> Ideally some test would "prove" this all works, which would
>> also make it possible to more confidently change the implementation
>> later on if we find it necessary. It's been years since I'd tried to
>> run the testsuite for mingw gdb (under cygwin/msys/msys2 of course)
>> and I have no idea whether people are doing that nowadays. I have
>> the impression that maybe no one is.. And then, I can't seem to
>> find any existing test that exercises redirection, even
>> on Unix... :-/ Oh well.
>
> Right. I don't have a setup for running the test suite. I did, of
> course, test the code manually.
>
>>>> + if (inferior_io_terminal
>>>> + && !(inf_stdin != INVALID_HANDLE_VALUE
>>>> + && inf_stdout != INVALID_HANDLE_VALUE
>>>> + && inf_stderr != INVALID_HANDLE_VALUE))
>>
>> I find these double-negatives hard to read. I'd suggest:
>>
>> if (inferior_io_terminal
>> && (inf_stdin == INVALID_HANDLE_VALUE
>> || inf_stdout == INVALID_HANDLE_VALUE
>> || inf_stderr == INVALID_HANDLE_VALUE))
>
> Interesting, I actually find the latter harder to grasp. The former
> says "if not all of the handles are valid". I can add a macro
> VALID_HANDLE, if that would help.
Leave it be as you had it then. It was just a minor suggestion.
>
> Thanks for the review, I will add the missing bits and fixes and
> resubmit.
Thanks,
Pedro Alves