summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2016-07-20 15:02:37 +0000
committerkib <kib@FreeBSD.org>2016-07-20 15:02:37 +0000
commitb0424ee31b065c0390e86c0056da48d6af6092fd (patch)
treeaf60dcd36c8d29edccc17da766acb964f1c74500
parente9d4bb286de33cda524b2ea79838257cff9889f3 (diff)
downloadFreeBSD-src-b0424ee31b065c0390e86c0056da48d6af6092fd.zip
FreeBSD-src-b0424ee31b065c0390e86c0056da48d6af6092fd.tar.gz
MFC r302770:
Trace timeval parameters to the getitimer(2) and setitimer(2) syscalls. Approved by: re (gjb)
-rw-r--r--sys/kern/kern_time.c17
-rw-r--r--sys/sys/ktrace.h2
-rw-r--r--usr.bin/kdump/kdump.c25
3 files changed, 44 insertions, 0 deletions
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 148da2b..c04aa30 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -32,6 +32,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include "opt_ktrace.h"
+
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/limits.h>
@@ -54,6 +56,9 @@ __FBSDID("$FreeBSD$");
#include <sys/timers.h>
#include <sys/timetc.h>
#include <sys/vnode.h>
+#ifdef KTRACE
+#include <sys/ktrace.h>
+#endif
#include <vm/vm.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];
PROC_ITIMUNLOCK(p);
}
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_STRUCT))
+ ktritimerval(aitv);
+#endif
return (0);
}
@@ -742,6 +751,10 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv,
if (which > ITIMER_PROF)
return (EINVAL);
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_STRUCT))
+ ktritimerval(aitv);
+#endif
if (itimerfix(&aitv->it_value) ||
aitv->it_value.tv_sec > INT32_MAX / 2)
return (EINVAL);
@@ -786,6 +799,10 @@ kern_setitimer(struct thread *td, u_int which, struct itimerval *aitv,
p->p_stats->p_timer[which] = *aitv;
PROC_ITIMUNLOCK(p);
}
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_STRUCT))
+ ktritimerval(oitv);
+#endif
return (0);
}
diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h
index e9cfa6e..e63a41a 100644
--- a/sys/sys/ktrace.h
+++ b/sys/sys/ktrace.h
@@ -270,6 +270,8 @@ void ktrcapfail(enum ktr_cap_fail_type, const cap_rights_t *,
const cap_rights_t *);
#define ktrcaprights(s) \
ktrstruct("caprights", (s), sizeof(cap_rights_t))
+#define ktritimerval(s) \
+ ktrstruct("itimerval", (s), sizeof(struct itimerval))
#define ktrsockaddr(s) \
ktrstruct("sockaddr", (s), ((struct sockaddr *)(s))->sa_len)
#define ktrstat(s) \
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
index 7010bbf..8cfe540 100644
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -109,6 +109,7 @@ void ktruser_malloc(void *);
void ktruser_rtld(int, void *);
void ktruser(int, void *);
void ktrcaprights(cap_rights_t *);
+void ktritimerval(struct itimerval *it);
void ktrsockaddr(struct sockaddr *);
void ktrstat(struct stat *);
void ktrstruct(char *, size_t);
@@ -1562,6 +1563,24 @@ ktrcaprights(cap_rights_t *rightsp)
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
ktrsockaddr(struct sockaddr *sa)
{
@@ -1737,6 +1756,7 @@ ktrstruct(char *buf, size_t buflen)
size_t namelen, datalen;
int i;
cap_rights_t rights;
+ struct itimerval it;
struct stat sb;
struct sockaddr_storage ss;
@@ -1761,6 +1781,11 @@ ktrstruct(char *buf, size_t buflen)
goto invalid;
memcpy(&rights, data, datalen);
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) {
if (datalen != sizeof(struct stat))
goto invalid;
OpenPOWER on IntegriCloud