Add a ktrkuser() function that can be used to generate a KTR_USER trace

entry from kernel-resident data.
Mainly so I can (ab)use the KTR_USER entry for extra info.
This commit is contained in:
dsl 2007-06-01 20:24:21 +00:00
parent 5a557927e4
commit d23c3b01a0
2 changed files with 25 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_ktrace.c,v 1.122 2007/04/26 16:27:32 dsl Exp $ */
/* $NetBSD: kern_ktrace.c,v 1.123 2007/06/01 20:24:21 dsl Exp $ */
/*
* Copyright (c) 1989, 1993
@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.122 2007/04/26 16:27:32 dsl Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_ktrace.c,v 1.123 2007/06/01 20:24:21 dsl Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h"
@ -818,6 +818,27 @@ ktruser(struct lwp *l, const char *id, void *addr, size_t len, int ustr)
return error;
}
void
ktrkuser(struct lwp *l, const char *id, void *addr, size_t len)
{
struct ktrace_entry *kte;
struct ktr_user *ktp;
int error;
if (len > KTR_USER_MAXLEN)
return;
error = ktealloc(&kte, (void *)&ktp, l, KTR_USER, sizeof(*ktp) + len);
if (error != 0)
return;
strlcpy(ktp->ktr_id, id, KTR_USER_MAXIDLEN);
memcpy(ktp + 1, addr, len);
ktraddentry(l, kte, KTA_WAITOK);
}
void
ktrmmsg(struct lwp *l, const void *msgh, size_t size)
{

View File

@ -1,4 +1,4 @@
/* $NetBSD: ktrace.h,v 1.47 2007/04/26 16:27:32 dsl Exp $ */
/* $NetBSD: ktrace.h,v 1.48 2007/06/01 20:24:21 dsl Exp $ */
/*
* Copyright (c) 1988, 1993
@ -289,6 +289,7 @@ void ktrsyscall(struct lwp *, register_t, register_t,
const struct sysent *, register_t []);
void ktrsysret(struct lwp *, register_t, int, register_t *);
int ktruser(struct lwp *, const char *, void *, size_t, int);
void ktrkuser(struct lwp *, const char *, void *, size_t);
void ktrmmsg(struct lwp *, const void *, size_t);
void ktrkmem(struct lwp *, int, const void *, size_t);
void ktrmib(struct lwp *, const int *, u_int);