Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] sim updates which fix some fileio.exp failures for v850-elf
@ 2011-03-11 22:17 Kevin Buettner
  2011-03-22  9:34 ` Kevin Buettner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Kevin Buettner @ 2011-03-11 22:17 UTC (permalink / raw)
  To: gdb-patches

The patch below, in conjunction with a corresponding patch to libgloss
and newlib, fixes several failures in the gdb.base/fileio.exp test.

The patch to newlib can be found here:

http://sourceware.org/ml/newlib/2011/msg00095.html

Note that the newlib changes are needed for regenerating nltvals.def.  I
didn't post the regenerated file below as it's quite large.  (There are
some whitespace differences which make it look a lot bigger than it really
is.  A more meaningful patch can be obtained by use of diff's -w switch.
I'd be willing to post that diff if anyone's interested.)

This patch, in conjunction with a small patch that I committed for the
sim a few weeks ago, fix the following failures:

FAIL: gdb.base/fileio.exp: Creating already existing file returns EEXIST
FAIL: gdb.base/fileio.exp: Open directory for writing returns EISDIR
FAIL: gdb.base/fileio.exp: Opening nonexistant file returns ENOENT
FAIL: gdb.base/fileio.exp: Open for write but no write permission returns EACCES
FAIL: gdb.base/fileio.exp: Write using invalid file descriptor returns EBADF
FAIL: gdb.base/fileio.exp: Writing to a read-only file returns EBADF
FAIL: gdb.base/fileio.exp: Read using invalid file descriptor returns EBADF
FAIL: gdb.base/fileio.exp: Closing an invalid file descriptor returns EBADF
FAIL: gdb.base/fileio.exp: Stat a NULL pathname returns ENOENT or EFAULT
FAIL: gdb.base/fileio.exp: Stat an empty pathname returns ENOENT
FAIL: gdb.base/fileio.exp: Stat a nonexistant file returns ENOENT
FAIL: gdb.base/fileio.exp: Fstat an open file
FAIL: gdb.base/fileio.exp: Fstat an invalid file descriptor returns EBADF
FAIL: gdb.base/fileio.exp: Rename a file
FAIL: gdb.base/fileio.exp: Unlinking a nonexistant file returns ENOENT

Comments?

sim/common/ChangeLog:

	* gennltvals.sh: Search sys/_default_fcntl.h, in addition to
	fcntl.h and sys/fcntl.h, for constants.
	* nltvals.def: Regenerate.
	* sim-io.c (sim_io_stat, sim_io_fstat): New functions.
	* sim-io.h (sys/types.h, sys/stat.h): Include.
	(sim_io_stat, sim_io_fstat): Declare.

sim/v850/ChangeLog:

	* simops (OP_10007E0): Update errno handling as most traps
	do not invoke the host's functionality directly.  Invoke
	sim_io_stat() instead of stat() for implementing TARGET_SYS_stat.
	Implement TARGET_SYS_fstat, TARGET_SYS_rename, and TARGET_SYS_unlink.


Index: sim/common/gennltvals.sh
===================================================================
RCS file: /cvs/src/src/sim/common/gennltvals.sh,v
retrieving revision 1.6
diff -u -p -r1.6 gennltvals.sh
--- sim/common/gennltvals.sh	6 Mar 2011 00:20:21 -0000	1.6
+++ sim/common/gennltvals.sh	11 Mar 2011 21:20:47 -0000
@@ -20,7 +20,7 @@ $shell ${srccom}/gentvals.sh "" signal $
 	"signal.h sys/signal.h" 'SIG[A-Z0-9]*' "${cpp}"
 
 $shell ${srccom}/gentvals.sh "" open ${srcroot}/newlib/libc/include \
-	"fcntl.h sys/fcntl.h" 'O_[A-Z0-9]*' "${cpp}"
+	"fcntl.h sys/fcntl.h sys/_default_fcntl.h" 'O_[A-Z0-9]*' "${cpp}"
 
 # Unfortunately, each newlib/libgloss port has seen fit to define their own
 # syscall.h file.  This means that system call numbers can vary for each port.
Index: sim/common/sim-io.c
===================================================================
RCS file: /cvs/src/src/sim/common/sim-io.c,v
retrieving revision 1.8
diff -u -p -r1.8 sim-io.c
--- sim/common/sim-io.c	1 Jan 2011 15:33:56 -0000	1.8
+++ sim/common/sim-io.c	11 Mar 2011 21:20:47 -0000
@@ -387,3 +387,15 @@ sim_io_poll_read (SIM_DESC sd,
   return sim_io_read (sd, sim_io_fd, buf, sizeof_buf);
 #endif
 }
+
+int
+sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf)
+{
+  return STATE_CALLBACK (sd)->stat (STATE_CALLBACK (sd), path, buf);
+}
+
+int
+sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf)
+{
+  return STATE_CALLBACK (sd)->fstat (STATE_CALLBACK (sd), fd, buf);
+}
Index: sim/common/sim-io.h
===================================================================
RCS file: /cvs/src/src/sim/common/sim-io.h,v
retrieving revision 1.9
diff -u -p -r1.9 sim-io.h
--- sim/common/sim-io.h	1 Jan 2011 15:33:56 -0000	1.9
+++ sim/common/sim-io.h	11 Mar 2011 21:20:47 -0000
@@ -84,4 +84,10 @@ void sim_io_poll_quit (SIM_DESC sd);
 /* Returns -1 and sets (host) EAGAIN if not ready. */
 int sim_io_poll_read (SIM_DESC sd, int, char *, int);
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
+int sim_io_stat (SIM_DESC sd, const char *path, struct stat *buf);
+
+int sim_io_fstat (SIM_DESC sd, int fd, struct stat *buf);
 #endif
Index: sim/v850/simops.c
===================================================================
RCS file: /cvs/src/src/sim/v850/simops.c,v
retrieving revision 1.11
diff -u -p -r1.11 simops.c
--- sim/v850/simops.c	14 Feb 2011 05:14:28 -0000	1.11
+++ sim/v850/simops.c	11 Mar 2011 21:20:47 -0000
@@ -1629,6 +1629,8 @@ OP_10007E0 ()
 
 #define MEMPTR(x) (map (x))
 
+      RETERR = 0;
+
       switch (FUNC)
 	{
 
@@ -1636,6 +1638,7 @@ OP_10007E0 ()
 #ifdef TARGET_SYS_fork
 	case TARGET_SYS_fork:
 	  RETVAL = fork ();
+	  RETERR = errno;
 	  break;
 #endif
 #endif
@@ -1651,6 +1654,7 @@ OP_10007E0 ()
 	    free (path);
 	    freeargv (argv);
 	    freeargv (envp);
+	    RETERR = errno;
 	    break;
 	  }
 #endif
@@ -1665,6 +1669,7 @@ OP_10007E0 ()
 	    RETVAL = execv (path, argv);
 	    free (path);
 	    freeargv (argv);
+	    RETERR = errno;
 	    break;
 	  }
 #endif
@@ -1682,6 +1687,7 @@ OP_10007E0 ()
 	    SW (buf, host_fd[0]);
 	    buf += sizeof(uint16);
 	    SW (buf, host_fd[1]);
+	    RETERR = errno;
 	  }
 	  break;
 #endif
@@ -1695,6 +1701,7 @@ OP_10007E0 ()
 
 	    RETVAL = wait (&status);
 	    SW (PARM1, status);
+	    RETERR = errno;
 	  }
 	  break;
 #endif
@@ -1707,6 +1714,8 @@ OP_10007E0 ()
 	    RETVAL = sim_io_read (simulator, PARM1, buf, PARM3);
 	    sim_write (simulator, PARM2, buf, PARM3);
 	    free (buf);
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
 	    break;
 	  }
 #endif
@@ -1721,6 +1730,8 @@ OP_10007E0 ()
 	    else
 	      RETVAL = sim_io_write (simulator, PARM1, buf, PARM3);
 	    free (buf);
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
 	    break;
 	  }
 #endif
@@ -1728,12 +1739,16 @@ OP_10007E0 ()
 #ifdef TARGET_SYS_lseek
 	case TARGET_SYS_lseek:
 	  RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
+	  if ((int) RETVAL < 0)
+	    RETERR = sim_io_get_errno (simulator);
 	  break;
 #endif
 
 #ifdef TARGET_SYS_close
 	case TARGET_SYS_close:
 	  RETVAL = sim_io_close (simulator, PARM1);
+	  if ((int) RETVAL < 0)
+	    RETERR = sim_io_get_errno (simulator);
 	  break;
 #endif
 
@@ -1743,6 +1758,8 @@ OP_10007E0 ()
 	    char *buf = fetch_str (simulator, PARM1);
 	    RETVAL = sim_io_open (simulator, buf, PARM2);
 	    free (buf);
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
 	    break;
 	  }
 #endif
@@ -1764,7 +1781,6 @@ OP_10007E0 ()
 	  break;
 #endif
 
-#if !defined(__GO32__) && !defined(_WIN32)
 #ifdef TARGET_SYS_stat
 	case TARGET_SYS_stat:	/* added at hmsi */
 	  /* stat system call */
@@ -1773,7 +1789,7 @@ OP_10007E0 ()
 	    reg_t buf;
 	    char *path = fetch_str (simulator, PARM1);
 
-	    RETVAL = stat (path, &host_stat);
+	    RETVAL = sim_io_stat (simulator, path, &host_stat);
 
 	    free (path);
 	    buf = PARM2;
@@ -1790,9 +1806,67 @@ OP_10007E0 ()
 	    store_mem (buf + 20, 4, host_stat.st_atime);
 	    store_mem (buf + 28, 4, host_stat.st_mtime);
 	    store_mem (buf + 36, 4, host_stat.st_ctime);
+
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
+	  }
+	  break;
+#endif
+
+#ifdef TARGET_SYS_fstat
+	case TARGET_SYS_fstat:
+	  /* fstat system call */
+	  {
+	    struct stat host_stat;
+	    reg_t buf;
+
+	    RETVAL = sim_io_fstat (simulator, PARM1, &host_stat);
+
+	    buf = PARM2;
+
+	    /* Just wild-assed guesses.  */
+	    store_mem (buf, 2, host_stat.st_dev);
+	    store_mem (buf + 2, 2, host_stat.st_ino);
+	    store_mem (buf + 4, 4, host_stat.st_mode);
+	    store_mem (buf + 8, 2, host_stat.st_nlink);
+	    store_mem (buf + 10, 2, host_stat.st_uid);
+	    store_mem (buf + 12, 2, host_stat.st_gid);
+	    store_mem (buf + 14, 2, host_stat.st_rdev);
+	    store_mem (buf + 16, 4, host_stat.st_size);
+	    store_mem (buf + 20, 4, host_stat.st_atime);
+	    store_mem (buf + 28, 4, host_stat.st_mtime);
+	    store_mem (buf + 36, 4, host_stat.st_ctime);
+
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
 	  }
 	  break;
 #endif
+
+#ifdef TARGET_SYS_rename
+	case TARGET_SYS_rename:
+	  {
+	    char *oldpath = fetch_str (simulator, PARM1);
+	    char *newpath = fetch_str (simulator, PARM2);
+	    RETVAL = sim_io_rename (simulator, oldpath, newpath);
+	    free (oldpath);
+	    free (newpath);
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
+	  }
+	  break;
+#endif
+
+#ifdef TARGET_SYS_unlink
+	case TARGET_SYS_unlink:
+	  {
+	    char *path = fetch_str (simulator, PARM1);
+	    RETVAL = sim_io_unlink (simulator, path);
+	    free (path);
+	    if ((int) RETVAL < 0)
+	      RETERR = sim_io_get_errno (simulator);
+	  }
+	  break;
 #endif
 
 #ifdef HAVE_CHOWN
@@ -1802,6 +1876,7 @@ OP_10007E0 ()
 	    char *path = fetch_str (simulator, PARM1);
 	    RETVAL = chown (path, PARM2, PARM3);
 	    free (path);
+	    RETERR = errno;
 	  }
 	  break;
 #endif
@@ -1814,6 +1889,7 @@ OP_10007E0 ()
 	    char *path = fetch_str (simulator, PARM1);
 	    RETVAL = chmod (path, PARM2);
 	    free (path);
+	    RETERR = errno;
 	  }
 	  break;
 #endif
@@ -1826,6 +1902,7 @@ OP_10007E0 ()
 	    time_t now;
 	    RETVAL = time (&now);
 	    store_mem (PARM1, 4, now);
+	    RETERR = errno;
 	  }
 	  break;
 #endif
@@ -1841,6 +1918,7 @@ OP_10007E0 ()
 	    store_mem (PARM1 + 4, 4, tms.tms_stime);
 	    store_mem (PARM1 + 8, 4, tms.tms_cutime);
 	    store_mem (PARM1 + 12, 4, tms.tms_cstime);
+	    reterr = errno;
 	    break;
 	  }
 #endif
@@ -1857,6 +1935,7 @@ OP_10007E0 ()
 	    store_mem (PARM1 + 4, 4, t.tv_usec);
 	    store_mem (PARM2, 4, tz.tz_minuteswest);
 	    store_mem (PARM2 + 4, 4, tz.tz_dsttime);
+	    RETERR = errno;
 	    break;
 	  }
 #endif
@@ -1878,7 +1957,6 @@ OP_10007E0 ()
 	default:
 	  abort ();
 	}
-      RETERR = errno;
       errno = save_errno;
 
       return 4;


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] sim updates which fix some fileio.exp failures for v850-elf
  2011-03-11 22:17 [RFC] sim updates which fix some fileio.exp failures for v850-elf Kevin Buettner
@ 2011-03-22  9:34 ` Kevin Buettner
  2011-05-25 13:30 ` Mike Frysinger
  2011-06-09  4:44 ` Mike Frysinger
  2 siblings, 0 replies; 5+ messages in thread
