diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c
index b56971b9af..ca51a4ec7d 100644
--- a/gdb/common/ptid.c
+++ b/gdb/common/ptid.c
@@ -22,20 +22,16 @@
 
 /* See ptid.h for these.  */
 
-ptid_t null_ptid = { 0, 0, 0 };
-ptid_t minus_one_ptid = { -1, 0, 0 };
+ptid_t null_ptid = ptid_t::build (0, 0, 0);
+ptid_t minus_one_ptid = ptid_t::build (-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;
+  return ptid_t::build (pid, lwp, tid);
 }
 
 /* See ptid.h.  */
@@ -43,81 +39,69 @@ ptid_build (int pid, long lwp, long tid)
 ptid_t
 pid_to_ptid (int pid)
 {
-  return ptid_build (pid, 0, 0);
+  return ptid_t::build (pid);
 }
 
 /* See ptid.h.  */
 
 int
-ptid_get_pid (ptid_t ptid)
+ptid_get_pid (const ptid_t &ptid)
 {
-  return ptid.pid;
+  return ptid.pid ();
 }
 
 /* See ptid.h.  */
 
 long
-ptid_get_lwp (ptid_t ptid)
+ptid_get_lwp (const ptid_t &ptid)
 {
-  return ptid.lwp;
+  return ptid.lwp ();
 }
 
 /* See ptid.h.  */
 
 long
-ptid_get_tid (ptid_t ptid)
+ptid_get_tid (const ptid_t &ptid)
 {
-  return ptid.tid;
+  return ptid.tid ();
 }
 
 /* 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;
 }
 
 /* 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 ();
 }
 
 /* See ptid.h.  */
 
 int
-ptid_lwp_p (ptid_t ptid)
+ptid_lwp_p (const ptid_t &ptid)
 {
-  return (ptid_get_lwp (ptid) != 0);
+  return ptid.lwp_p ();
 }
 
 /* See ptid.h.  */
 
 int
-ptid_tid_p (ptid_t ptid)
+ptid_tid_p (const ptid_t &ptid)
 {
-  return (ptid_get_tid (ptid) != 0);
+  return ptid.tid_p ();
 }
 
+/* See ptid.h.  */
+
 int
-ptid_match (ptid_t ptid, ptid_t filter)
+ptid_match (const ptid_t &ptid, const 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;
+  return ptid.matches (filter);
 }
diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h
index 337bfb0899..c8649ae9a8 100644
--- a/gdb/common/ptid.h
+++ b/gdb/common/ptid.h
@@ -20,6 +20,15 @@
 #ifndef PTID_H
 #define PTID_H
 
+class ptid_t;
+
+/* The null or zero ptid, often used to indicate no process.  */
+extern ptid_t null_ptid;
+
+/* The (-1,0,0) ptid, often used to indicate either an error condition
+   or a "don't care" condition, i.e, "run all threads."  */
+extern ptid_t minus_one_ptid;
+
 /* The ptid struct is a collection of the various "ids" necessary for
    identifying the inferior process/thread being debugged.  This
    consists of the process id (pid), lightweight process id (lwp) and
@@ -32,27 +41,85 @@
    thread_stratum target that might want to sit on top.
 */
 
