Movatterモバイル変換


[0]ホーム

URL:


Google Git
Sign in
chromium /chromium /src /refs/heads/main /. /base /linux_util.h
blob: 9f913e8f7fe730fe09749e40b821f5f0c0bd45f5 [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:06[diff] [blame]1// Copyright 2012 The Chromium Authors
sgk@google.com75ae5422009-04-21 17:20:10[diff] [blame]2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
thestig@chromium.org9bc8cff2010-04-03 01:05:39[diff] [blame]5#ifndef BASE_LINUX_UTIL_H_
6#define BASE_LINUX_UTIL_H_
sgk@google.com75ae5422009-04-21 17:20:10[diff] [blame]7
8#include<stdint.h>
craig.schlenter@chromium.orgb28af7522009-10-29 18:21:30[diff] [blame]9#include<sys/types.h>
sgk@google.com75ae5422009-04-21 17:20:10[diff] [blame]10
thestig@chromium.org912c6452009-07-17 05:55:51[diff] [blame]11#include<string>
Alexandr Ilind4f4b342019-01-08 15:34:09[diff] [blame]12#include<vector>
thestig@chromium.org912c6452009-07-17 05:55:51[diff] [blame]13
darin@chromium.org0bea7252011-08-05 15:34:00[diff] [blame]14#include"base/base_export.h"
evan@chromium.org68a008e82011-05-02 17:54:14[diff] [blame]15
sgk@google.com75ae5422009-04-21 17:20:10[diff] [blame]16namespacebase{
17
mnissler@chromium.org6dde9d72010-08-26 08:55:22[diff] [blame]18// This is declared here so the crash reporter can access the memory directly
19// in compromised context without going through the standard library.
darin@chromium.org0bea7252011-08-05 15:34:00[diff] [blame]20BASE_EXPORTexternchar g_linux_distro[];
mnissler@chromium.org6dde9d72010-08-26 08:55:22[diff] [blame]21
brettw@google.coma8e20582010-12-31 17:18:50[diff] [blame]22// Get the Linux Distro if we can, or return "Unknown".
darin@chromium.org0bea7252011-08-05 15:34:00[diff] [blame]23BASE_EXPORT std::stringGetLinuxDistro();
thestig@chromium.org912c6452009-07-17 05:55:51[diff] [blame]24
Tomas Popela5b9b01f2019-09-10 19:42:31[diff] [blame]25#if defined(UNIT_TEST)
26// Get the value of given key from the given input (content of the
27// /etc/os-release file. Exposed for testing.
28BASE_EXPORT std::stringGetKeyValueFromOSReleaseFileForTesting(
29const std::string& input,
30constchar* key);
31#endif// defined(UNIT_TEST)
32
mnissler@chromium.org6dde9d72010-08-26 08:55:22[diff] [blame]33// Set the Linux Distro string.
darin@chromium.org0bea7252011-08-05 15:34:00[diff] [blame]34BASE_EXPORTvoidSetLinuxDistro(const std::string& distro);
mnissler@chromium.org6dde9d72010-08-26 08:55:22[diff] [blame]35
Alexandr Ilind4f4b342019-01-08 15:34:09[diff] [blame]36// For a given process |pid|, get a list of all its threads. On success, returns
37// true and appends the list of threads to |tids|. Otherwise, returns false.
38BASE_EXPORTboolGetThreadsForProcess(pid_t pid, std::vector<pid_t>* tids);
39
Igor Kraskevichbfc62af2023-10-17 15:09:28[diff] [blame]40// Get a list of all threads for the current process. On success, returns true
41// and appends the list of threads to |tids|. Otherwise, returns false.
42// Unlike the function above, this function reads /proc/self/tasks, not
43// /proc/<pid>/tasks. On Android, the former should always be accessible to
44// GPU and Browser processes, while the latter may or may not be accessible
45// depending on the system and the app configuration.
46BASE_EXPORTboolGetThreadsForCurrentProcess(std::vector<pid_t>* tids);
47
thestig@chromium.org662183142010-07-16 19:28:17[diff] [blame]48// For a given process |pid|, look through all its threads and find the first
49// thread with /proc/[pid]/task/[thread_id]/syscall whose first N bytes matches
50// |expected_data|, where N is the length of |expected_data|.
kmixter@chromium.orgcb7d53e2011-06-21 04:21:06[diff] [blame]51// Returns the thread id or -1 on error. If |syscall_supported| is
52// set to false the kernel does not support syscall in procfs.
darin@chromium.org0bea7252011-08-05 15:34:00[diff] [blame]53BASE_EXPORTpid_tFindThreadIDWithSyscall(pid_t pid,
54const std::string& expected_data,
55bool* syscall_supported);
thestig@chromium.org662183142010-07-16 19:28:17[diff] [blame]56
reveman7b97c322016-09-20 02:10:58[diff] [blame]57// For a given process |pid|, look through all its threads and find the first
58// thread with /proc/[pid]/task/[thread_id]/status where NSpid matches |ns_tid|.
59// Returns the thread id or -1 on error. If |ns_pid_supported| is
60// set to false the kernel does not support NSpid in procfs.
61BASE_EXPORTpid_tFindThreadID(pid_t pid,pid_t ns_tid,bool* ns_pid_supported);
62
sgk@google.com75ae5422009-04-21 17:20:10[diff] [blame]63}// namespace base
64
thestig@chromium.org9bc8cff2010-04-03 01:05:39[diff] [blame]65#endif// BASE_LINUX_UTIL_H_

[8]ページ先頭

©2009-2025 Movatter.jp