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: Windows semihosting (remote-fileio) fix for console reads


On Sun, Jun 11, 2006 at 12:28:33AM +0300, Eli Zaretskii wrote:
> That rings a bell, but I'll need to dig deep into old files to find
> out the details.  In the meantime, could you please post a short test
> program that demonstrates this failure?

I'm afraid I don't have one; I tested by changing the size of the read
performed by remote-fileio, which requires a remote target and stub to
reproduce.

It turned out to be trivial to reproduce it manually though.  Here.
Running this under Cygwin works (there, stdin is a pipe); this includes
running it from a Cygwin bash in a command terminal.  But if you
Start->Run cmd.exe, and then run the test program, read will fail.

[Interestingly, if I use a stack buffer and it's far too small for the
read request, Cygwin returns EINVAL... nice trick.]

#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>

static char buf[32768];

int
main (int argc, char **argv)
{
  int ret, err;

  sprintf (buf, "Type something:\n");
  write (1, buf, strlen (buf));
  errno = 0;
  ret = read (0, buf, 26609);
  err = errno;

  sprintf (buf, "read returned %d, errno %d\n", ret, err);
  write (1, buf, strlen (buf));
  return 0;
}

-- 
Daniel Jacobowitz
CodeSourcery


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