GDB (xrefs)
ptid.c
Go to the documentation of this file.
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 #include "common-defs.h"
21 #include "ptid.h"
22 
23 /* See ptid.h for these. */
24 
25 ptid_t null_ptid = { 0, 0, 0 };
26 ptid_t minus_one_ptid = { -1, 0, 0 };
27 
28 /* See ptid.h. */
29 
30 ptid_t
31 ptid_build (int pid, long lwp, long tid)
32 {
33  ptid_t ptid;
34 
35  ptid.pid = pid;
36  ptid.lwp = lwp;
37  ptid.tid = tid;
38  return ptid;
39 }
40 
41 /* See ptid.h. */
42 
43 ptid_t
45 {
46  return ptid_build (pid, 0, 0);
47 }
48 
49 /* See ptid.h. */
50 
51 int
53 {
54  return ptid.pid;
55 }
56 
57 /* See ptid.h. */
58 
59 long
61 {
62  return ptid.lwp;
63 }
64 
65 /* See ptid.h. */
66 
67 long
69 {
70  return ptid.tid;
71 }
72 
73 /* See ptid.h. */
74 
75 int
76 ptid_equal (ptid_t ptid1, ptid_t ptid2)
77 {
78  return (ptid1.pid == ptid2.pid
79  && ptid1.lwp == ptid2.lwp
80  && ptid1.tid == ptid2.tid);
81 }
82 
83 /* See ptid.h. */
84 
85 int
87 {
88  if (ptid_equal (minus_one_ptid, ptid)
89  || ptid_equal (null_ptid, ptid))
90  return 0;
91 
92  return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
93 }
94 
95 /* See ptid.h. */
96 
97 int
99 {
100  if (ptid_equal (minus_one_ptid, ptid)
101  || ptid_equal (null_ptid, ptid))
102  return 0;
103 
104  return (ptid_get_lwp (ptid) != 0);
105 }
106 
107 /* See ptid.h. */
108 
109 int
111 {
112  if (ptid_equal (minus_one_ptid, ptid)
113  || ptid_equal (null_ptid, ptid))
114  return 0;
115 
116  return (ptid_get_tid (ptid) != 0);
117 }
118 
119 int
121 {
122  if (ptid_equal (filter, minus_one_ptid))
123  return 1;
124  if (ptid_is_pid (filter)
125  && ptid_get_pid (ptid) == ptid_get_pid (filter))
126  return 1;
127  else if (ptid_equal (ptid, filter))
128  return 1;
129 
130  return 0;
131 }
int ptid_is_pid(ptid_t ptid)
Definition: ptid.c:86
int ptid_equal(ptid_t ptid1, ptid_t ptid2)
Definition: ptid.c:76
int ptid_match(ptid_t ptid, ptid_t filter)
Definition: ptid.c:120
long tid
Definition: ptid.h:44
Definition: ptid.h:35
ptid_t ptid_build(int pid, long lwp, long tid)
Definition: ptid.c:31
ptid_t pid_to_ptid(int pid)
Definition: ptid.c:44
int ptid_get_pid(ptid_t ptid)
Definition: ptid.c:52
int pid
Definition: ptid.h:38
long ptid_get_tid(ptid_t ptid)
Definition: ptid.c:68
long lwp
Definition: ptid.h:41
long ptid_get_lwp(ptid_t ptid)
Definition: ptid.c:60
int ptid_tid_p(ptid_t ptid)
Definition: ptid.c:110
int ptid_lwp_p(ptid_t ptid)
Definition: ptid.c:98
mach_port_t mach_port_t name mach_port_t mach_port_t name error_t int int rusage_t pid_t pid
Definition: gnu-nat.c:1818