1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_LINUX_UTIL_H_
6 #define BASE_LINUX_UTIL_H_
14 #include "base/base_export.h"
18 // This is declared here so the crash reporter can access the memory directly
19 // in compromised context without going through the standard library.
20 BASE_EXPORT extern char g_linux_distro[];
22 // Get the Linux Distro if we can, or return "Unknown".
23 BASE_EXPORT std::string GetLinuxDistro();
25 // Set the Linux Distro string.
26 BASE_EXPORT void SetLinuxDistro(const std::string& distro);
28 // For a given process |pid|, get a list of all its threads. On success, returns
29 // true and appends the list of threads to |tids|. Otherwise, returns false.
30 BASE_EXPORT bool GetThreadsForProcess(pid_t pid, std::vector<pid_t>* tids);
32 // For a given process |pid|, look through all its threads and find the first
33 // thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches
34 // |expected_data|, where N is the length of |expected_data|.
35 // Returns the thread id or -1 on error. If |syscall_supported| is
36 // set to false the kernel does not support syscall in procfs.
37 BASE_EXPORT pid_t FindThreadIDWithSyscall(pid_t pid,
38 const std::string& expected_data,
39 bool* syscall_supported);
41 // For a given process |pid|, look through all its threads and find the first
42 // thread with /proc/[pid]/task/[thread_id]/status where NSpid matches |ns_tid|.
43 // Returns the thread id or -1 on error. If |ns_pid_supported| is
44 // set to false the kernel does not support NSpid in procfs.
45 BASE_EXPORT pid_t FindThreadID(pid_t pid, pid_t ns_tid, bool* ns_pid_supported);
49 #endif // BASE_LINUX_UTIL_H_