class KTrace
Defined at line 650 of file ../../zircon/kernel/include/lib/ktrace.h
Public Methods
zx::result<size_t> ReadUser (user_out_ptr<void>ptr,uint32_toff,size_tlen)
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 299 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 82 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 367 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 657 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 707 of file ../../zircon/kernel/include/lib/ktrace.h
(lambda at ../../zircon/kernel/include/lib/ktrace.h:714: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 713 of file ../../zircon/kernel/include/lib/ktrace.h
bool CategoryEnabled (const fxt::InternedCategory & category)
Defined at line 722 of file ../../zircon/kernel/include/lib/ktrace.h
void Probe (Contextcontext,const fxt::InternedString &label,uint64_ta,uint64_tb)
Generates an instant event record that contains the given arguments if the kernel:probe
category is enabled.
Defined at line 728 of file ../../zircon/kernel/include/lib/ktrace.h
template <fxt::RefType name_type, typename... Ts>
void EmitKernelObject (zx_koid_tkoid,zx_obj_type_tobj_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 742 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_tstart_time,uint64_tend_time,Contextcontext,const ktl::tuple<Ts...> &args)
Defined at line 755 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_ttimestamp,Contextcontext,Unused,const ktl::tuple<Ts...> &args)
Defined at line 769 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_ttimestamp,Contextcontext,Unused,const ktl::tuple<Ts...> &args)
Defined at line 782 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_ttimestamp,Contextcontext,Unused,const ktl::tuple<Ts...>args)
Defined at line 796 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_ttimestamp,Contextcontext,uint64_tcounter_id,const ktl::tuple<Ts...> &args)
Defined at line 810 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_ttimestamp,Contextcontext,uint64_tflow_id,const ktl::tuple<Ts...> &args)
Defined at line 824 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_ttimestamp,Contextcontext,uint64_tflow_id,const ktl::tuple<Ts...> &args)
Defined at line 838 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_ttimestamp,Contextcontext,uint64_tflow_id,const ktl::tuple<Ts...> &args)
Defined at line 852 of file ../../zircon/kernel/include/lib/ktrace.h
template <typename... Ts>
void EmitThreadWakeup (const cpu_num_tcpu,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 868 of file ../../zircon/kernel/include/lib/ktrace.h
template <typename... Ts>
void EmitContextSwitch (const cpu_num_tcpu,zx_thread_state_toutgoing_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 881 of file ../../zircon/kernel/include/lib/ktrace.h
KTrace & GetInstance ()
Retrieves a reference to the global KTrace instance.
Defined at line 896 of file ../../zircon/kernel/include/lib/ktrace.h
Enumerations
enum class Context
| Name | Value |
|---|---|
| Thread | 0 |
| Cpu | 1 |
Specifies whether a trace record applies to the current thread or CPU.
Defined at line 696 of file ../../zircon/kernel/include/lib/ktrace.h
Records
Friends
class TestKTrace
class KTraceTests