Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org, samsurfer117@gmail.com
Subject: Re: CYGWIN file input redirection
Date: Mon, 24 Oct 2016 13:24:00 -0000	[thread overview]
Message-ID: <83oa29518t.fsf@gnu.org> (raw)
In-Reply-To: <b1c5558f-bcad-1d3d-09d8-b5e24dfdf868@redhat.com> (message from	Pedro Alves on Mon, 24 Oct 2016 13:36:34 +0100)

> Cc: samsurfer117@gmail.com
> From: Pedro Alves <palves@redhat.com>
> Date: Mon, 24 Oct 2016 13:36:34 +0100
> 
> On 10/22/2016 10:30 AM, Eli Zaretskii wrote:
> > Ping!  Is this OK to push to master, please?
> 
> I think this should have a NEWS entry.  

Yes, I thought about this myself.  Will do.

> Since on Windows, programs are expected to handle redirection
> themselves

??? No, they don't (I believe you thought about wildcard expansion?).
Redirection on Windows shell command line works like on Unix: the
shell invokes the program with standard streams redirected according
to the redirection symbols.  Which is exactly what this code emulates
inside GDB.

> isn't there a chance that this will make it a bit
> harder to debug such redirection code in inferiors that
> do it themselves?  E.g., imagine if you're debugging cmd.exe's
> redirection code.  Or maybe even debugging this new code
> in gdb itself?  Do we need a knob to be able to disable
> this feature?

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?

> 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?

> 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.

Thanks for the review, I will add the missing bits and fixes and
resubmit.


  reply	other threads:[~2016-10-24 13:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-26 14:27 Steve Mucci
2016-09-30 14:06 ` Eli Zaretskii
2016-10-15 11:33   ` Eli Zaretskii
2016-10-15 12:40     ` Eli Zaretskii
2016-10-22  9:31       ` Eli Zaretskii
2016-10-24 12:36         ` Pedro Alves
2016-10-24 13:24           ` Eli Zaretskii [this message]
2016-10-24 13:43             ` Pedro Alves
2016-10-29  9:55               ` MS-Windows file input redirection, v2 Eli Zaretskii
2016-10-29 15:06                 ` Pedro Alves
2016-10-29 15:11                   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83oa29518t.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=samsurfer117@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox