a21d2d4b081d51797750602088f1577d047e5ab6
[dragonfly.git] / contrib / gdb-7 / gdb / common / ptid.h
1 /* The ptid_t type and common functions operating on it.
2
3    Copyright (C) 1986-2015 Free Software Foundation, Inc.
4
5    This file is part of GDB.
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19
20 #ifndef PTID_H
21 #define PTID_H
22
23 /* The ptid struct is a collection of the various "ids" necessary for
24    identifying the inferior process/thread being debugged.  This
25    consists of the process id (pid), lightweight process id (lwp) and
26    thread id (tid).  When manipulating ptids, the constructors,
27    accessors, and predicates declared in this file should be used.  Do
28    NOT access the struct ptid members directly.
29
30    process_stratum targets that handle threading themselves should
31    prefer using the ptid.lwp field, leaving the ptid.tid field for any
32    thread_stratum target that might want to sit on top.
33 */
34
35 struct ptid
36 {
37   /* Process id.  */
38   int pid;
39
40   /* Lightweight process id.  */
41   long lwp;
42
43   /* Thread id.  */
44   long tid;
45 };
46
47 typedef struct ptid ptid_t;
48
49 /* The null or zero ptid, often used to indicate no process. */
50 extern ptid_t null_ptid;
51
52 /* The (-1,0,0) ptid, often used to indicate either an error condition
53    or a "don't care" condition, i.e, "run all threads."  */
54 extern ptid_t minus_one_ptid;
55
56 /* Make a ptid given the necessary PID, LWP, and TID components.  */
57 ptid_t ptid_build (int pid, long lwp, long tid);
58
59 /* Make a new ptid from just a pid.  This ptid is usually used to
60    represent a whole process, including all its lwps/threads.  */
61 ptid_t pid_to_ptid (int pid);
62
63 /* Fetch the pid (process id) component from a ptid.  */
64 int ptid_get_pid (ptid_t ptid);
65
66 /* Fetch the lwp (lightweight process) component from a ptid.  */
67 long ptid_get_lwp (ptid_t ptid);
68
69 /* Fetch the tid (thread id) component from a ptid.  */
70 long ptid_get_tid (ptid_t ptid);
71
72 /* Compare two ptids to see if they are equal.  */
73 int ptid_equal (ptid_t ptid1, ptid_t ptid2);
74
75 /* Returns true if PTID represents a whole process, including all its
76    lwps/threads.  Such ptids have the form of (pid,0,0), with pid !=
77    -1.  */
78 int ptid_is_pid (ptid_t ptid);
79
80 /* Return true if PTID's lwp member is non-zero.  */
81 int ptid_lwp_p (ptid_t ptid);
82
83 /* Return true if PTID's tid member is non-zero.  */
84 int ptid_tid_p (ptid_t ptid);
85
86 /* Returns true if PTID matches filter FILTER.  FILTER can be the wild
87    card MINUS_ONE_PTID (all ptid match it); can be a ptid representing
88    a process (ptid_is_pid returns true), in which case, all lwps and
89    threads of that given process match, lwps and threads of other
90    processes do not; or, it can represent a specific thread, in which
91    case, only that thread will match true.  PTID must represent a
92    specific LWP or THREAD, it can never be a wild card.  */
93
94 extern int ptid_match (ptid_t ptid, ptid_t filter);
95
96 #endif