From: Kevin Buettner @ 2011-03-22  9:34 UTC (permalink / raw)
  To: gdb-patches

On Fri, 11 Mar 2011 15:04:47 -0700
Kevin Buettner <kevinb@redhat.com> wrote:

> sim/common/ChangeLog:
> 
> 	* gennltvals.sh: Search sys/_default_fcntl.h, in addition to
> 	fcntl.h and sys/fcntl.h, for constants.
> 	* nltvals.def: Regenerate.
> 	* sim-io.c (sim_io_stat, sim_io_fstat): New functions.
> 	* sim-io.h (sys/types.h, sys/stat.h): Include.
> 	(sim_io_stat, sim_io_fstat): Declare.
> 
> sim/v850/ChangeLog:
> 
> 	* simops (OP_10007E0): Update errno handling as most traps
> 	do not invoke the host's functionality directly.  Invoke
> 	sim_io_stat() instead of stat() for implementing TARGET_SYS_stat.
> 	Implement TARGET_SYS_fstat, TARGET_SYS_rename, and TARGET_SYS_unlink.

Committed.

Kevin


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] sim updates which fix some fileio.exp failures for v850-elf
  2011-03-11 22:17 [RFC] sim updates which fix some fileio.exp failures for v850-elf Kevin Buettner
  2011-03-22  9:34 ` Kevin Buettner
@ 2011-05-25 13:30 ` Mike Frysinger
  2011-05-26 18:19   ` Mike Frysinger
  2011-06-09  4:44 ` Mike Frysinger
  2 siblings, 1 reply; 5+ messages in thread
