1 // Copyright 2019 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/profiler/sampling_profiler_thread_token.h"
7 #include "build/build_config.h"
9 #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
12 #include "base/profiler/stack_base_address_posix.h"
17 SamplingProfilerThreadToken GetSamplingProfilerCurrentThreadToken() {
18 PlatformThreadId id = PlatformThread::CurrentId();
19 #if BUILDFLAG(IS_ANDROID)
20 return {id, pthread_self()};
21 #elif BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
22 absl::optional<uintptr_t> maybe_stack_base =
23 GetThreadStackBaseAddress(id, pthread_self());
24 return {id, maybe_stack_base};