Closed trombonehero closed 8 years ago
As ktr(4)
is not the same as ktrace(1)
, it might be worth using the name ktrace
here rather than ktr
if that is what we mean.
I was considering using ktr(4)
as a kernel-mode logging sink for events (like we use printf
or libxo
in userland). We could then, if I haven't confused myself, fetch these trace events using ktrace(1)
and parse them with... well, that's the next question! It looks like the KTR_USER
type will let us dump up to 2 kB of raw data per event, but what might be even more useful would be a new KTR_NV
type that contains binary representations of objects that libnv
can parse.
The in-kernel ktr(4)
buffer is read using ktrdump(8)
and not ktrace(1)
-- and hence my question. ktr(4)
is a simple, fast, in-kernel ring-buffer-based tracing mechanism used for things like scheduler debugging. ktrace(1)
is a system-call tracing facility for user processes that can also trace other user-relevant debugging events such as context switches, system-call I/O requests, and for the truly crazy, CHERI CCall/CReturn events. Despite similarity of name, they are independent subsystems.
I see my confusion now, but I hope that I can be forgiven because of the naming conventions at play. It looks like, when ktr(4)
was introduced in 2000, ktrace
was already there and using names like ktr_header
and ktr_buf
. Then, an entirely independent subsystem was created with names like ktr_entry
and... ktr_buf
. Helpfully, ktrace
's ktr_buf
was renamed to ktr_buffer
to avoid confusion, but... well, I think that a little confusion is understandable!
Anyway, yes, it seems that I mean ktrace
rather than ktr
with respect to Loom. I shall change this issue's description accordingly and suppress the desire to mass-rename long-settled code.
Add a
ktrace
Logger for instrumented events.