This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CYGWIN file input redirection


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]