diff options
Diffstat (limited to 'sys/kern/kern_ktrace.c')
-rw-r--r-- | sys/kern/kern_ktrace.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index 4ca73fced3c..09eb8d1d842 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.52 2011/07/07 18:11:24 art Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.53 2011/07/08 19:28:36 otto Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -278,6 +278,30 @@ ktrcsw(struct proc *p, int out, int user) p->p_traceflag &= ~KTRFAC_ACTIVE; } +void +ktrstruct(struct proc *p, const char *name, const void *data, size_t datalen) +{ + struct ktr_header kth; + void *buf; + size_t buflen; + + p->p_traceflag |= KTRFAC_ACTIVE; + ktrinitheader(&kth, p, KTR_STRUCT); + + if (data == NULL) + datalen = 0; + buflen = strlen(name) + 1 + datalen; + buf = malloc(buflen, M_TEMP, M_WAITOK); + strlcpy(buf, name, buflen); + bcopy(data, buf + strlen(name) + 1, datalen); + kth.ktr_buf = buf; + kth.ktr_len = buflen; + + ktrwrite(p, &kth); + free(buf, M_TEMP); + p->p_traceflag &= ~KTRFAC_ACTIVE; +} + /* Interface and common routines */ /* |