KTR: Add CTR() and TR() macros which accept a variable number of arguments.
These can be used in place of the CTRn() macros which require n to match the number of optional arguments. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D34852
This commit is contained in:
parent
c434b26cf3
commit
4eb43c2c46
@ -23,7 +23,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 26, 2021
|
||||
.Dd April 12, 2022
|
||||
.Dt KTR 9
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -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 @@ or
|
||||
.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 @@ argument is a
|
||||
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 @@ and formatting is done at the dump time.
|
||||
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 @@ The KTR kernel tracing facility first appeared in
|
||||
.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
|
||||
|
@ -107,6 +107,13 @@ void ktr_tracepoint(uint64_t mask, const char *file, int line,
|
||||
#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
|
||||
|
Loading…
Reference in New Issue
Block a user