From: Mike Frysinger @ 2011-05-25 13:30 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

[-- Attachment #1: Type: Text/Plain, Size: 679 bytes --]

On Friday, March 11, 2011 17:04:47 Kevin Buettner wrote:
> Note that the newlib changes are needed for regenerating nltvals.def.  I
> didn't post the regenerated file below as it's quite large.  (There are
> some whitespace differences which make it look a lot bigger than it really
> is.  A more meaningful patch can be obtained by use of diff's -w switch.
> I'd be willing to post that diff if anyone's interested.)

it looks like you regenerated against an old tree because your new file 
dropped all Blackfin defines.  so now the bfin sim fails to execute any 
libgloss syscalls.

could you figure out what's up on your side and then commit a fixed list ?
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] sim updates which fix some fileio.exp failures for v850-elf
  2011-05-25 13:30 ` Mike Frysinger
@ 2011-05-26 18:19   ` Mike Frysinger
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2011-05-26 18:19 UTC (permalink / raw)
  To: gdb-patches; +Cc: Kevin Buettner

On Wed, May 25, 2011 at 09:30, Mike Frysinger wrote:
> On Friday, March 11, 2011 17:04:47 Kevin Buettner wrote:
>> Note that the newlib changes are needed for regenerating nltvals.def.  I
>> didn't post the regenerated file below as it's quite large.  (There are
>> some whitespace differences which make it look a lot bigger than it really
>> is.  A more meaningful patch can be obtained by use of diff's -w switch.
>> I'd be willing to post that diff if anyone's interested.)
>
> it looks like you regenerated against an old tree because your new file
> dropped all Blackfin defines.  so now the bfin sim fails to execute any
> libgloss syscalls.
>
> could you figure out what's up on your side and then commit a fixed list ?

