diff options
author | jasone <jasone@FreeBSD.org> | 2000-09-07 01:29:44 +0000 |
---|---|---|
committer | jasone <jasone@FreeBSD.org> | 2000-09-07 01:29:44 +0000 |
commit | acf1927de02afda4855ec278b1128fd9446405ea (patch) | |
tree | 933220e815ca47c927c731c502b972d6521ca88f /sys/kern | |
parent | 2359f15a4f302f0b4f64c646630521ccf8383ae9 (diff) | |
download | FreeBSD-src-acf1927de02afda4855ec278b1128fd9446405ea.zip FreeBSD-src-acf1927de02afda4855ec278b1128fd9446405ea.tar.gz |
Add KTR, a facility that logs kernel events in order to to facilitate
debugging.
Acquired from: BSDi (BSD/OS)
Submitted by: dfr, grog, jake, jhb
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_ktr.c | 64 | ||||
-rw-r--r-- | sys/kern/kern_ktrace.c | 16 |
2 files changed, 72 insertions, 8 deletions
diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c new file mode 100644 index 0000000..486379d --- /dev/null +++ b/sys/kern/kern_ktr.c @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2000 + * John Baldwin <jhb@FreeBSD.org>. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the author nor the names of any co-contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +/* + * This module holds the global variables used by KTR. + */ + +#include <sys/types.h> +#include <sys/time.h> +#include <sys/ktr.h> +#include <sys/linker_set.h> +#include <sys/sysctl.h> + +#ifdef KTR_EXTEND +/* + * This variable is used only by gdb to work out what fields are in + * ktr_entry. + */ +int ktr_extend = 1; +SYSCTL_INT(_debug, OID_AUTO, ktr_extend, CTLFLAG_RD, &ktr_extend, 1, ""); +#else +int ktr_extend = 0; +SYSCTL_INT(_debug, OID_AUTO, ktr_extend, CTLFLAG_RD, &ktr_extend, 0, ""); +#endif + +int ktr_cpumask = KTR_CPUMASK; +SYSCTL_INT(_debug, OID_AUTO, ktr_cpumask, CTLFLAG_RW, &ktr_cpumask, KTR_CPUMASK, ""); + +int ktr_mask = KTR_MASK; +SYSCTL_INT(_debug, OID_AUTO, ktr_mask, CTLFLAG_RW, &ktr_mask, KTR_MASK, ""); + +int ktr_entries = KTR_ENTRIES; +SYSCTL_INT(_debug, OID_AUTO, ktr_entries, CTLFLAG_RD, &ktr_entries, KTR_ENTRIES, ""); + +volatile int ktr_idx = 0; +struct ktr_entry ktr_buf[KTR_ENTRIES]; diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index ef82c6c..e51f8d1 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -100,7 +100,7 @@ ktrsyscall(vp, code, narg, args) argp = &ktp->ktr_args[0]; for (i = 0; i < narg; i++) *argp++ = args[i]; - kth->ktr_buf = (caddr_t)ktp; + kth->ktr_buffer = (caddr_t)ktp; kth->ktr_len = len; ktrwrite(vp, kth, NULL); FREE(ktp, M_KTRACE); @@ -124,7 +124,7 @@ ktrsysret(vp, code, error, retval) ktp.ktr_error = error; ktp.ktr_retval = retval; /* what about val2 ? */ - kth->ktr_buf = (caddr_t)&ktp; + kth->ktr_buffer = (caddr_t)&ktp; kth->ktr_len = sizeof(struct ktr_sysret); ktrwrite(vp, kth, NULL); @@ -143,7 +143,7 @@ ktrnamei(vp, path) p->p_traceflag |= KTRFAC_ACTIVE; kth = ktrgetheader(KTR_NAMEI); kth->ktr_len = strlen(path); - kth->ktr_buf = path; + kth->ktr_buffer = path; ktrwrite(vp, kth, NULL); FREE(kth, M_KTRACE); @@ -168,7 +168,7 @@ ktrgenio(vp, fd, rw, uio, error) kth = ktrgetheader(KTR_GENIO); ktg.ktr_fd = fd; ktg.ktr_rw = rw; - kth->ktr_buf = (caddr_t)&ktg; + kth->ktr_buffer = (caddr_t)&ktg; kth->ktr_len = sizeof(struct ktr_genio); uio->uio_offset = 0; uio->uio_rw = UIO_WRITE; @@ -196,7 +196,7 @@ ktrpsig(vp, sig, action, mask, code) kp.action = action; kp.mask = *mask; kp.code = code; - kth->ktr_buf = (caddr_t)&kp; + kth->ktr_buffer = (caddr_t)&kp; kth->ktr_len = sizeof (struct ktr_psig); ktrwrite(vp, kth, NULL); @@ -217,7 +217,7 @@ ktrcsw(vp, out, user) kth = ktrgetheader(KTR_CSW); kc.out = out; kc.user = user; - kth->ktr_buf = (caddr_t)&kc; + kth->ktr_buffer = (caddr_t)&kc; kth->ktr_len = sizeof (struct ktr_csw); ktrwrite(vp, kth, NULL); @@ -365,7 +365,7 @@ utrace(curp, uap) kth = ktrgetheader(KTR_USER); MALLOC(cp, caddr_t, uap->len, M_KTRACE, M_WAITOK); if (!copyin(uap->addr, cp, uap->len)) { - kth->ktr_buf = cp; + kth->ktr_buffer = cp; kth->ktr_len = uap->len; ktrwrite(p->p_tracep, kth, NULL); } @@ -474,7 +474,7 @@ ktrwrite(vp, kth, uio) auio.uio_procp = curproc; if (kth->ktr_len > 0) { auio.uio_iovcnt++; - aiov[1].iov_base = kth->ktr_buf; + aiov[1].iov_base = kth->ktr_buffer; aiov[1].iov_len = kth->ktr_len; auio.uio_resid += kth->ktr_len; if (uio != NULL) |