-struct ptid
+class ptid_t
 {
+public:
+  static ptid_t build (int pid, long lwp = 0, long tid = 0)
+  {
+    ptid_t ptid;
+
+    ptid.m_pid = pid;
+    ptid.m_lwp = lwp;
+    ptid.m_tid = tid;
+
+    return ptid;
+  }
+
+  bool is_pid () const
+  {
+    if (is_any () || is_null())
+      return false;
+
+    return m_lwp == 0 && m_tid == 0;
+  }
+
+  bool is_null () const
+  {
+    return *this == null_ptid;
+  }
+
+  bool is_any () const
+  {
+    return *this == minus_one_ptid;
+  }
+
+  int pid () const
+  { return m_pid; }
+
+  bool lwp_p () const
+  { return m_lwp != 0; }
+
+  long lwp () const
+  { return m_lwp; }
+
+  bool tid_p () const
+  { return m_tid != 0; }
+
+  long tid () const
+  { return m_tid; }
+
+  bool operator== (const ptid_t &other) const
+  {
+    return (m_pid == other.m_pid
+	    && m_lwp == other.m_lwp
+	    && m_tid == other.m_tid);
+  }
+
+  bool matches (const ptid_t &filter) const
+  {
+    /* If filter represents any ptid, it's always a match.  */
+    if (filter.is_any ())
+      return true;
+
+    /* If filter is only a pid, any ptid with that pid matches.  */
+    if (filter.is_pid () && m_pid == filter.pid ())
+      return true;
+
+    /* Otherwise, this ptid only matches if it's exactly equal to filter.  */
+    return *this == filter;
+  }
+
+private:
   /* Process id.  */
-  int pid;
+  int m_pid;
 
   /* Lightweight process id.  */
-  long lwp;
+  long m_lwp;
 
   /* Thread id.  */
-  long tid;
+  long m_tid;
 };
 
-typedef struct ptid ptid_t;
-
-/* The null or zero ptid, often used to indicate no process. */
-extern ptid_t null_ptid;
-
-/* The (-1,0,0) ptid, often used to indicate either an error condition
-   or a "don't care" condition, i.e, "run all threads."  */
-extern ptid_t minus_one_ptid;
-
 /* Make a ptid given the necessary PID, LWP, and TID components.  */
 ptid_t ptid_build (int pid, long lwp, long tid);
 
@@ -61,27 +128,27 @@ ptid_t ptid_build (int pid, long lwp, long tid);
 ptid_t pid_to_ptid (int pid);
 
 /* Fetch the pid (process id) component from a ptid.  */
-int ptid_get_pid (ptid_t ptid);
+int ptid_get_pid (const ptid_t &ptid);
 
 /* Fetch the lwp (lightweight process) component from a ptid.  */
-long ptid_get_lwp (ptid_t ptid);
+long ptid_get_lwp (const ptid_t &ptid);
 
 /* Fetch the tid (thread id) component from a ptid.  */
-long ptid_get_tid (ptid_t ptid);
+long ptid_get_tid (const ptid_t &ptid);
 
 /* Compare two ptids to see if they are equal.  */
-int ptid_equal (ptid_t ptid1, ptid_t ptid2);
+int ptid_equal (const ptid_t &ptid1, const ptid_t &ptid2);
 
 /* Returns true if PTID represents a whole process, including all its
    lwps/threads.  Such ptids have the form of (pid,0,0), with pid !=
    -1.  */
-int ptid_is_pid (ptid_t ptid);
+int ptid_is_pid (const ptid_t &ptid);
 
 /* Return true if PTID's lwp member is non-zero.  */
-int ptid_lwp_p (ptid_t ptid);
+int ptid_lwp_p (const ptid_t &ptid);
 
 /* Return true if PTID's tid member is non-zero.  */
-int ptid_tid_p (ptid_t ptid);
+int ptid_tid_p (const ptid_t &ptid);
 
 /* Returns true if PTID matches filter FILTER.  FILTER can be the wild
    card MINUS_ONE_PTID (all ptid match it); can be a ptid representing
@@ -91,6 +158,6 @@ int ptid_tid_p (ptid_t ptid);
    case, only that thread will match true.  PTID must represent a
    specific LWP or THREAD, it can never be a wild card.  */
 
-extern int ptid_match (ptid_t ptid, ptid_t filter);
+extern int ptid_match (const ptid_t &ptid, const ptid_t &filter);
 
 #endif
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index 4bc7f71b00..1287114cc1 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -2654,7 +2654,9 @@ handle_v_cont (char *own_buf)
   char *p, *q;
   int n = 0, i = 0;
   struct thread_resume *resume_info;
-  struct thread_resume default_action = {{0}};
+  struct thread_resume default_action = {
+    .thread = null_ptid,
+  };
 
   /* Count the number of semicolons in the packet.  There should be one
      for every action.  */
