#include "base/profiler/stack_sampler.h"
#include <iterator>
#include <utility>
#include "base/check.h"
#include "base/compiler_specific.h"
#include "base/memory/ptr_util.h"
#include "base/memory/stack_allocated.h"
#include "base/metrics/histogram_functions.h"
#include "base/numerics/safe_conversions.h"
#include "base/profiler/metadata_recorder.h"
#include "base/profiler/profile_builder.h"
#include "base/profiler/sample_metadata.h"
#include "base/profiler/stack_buffer.h"
#include "base/profiler/stack_copier.h"
#include "base/profiler/suspendable_thread_delegate.h"
#include "base/profiler/unwinder.h"
#include "base/ranges/algorithm.h"
#include "base/task/thread_pool.h"
namespace base {
namespace {
CallbackRunner;
Unwinder* GetUnwinder(const UnwinderCapture& state) { … }
UnwinderStateCapture* GetStateCapture(const UnwinderCapture& state) { … }
class StackCopierDelegate : public StackCopier::Delegate { … };
bool g_use_thread_pool = …;
}
StackSampler::~StackSampler() = default;
void StackSampler::SetUseThreadPool(bool use_thread_pool) { … }
std::unique_ptr<StackBuffer> StackSampler::CreateStackBuffer() { … }
void StackSampler::Initialize() { … }
void StackSampler::ThreadPoolRunning() { … }
void StackSampler::Stop(OnceClosure done_callback) { … }
void StackSampler::AddAuxUnwinder(std::unique_ptr<Unwinder> unwinder) { … }
void StackSampler::AddAuxUnwinderWithoutInit(
std::unique_ptr<Unwinder> unwinder) { … }
void StackSampler::RecordStackFrames(StackBuffer* stack_buffer,
PlatformThreadId thread_id,
base::OnceClosure done_callback) { … }
void StackSampler::UnwindComplete(TimeTicks timestamp,
OnceClosure done_callback,
std::vector<Frame> frames) { … }
StackUnwindData* StackSampler::GetStackUnwindData() { … }
std::vector<Frame> StackSampler::WalkStackForTesting(
ModuleCache* module_cache,
RegisterContext* thread_context,
uintptr_t stack_top,
std::vector<UnwinderCapture> unwinders) { … }
std::unique_ptr<StackSampler> StackSampler::CreateForTesting(
std::unique_ptr<StackCopier> stack_copier,
std::unique_ptr<StackUnwindData> stack_unwind_data,
UnwindersFactory core_unwinders_factory,
RepeatingClosure record_sample_callback,
StackSamplerTestDelegate* test_delegate) { … }
StackSampler::StackSampler(std::unique_ptr<StackCopier> stack_copier,
std::unique_ptr<StackUnwindData> stack_unwind_data,
UnwindersFactory core_unwinders_factory,
RepeatingClosure record_sample_callback,
StackSamplerTestDelegate* test_delegate)
: … { … }
std::vector<Frame> StackSampler::WalkStack(
ModuleCache* module_cache,
RegisterContext* thread_context,
uintptr_t stack_top,
std::vector<UnwinderCapture> unwinders) { … }
StackSamplerTestDelegate::~StackSamplerTestDelegate() = default;
StackSamplerTestDelegate::StackSamplerTestDelegate() = default;
}