|
From: Sebastian B. <sb...@bi...> - 2004-08-30 14:53:42
|
Hi! I'm about to implement the following syscall wrappers for valgrind: timer_create timer_delete timer_settime clock_getres But before I'd like to ask: a) Is there already an implementation/patch/development version somewhere? b) Is this feasable without stepping to deep into valgrind (since some of the above functions seem to need signal-handling special cases)? Sebastian |
|
From: Tom H. <th...@cy...> - 2004-08-30 15:00:49
|
In message <413...@bi...>
Sebastian Biallas <sb...@bi...> wrote:
> I'm about to implement the following syscall wrappers for valgrind:
>
> timer_create
> timer_delete
> timer_settime
> clock_getres
>
> But before I'd like to ask:
>
> a) Is there already an implementation/patch/development version somewhere?
I thought some of them had been done, but I can't find any sign of it...
> b) Is this feasable without stepping to deep into valgrind (since some
> of the above functions seem to need signal-handling special cases)?
They should all be sumple enough. The only signal related thing looked
like timer_create being able to ask for a signal to be delivered when
the timer expires and that doesn't need anything special.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Bob F. <bfr...@si...> - 2004-08-30 15:13:46
|
On Mon, 30 Aug 2004, Tom Hughes wrote:
> In message <413...@bi...>
> Sebastian Biallas <sb...@bi...> wrote:
>
>> I'm about to implement the following syscall wrappers for valgrind:
>>
>> timer_create
>> timer_delete
>> timer_settime
>> clock_getres
>>
>> But before I'd like to ask:
>>
>> a) Is there already an implementation/patch/development version somewhere?
>
> I thought some of them had been done, but I can't find any sign of it...
>
>> b) Is this feasable without stepping to deep into valgrind (since some
>> of the above functions seem to need signal-handling special cases)?
>
> They should all be sumple enough. The only signal related thing looked
> like timer_create being able to ask for a signal to be delivered when
> the timer expires and that doesn't need anything special.
This patch provides an implementation. It may be complete crap, but
then again, maybe it will hasten development.
Bob
Index: coregrind/vg_syscalls.c
===================================================================
RCS file: /home/kde/valgrind/coregrind/vg_syscalls.c,v
retrieving revision 1.97
diff -u -r1.97 vg_syscalls.c
--- coregrind/vg_syscalls.c 13 Jun 2004 14:23:00 -0000 1.97
+++ coregrind/vg_syscalls.c 30 Aug 2004 15:09:57 -0000
@@ -1,3 +1,4 @@
+#define SUPPORT_TIMERS 1 /* ReQuest added timer_ support */
/*--------------------------------------------------------------------*/
/*--- Handle system calls. vg_syscalls.c ---*/
@@ -4952,6 +4953,76 @@
VG_TRACK(post_mem_write, arg1, sizeof(struct timex));
}
+#if SUPPORT_TIMERS
+PRE(timer_create)
+{
+ /*
+ int timer_create(clockid_t clock_id, struct sigevent *evp, timer_t *timerid);
+ */
+ MAYBE_PRINTF("timer_create(%d,%p,%p)\n",arg1,arg2,arg3);
+ SYSCALL_TRACK( pre_mem_read, tid, "timer_create(evp)",arg2, sizeof(struct sigevent));
+ SYSCALL_TRACK( pre_mem_write, tid, "timer_create(timerid)",arg3, sizeof(timer_t *));
+}
+
+POST(timer_create)
+{
+ VG_TRACK( post_mem_write, arg3, sizeof(timer_t *) );
+}
+
+PRE(timer_settime)
+{
+ /*
+ int timer_settime(timer_t timerid, int flags, const struct
+ itimerspec *value, struct itimerspec *ovalue);
+ */
+ MAYBE_PRINTF("timer_settime(%p,%d,%p,%p)\n",arg1,arg2,arg3,arg4);
+ SYSCALL_TRACK( pre_mem_read, tid, "timer_settime(value)", arg3,sizeof(struct vki_itimerspec));
+ if (arg4 != (UInt) NULL)
+ {
+ SYSCALL_TRACK( pre_mem_write, tid, "timer_settime(ovalue)",arg4,sizeof(struct vki_itimerspec));
+ }
+}
+
+POST(timer_settime)
+{
+ if (arg4 != (UInt) NULL)
+ {
+ VG_TRACK( post_mem_write, arg4, sizeof(struct vki_itimerspec));
+ }
+}
+
+PRE(timer_gettime)
+{
+ /*
+ int timer_gettime(timer_t timerid, struct itimerspec *value);
+ */
+ MAYBE_PRINTF("timer_gettime(%p,%p)\n",arg1,arg2);
+ SYSCALL_TRACK( pre_mem_write, tid, "timer_gettime(value)",arg2,sizeof(struct vki_itimerspec));
+}
+
+POST(timer_gettime)
+{
+ VG_TRACK( post_mem_write, arg2, sizeof(struct vki_itimerspec));
+}
+
+PRE(timer_getoverrun)
+{
+ /*
+ int timer_getoverrun(timer_t timerid);
+ */
+ MAYBE_PRINTF("timer_getoverrun(%p)\n",arg1);
+}
+
+PRE(timer_delete)
+{
+ /*
+ int timer_delete(timer_t timerid);
+ */
+ MAYBE_PRINTF("timer_delete(%p)\n",arg1);
+}
+
+#endif /* SUPPORT_TIMERS */
+
PRE(clock_gettime)
{
/* int clock_gettime(clockid_t clk_id, struct timespec *tp); */
@@ -5415,6 +5486,13 @@
SYSB_(prctl, True),
SYSBA(adjtimex, False),
SYSBA(mmap2, False),
+#if SUPPORT_TIMERS
+ SYSBA(timer_create, False),
+ SYSBA(timer_settime, False),
+ SYSBA(timer_gettime, False),
+ SYSB_(timer_getoverrun, False),
+ SYSB_(timer_delete, False),
+#endif /* SUPPORT_TIMERS */
SYSBA(clock_gettime, False),
SYSBA(futex, True),
SYSB_(acct, False),
Index: include/vg_kerneliface.h
===================================================================
RCS file: /home/kde/valgrind/include/vg_kerneliface.h,v
retrieving revision 1.17
diff -u -r1.17 vg_kerneliface.h
--- include/vg_kerneliface.h 3 Jun 2004 10:00:42 -0000 1.17
+++ include/vg_kerneliface.h 30 Aug 2004 15:09:57 -0000
@@ -537,8 +537,6 @@
/* suseconds_t */ long tv_usec; /* microseconds */
};
-
-
/* For fcntl on fds ..
from ./include/asm-i386/fcntl.h */
#define VKI_F_DUPFD 0 /* dup */
@@ -559,6 +557,12 @@
long tv_nsec; /* nanoseconds */
};
+/* POSIX.1b structure for timer start values and intervals. */
+struct vki_itimerspec
+ {
+ struct vki_timespec it_interval;
+ struct vki_timespec it_value;
+ };
/* STAT stuff
from /usr/src/linux-2.4.9-31/include/asm-i386/stat.h */
|
|
From: Tom H. <th...@cy...> - 2004-08-30 15:46:48
Attachments:
valgrind-timer-patch
|
In message <Pin...@bl...>
Bob Friesenhahn <bfr...@si...> wrote:
> On Mon, 30 Aug 2004, Tom Hughes wrote:
>
> > They should all be sumple enough. The only signal related thing looked
> > like timer_create being able to ask for a signal to be delivered when
> > the timer expires and that doesn't need anything special.
>
> This patch provides an implementation. It may be complete crap, but
> then again, maybe it will hasten development.
There were a couple of mistakes in timer_create but it was mostly
correct by the looks of it. Attached is my tidied up version to
which I have added most of the clock_ routines as well - all except
clock_nanosleep in fact as that requires more work.
Tom
--
Tom Hughes (th...@cy...)
Software Engineer, Cyberscience Corporation
http://www.cyberscience.com/
|
|
From: Bob F. <bfr...@si...> - 2004-08-30 15:06:40
|
On Mon, 30 Aug 2004, Sebastian Biallas wrote: > Hi! > > I'm about to implement the following syscall wrappers for valgrind: > > timer_create > timer_delete > timer_settime > clock_getres > > But before I'd like to ask: > > a) Is there already an implementation/patch/development version somewhere? I have written wrappers for the timer_* functions but I didn't read kernel/glibc internals source code in order to do so. Therefore, my implementation may be useless. Due to this uncertainty, I have not submitted a patch. Regardless, a patched valgrind does seem to work ok (no reported error or crash) with programs using the timer_* functions. Bob ====================================== Bob Friesenhahn bfr...@si... http://www.simplesystems.org/users/bfriesen |