This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Committed: fix cris sim time syscall
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gdb-patches at sourceware dot org
- Date: Thu, 23 Feb 2006 03:04:24 +0100
- Subject: Committed: fix cris sim time syscall
Caught by observing the hard way a spurious execution path change when
measuring execution time difference for a GCC change. (Yep, the
simulator time syscall returns is kept deterministic across such
changes.) I think it'd be too hard to fix syscall.c:cb_syscall to
DTRT; it'd have to know sizeof (time_t) for the target or something.
NB: the test-case will pass for newlib, which uses the gettimeofday
syscall.
Committed.
sim:
* cris/traps.c (syscall_map): Remove CB_SYS_time / TARGET_SYS_time
mapping.
(cris_break_13_handler) <case TARGET_SYS_time>: New case.
sim/testsuite:
* sim/cris/c/time2.c: New test.
Index: cris/traps.c
===================================================================
RCS file: /cvs/src/src/sim/cris/traps.c,v
retrieving revision 1.6
diff -p -u -r1.6 traps.c
--- cris/traps.c 20 Nov 2005 14:52:36 -0000 1.6
+++ cris/traps.c 23 Feb 2006 01:51:32 -0000
@@ -244,7 +244,6 @@ static const CB_TARGET_DEFS_MAP syscall_
{ CB_SYS_lstat, TARGET_SYS_lstat64 },
{ CB_SYS_stat, TARGET_SYS_stat64 },
{ CB_SYS_pipe, TARGET_SYS_pipe },
- { CB_SYS_time, TARGET_SYS_time },
{ CB_SYS_rename, TARGET_SYS_rename },
{ CB_SYS_truncate, TARGET_SYS_truncate },
{ CB_SYS_ftruncate, TARGET_SYS_ftruncate },
@@ -2044,6 +2043,17 @@ cris_break_13_handler (SIM_CPU *current_
break;
}
+ case TARGET_SYS_time:
+ {
+ retval = (int) (*cb->time) (cb, 0L);
+
+ /* At time of this writing, CB_SYSCALL_time doesn't do the
+ part of setting *arg1 to the return value. */
+ if (arg1)
+ sim_core_write_unaligned_4 (current_cpu, pc, 0, arg1, retval);
+ break;
+ }
+
case TARGET_SYS_gettimeofday:
if (arg1 != 0)
{
Index: sim/cris/c/time2.c
===================================================================
RCS file: sim/cris/c/time2.c
diff -N sim/cris/c/time2.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sim/cris/c/time2.c 23 Feb 2006 01:54:29 -0000
@@ -0,0 +1,18 @@
+/* CB_SYS_time doesn't implement the Linux time syscall; the return
+ value isn't written to the argument. */
+
+#include <time.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int
+main (void)
+{
+ time_t x = (time_t) -1;
+ time_t t = time (&x);
+
+ if (t == (time_t) -1 || t != x)
+ abort ();
+ printf ("pass\n");
+ exit (0);
+}
brgds, H-P