blob: 979ae0dbd824765914708a6d5c314b7632140965 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
/* Linux-specific PROCFS manipulation routines.
Copyright (C) 2011-2015 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef COMMON_LINUX_PROCFS_H
#define COMMON_LINUX_PROCFS_H
#include <unistd.h>
/* Return the TGID of LWPID from /proc/pid/status. Returns -1 if not
found. Failure to open the /proc file results in a warning. */
extern int linux_proc_get_tgid (pid_t lwpid);
/* Return the TracerPid of LWPID from /proc/pid/status. Returns -1 if
not found. Does not warn on failure to open the /proc file. */
extern pid_t linux_proc_get_tracerpid_nowarn (pid_t lwpid);
/* Detect `T (stopped)' in `/proc/PID/status'.
Other states including `T (tracing stop)' are reported as false. */
extern int linux_proc_pid_is_stopped (pid_t pid);
/* Return non-zero if PID is a zombie. Failure to open the
/proc/pid/status file results in a warning. */
extern int linux_proc_pid_is_zombie (pid_t pid);
/* Return non-zero if PID is a zombie. Does not warn on failure to
open the /proc file. */
extern int linux_proc_pid_is_zombie_nowarn (pid_t pid);
/* Return non-zero if /proc/PID/status indicates that PID is gone
(i.e., in Z/Zombie or X/Dead state). Failure to open the /proc
file is assumed to indicate the thread is gone. */
extern int linux_proc_pid_is_gone (pid_t pid);
/* Return an opaque string identifying PID's NS namespace or NULL if
* the information is unavailable. The returned string must be
* released with xfree. */
extern char *linux_proc_pid_get_ns (pid_t pid, const char *ns);
/* Callback function for linux_proc_attach_tgid_threads. If the PTID
thread is not yet known, try to attach to it and return true,
otherwise return false. */
typedef int (*linux_proc_attach_lwp_func) (ptid_t ptid);
/* If PID is a tgid, scan the /proc/PID/task/ directory for existing
threads, and call FUNC for each thread found. */
extern void linux_proc_attach_tgid_threads (pid_t pid,
linux_proc_attach_lwp_func func);
/* Return true if the /proc/PID/task/ directory exists. */
extern int linux_proc_task_list_dir_exists (pid_t pid);
#endif /* COMMON_LINUX_PROCFS_H */
|