class KTrace
Defined at line 649 of file ../../zircon/kernel/include/lib/ktrace.h
Public Methods
zx::result<size_t> ReadUser (user_out_ptr<void> ptr, uint32_t off, size_t len)
ReadUser reads len bytes from the ktrace buffer starting at offset off into the given user
buffer.
May block on page requests and must be called without locks held.
The return value is one of the following:
* If ptr is nullptr, the number of bytes needed to read all of the available data is returned.
* Otherwise:
* On success, this function returns the number of bytes that were read into the buffer.
* On failure, a zx_status_t error code is returned.
Defined at line 317 of file ../../zircon/kernel/lib/ktrace/ktrace.cc
zx::result<Reservation> Reserve (uint64_t header)
Reserve reserves a slot of memory to write a record into.
This is likely not the method you want to use. In fact, it is exposed as a public method only
because the FXT serializer library requires it. If you're trying to write a record to the
global KTrace buffer, prefer using the Emit* methods below instead.
This method MUST be invoked with interrupts disabled to enforce the single-writer invariant of
the per-CPU buffers.
Defined at line 134 of file ../../zircon/kernel/lib/ktrace/ktrace.cc
void InitHook (unsigned int )
Initializes all of the state needed to support kernel tracing. This includes, but is not
limited to, calling Init on the KTrace instance. This is a no-op if tracing has been disabled.
Defined at line 385 of file ../../zircon/kernel/lib/ktrace/ktrace.cc
zx_status_t Control (uint32_t action, uint32_t options)
Control is responsible for starting, stopping, or rewinding the ktrace buffer.
The meaning of the options changes based on the action. If the action is to start tracing,
then the options field functions as the group mask.
Defined at line 898 of file ../../zircon/kernel/include/lib/ktrace.h
zx_instant_boot_ticks_t Timestamp ()
Returns the timestamp that should be used to annotate ktrace records.
Defined at line 949 of file ../../zircon/kernel/include/lib/ktrace.h
(lambda at ../../zircon/kernel/include/lib/ktrace.h:956:12) LatchedTimestamp ()
Returns a callable that will return the current ktrace timestamp on the
first call and repeat the same value on subsequent calls. This is useful
for emitting multiple trace events with the same timestamp while keeping
sampling of the timestamp within the trace predicates.
Defined at line 955 of file ../../zircon/kernel/include/lib/ktrace.h
bool CategoryEnabled (const fxt::InternedCategory & category)
Defined at line 964 of file ../../zircon/kernel/include/lib/ktrace.h
void Probe (Context context, const fxt::InternedString & label, uint64_t a, uint64_t b)
Generates an instant event record that contains the given arguments if the kernel:probe
category is enabled.
Defined at line 970 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitKernelObject (zx_koid_t koid, zx_obj_type_t obj_type, const fxt::StringRef<name_type> & name, const ktl::tuple<Ts...> & args)
The Emit* functions provide an API by which the ktrace macros above can write a trace record
to the ktrace buffer.
Defined at line 984 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitComplete (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t start_time, uint64_t end_time, Context context, const ktl::tuple<Ts...> & args)
Defined at line 997 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitInstant (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, Unused , const ktl::tuple<Ts...> & args)
Defined at line 1011 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitDurationBegin (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, Unused , const ktl::tuple<Ts...> & args)
Defined at line 1024 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitDurationEnd (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, Unused , const ktl::tuple<Ts...> args)
Defined at line 1038 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitCounter (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, uint64_t counter_id, const ktl::tuple<Ts...> & args)
Defined at line 1052 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitFlowBegin (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, uint64_t flow_id, const ktl::tuple<Ts...> & args)
Defined at line 1066 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitFlowStep (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, uint64_t flow_id, const ktl::tuple<Ts...> & args)
Defined at line 1080 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitFlowEnd (const fxt::InternedCategory & category, const fxt::StringRef<name_type> & label, uint64_t timestamp, Context context, uint64_t flow_id, const ktl::tuple<Ts...> & args)
Defined at line 1094 of file ../../zircon/kernel/include/lib/ktrace.h
template <typename... Ts>
void EmitThreadWakeup (const cpu_num_t cpu, fxt::ThreadRef<fxt::RefType::kInline> thread_ref, const ktl::tuple<Ts...> & args)
The EmitThreadWakeup and EmitContextSwitch functions have slightly different signatures from
the other Emit functions because they do not utilize the FXT_* macros to invoke them.
Defined at line 1110 of file ../../zircon/kernel/include/lib/ktrace.h
template <typename... Ts>
void EmitContextSwitch (const cpu_num_t cpu, zx_thread_state_t outgoing_thread_state, const fxt::ThreadRef<fxt::RefType::kInline> & outgoing_thread, const fxt::ThreadRef<fxt::RefType::kInline> & incoming_thread, const ktl::tuple<Ts...> & args)
Defined at line 1123 of file ../../zircon/kernel/include/lib/ktrace.h
KTrace & GetInstance ()
Retrieves a reference to the global KTrace instance.
Defined at line 1138 of file ../../zircon/kernel/include/lib/ktrace.h
Enumerations
enum Context
| Name | Value |
|---|---|
| Thread | 0 |
| Cpu | 1 |
Specifies whether a trace record applies to the current thread or CPU.
Defined at line 938 of file ../../zircon/kernel/include/lib/ktrace.h
Records
Friends
class TestKTrace
class KTraceTests