Trace timeval parameters to the getitimer(2) and setitimer(2) syscalls.
Reviewed by: jhb Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D7158
This commit is contained in:
parent
1d148a7c3f
commit
de56aee0bf
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=302770
@ -32,6 +32,8 @@
|
|||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
|
#include "opt_ktrace.h"
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/limits.h>
|
#include <sys/limits.h>
|
||||||
@ -54,6 +56,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/timers.h>
|
#include <sys/timers.h>
|
||||||
#include <sys/timetc.h>
|
#include <sys/timetc.h>
|
||||||
#include <sys/vnode.h>
|
#include <sys/vnode.h>
|
||||||
|
#ifdef KTRACE
|
||||||
|
#include <sys/ktrace.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <vm/vm.h>
|
#include <vm/vm.h>
|
||||||
#include <vm/vm_extern.h>
|
#include <vm/vm_extern.h>
|
||||||
@ -701,6 +706,10 @@ kern_getitimer(struct thread *td, u_int which, struct itimerval *aitv)
|
|||||||
*aitv = p->p_stats->p_timer[which];
|
*aitv = p->p_stats->p_timer[which];
|
||||||
PROC_ITIMUNLOCK(p);
|
PROC_ITIMUNLOCK(p);
|
||||||
}
|
}
|
||||||
|
#ifdef KTRACE
|
||||||
|
if (KTRPOINT(td, KTR_STRUCT))
|
||||||
|
ktritimerval(aitv);
|
||||||
|
#endif
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,6 +751,10 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv,
|
|||||||
|
|
||||||
if (which > ITIMER_PROF)
|
if (which > ITIMER_PROF)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
|
#ifdef KTRACE
|
||||||
|
if (KTRPOINT(td, KTR_STRUCT))
|
||||||
|
ktritimerval(aitv);
|
||||||
|
#endif
|
||||||
if (itimerfix(&aitv->it_value) ||
|
if (itimerfix(&aitv->it_value) ||
|
||||||
aitv->it_value.tv_sec > INT32_MAX / 2)
|
aitv->it_value.tv_sec > INT32_MAX / 2)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
@ -786,6 +799,10 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv,
|
|||||||
p->p_stats->p_timer[which] = *aitv;
|
p->p_stats->p_timer[which] = *aitv;
|
||||||
PROC_ITIMUNLOCK(p);
|
PROC_ITIMUNLOCK(p);
|
||||||
}
|
}
|
||||||
|
#ifdef KTRACE
|
||||||
|
if (KTRPOINT(td, KTR_STRUCT))
|
||||||
|
ktritimerval(oitv);
|
||||||
|
#endif
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,6 +270,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *,
|
|||||||
const cap_rights_t *);
|
const cap_rights_t *);
|
||||||
#define ktrcaprights(s) \
|
#define ktrcaprights(s) \
|
||||||
ktrstruct("caprights", (s), sizeof(cap_rights_t))
|
ktrstruct("caprights", (s), sizeof(cap_rights_t))
|
||||||
|
#define ktritimerval(s) \
|
||||||
|
ktrstruct("itimerval", (s), sizeof(struct itimerval))
|
||||||
#define ktrsockaddr(s) \
|
#define ktrsockaddr(s) \
|
||||||
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
|
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
|
||||||
#define ktrstat(s) \
|
#define ktrstat(s) \
|
||||||
|
@ -109,6 +109,7 @@ void ktruser_malloc(void *);
|
|||||||
void ktruser_rtld(int, void *);
|
void ktruser_rtld(int, void *);
|
||||||
void ktruser(int, void *);
|
void ktruser(int, void *);
|
||||||
void ktrcaprights(cap_rights_t *);
|
void ktrcaprights(cap_rights_t *);
|
||||||
|
void ktritimerval(struct itimerval *it);
|
||||||
void ktrsockaddr(struct sockaddr *);
|
void ktrsockaddr(struct sockaddr *);
|
||||||
void ktrstat(struct stat *);
|
void ktrstat(struct stat *);
|
||||||
void ktrstruct(char *, size_t);
|
void ktrstruct(char *, size_t);
|
||||||
@ -1562,6 +1563,24 @@ ktrcaprights(cap_rights_t *rightsp)
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ktrtimeval(struct timeval *tv)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("{%ld, %ld}", (long)tv->tv_sec, tv->tv_usec);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ktritimerval(struct itimerval *it)
|
||||||
|
{
|
||||||
|
|
||||||
|
printf("itimerval { .interval = ");
|
||||||
|
ktrtimeval(&it->it_interval);
|
||||||
|
printf(", .value = ");
|
||||||
|
ktrtimeval(&it->it_value);
|
||||||
|
printf(" }\n");
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ktrsockaddr(struct sockaddr *sa)
|
ktrsockaddr(struct sockaddr *sa)
|
||||||
{
|
{
|
||||||
@ -1737,6 +1756,7 @@ ktrstruct(char *buf, size_t buflen)
|
|||||||
size_t namelen, datalen;
|
size_t namelen, datalen;
|
||||||
int i;
|
int i;
|
||||||
cap_rights_t rights;
|
cap_rights_t rights;
|
||||||
|
struct itimerval it;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct sockaddr_storage ss;
|
struct sockaddr_storage ss;
|
||||||
|
|
||||||
@ -1761,6 +1781,11 @@ ktrstruct(char *buf, size_t buflen)
|
|||||||
goto invalid;
|
goto invalid;
|
||||||
memcpy(&rights, data, datalen);
|
memcpy(&rights, data, datalen);
|
||||||
ktrcaprights(&rights);
|
ktrcaprights(&rights);
|
||||||
|
} else if (strcmp(name, "itimerval") == 0) {
|
||||||
|
if (datalen != sizeof(struct itimerval))
|
||||||
|
goto invalid;
|
||||||
|
memcpy(&it, data, datalen);
|
||||||
|
ktritimerval(&it);
|
||||||
} else if (strcmp(name, "stat") == 0) {
|
} else if (strcmp(name, "stat") == 0) {
|
||||||
if (datalen != sizeof(struct stat))
|
if (datalen != sizeof(struct stat))
|
||||||
goto invalid;
|
goto invalid;
|
||||||
|
Loading…
Reference in New Issue
Block a user