cadets / loom

The LOOM IR instrumentation framework
Other
19 stars 4 forks source link

KTrace output #10

Closed trombonehero closed 8 years ago

trombonehero commented 8 years ago

Add a ktrace Logger for instrumented events.

rwatson commented 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.

trombonehero commented 8 years ago

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.

rwatson commented 8 years ago

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.

trombonehero commented 8 years ago

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.

trombonehero commented 8 years ago

This should be addressed by https://github.com/cadets/loom/commit/7d0ed2935374fd3e01a0bd20158138d2dd5ea3da, https://github.com/cadets/loom/commit/068fe522f13c8bd0814e06e0f4e02c43b2001a2a, etc.