xref: /dflybsd-src/contrib/gdb-7/gdb/common/ptid.h (revision 8a286ab35ddbd8fd8ac6b75a2820e262cf43e21c)
1a45ae5f8SJohn Marino /* The ptid_t type and common functions operating on it.
2a45ae5f8SJohn Marino 
3ef5ccd6cSJohn Marino    Copyright (C) 1986-2013 Free Software Foundation, Inc.
4a45ae5f8SJohn Marino 
5a45ae5f8SJohn Marino    This file is part of GDB.
6a45ae5f8SJohn Marino 
7a45ae5f8SJohn Marino    This program is free software; you can redistribute it and/or modify
8a45ae5f8SJohn Marino    it under the terms of the GNU General Public License as published by
9a45ae5f8SJohn Marino    the Free Software Foundation; either version 3 of the License, or
10a45ae5f8SJohn Marino    (at your option) any later version.
11a45ae5f8SJohn Marino 
12a45ae5f8SJohn Marino    This program is distributed in the hope that it will be useful,
13a45ae5f8SJohn Marino    but WITHOUT ANY WARRANTY; without even the implied warranty of
14a45ae5f8SJohn Marino    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15a45ae5f8SJohn Marino    GNU General Public License for more details.
16a45ae5f8SJohn Marino 
17a45ae5f8SJohn Marino    You should have received a copy of the GNU General Public License
18a45ae5f8SJohn Marino    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19a45ae5f8SJohn Marino 
20a45ae5f8SJohn Marino #ifndef PTID_H
21a45ae5f8SJohn Marino #define PTID_H
22a45ae5f8SJohn Marino 
23a45ae5f8SJohn Marino /* The ptid struct is a collection of the various "ids" necessary
24a45ae5f8SJohn Marino    for identifying the inferior.  This consists of the process id
25a45ae5f8SJohn Marino    (pid), thread id (tid), and other fields necessary for uniquely
26a45ae5f8SJohn Marino    identifying the inferior process/thread being debugged.  When
27a45ae5f8SJohn Marino    manipulating ptids, the constructors, accessors, and predicate
28a45ae5f8SJohn Marino    declared in server.h should be used.  These are as follows:
29a45ae5f8SJohn Marino 
30a45ae5f8SJohn Marino       ptid_build	- Make a new ptid from a pid, lwp, and tid.
31a45ae5f8SJohn Marino       pid_to_ptid	- Make a new ptid from just a pid.
32a45ae5f8SJohn Marino       ptid_get_pid	- Fetch the pid component of a ptid.
33a45ae5f8SJohn Marino       ptid_get_lwp	- Fetch the lwp component of a ptid.
34a45ae5f8SJohn Marino       ptid_get_tid	- Fetch the tid component of a ptid.
35a45ae5f8SJohn Marino       ptid_equal	- Test to see if two ptids are equal.
36a45ae5f8SJohn Marino 
37a45ae5f8SJohn Marino    Please do NOT access the struct ptid members directly (except, of
38a45ae5f8SJohn Marino    course, in the implementation of the above ptid manipulation
39a45ae5f8SJohn Marino    functions).  */
40a45ae5f8SJohn Marino 
41a45ae5f8SJohn Marino struct ptid
42a45ae5f8SJohn Marino   {
43a45ae5f8SJohn Marino     /* Process id */
44a45ae5f8SJohn Marino     int pid;
45a45ae5f8SJohn Marino 
46a45ae5f8SJohn Marino     /* Lightweight process id */
47a45ae5f8SJohn Marino     long lwp;
48a45ae5f8SJohn Marino 
49a45ae5f8SJohn Marino     /* Thread id */
50*8a286ab3SJohn Marino     unsigned long tid;
51a45ae5f8SJohn Marino   };
52a45ae5f8SJohn Marino 
53a45ae5f8SJohn Marino typedef struct ptid ptid_t;
54a45ae5f8SJohn Marino 
55a45ae5f8SJohn Marino /* The null or zero ptid, often used to indicate no process. */
56a45ae5f8SJohn Marino extern ptid_t null_ptid;
57a45ae5f8SJohn Marino 
58a45ae5f8SJohn Marino /* The -1 ptid, often used to indicate either an error condition
59a45ae5f8SJohn Marino    or a "don't care" condition, i.e, "run all threads."  */
60a45ae5f8SJohn Marino extern ptid_t minus_one_ptid;
61a45ae5f8SJohn Marino 
62a45ae5f8SJohn Marino /* Attempt to find and return an existing ptid with the given PID, LWP,
63a45ae5f8SJohn Marino    and TID components.  If none exists, create a new one and return
64a45ae5f8SJohn Marino    that.  */
65a45ae5f8SJohn Marino ptid_t ptid_build (int pid, long lwp, long tid);
66a45ae5f8SJohn Marino 
67a45ae5f8SJohn Marino /* Find/Create a ptid from just a pid. */
68a45ae5f8SJohn Marino ptid_t pid_to_ptid (int pid);
69a45ae5f8SJohn Marino 
70a45ae5f8SJohn Marino /* Fetch the pid (process id) component from a ptid. */
71a45ae5f8SJohn Marino int ptid_get_pid (ptid_t ptid);
72a45ae5f8SJohn Marino 
73a45ae5f8SJohn Marino /* Fetch the lwp (lightweight process) component from a ptid. */
74a45ae5f8SJohn Marino long ptid_get_lwp (ptid_t ptid);
75a45ae5f8SJohn Marino 
76a45ae5f8SJohn Marino /* Fetch the tid (thread id) component from a ptid. */
77a45ae5f8SJohn Marino long ptid_get_tid (ptid_t ptid);
78a45ae5f8SJohn Marino 
79a45ae5f8SJohn Marino /* Compare two ptids to see if they are equal */
80a45ae5f8SJohn Marino int ptid_equal (ptid_t p1, ptid_t p2);
81a45ae5f8SJohn Marino 
82a45ae5f8SJohn Marino /* Return true if PTID represents a process id.  */
83a45ae5f8SJohn Marino int ptid_is_pid (ptid_t ptid);
84a45ae5f8SJohn Marino 
85a45ae5f8SJohn Marino #endif
86