X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=gdbsupport%2Fptid.h;h=d66cd9884590c3d91c2aae3b3f3c3615a1de9ca2;hb=90a00d6c65e7cd015ab133a129819bddf685c2b3;hp=ef52d55512600c3b108dcdee8e029523c430501d;hpb=01027315f54048dbaf03ac37455c2528c72a6d9b;p=binutils-gdb.git diff --git a/gdbsupport/ptid.h b/gdbsupport/ptid.h index ef52d555126..d66cd988459 100644 --- a/gdbsupport/ptid.h +++ b/gdbsupport/ptid.h @@ -1,6 +1,6 @@ /* The ptid_t type and common functions operating on it. - Copyright (C) 1986-2020 Free Software Foundation, Inc. + Copyright (C) 1986-2022 Free Software Foundation, Inc. This file is part of GDB. @@ -32,6 +32,10 @@ thread_stratum target that might want to sit on top. */ +#include +#include +#include "gdbsupport/common-types.h" + class ptid_t { public: @@ -44,7 +48,7 @@ public: A ptid with only a PID (LWP and TID equal to zero) is usually used to represent a whole process, including all its lwps/threads. */ - explicit constexpr ptid_t (int pid, long lwp = 0, long tid = 0) + explicit constexpr ptid_t (int pid, long lwp = 0, ULONGEST tid = 0) : m_pid (pid), m_lwp (lwp), m_tid (tid) {} @@ -70,7 +74,7 @@ public: /* Fetch the tid (thread id) component from a ptid. */ - constexpr long tid () const + constexpr ULONGEST tid () const { return m_tid; } /* Return true if the ptid represents a whole process, including all its @@ -122,6 +126,12 @@ public: || *this == filter); } + /* Return a string representation of the ptid. + + This is only meant to be used in debug messages. */ + + std::string to_string () const; + /* Make a null ptid. */ static constexpr ptid_t make_null () @@ -140,7 +150,21 @@ private: long m_lwp; /* Thread id. */ - long m_tid; + ULONGEST m_tid; +}; + +/* Functor to hash a ptid. */ + +struct hash_ptid +{ + size_t operator() (const ptid_t &ptid) const + { + std::hash long_hash; + + return (long_hash (ptid.pid ()) + + long_hash (ptid.lwp ()) + + long_hash (ptid.tid ())); + } }; /* The null or zero ptid, often used to indicate no process. */