/* The ptid_t type and common functions operating on it.
- Copyright (C) 1986-2013 Free Software Foundation, Inc.
+ Copyright (C) 1986-2017 Free Software Foundation, Inc.
This file is part of GDB.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
+#include "common-defs.h"
#include "ptid.h"
-/* Oft used ptids */
-ptid_t null_ptid = { 0, 0, 0 };
-ptid_t minus_one_ptid = { -1, 0, 0 };
+/* See ptid.h for these. */
-/* Create a ptid given the necessary PID, LWP, and TID components. */
+ptid_t null_ptid = ptid_t::make_null ();
+ptid_t minus_one_ptid = ptid_t::make_minus_one ();
+
+/* See ptid.h. */
ptid_t
ptid_build (int pid, long lwp, long tid)
{
- ptid_t ptid;
-
- ptid.pid = pid;
- ptid.lwp = lwp;
- ptid.tid = tid;
- return ptid;
+ return ptid_t (pid, lwp, tid);
}
-/* Create a ptid from just a pid. */
+/* See ptid.h. */
ptid_t
pid_to_ptid (int pid)
{
- return ptid_build (pid, 0, 0);
+ return ptid_t (pid);
}
-/* Fetch the pid (process id) component from a ptid. */
+/* See ptid.h. */
int
-ptid_get_pid (ptid_t ptid)
+ptid_get_pid (const ptid_t &ptid)
{
- return ptid.pid;
+ return ptid.pid ();
}
-/* Fetch the lwp (lightweight process) component from a ptid. */
+/* See ptid.h. */
long
-ptid_get_lwp (ptid_t ptid)
+ptid_get_lwp (const ptid_t &ptid)
{
- return ptid.lwp;
+ return ptid.lwp ();
}
-/* Fetch the tid (thread id) component from a ptid. */
+/* See ptid.h. */
long
-ptid_get_tid (ptid_t ptid)
+ptid_get_tid (const ptid_t &ptid)
{
- return ptid.tid;
+ return ptid.tid ();
}
-/* ptid_equal() is used to test equality of two ptids. */
+/* See ptid.h. */
int
-ptid_equal (ptid_t ptid1, ptid_t ptid2)
+ptid_equal (const ptid_t &ptid1, const ptid_t &ptid2)
{
- return (ptid1.pid == ptid2.pid
- && ptid1.lwp == ptid2.lwp
- && ptid1.tid == ptid2.tid);
+ return ptid1 == ptid2;
}
-/* Returns true if PTID represents a process. */
+/* See ptid.h. */
int
-ptid_is_pid (ptid_t ptid)
+ptid_is_pid (const ptid_t &ptid)
{
- if (ptid_equal (minus_one_ptid, ptid)
- || ptid_equal (null_ptid, ptid))
- return 0;
-
- return (ptid_get_lwp (ptid) == 0 && ptid_get_tid (ptid) == 0);
+ return ptid.is_pid ();
}
-/* Returns true if PTID represents a lwp. */
+/* See ptid.h. */
int
-ptid_lwp_p (ptid_t ptid)
+ptid_lwp_p (const ptid_t &ptid)
{
- if (ptid_equal (minus_one_ptid, ptid)
- || ptid_equal (null_ptid, ptid))
- return 0;
-
- return (ptid_get_lwp (ptid) != 0);
+ return ptid.lwp_p ();
}
-/* Returns true if PTID represents a tid. */
+/* See ptid.h. */
int
-ptid_tid_p (ptid_t ptid)
+ptid_tid_p (const ptid_t &ptid)
{
- if (ptid_equal (minus_one_ptid, ptid)
- || ptid_equal (null_ptid, ptid))
- return 0;
+ return ptid.tid_p ();
+}
+
+/* See ptid.h. */
- return (ptid_get_tid (ptid) != 0);
+int
+ptid_match (const ptid_t &ptid, const ptid_t &filter)
+{
+ return ptid.matches (filter);
}