From bef4bf1adf2652cbee085d36c7475cb2db3fa869 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 27 Jan 2006 22:17:31 +0000 Subject: Add a new sysctl, debug.ktr.clear. If you write a non-zero value to this sysctl then it will clear the KTR buffer. Note that if you have active KTR traces at the same time as a clear operation the behavior is undefined, though it shouldn't panic. --- sys/kern/kern_ktr.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'sys/kern') diff --git a/sys/kern/kern_ktr.c b/sys/kern/kern_ktr.c index ad5d8e800035..7dfaec99bf20 100644 --- a/sys/kern/kern_ktr.c +++ b/sys/kern/kern_ktr.c @@ -100,6 +100,26 @@ SYSCTL_INT(_debug_ktr, OID_AUTO, version, CTLFLAG_RD, &ktr_version, 0, ""); volatile int ktr_idx = 0; struct ktr_entry ktr_buf[KTR_ENTRIES]; +static int +sysctl_debug_ktr_clear(SYSCTL_HANDLER_ARGS) +{ + int clear, error; + + clear = 0; + error = sysctl_handle_int(oidp, &clear, 0, req); + if (error || !req->newptr) + return (error); + + if (clear) { + bzero(ktr_buf, sizeof(ktr_buf)); + ktr_idx = 0; + } + + return (error); +} +SYSCTL_PROC(_debug_ktr, OID_AUTO, clear, CTLTYPE_INT|CTLFLAG_RW, 0, 0, + sysctl_debug_ktr_clear, "I", "Clear KTR Buffer"); + #ifdef KTR_VERBOSE int ktr_verbose = KTR_VERBOSE; TUNABLE_INT("debug.ktr.verbose", &ktr_verbose); -- cgit v1.2.3