Index: share/man/man9/ktr.9 =================================================================== --- share/man/man9/ktr.9 +++ share/man/man9/ktr.9 @@ -39,6 +39,8 @@ .Vt "extern int ktr_verbose" ; .Vt "extern struct ktr_entry ktr_buf[]" ; .Ft void +.Fn CTR "u_int mask" "char *format" "..." +.Ft void .Fn CTR0 "u_int mask" "char *format" .Ft void .Fn CTR1 "u_int mask" "char *format" "arg1" @@ -64,6 +66,8 @@ .Xr ktrdump 8 . .Pp Events are created and logged in the kernel via the +.Dv CTR +and .Dv CTR Ns Ar x macros. The first parameter is a mask of event types @@ -81,7 +85,7 @@ style format string used to build the text of the event log message. Following the .Fa format -string are zero to five arguments referenced by +string are zero to six arguments referenced by .Fa format . Each event is logged with a file name and source line number of the originating CTR call, and a timestamp in addition to the log message. @@ -91,7 +95,9 @@ Do not use pointers to the objects with limited lifetime, for instance, strings, because the pointer may become invalid when buffer is printed. .Pp -Note that the different macros differ only in the number of arguments each +The +.Dv CTR Ns Ar x +macros differ only in the number of arguments each one takes, as indicated by its name. .Pp The @@ -143,6 +149,11 @@ .Bsx 3.0 and was imported into .Fx 5.0 . +.Pp +The +.Fn CTR +macro accepting a variable number of arguments first appeared in +.Fx 14.0 . .Sh BUGS Currently there is one global buffer shared among all CPUs. It might be profitable at some point in time to use per-CPU buffers instead Index: sys/sys/ktr.h =================================================================== --- sys/sys/ktr.h +++ sys/sys/ktr.h @@ -107,6 +107,13 @@ #define TR5(d, p1, p2, p3, p4, p5) CTR5(KTR_GEN, d, p1, p2, p3, p4, p5) #define TR6(d, p1, p2, p3, p4, p5, p6) CTR6(KTR_GEN, d, p1, p2, p3, p4, p5, p6) +#define _KTR_MACRO(m, format, _1, _2, _3, _4, _5, _6, NAME, ...) \ + NAME +#define CTR(...) \ + _KTR_MACRO(__VA_ARGS__, CTR6, CTR5, CTR4, CTR3, CTR2, CTR1, \ + CTR0)(__VA_ARGS__) +#define TR(...) CTR(KTR_GEN, __VA_ARGS__) + /* * The event macros implement KTR graphic plotting facilities provided * by src/tools/sched/schedgraph.py. Three generic types of events are