// Copyright 2017 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/profiler/stack_sampler.h" #include #include "base/bind.h" #include "base/check.h" #include "base/profiler/frame_pointer_unwinder.h" #include "base/profiler/stack_copier_suspend.h" #include "base/profiler/stack_sampler_impl.h" #include "base/profiler/suspendable_thread_delegate_mac.h" #include "base/profiler/unwinder.h" namespace base { namespace { std::vector> CreateUnwinders() { std::vector> unwinders; unwinders.push_back(std::make_unique()); return unwinders; } } // namespace // static std::unique_ptr StackSampler::Create( SamplingProfilerThreadToken thread_token, ModuleCache* module_cache, UnwindersFactory core_unwinders_factory, RepeatingClosure record_sample_callback, StackSamplerTestDelegate* test_delegate) { DCHECK(!core_unwinders_factory); return std::make_unique( std::make_unique( std::make_unique(thread_token)), BindOnce(&CreateUnwinders), module_cache, std::move(record_sample_callback), test_delegate); } // static size_t StackSampler::GetStackBufferSize() { size_t stack_size = PlatformThread::GetDefaultThreadStackSize(); // If getrlimit somehow fails, return the default macOS main thread stack size // of 8 MB (DFLSSIZ in ) with extra wiggle room. return stack_size > 0 ? stack_size : 12 * 1024 * 1024; } } // namespace base