i like having this worked so i just committed the attached patch.
please still double check stuff on your side though so it doesnt break
things again.
-mike

2011-05-26  Mike Frysinger  <vapier@gentoo.org>

    * nltvals.def: Regenerate to include Blackfin syscalls again.

 sim/common/nltvals.def |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index 07c76a1..bc858b8 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -149,6 +149,37 @@
  { "O_WRONLY", 1 },
 /* end open target macros */
 #endif
+#ifdef NL_TARGET_bfin
+#ifdef sys_defs
+/* from syscall.h */
+/* begin bfin sys target macros */
+ { "SYS_argc", 22 },
+ { "SYS_argn", 24 },
+ { "SYS_argnlen", 23 },
+ { "SYS_argv", 13 },
+ { "SYS_argvlen", 12 },
+ { "SYS_chdir", 14 },
+ { "SYS_chmod", 16 },
+ { "SYS_close", 3 },
+ { "SYS_exit", 1 },
+ { "SYS_fstat", 10 },
+ { "SYS_getpid", 8 },
+ { "SYS_gettimeofday", 19 },
+ { "SYS_kill", 9 },
+ { "SYS_link", 21 },
+ { "SYS_lseek", 6 },
+ { "SYS_open", 2 },
+ { "SYS_read", 4 },
+ { "SYS_reconfig", 25 },
+ { "SYS_stat", 15 },
+ { "SYS_time", 18 },
+ { "SYS_times", 20 },
+ { "SYS_unlink", 7 },
+ { "SYS_utime", 17 },
+ { "SYS_write", 5 },
+/* end bfin sys target macros */
+#endif
+#endif
 #ifdef NL_TARGET_d10v
 #ifdef sys_defs
 /* from syscall.h */
