class ThreadSampler

Defined at line 70 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

Public Methods

zx::result<> SetUp (const zx_sampler_config_t & config)

Defined at line 31 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

void ThreadSampler ()

Defined at line 72 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

void ~ThreadSampler ()

Defined at line 73 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

SamplingState State ()

Defined at line 75 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

zx::result<> Start ()

Defined at line 95 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

zx::result<> Stop ()

Defined at line 108 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

ktl::optional<PerCpuBufferRef> GetBufferRefForWriting (cpu_num_t cpu_num)

Atomically acquire a reference to the buffer for `cpu_num` and ensure that the buffers are not

destroyed until the reference is released.

Defined at line 108 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

ktl::optional<ReadToken> GetBufferRefForReading ()

Atomically acquire a reference to the buffer for `cpu_num` and ensure that the buffers are not

destroyed until the reference is released.

Defined at line 150 of file ../../zircon/kernel/lib/thread_sampler/include/lib/thread_sampler/thread_sampler.h

zx::result<> Destroy ()

Defined at line 163 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

ktl::pair<zx_status_t, size_t> ReadUser (user_out_ptr<void> ptr, size_t len)

ReadUser calls into VmObject::ReadUser. As we could be copying to pager backed user memory, we

must not hold any locks.

Defined at line 342 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

void ScheduleMarking ()

Atomically request the current cpu mark a thread for sampling if the session is Running.

Defined at line 407 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

void RescheduleMarking ()

Atomically rerequest the current cpu mark a thread for sampling if the session is Running.

Avoids modifying the ref count unless the session has stopped.

Defined at line 442 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

void CancelMarking ()

Atomically cancel a request that the current cpu mark a thread for sampling.

Defined at line 457 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

zx::result<> SampleThread (zx_koid_t pid, zx_koid_t tid, GeneralRegsSource source, const void * gregs, uint64_t session_id)

Given information about a thread and its registers, walk its userstack and write out a sample

if sampling is enabled.

Must stay out of line: this puts a 512 byte backtrace buffer on the kernel stack (see the

definition), and it is reached only when a sampling session is running. Inlined into a caller

on the exception path, that buffer would be charged to every exception's frame rather than to

this shallow-stack call site.

Defined at line 204 of file ../../zircon/kernel/lib/thread_sampler/thread_sampler.cc

Records

Friends

class TestThreadSampler