| 6 |
| 7 | #include <pthread.h> |
| 8 |
| 9 | #include "base/threading/platform_thread.h" |
| 10 | #include "build/build_config.h" |
| 11 |
| 12 | namespace base { |
| 13 |
| 14 | std::unique_ptr<StackSampler> StackSampler::Create( |
| 15 | SamplingProfilerThreadToken thread_token, |
| 16 | ModuleCache* module_cache, |
| 17 | StackSamplerTestDelegate* test_delegate, |
| 18 | std::unique_ptr<Unwinder> native_unwinder) { |
| 19 | return nullptr; |
| 20 | } |
| 21 |
| 22 | size_t StackSampler::GetStackBufferSize() { |
| 23 | size_t stack_size = PlatformThread::GetDefaultThreadStackSize(); |
| 24 |
| 25 | pthread_attr_t attr; |
| 26 | if (stack_size == 0 && pthread_attr_init(&attr) == 0) { |
| 27 | if (pthread_attr_getstacksize(&attr, &stack_size) != 0) |
| 28 | stack_size = 0; |
| 29 | pthread_attr_destroy(&attr); |
| 30 | } |
| 31 |
| 32 | // Maximum limits under NPTL implementation. |
| 33 | constexpr size_t kDefaultStackLimit = 4 * (1 << 20); |
| 34 | return stack_size > 0 ? stack_size : kDefaultStackLimit; |
| 35 | } |
| 36 |
| 37 | } // namespace base |
| 38 |