class SamplerDispatcher

Defined at line 19 of file ../../zircon/kernel/object/include/object/sampler_dispatcher.h

A Sampler manages sampling threads and writing the results out to per cpu buffers.

Public Methods

void on_zero_handles ()

When the user drops their end of the buffer/sampler, we need to stop sampling and clean up the

state.

Defined at line 11 of file ../../zircon/kernel/object/sampler_dispatcher.cc

zx::result<KernelHandle<SamplerDispatcher>> Create (const zx_sampler_config_t & config)

Defined at line 17 of file ../../zircon/kernel/object/sampler_dispatcher.cc

void ~SamplerDispatcher ()

Defined at line 21 of file ../../zircon/kernel/object/include/object/sampler_dispatcher.h

zx_obj_type_t get_type ()

Defined at line 27 of file ../../zircon/kernel/object/include/object/sampler_dispatcher.h

zx::result<> Start ()

Defined at line 36 of file ../../zircon/kernel/object/sampler_dispatcher.cc

zx::result<> Stop ()

Defined at line 34 of file ../../zircon/kernel/object/sampler_dispatcher.cc

zx::result<> AddThread (const fbl::RefPtr<ThreadDispatcher> & thread)
zx::result<> SampleThread (zx_koid_t pid, zx_koid_t tid, GeneralRegsSource source, const void * gregs)

Given a thread's registers, pid, and tid, walk the thread's user stack and write each

pointer to the sampling buffers if sampling is enabled.

WARNING: SampleThread both

a) does a large number of user copies, and

b) allocates a large amount of stack space

It should only be called from Thread::Current::ProcessPendingSignals where we can be user that

the user copies are safe to do and where the current stack size should be relatively shallow.

Defined at line 38 of file ../../zircon/kernel/object/sampler_dispatcher.cc

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

Read out the data contained in the sampler buffers into `ptr` return the number of bytes

written. The Sampling state must be Stopped before calling this function.

`len` _must_ be at least equal to the total size of the sampler buffers, which can be queried

by passing a nullptr `ptr`. In this case, no data will be written and the return value will be

the required minimum size of the buffer to write to.

Defined at line 43 of file ../../zircon/kernel/object/sampler_dispatcher.cc

Protected Methods

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

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

if sampling is enabled.

void SamplerDispatcher ()

Defined at line 55 of file ../../zircon/kernel/object/include/object/sampler_dispatcher.h