2 * Copyright (C) 2015 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef SIMPLE_PERF_ENVIRONMENT_H_
18 #define SIMPLE_PERF_ENVIRONMENT_H_
20 #include <sys/types.h>
29 std::vector<int> GetOnlineCpus();
30 std::vector<int> GetCpusFromString(const std::string& s);
32 constexpr char DEFAULT_KERNEL_MMAP_NAME[] = "[kernel.kallsyms]_text";
41 void GetKernelAndModuleMmaps(KernelMmap* kernel_mmap, std::vector<KernelMmap>* module_mmaps);
48 bool GetThreadComms(std::vector<ThreadComm>* thread_comms);
50 constexpr char DEFAULT_EXECNAME_FOR_THREAD_MMAP[] = "//anon";
60 bool GetThreadMmapsInProcess(pid_t pid, std::vector<ThreadMmap>* thread_mmaps);
62 constexpr char DEFAULT_KERNEL_FILENAME_FOR_BUILD_ID[] = "[kernel.kallsyms]";
64 bool GetKernelBuildId(BuildId* build_id);
65 bool GetModuleBuildId(const std::string& module_name, BuildId* build_id);
67 bool GetValidThreadsFromProcessString(const std::string& pid_str, std::set<pid_t>* tid_set);
68 bool GetValidThreadsFromThreadString(const std::string& tid_str, std::set<pid_t>* tid_set);
70 bool GetExecPath(std::string* exec_path);
72 // Expose the following functions for unit tests.
77 const char* module; // If nullptr, the symbol is not in a kernel module.
80 bool ProcessKernelSymbols(const std::string& symbol_file,
81 std::function<bool(const KernelSymbol&)> callback);
83 #endif // SIMPLE_PERF_ENVIRONMENT_H_