| 6 |
| 7 | #include "base/profiler/native_unwinder_mac.h" |
| 8 | #include "base/profiler/stack_copier_suspend.h" |
| 9 | #include "base/profiler/stack_sampler_impl.h" |
| 10 | #include "base/profiler/suspendable_thread_delegate_mac.h" |
| 11 |
| 12 | namespace base { |
| 13 |
| 14 | // static |
| 15 | std::unique_ptr<StackSampler> StackSampler::Create( |
| 16 | SamplingProfilerThreadToken thread_token, |
| 17 | ModuleCache* module_cache, |
| 18 | StackSamplerTestDelegate* test_delegate, |
| 19 | std::unique_ptr<Unwinder> native_unwinder) { |
| 20 | DCHECK(!native_unwinder); |
| 21 | return std::make_unique<StackSamplerImpl>( |
| 22 | std::make_unique<StackCopierSuspend>( |
| 23 | std::make_unique<SuspendableThreadDelegateMac>(thread_token)), |
| 24 | std::make_unique<NativeUnwinderMac>(module_cache), module_cache, |
| 25 | test_delegate); |
| 26 | } |
| 27 |
| 28 | // static |
| 29 | size_t StackSampler::GetStackBufferSize() { |
| 30 | size_t stack_size = PlatformThread::GetDefaultThreadStackSize(); |
| 31 |
| 32 | // If getrlimit somehow fails, return the default macOS main thread stack size |
| 33 | // of 8 MB (DFLSSIZ in <i386/vmparam.h>) with extra wiggle room. |
| 34 | return stack_size > 0 ? stack_size : 12 * 1024 * 1024; |
| 35 | } |
| 36 |
| 37 | } // namespace base |
| 38 |