d41f6d8ea2
This commit makes all source files under gdb/ that include headers from gdb/ include either defs.h or server.h before any other code. This ensures that definitions and macros from the two config.h files are always in place for our code. An exception has been made for gdb/gdbserver/gdbreplay.c which seems to be a special case. gdb/ 2014-07-30 Gary Benson <gbenson@redhat.com> * btrace.c: Include defs.h. * common/ptid.c: Include defs.h or server.h as appropriate. * nat/mips-linux-watch.c: Likewise. gdb/gdbserver/ 2014-07-30 Gary Benson <gbenson@redhat.com> * hostio-errno.c: Move server.h to top of includes list. * inferiors.c: Likewise. * linux-x86-low.c: Likewise. * notif.c: Include server.h.
135 lines
2.4 KiB
C
135 lines
2.4 KiB
C
/* The ptid_t type and common functions operating on it.
|
|
|
|
Copyright (C) 1986-2014 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/>. */
|
|
|
|
#ifdef GDBSERVER
|
|
#include "server.h"
|
|
#else
|
|
#include "defs.h"
|
|
#endif
|
|
#include "ptid.h"
|
|
|
|
/* See ptid.h for these. */
|
|
|
|
ptid_t null_ptid = { 0, 0, 0 };
|
|
ptid_t minus_one_ptid = { -1, 0, 0 };
|
|
|
|
/* 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;
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
ptid_t
|
|
pid_to_ptid (int pid)
|
|
{
|
|
return ptid_build (pid, 0, 0);
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
int
|
|
ptid_get_pid (ptid_t ptid)
|
|
{
|
|
return ptid.pid;
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
long
|
|
ptid_get_lwp (ptid_t ptid)
|
|
{
|
|
return ptid.lwp;
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
long
|
|
ptid_get_tid (ptid_t ptid)
|
|
{
|
|
return ptid.tid;
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
int
|
|
ptid_equal (ptid_t ptid1, ptid_t ptid2)
|
|
{
|
|
return (ptid1.pid == ptid2.pid
|
|
&& ptid1.lwp == ptid2.lwp
|
|
&& ptid1.tid == ptid2.tid);
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
int
|
|
ptid_is_pid (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);
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
int
|
|
ptid_lwp_p (ptid_t ptid)
|
|
{
|
|
if (ptid_equal (minus_one_ptid, ptid)
|
|
|| ptid_equal (null_ptid, ptid))
|
|
return 0;
|
|
|
|
return (ptid_get_lwp (ptid) != 0);
|
|
}
|
|
|
|
/* See ptid.h. */
|
|
|
|
int
|
|
ptid_tid_p (ptid_t ptid)
|
|
{
|
|
if (ptid_equal (minus_one_ptid, ptid)
|
|
|| ptid_equal (null_ptid, ptid))
|
|
return 0;
|
|
|
|
return (ptid_get_tid (ptid) != 0);
|
|
}
|
|
|
|
int
|
|
ptid_match (ptid_t ptid, ptid_t filter)
|
|
{
|
|
if (ptid_equal (filter, minus_one_ptid))
|
|
return 1;
|
|
if (ptid_is_pid (filter)
|
|
&& ptid_get_pid (ptid) == ptid_get_pid (filter))
|
|
return 1;
|
|
else if (ptid_equal (ptid, filter))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|