mirror of
https://github.com/openbsd/src.git
synced 2024-12-21 23:18:00 -08:00
Trace struct itimerval
ok deraadt@ claudio@
This commit is contained in:
parent
35c0c3c8be
commit
a984a0c3bb
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: kern_time.c,v 1.168 2024/07/08 13:17:12 claudio Exp $ */
|
||||
/* $OpenBSD: kern_time.c,v 1.169 2024/07/26 19:16:31 guenther Exp $ */
|
||||
/* $NetBSD: kern_time.c,v 1.20 1996/02/18 11:57:06 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
@ -602,7 +602,7 @@ sys_getitimer(struct proc *p, void *v, register_t *retval)
|
||||
syscallarg(struct itimerval *) itv;
|
||||
} */ *uap = v;
|
||||
struct itimerval aitv;
|
||||
int which;
|
||||
int which, error;
|
||||
|
||||
which = SCARG(uap, which);
|
||||
if (which < ITIMER_REAL || which > ITIMER_PROF)
|
||||
@ -612,7 +612,12 @@ sys_getitimer(struct proc *p, void *v, register_t *retval)
|
||||
|
||||
setitimer(which, NULL, &aitv);
|
||||
|
||||
return copyout(&aitv, SCARG(uap, itv), sizeof(aitv));
|
||||
error = copyout(&aitv, SCARG(uap, itv), sizeof(aitv));
|
||||
#ifdef KTRACE
|
||||
if (error == 0 && KTRPOINT(p, KTR_STRUCT))
|
||||
ktritimerval(p, &aitv);
|
||||
#endif
|
||||
return (error);
|
||||
}
|
||||
|
||||
int
|
||||
@ -636,6 +641,10 @@ sys_setitimer(struct proc *p, void *v, register_t *retval)
|
||||
error = copyin(SCARG(uap, itv), &aitv, sizeof(aitv));
|
||||
if (error)
|
||||
return error;
|
||||
#ifdef KTRACE
|
||||
if (KTRPOINT(p, KTR_STRUCT))
|
||||
ktritimerval(p, &aitv);
|
||||
#endif
|
||||
error = itimerfix(&aitv);
|
||||
if (error)
|
||||
return error;
|
||||
@ -650,8 +659,14 @@ sys_setitimer(struct proc *p, void *v, register_t *retval)
|
||||
|
||||
setitimer(which, newitvp, olditvp);
|
||||
|
||||
if (SCARG(uap, oitv) != NULL)
|
||||
return copyout(&olditv, SCARG(uap, oitv), sizeof(olditv));
|
||||
if (SCARG(uap, oitv) != NULL) {
|
||||
error = copyout(&olditv, SCARG(uap, oitv), sizeof(olditv));
|
||||
#ifdef KTRACE
|
||||
if (error == 0 && KTRPOINT(p, KTR_STRUCT))
|
||||
ktritimerval(p, &aitv);
|
||||
#endif
|
||||
return error;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ktrace.h,v 1.48 2023/12/15 15:12:08 deraadt Exp $ */
|
||||
/* $OpenBSD: ktrace.h,v 1.49 2024/07/26 19:16:31 guenther Exp $ */
|
||||
/* $NetBSD: ktrace.h,v 1.12 1996/02/04 02:12:29 christos Exp $ */
|
||||
|
||||
/*
|
||||
@ -241,6 +241,8 @@ void ktrstruct(struct proc *, const char *, const void *, size_t);
|
||||
ktrstruct((p), "abstimeval", (s), sizeof(struct timeval))
|
||||
#define ktrreltimeval(p, s) \
|
||||
ktrstruct((p), "reltimeval", (s), sizeof(struct timeval))
|
||||
#define ktritimerval(p, s) \
|
||||
ktrstruct((p), "itimerval", (s), sizeof(struct itimerval))
|
||||
#define ktrsigaction(p, s) \
|
||||
ktrstruct((p), "sigaction", (s), sizeof(struct sigaction))
|
||||
#define ktrrlimit(p, s) \
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: ktrstruct.c,v 1.31 2022/12/29 01:36:36 guenther Exp $ */
|
||||
/* $OpenBSD: ktrstruct.c,v 1.32 2024/07/26 19:16:31 guenther Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1988, 1993
|
||||
@ -265,6 +265,18 @@ ktrtimeval(const struct timeval *tvp, int relative)
|
||||
printf(" }\n");
|
||||
}
|
||||
|
||||
static void
|
||||
ktritimerval(const struct itimerval *itvp)
|
||||
{
|
||||
printf("struct itimerval { value=");
|
||||
print_timeval(&itvp->it_value, 0);
|
||||
if (timerisset(&itvp->it_interval)) {
|
||||
printf(", interval=");
|
||||
print_timeval(&itvp->it_interval, 1);
|
||||
}
|
||||
printf(" }\n");
|
||||
}
|
||||
|
||||
static void
|
||||
ktrsigaction(const struct sigaction *sa)
|
||||
{
|
||||
@ -615,6 +627,13 @@ ktrstruct(char *buf, size_t buflen)
|
||||
goto invalid;
|
||||
memcpy(&tv, data, datalen);
|
||||
ktrtimeval(&tv, name[0] == 'r');
|
||||
} else if (strcmp(name, "itimerval") == 0) {
|
||||
struct itimerval itv;
|
||||
|
||||
if (datalen != sizeof(itv))
|
||||
goto invalid;
|
||||
memcpy(&itv, data, datalen);
|
||||
ktritimerval(&itv);
|
||||
} else if (strcmp(name, "sigaction") == 0) {
|
||||
struct sigaction sa;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user