--


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [RFC] sim updates which fix some fileio.exp failures for v850-elf
  2011-03-11 22:17 [RFC] sim updates which fix some fileio.exp failures for v850-elf Kevin Buettner
  2011-03-22  9:34 ` Kevin Buettner
  2011-05-25 13:30 ` Mike Frysinger
@ 2011-06-09  4:44 ` Mike Frysinger
  2 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2011-06-09  4:44 UTC (permalink / raw)
  To: Kevin Buettner, MR.Swami.Reddy; +Cc: gdb-patches

[-- Attachment #1: Type: Text/Plain, Size: 1211 bytes --]

On Friday, March 11, 2011 17:04:47 Kevin Buettner wrote:
> sim/common/ChangeLog:
> 
> 	* gennltvals.sh: Search sys/_default_fcntl.h, in addition to
> 	fcntl.h and sys/fcntl.h, for constants.
> 	* nltvals.def: Regenerate.

this also breaks cr16, but that might be more of cr16's fault than yours as
the cr16 list in the def file might have been hand tweaked ...

moved to bugzilla:
http://sourceware.org/bugzilla/show_bug.cgi?id=12862

sim/cr16/simops.c: In function ‘OP_C_C’:
sim/cr16/simops.c:5134:9: error: ‘TARGET_SYS_fork’ undeclared (first use in this function)
sim/cr16/simops.c:5134:9: note: each undeclared identifier is reported only once for each function it appears in
sim/cr16/simops.c:5275:9: error: ‘TARGET_SYS_execve’ undeclared (first use in this function)
sim/cr16/simops.c:5290:9: error: ‘TARGET_SYS_pipe’ undeclared (first use in this function)
sim/cr16/simops.c:5368:9: error: ‘TARGET_SYS_rename’ undeclared (first use in this function)
sim/cr16/simops.c:5378:18: warning: assignment makes integer from pointer without a cast [enabled by default]
sim/cr16/simops.c:5427:9: error: ‘TARGET_SYS_chown’ undeclared (first use in this function)
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-06-09  4:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-11 22:17 [RFC] sim updates which fix some fileio.exp failures for v850-elf Kevin Buettner
2011-03-22  9:34 ` Kevin Buettner
2011-05-25 13:30 ` Mike Frysinger
2011-05-26 18:19   ` Mike Frysinger
2011-06-09  4:44 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox