Patchwork [RFA,02/10] Remove pid_to_ptid

login
register
mail settings
Submitter Tom Tromey
Date June 13, 2018, 9:50 p.m.
Message ID <20180613215049.9691-3-tom@tromey.com>
Download mbox | patch
Permalink /patch/27819/
State New
Headers show

Comments

Tom Tromey - June 13, 2018, 9:50 p.m.
This removes pid_to_ptid in favor of calling the ptid_t constructor
directly.

ChangeLog
2018-06-13  Tom Tromey  <tom@tromey.com>

	* common/ptid.c (pid_to_ptid): Remove.
	* common/ptid.h (pid_to_ptid): Don't declare.
	* aix-thread.c: Update.
	* arm-linux-nat.c: Update.
	* common/ptid.c: Update.
	* common/ptid.h: Update.
	* corelow.c: Update.
	* ctf.c: Update.
	* darwin-nat.c: Update.
	* fbsd-nat.c: Update.
	* fork-child.c: Update.
	* gnu-nat.c: Update.
	* go32-nat.c: Update.
	* inf-ptrace.c: Update.
	* infcmd.c: Update.
	* inferior.c: Update.
	* infrun.c: Update.
	* linux-fork.c: Update.
	* linux-nat.c: Update.
	* nat/aarch64-linux-hw-point.c: Update.
	* nat/fork-inferior.c: Update.
	* nat/x86-linux-dregs.c: Update.
	* nto-procfs.c: Update.
	* obsd-nat.c: Update.
	* procfs.c: Update.
	* progspace.c: Update.
	* remote.c: Update.
	* rs6000-nat.c: Update.
	* s390-linux-nat.c: Update.
	* sol-thread.c: Update.
	* spu-linux-nat.c: Update.
	* target.c: Update.
	* top.c: Update.
	* tracefile-tfile.c: Update.
	* windows-nat.c: Update.

gdbserver/ChangeLog
2018-06-13  Tom Tromey  <tom@tromey.com>

	* linux-low.c: Update.
	* linux-ppc-low.c: Update.
	* linux-x86-low.c: Update.
	* proc-service.c: Update.
	* server.c: Update.
	* spu-low.c: Update.
	* thread-db.c: Update.
	* win32-low.c: Update.
---
 gdb/ChangeLog                    | 38 ++++++++++++++++++++++++++++++++++++++
 gdb/aix-thread.c                 | 10 +++++-----
 gdb/arm-linux-nat.c              |  4 ++--
 gdb/common/ptid.c                |  8 --------
 gdb/common/ptid.h                |  4 ----
 gdb/corelow.c                    |  4 ++--
 gdb/ctf.c                        |  2 +-
 gdb/darwin-nat.c                 |  6 +++---
 gdb/fbsd-nat.c                   |  6 +++---
 gdb/fork-child.c                 |  2 +-
 gdb/gdbserver/ChangeLog          | 11 +++++++++++
 gdb/gdbserver/linux-low.c        | 12 ++++++------
 gdb/gdbserver/linux-ppc-low.c    |  2 +-
 gdb/gdbserver/linux-x86-low.c    |  2 +-
 gdb/gdbserver/proc-service.c     |  2 +-
 gdb/gdbserver/server.c           | 12 ++++++------
 gdb/gdbserver/spu-low.c          |  4 ++--
 gdb/gdbserver/thread-db.c        |  2 +-
 gdb/gdbserver/win32-low.c        |  4 ++--
 gdb/gnu-nat.c                    |  4 ++--
 gdb/go32-nat.c                   |  4 ++--
 gdb/inf-ptrace.c                 | 18 +++++++++---------
 gdb/infcmd.c                     |  6 +++---
 gdb/inferior.c                   |  6 +++---
 gdb/infrun.c                     | 18 +++++++++---------
 gdb/linux-fork.c                 |  2 +-
 gdb/linux-nat.c                  | 16 ++++++++--------
 gdb/nat/aarch64-linux-hw-point.c |  2 +-
 gdb/nat/fork-inferior.c          |  2 +-
 gdb/nat/x86-linux-dregs.c        |  4 ++--
 gdb/nto-procfs.c                 |  8 ++++----
 gdb/obsd-nat.c                   | 10 +++++-----
 gdb/procfs.c                     | 22 +++++++++++-----------
 gdb/progspace.c                  |  4 ++--
 gdb/remote.c                     | 20 ++++++++++----------
 gdb/rs6000-nat.c                 |  2 +-
 gdb/s390-linux-nat.c             |  2 +-
 gdb/sol-thread.c                 | 14 +++++++-------
 gdb/spu-linux-nat.c              |  2 +-
 gdb/target.c                     |  2 +-
 gdb/top.c                        |  4 ++--
 gdb/tracefile-tfile.c            |  2 +-
 gdb/windows-nat.c                |  6 +++---
 43 files changed, 176 insertions(+), 139 deletions(-)

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2ee61577af..43061b54c7 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,41 @@ 
+2018-06-13  Tom Tromey  <tom@tromey.com>
+
+	* common/ptid.c (pid_to_ptid): Remove.
+	* common/ptid.h (pid_to_ptid): Don't declare.
+	* aix-thread.c: Update.
+	* arm-linux-nat.c: Update.
+	* common/ptid.c: Update.
+	* common/ptid.h: Update.
+	* corelow.c: Update.
+	* ctf.c: Update.
+	* darwin-nat.c: Update.
+	* fbsd-nat.c: Update.
+	* fork-child.c: Update.
+	* gnu-nat.c: Update.
+	* go32-nat.c: Update.
+	* inf-ptrace.c: Update.
+	* infcmd.c: Update.
+	* inferior.c: Update.
+	* infrun.c: Update.
+	* linux-fork.c: Update.
+	* linux-nat.c: Update.
+	* nat/aarch64-linux-hw-point.c: Update.
+	* nat/fork-inferior.c: Update.
+	* nat/x86-linux-dregs.c: Update.
+	* nto-procfs.c: Update.
+	* obsd-nat.c: Update.
+	* procfs.c: Update.
+	* progspace.c: Update.
+	* remote.c: Update.
+	* rs6000-nat.c: Update.
+	* s390-linux-nat.c: Update.
+	* sol-thread.c: Update.
+	* spu-linux-nat.c: Update.
+	* target.c: Update.
+	* top.c: Update.
+	* tracefile-tfile.c: Update.
+	* windows-nat.c: Update.
+
 2018-06-13  Tom Tromey  <tom@tromey.com>
 
 	* common/ptid.h (ptid_build): Don't declare.
diff --git a/gdb/aix-thread.c b/gdb/aix-thread.c
index f4d3ac4770..bd66889e9d 100644
--- a/gdb/aix-thread.c
+++ b/gdb/aix-thread.c
@@ -325,7 +325,7 @@  pid_to_prc (ptid_t *ptidp)
 
   ptid = *ptidp;
   if (PD_TID (ptid))
-    *ptidp = pid_to_ptid (ptid_get_pid (ptid));
+    *ptidp = ptid_t (ptid_get_pid (ptid));
 }
 
 /* pthdb callback: for <i> from 0 to COUNT, set SYMBOLS[<i>].addr to
@@ -1042,7 +1042,7 @@  aix_thread_target::resume (ptid_t ptid, int step, enum gdb_signal sig)
     {
       scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
       
-      inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+      inferior_ptid = ptid_t (ptid_get_pid (inferior_ptid));
       beneath ()->resume (ptid, step, sig);
     }
   else
@@ -1082,12 +1082,12 @@  aix_thread_target::wait (ptid_t ptid, struct target_waitstatus *status,
 
     pid_to_prc (&ptid);
 
-    inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+    inferior_ptid = ptid_t (ptid_get_pid (inferior_ptid));
     ptid = beneath ()->wait (ptid, status, options);
   }
 
   if (ptid_get_pid (ptid) == -1)
-    return pid_to_ptid (-1);
+    return ptid_t (-1);
 
   /* Check whether libpthdebug might be ready to be initialized.  */
   if (!pd_active && status->kind == TARGET_WAITKIND_STOPPED
@@ -1722,7 +1722,7 @@  aix_thread_target::xfer_partial (enum target_object object,
 {
   scoped_restore save_inferior_ptid = make_scoped_restore (&inferior_ptid);
 
-  inferior_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+  inferior_ptid = ptid_t (ptid_get_pid (inferior_ptid));
   return beneath ()->xfer_partial (object, annex, readbuf,
 				   writebuf, offset, len, xfered_len);
 }
diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c
index d0b43132b8..b5ee3a9063 100644
--- a/gdb/arm-linux-nat.c
+++ b/gdb/arm-linux-nat.c
@@ -994,7 +994,7 @@  arm_linux_insert_hw_breakpoint1 (const struct arm_linux_hw_breakpoint* bpt,
   struct update_registers_data data;
 
   pid = ptid_get_pid (inferior_ptid);
-  pid_ptid = pid_to_ptid (pid);
+  pid_ptid = ptid_t (pid);
 
   if (watchpoint)
     {
@@ -1033,7 +1033,7 @@  arm_linux_remove_hw_breakpoint1 (const struct arm_linux_hw_breakpoint *bpt,
   struct update_registers_data data;
 
   pid = ptid_get_pid (inferior_ptid);
-  pid_ptid = pid_to_ptid (pid);
+  pid_ptid = ptid_t (pid);
 
   if (watchpoint)
     {
diff --git a/gdb/common/ptid.c b/gdb/common/ptid.c
index 49d27b4d55..42e51d2624 100644
--- a/gdb/common/ptid.c
+++ b/gdb/common/ptid.c
@@ -27,14 +27,6 @@  ptid_t minus_one_ptid = ptid_t::make_minus_one ();
 
 /* See ptid.h.  */
 
-ptid_t
-pid_to_ptid (int pid)
-{
-  return ptid_t (pid);
-}
-
-/* See ptid.h.  */
-
 int
 ptid_get_pid (const ptid_t &ptid)
 {
diff --git a/gdb/common/ptid.h b/gdb/common/ptid.h
index 030e97d45b..5591690437 100644
--- a/gdb/common/ptid.h
+++ b/gdb/common/ptid.h
@@ -156,10 +156,6 @@  extern ptid_t minus_one_ptid;
 /* The following functions are kept for backwards compatibility.  The use of
    the ptid_t methods is preferred.  */
 
-/* See ptid_t::ptid_t.  */
-
-extern ptid_t pid_to_ptid (int pid);
-
 /* See ptid_t::pid.  */
 
 extern int ptid_get_pid (const ptid_t &ptid);
diff --git a/gdb/corelow.c b/gdb/corelow.c
index 99fe04c8c9..9c92095e05 100644
--- a/gdb/corelow.c
+++ b/gdb/corelow.c
@@ -459,7 +459,7 @@  core_target_open (const char *arg, int from_tty)
       if (thread == NULL)
 	{
 	  inferior_appeared (current_inferior (), CORELOW_PID);
-	  inferior_ptid = pid_to_ptid (CORELOW_PID);
+	  inferior_ptid = ptid_t (CORELOW_PID);
 	  add_thread_silent (inferior_ptid);
 	}
       else
@@ -1009,7 +1009,7 @@  core_target::pid_to_str (ptid_t ptid)
   /* Try the LWPID field first.  */
   pid = ptid_get_lwp (ptid);
   if (pid != 0)
-    return normal_pid_to_str (pid_to_ptid (pid));
+    return normal_pid_to_str (ptid_t (pid));
 
   /* Otherwise, this isn't a "threaded" core -- use the PID field, but
      only if it isn't a fake PID.  */
diff --git a/gdb/ctf.c b/gdb/ctf.c
index 7e2207484c..ebc01a5b97 100644
--- a/gdb/ctf.c
+++ b/gdb/ctf.c
@@ -1160,7 +1160,7 @@  ctf_target_open (const char *dirname, int from_tty)
   push_target (&ctf_ops);
 
   inferior_appeared (current_inferior (), CTF_PID);
-  inferior_ptid = pid_to_ptid (CTF_PID);
+  inferior_ptid = ptid_t (CTF_PID);
   add_thread_silent (inferior_ptid);
 
   merge_uploaded_trace_state_variables (&uploaded_tsvs);
diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c
index 363a89f3c1..682a62f1d3 100644
--- a/gdb/darwin-nat.c
+++ b/gdb/darwin-nat.c
@@ -1864,10 +1864,10 @@  darwin_nat_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
       else
 	printf_unfiltered (_("Attaching to %s\n"),
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }
@@ -1876,7 +1876,7 @@  darwin_nat_target::attach (const char *args, int from_tty)
     error (_("Can't attach to process %d: %s (%d)"),
            pid, safe_strerror (errno), errno);
 
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c
index cfacb2cf23..27fee703e0 100644
--- a/gdb/fbsd-nat.c
+++ b/gdb/fbsd-nat.c
@@ -926,7 +926,7 @@  fbsd_add_threads (pid_t pid)
 {
   int i, nlwps;
 
-  gdb_assert (!in_thread_list (pid_to_ptid (pid)));
+  gdb_assert (!in_thread_list (ptid_t (pid)));
   nlwps = ptrace (PT_GETNUMLWPS, pid, NULL, 0);
   if (nlwps == -1)
     perror_with_name (("ptrace"));
@@ -1297,13 +1297,13 @@  fbsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	     PL_FLAG_BORN in case the first stop reported after
 	     attaching to an existing process is a PL_FLAG_BORN
 	     event.  */
-	  if (in_thread_list (pid_to_ptid (pid)))
+	  if (in_thread_list (ptid_t (pid)))
 	    {
 	      if (debug_fbsd_lwp)
 		fprintf_unfiltered (gdb_stdlog,
 				    "FLWP: using LWP %u for first thread\n",
 				    pl.pl_lwpid);
-	      thread_change_ptid (pid_to_ptid (pid), wptid);
+	      thread_change_ptid (ptid_t (pid), wptid);
 	    }
 
 #ifdef PT_LWP_EVENTS
diff --git a/gdb/fork-child.c b/gdb/fork-child.c
index e1719a09ce..1de96b6685 100644
--- a/gdb/fork-child.c
+++ b/gdb/fork-child.c
@@ -88,7 +88,7 @@  postfork_hook (pid_t pid)
   inferior_appeared (inf, pid);
 
   /* Needed for wait_for_inferior stuff.  */
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
 
   gdb_assert (saved_ui != NULL);
   current_ui = saved_ui;
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index 86f77a957d..ca4a82bdb3 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,14 @@ 
+2018-06-13  Tom Tromey  <tom@tromey.com>
+
+	* linux-low.c: Update.
+	* linux-ppc-low.c: Update.
+	* linux-x86-low.c: Update.
+	* proc-service.c: Update.
+	* server.c: Update.
+	* spu-low.c: Update.
+	* thread-db.c: Update.
+	* win32-low.c: Update.
+
 2018-06-13  Tom Tromey  <tom@tromey.com>
 
 	* linux-low.c: Update.
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index ce4d660806..a5e0d5beb6 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -1226,13 +1226,13 @@  linux_attach (unsigned long pid)
     {
       struct lwp_info *lwp;
       int wstat, lwpid;
-      ptid_t pid_ptid = pid_to_ptid (pid);
+      ptid_t pid_ptid = ptid_t (pid);
 
       lwpid = linux_wait_for_event_filtered (pid_ptid, pid_ptid,
 					     &wstat, __WALL);
       gdb_assert (lwpid > 0);
 
-      lwp = find_lwp_pid (pid_to_ptid (lwpid));
+      lwp = find_lwp_pid (ptid_t (lwpid));
 
       if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
 	{
@@ -1405,7 +1405,7 @@  linux_kill (int pid)
 
   /* See the comment in linux_kill_one_lwp.  We did not kill the first
      thread in the list, so do so now.  */
-  lwp = find_lwp_pid (pid_to_ptid (pid));
+  lwp = find_lwp_pid (ptid_t (pid));
 
   if (lwp == NULL)
     {
@@ -1640,7 +1640,7 @@  linux_detach (int pid)
      able to reap the leader.  */
   for_each_thread (pid, linux_detach_lwp_callback);
 
-  main_lwp = find_lwp_pid (pid_to_ptid (pid));
+  main_lwp = find_lwp_pid (ptid_t (pid));
   linux_detach_one_lwp (main_lwp);
 
   the_target->mourn (process);
@@ -1878,7 +1878,7 @@  check_zombie_leaders (void)
     pid_t leader_pid = pid_of (proc);
     struct lwp_info *leader_lp;
 
-    leader_lp = find_lwp_pid (pid_to_ptid (leader_pid));
+    leader_lp = find_lwp_pid (ptid_t (leader_pid));
 
     if (debug_threads)
       debug_printf ("leader_pid=%d, leader_lp!=NULL=%d, "
@@ -2363,7 +2363,7 @@  linux_low_filter_event (int lwpid, int wstat)
   struct thread_info *thread;
   int have_stop_pc = 0;
 
-  child = find_lwp_pid (pid_to_ptid (lwpid));
+  child = find_lwp_pid (ptid_t (lwpid));
 
   /* Check for stop events reported by a process we didn't already
      know about - anything not already in our LWP list.
diff --git a/gdb/gdbserver/linux-ppc-low.c b/gdb/gdbserver/linux-ppc-low.c
index c6e00b7eb8..47428c1529 100644
--- a/gdb/gdbserver/linux-ppc-low.c
+++ b/gdb/gdbserver/linux-ppc-low.c
@@ -703,7 +703,7 @@  ppc_supports_tracepoints (void)
 static int
 ppc_get_thread_area (int lwpid, CORE_ADDR *addr)
 {
-  struct lwp_info *lwp = find_lwp_pid (pid_to_ptid (lwpid));
+  struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
   struct thread_info *thr = get_lwp_thread (lwp);
   struct regcache *regcache = get_thread_regcache (thr, 1);
   ULONGEST tp = 0;
diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c
index 408b54f257..80b43802c7 100644
--- a/gdb/gdbserver/linux-x86-low.c
+++ b/gdb/gdbserver/linux-x86-low.c
@@ -255,7 +255,7 @@  x86_get_thread_area (int lwpid, CORE_ADDR *addr)
 #endif
 
   {
-    struct lwp_info *lwp = find_lwp_pid (pid_to_ptid (lwpid));
+    struct lwp_info *lwp = find_lwp_pid (ptid_t (lwpid));
     struct thread_info *thr = get_lwp_thread (lwp);
     struct regcache *regcache = get_thread_regcache (thr, 1);
     unsigned int desc[4];
diff --git a/gdb/gdbserver/proc-service.c b/gdb/gdbserver/proc-service.c
index f7912b884c..64fdf8a9d5 100644
--- a/gdb/gdbserver/proc-service.c
+++ b/gdb/gdbserver/proc-service.c
@@ -108,7 +108,7 @@  ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset)
   struct thread_info *reg_thread, *saved_thread;
   struct regcache *regcache;
 
-  lwp = find_lwp_pid (pid_to_ptid (lwpid));
+  lwp = find_lwp_pid (ptid_t (lwpid));
   if (lwp == NULL)
     return PS_ERR;
 
diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c
index e4de426476..c2f7287a94 100644
--- a/gdb/gdbserver/server.c
+++ b/gdb/gdbserver/server.c
@@ -308,7 +308,7 @@  attach_inferior (int pid)
 
   if (!non_stop)
     {
-      cs.last_ptid = mywait (pid_to_ptid (pid), &cs.last_status, 0, 0);
+      cs.last_ptid = mywait (ptid_t (pid), &cs.last_status, 0, 0);
 
       /* GDB knows to ignore the first SIGSTOP after attaching to a running
 	 process using the "attach" command, but this is different; it's
@@ -1256,7 +1256,7 @@  handle_detach (char *own_buf)
     write_enn (own_buf);
   else
     {
-      discard_queued_stop_replies (pid_to_ptid (pid));
+      discard_queued_stop_replies (ptid_t (pid));
       write_ok (own_buf);
 
       if (extended_protocol || target_running ())
@@ -1266,7 +1266,7 @@  handle_detach (char *own_buf)
 	     and instead treat this like a normal program exit.  */
 	  cs.last_status.kind = TARGET_WAITKIND_EXITED;
 	  cs.last_status.value.integer = 0;
-	  cs.last_ptid = pid_to_ptid (pid);
+	  cs.last_ptid = ptid_t (pid);
 
 	  current_thread = NULL;
 	}
@@ -3081,7 +3081,7 @@  handle_v_kill (char *own_buf)
     {
       cs.last_status.kind = TARGET_WAITKIND_SIGNALLED;
       cs.last_status.value.sig = GDB_SIGNAL_KILL;
-      cs.last_ptid = pid_to_ptid (pid);
+      cs.last_ptid = ptid_t (pid);
       discard_queued_stop_replies (cs.last_ptid);
       write_ok (own_buf);
       return 1;
@@ -3481,7 +3481,7 @@  kill_inferior_callback (process_info *process)
   int pid = process->pid;
 
   kill_inferior (pid);
-  discard_queued_stop_replies (pid_to_ptid (pid));
+  discard_queued_stop_replies (ptid_t (pid));
 }
 
 /* Call this when exiting gdbserver with possible inferiors that need
@@ -3527,7 +3527,7 @@  detach_or_kill_for_exit (void)
     else
       kill_inferior (pid);
 
-    discard_queued_stop_replies (pid_to_ptid (pid));
+    discard_queued_stop_replies (ptid_t (pid));
   });
 }
 
diff --git a/gdb/gdbserver/spu-low.c b/gdb/gdbserver/spu-low.c
index 13f2b353f2..8a221a2c6c 100644
--- a/gdb/gdbserver/spu-low.c
+++ b/gdb/gdbserver/spu-low.c
@@ -457,7 +457,7 @@  spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
       ourstatus->kind =  TARGET_WAITKIND_EXITED;
       ourstatus->value.integer = WEXITSTATUS (w);
       clear_inferiors ();
-      return pid_to_ptid (ret);
+      return ptid_t (ret);
     }
   else if (!WIFSTOPPED (w))
     {
@@ -465,7 +465,7 @@  spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
       ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
       ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));
       clear_inferiors ();
-      return pid_to_ptid (ret);
+      return ptid_t (ret);
     }
 
   /* After attach, we may have received a SIGSTOP.  Do not return this
diff --git a/gdb/gdbserver/thread-db.c b/gdb/gdbserver/thread-db.c
index 3e42db4420..80125ee9b7 100644
--- a/gdb/gdbserver/thread-db.c
+++ b/gdb/gdbserver/thread-db.c
@@ -252,7 +252,7 @@  maybe_attach_thread (const td_thrhandle_t *th_p, td_thrinfo_t *ti_p,
 {
   struct lwp_info *lwp;
 
-  lwp = find_lwp_pid (pid_to_ptid (ti_p->ti_lid));
+  lwp = find_lwp_pid (ptid_t (ti_p->ti_lid));
   if (lwp != NULL)
     return 1;
 
diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c
index 05bea69adb..53b843b3ba 100644
--- a/gdb/gdbserver/win32-low.c
+++ b/gdb/gdbserver/win32-low.c
@@ -707,7 +707,7 @@  win32_create_inferior (const char *program,
 
   /* Wait till we are at 1st instruction in program, return new pid
      (assuming success).  */
-  cs.last_ptid = win32_wait (pid_to_ptid (current_process_id), &cs.last_status, 0);
+  cs.last_ptid = win32_wait (ptid_t (current_process_id), &cs.last_status, 0);
 
   return current_process_id;
 }
@@ -1612,7 +1612,7 @@  win32_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
 	  OUTMSG2 (("Child exited with retcode = %x\n",
 		    ourstatus->value.integer));
 	  win32_clear_inferiors ();
-	  return pid_to_ptid (current_event.dwProcessId);
+	  return ptid_t (current_event.dwProcessId);
 	case TARGET_WAITKIND_STOPPED:
 	case TARGET_WAITKIND_LOADED:
 	  OUTMSG2 (("Child Stopped with signal = %d \n",
diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c
index 491d725ce2..78276a71df 100644
--- a/gdb/gnu-nat.c
+++ b/gdb/gnu-nat.c
@@ -1100,7 +1100,7 @@  inf_validate_procs (struct inf *inf)
 
 	    /* Tell GDB's generic thread code.  */
 
-	    if (ptid_equal (inferior_ptid, pid_to_ptid (inf->pid)))
+	    if (ptid_equal (inferior_ptid, ptid_t (inf->pid)))
 	      /* This is the first time we're hearing about thread
 		 ids, after a fork-child.  */
 	      thread_change_ptid (inferior_ptid, ptid);
@@ -2148,7 +2148,7 @@  gnu_nat_target::create_inferior (const char *exec_file,
   /* We have something that executes now.  We'll be running through
      the shell at this point (if startup-with-shell is true), but the
      pid shouldn't change.  */
-  add_thread_silent (pid_to_ptid (pid));
+  add_thread_silent (ptid_t (pid));
 
   /* Attach to the now stopped child, which is actually a shell...  */
   inf_debug (inf, "attaching to child: %d", pid);
diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c
index f00e424d46..0120cbf7d2 100644
--- a/gdb/go32-nat.c
+++ b/gdb/go32-nat.c
@@ -533,7 +533,7 @@  go32_nat_target::wait (ptid_t ptid, struct target_waitstatus *status,
 	    }
 	}
     }
-  return pid_to_ptid (SOME_PID);
+  return ptid_t (SOME_PID);
 }
 
 static void
@@ -752,7 +752,7 @@  go32_nat_target::create_inferior (const char *exec_file,
   save_npx ();
 #endif
 
-  inferior_ptid = pid_to_ptid (SOME_PID);
+  inferior_ptid = ptid_t (SOME_PID);
   inf = current_inferior ();
   inferior_appeared (inf, SOME_PID);
 
diff --git a/gdb/inf-ptrace.c b/gdb/inf-ptrace.c
index 945af830c5..3b32b678ee 100644
--- a/gdb/inf-ptrace.c
+++ b/gdb/inf-ptrace.c
@@ -131,7 +131,7 @@  inf_ptrace_target::create_inferior (const char *exec_file,
   pid = fork_inferior (exec_file, allargs, env, inf_ptrace_me, NULL,
 		       NULL, NULL, NULL);
 
-  ptid = pid_to_ptid (pid);
+  ptid = ptid_t (pid);
   /* We have something that executes now.  We'll be running through
      the shell at this point (if startup-with-shell is true), but the
      pid shouldn't change.  */
@@ -213,10 +213,10 @@  inf_ptrace_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
       else
 	printf_unfiltered (_("Attaching to %s\n"),
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }
@@ -233,7 +233,7 @@  inf_ptrace_target::attach (const char *args, int from_tty)
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
 
   /* Always add a main thread.  If some target extends the ptrace
      target, it should decorate the ptid later with more info.  */
@@ -428,7 +428,7 @@  inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	{
 	case PTRACE_FORK:
 	  ourstatus->kind = TARGET_WAITKIND_FORKED;
-	  ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
+	  ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
 
 	  /* Make sure the other end of the fork is stopped too.  */
 	  fpid = waitpid (pe.pe_other_pid, &status, 0);
@@ -443,17 +443,17 @@  inf_ptrace_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	  gdb_assert (pe.pe_other_pid == pid);
 	  if (fpid == ptid_get_pid (inferior_ptid))
 	    {
-	      ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
-	      return pid_to_ptid (fpid);
+	      ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
+	      return ptid_t (fpid);
 	    }
 
-	  return pid_to_ptid (pid);
+	  return ptid_t (pid);
 	}
     }
 #endif
 
   store_waitstatus (ourstatus, status);
-  return pid_to_ptid (pid);
+  return ptid_t (pid);
 }
 
 /* Transfer data via ptrace into process PID's memory from WRITEBUF, or
diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index b3f0238eba..07c893663a 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -2599,7 +2599,7 @@  kill_command (const char *arg, int from_tty)
   int pid = current_inferior ()->pid;
   /* Save the pid as a string before killing the inferior, since that
      may unpush the current target, and we need the string after.  */
-  std::string pid_str = target_pid_to_str (pid_to_ptid (pid));
+  std::string pid_str = target_pid_to_str (ptid_t (pid));
   int infnum = current_inferior ()->num;
 
   target_kill ();
@@ -2750,7 +2750,7 @@  attach_post_wait (const char *args, int from_tty, enum attach_post_wait_mode mod
 	 Be sure to explicitly stop all threads of the process.  This
 	 should have no effect on already stopped threads.  */
       if (non_stop)
-	target_stop (pid_to_ptid (inferior->pid));
+	target_stop (ptid_t (inferior->pid));
       else if (target_is_non_stop_p ())
 	{
 	  struct thread_info *thread;
@@ -2896,7 +2896,7 @@  attach_command (const char *args, int from_tty)
       else
 	/* The user requested an `attach', so stop all threads of this
 	   inferior.  */
-	target_stop (pid_to_ptid (ptid_get_pid (inferior_ptid)));
+	target_stop (ptid_t (ptid_get_pid (inferior_ptid)));
     }
 
   mode = async_exec ? ATTACH_POST_WAIT_RESUME : ATTACH_POST_WAIT_STOP;
diff --git a/gdb/inferior.c b/gdb/inferior.c
index ec2f985919..c08893607a 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -124,7 +124,7 @@  add_inferior (int pid)
   if (print_inferior_events)
     printf_unfiltered (_("[New inferior %d (%s)]\n"),
 		       inf->num,
-		       target_pid_to_str (pid_to_ptid (pid)));
+		       target_pid_to_str (ptid_t (pid)));
 
   return inf;
 }
@@ -266,7 +266,7 @@  detach_inferior (inferior *inf)
   if (print_inferior_events)
     printf_unfiltered (_("[Inferior %d (%s) detached]\n"),
 		       inf->num,
-		       target_pid_to_str (pid_to_ptid (pid)));
+		       target_pid_to_str (ptid_t (pid)));
 }
 
 /* See inferior.h.  */
@@ -514,7 +514,7 @@  static const char *
 inferior_pid_to_str (int pid)
 {
   if (pid != 0)
-    return target_pid_to_str (pid_to_ptid (pid));
+    return target_pid_to_str (ptid_t (pid));
   else
     return _("<null>");
 }
diff --git a/gdb/infrun.c b/gdb/infrun.c
index f455af2948..1488bb16e4 100644
--- a/gdb/infrun.c
+++ b/gdb/infrun.c
@@ -464,7 +464,7 @@  holding the child stopped.  Try \"set detach-on-fork\" or \
 	  if (print_inferior_events)
 	    {
 	      /* Ensure that we have a process ptid.  */
-	      ptid_t process_ptid = pid_to_ptid (ptid_get_pid (child_ptid));
+	      ptid_t process_ptid = ptid_t (ptid_get_pid (child_ptid));
 
 	      target_terminal::ours_for_output ();
 	      fprintf_filtered (gdb_stdlog,
@@ -600,7 +600,7 @@  holding the child stopped.  Try \"set detach-on-fork\" or \
 	  if (print_inferior_events)
 	    {
 	      /* Ensure that we have a process ptid.  */
-	      ptid_t process_ptid = pid_to_ptid (ptid_get_pid (parent_ptid));
+	      ptid_t process_ptid = ptid_t (ptid_get_pid (parent_ptid));
 
 	      target_terminal::ours_for_output ();
 	      fprintf_filtered (gdb_stdlog,
@@ -962,7 +962,7 @@  handle_vfork_child_exec_or_exit (int exec)
 	  if (print_inferior_events)
 	    {
 	      const char *pidstr
-		= target_pid_to_str (pid_to_ptid (inf->vfork_parent->pid));
+		= target_pid_to_str (ptid_t (inf->vfork_parent->pid));
 
 	      target_terminal::ours_for_output ();
 
@@ -1151,7 +1151,7 @@  follow_exec (ptid_t ptid, char *exec_file_target)
   update_breakpoints_after_exec ();
 
   /* What is this a.out's name?  */
-  process_ptid = pid_to_ptid (pid);
+  process_ptid = ptid_t (pid);
   printf_unfiltered (_("%s is executing new program: %s\n"),
 		     target_pid_to_str (process_ptid),
 		     exec_file_target);
@@ -2277,7 +2277,7 @@  user_visible_resume_ptid (int step)
     {
       /* Resume all threads of the current process (and none of other
 	 processes).  */
-      resume_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+      resume_ptid = ptid_t (ptid_get_pid (inferior_ptid));
     }
   else
     {
@@ -3630,7 +3630,7 @@  void
 prepare_for_detach (void)
 {
   struct inferior *inf = current_inferior ();
-  ptid_t pid_ptid = pid_to_ptid (inf->pid);
+  ptid_t pid_ptid = ptid_t (inf->pid);
   struct displaced_step_inferior_state *displaced;
 
   displaced = get_displaced_stepping_state (inf->pid);
@@ -4567,7 +4567,7 @@  stop_all_threads (void)
 	    {
 	      if (debug_infrun)
 		{
-		  ptid_t ptid = pid_to_ptid (ws.value.integer);
+		  ptid_t ptid = ptid_t (ws.value.integer);
 
 		  fprintf_unfiltered (gdb_stdlog,
 				      "infrun: %s exited while "
@@ -4924,7 +4924,7 @@  handle_inferior_event_1 (struct execution_control_state *ecs)
 	   process as not-executing so that finish_thread_state marks
 	   them stopped (in the user's perspective) if/when we present
 	   the stop to the user.  */
-	mark_ptid = pid_to_ptid (ptid_get_pid (ecs->ptid));
+	mark_ptid = ptid_t (ptid_get_pid (ecs->ptid));
       }
     else
       mark_ptid = ecs->ptid;
@@ -7894,7 +7894,7 @@  void
 print_exited_reason (struct ui_out *uiout, int exitstatus)
 {
   struct inferior *inf = current_inferior ();
-  const char *pidstr = target_pid_to_str (pid_to_ptid (inf->pid));
+  const char *pidstr = target_pid_to_str (ptid_t (inf->pid));
 
   annotate_exited (exitstatus);
   if (exitstatus)
diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c
index 2ba67e0bd4..a0e16df553 100644
--- a/gdb/linux-fork.c
+++ b/gdb/linux-fork.c
@@ -216,7 +216,7 @@  fork_id_to_ptid (int num)
   if (fork)
     return fork->ptid;
   else
-    return pid_to_ptid (-1);
+    return ptid_t (-1);
 }
 
 static void
diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c
index aa1a22b8b5..c17f541591 100644
--- a/gdb/linux-nat.c
+++ b/gdb/linux-nat.c
@@ -1467,17 +1467,17 @@  linux_nat_target::detach (inferior *inf, int from_tty)
 
   /* Stop all threads before detaching.  ptrace requires that the
      thread is stopped to sucessfully detach.  */
-  iterate_over_lwps (pid_to_ptid (pid), stop_callback, NULL);
+  iterate_over_lwps (ptid_t (pid), stop_callback, NULL);
   /* ... and wait until all of them have reported back that
      they're no longer running.  */
-  iterate_over_lwps (pid_to_ptid (pid), stop_wait_callback, NULL);
+  iterate_over_lwps (ptid_t (pid), stop_wait_callback, NULL);
 
-  iterate_over_lwps (pid_to_ptid (pid), detach_callback, NULL);
+  iterate_over_lwps (ptid_t (pid), detach_callback, NULL);
 
   /* Only the initial process should be left right now.  */
   gdb_assert (num_lwps (pid) == 1);
 
-  main_lwp = find_lwp_pid (pid_to_ptid (pid));
+  main_lwp = find_lwp_pid (ptid_t (pid));
 
   if (forks_exist_p ())
     {
@@ -2914,7 +2914,7 @@  linux_nat_filter_event (int lwpid, int status)
   struct lwp_info *lp;
   int event = linux_ptrace_get_extended_event (status);
 
-  lp = find_lwp_pid (pid_to_ptid (lwpid));
+  lp = find_lwp_pid (ptid_t (lwpid));
 
   /* Check for stop events reported by a process we didn't already
      know about - anything not already in our LWP list.
@@ -3119,7 +3119,7 @@  linux_nat_filter_event (int lwpid, int status)
 		 will receive it - unless they're using CLONE_THREAD to
 		 share signals.  Since we only want to report it once, we
 		 mark it as ignored for all LWPs except this one.  */
-	      iterate_over_lwps (pid_to_ptid (ptid_get_pid (lp->ptid)),
+	      iterate_over_lwps (ptid_t (ptid_get_pid (lp->ptid)),
 					      set_ignore_sigint, NULL);
 	      lp->ignore_sigint = 0;
 	    }
@@ -3170,7 +3170,7 @@  check_zombie_leaders (void)
       if (inf->pid == 0)
 	continue;
 
-      leader_lp = find_lwp_pid (pid_to_ptid (inf->pid));
+      leader_lp = find_lwp_pid (ptid_t (inf->pid));
       if (leader_lp != NULL
 	  /* Check if there are other threads in the group, as we may
 	     have raced with the inferior simply exiting.  */
@@ -3707,7 +3707,7 @@  linux_nat_target::kill ()
     linux_fork_killall ();
   else
     {
-      ptid_t ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));
+      ptid_t ptid = ptid_t (ptid_get_pid (inferior_ptid));
 
       /* Stop all threads before killing them, since ptrace requires
 	 that the thread is stopped to sucessfully PTRACE_KILL.  */
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
index a3931ea6a9..22b265eaf0 100644
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -357,7 +357,7 @@  aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
 				 int is_watchpoint, unsigned int idx)
 {
   struct aarch64_dr_update_callback_param param;
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+  ptid_t pid_ptid = ptid_t (ptid_get_pid (current_lwp_ptid ()));
 
   param.is_watchpoint = is_watchpoint;
   param.idx = idx;
diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c
index 8b59387fa5..ea71aad25f 100644
--- a/gdb/nat/fork-inferior.c
+++ b/gdb/nat/fork-inferior.c
@@ -484,7 +484,7 @@  startup_inferior (pid_t pid, int ntraps,
     }
 
   if (target_supports_multi_process ())
-    resume_ptid = pid_to_ptid (pid);
+    resume_ptid = ptid_t (pid);
   else
     resume_ptid = minus_one_ptid;
 
diff --git a/gdb/nat/x86-linux-dregs.c b/gdb/nat/x86-linux-dregs.c
index 74e481c4f6..9865ac63b1 100644
--- a/gdb/nat/x86-linux-dregs.c
+++ b/gdb/nat/x86-linux-dregs.c
@@ -102,7 +102,7 @@  x86_linux_dr_get_addr (int regnum)
 void
 x86_linux_dr_set_addr (int regnum, CORE_ADDR addr)
 {
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+  ptid_t pid_ptid = ptid_t (ptid_get_pid (current_lwp_ptid ()));
 
   gdb_assert (DR_FIRSTADDR <= regnum && regnum <= DR_LASTADDR);
 
@@ -122,7 +122,7 @@  x86_linux_dr_get_control (void)
 void
 x86_linux_dr_set_control (unsigned long control)
 {
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+  ptid_t pid_ptid = ptid_t (ptid_get_pid (current_lwp_ptid ()));
 
   iterate_over_lwps (pid_ptid, update_debug_registers_callback, NULL);
 }
diff --git a/gdb/nto-procfs.c b/gdb/nto-procfs.c
index c1b38e8616..7591a608d7 100644
--- a/gdb/nto-procfs.c
+++ b/gdb/nto-procfs.c
@@ -713,14 +713,14 @@  nto_procfs_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
       else
 	printf_unfiltered ("Attaching to %s\n",
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }
-  inferior_ptid = do_attach (pid_to_ptid (pid));
+  inferior_ptid = do_attach (ptid_t (pid));
   inf = current_inferior ();
   inferior_appeared (inf, pid);
   inf->attach_flag = 1;
@@ -1311,7 +1311,7 @@  nto_procfs_target::create_inferior (const char *exec_file,
   if (fds[2] != STDERR_FILENO)
     close (fds[2]);
 
-  inferior_ptid = do_attach (pid_to_ptid (pid));
+  inferior_ptid = do_attach (ptid_t (pid));
   procfs_update_thread_list (ops);
 
   inf = current_inferior ();
diff --git a/gdb/obsd-nat.c b/gdb/obsd-nat.c
index 08e873d11f..ac05fae9a1 100644
--- a/gdb/obsd-nat.c
+++ b/gdb/obsd-nat.c
@@ -115,7 +115,7 @@  obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
     }
   while (pid == -1);
 
-  ptid = pid_to_ptid (pid);
+  ptid = ptid_t (pid);
 
   if (WIFSTOPPED (status))
     {
@@ -129,7 +129,7 @@  obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	{
 	case PTRACE_FORK:
 	  ourstatus->kind = TARGET_WAITKIND_FORKED;
-	  ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
+	  ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
 
 	  /* Make sure the other end of the fork is stopped too.  */
 	  fpid = waitpid (pe.pe_other_pid, &status, 0);
@@ -144,11 +144,11 @@  obsd_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
 	  gdb_assert (pe.pe_other_pid == pid);
 	  if (fpid == ptid_get_pid (inferior_ptid))
 	    {
-	      ourstatus->value.related_pid = pid_to_ptid (pe.pe_other_pid);
-	      return pid_to_ptid (fpid);
+	      ourstatus->value.related_pid = ptid_t (pe.pe_other_pid);
+	      return ptid_t (fpid);
 	    }
 
-	  return pid_to_ptid (pid);
+	  return ptid_t (pid);
 	}
 
       ptid = ptid_t (pid, pe.pe_tid, 0);
diff --git a/gdb/procfs.c b/gdb/procfs.c
index c4e01673c0..fc6568f956 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -1895,14 +1895,14 @@  procfs_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_filtered (_("Attaching to program `%s', %s\n"),
-			 exec_file, target_pid_to_str (pid_to_ptid (pid)));
+			 exec_file, target_pid_to_str (ptid_t (pid)));
       else
 	printf_filtered (_("Attaching to %s\n"),
-			 target_pid_to_str (pid_to_ptid (pid)));
+			 target_pid_to_str (ptid_t (pid)));
 
       fflush (stdout);
     }
-  inferior_ptid = do_attach (pid_to_ptid (pid));
+  inferior_ptid = do_attach (ptid_t (pid));
   if (!target_is_pushed (this))
     push_target (this);
 }
@@ -1921,7 +1921,7 @@  procfs_target::detach (inferior *inf, int from_tty)
 	exec_file = "";
 
       printf_filtered (_("Detaching from program: %s, %s\n"), exec_file,
-		       target_pid_to_str (pid_to_ptid (pid)));
+		       target_pid_to_str (ptid_t (pid)));
       gdb_flush (gdb_stdout);
     }
 
@@ -2208,7 +2208,7 @@  wait_again:
 
   retry++;
   wstat    = 0;
-  retval   = pid_to_ptid (-1);
+  retval   = ptid_t (-1);
 
   /* Find procinfo for main process.  */
   pi = find_procinfo_or_die (ptid_get_pid (inferior_ptid), 0);
@@ -2244,7 +2244,7 @@  wait_again:
 		       ptid_get_pid (inferior_ptid), wait_retval);
 	      /* FIXME: might I not just use waitpid?
 		 Or try find_procinfo to see if I know about this child?  */
-	      retval = pid_to_ptid (wait_retval);
+	      retval = ptid_t (wait_retval);
 	    }
 	  else if (errno == EINTR)
 	    goto wait_again;
@@ -2340,7 +2340,7 @@  wait_again:
 			/* If wait returns -1, that's what we return
 			   to GDB.  */
 			if (temp < 0)
-			  retval = pid_to_ptid (temp);
+			  retval = ptid_t (temp);
 		      }
 		  }
 		else
@@ -2507,7 +2507,7 @@  wait_again:
 		case FLTPAGE:	/* Recoverable page fault */
 		default:	/* FIXME: use si_signo if possible for
 				   fault.  */
-		  retval = pid_to_ptid (-1);
+		  retval = ptid_t (-1);
 		  printf_filtered ("procfs:%d -- ", __LINE__);
 		  printf_filtered (_("child stopped for unknown reason:\n"));
 		  proc_prettyprint_why (why, what, 1);
@@ -2959,7 +2959,7 @@  procfs_init_inferior (struct target_ops *ops, int pid)
   /* We already have a main thread registered in the thread table at
      this point, but it didn't have any lwp info yet.  Notify the core
      about it.  This changes inferior_ptid as well.  */
-  thread_change_ptid (pid_to_ptid (pid),
+  thread_change_ptid (ptid_t (pid),
 		      ptid_t (pid, lwpid, 0));
 
   gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
@@ -3126,7 +3126,7 @@  procfs_target::create_inferior (const char *exec_file,
   /* We have something that executes now.  We'll be running through
      the shell at this point (if startup-with-shell is true), but the
      pid shouldn't change.  */
-  add_thread_silent (pid_to_ptid (pid));
+  add_thread_silent (ptid_t (pid));
 
   procfs_init_inferior (this, pid);
 }
@@ -3749,7 +3749,7 @@  _initialize_procfs (void)
 ptid_t
 procfs_first_available (void)
 {
-  return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1);
+  return ptid_t (procinfo_list ? procinfo_list->pid : -1);
 }
 
 /* ===================  GCORE .NOTE "MODULE" =================== */
diff --git a/gdb/progspace.c b/gdb/progspace.c
index 9954a190d3..d11f9ef873 100644
--- a/gdb/progspace.c
+++ b/gdb/progspace.c
@@ -292,12 +292,12 @@  print_program_space (struct ui_out *uiout, int requested)
 		printed_header = 1;
 		printf_filtered ("\n\tBound inferiors: ID %d (%s)",
 				 inf->num,
-				 target_pid_to_str (pid_to_ptid (inf->pid)));
+				 target_pid_to_str (ptid_t (inf->pid)));
 	      }
 	    else
 	      printf_filtered (", ID %d (%s)",
 			       inf->num,
-			       target_pid_to_str (pid_to_ptid (inf->pid)));
+			       target_pid_to_str (ptid_t (inf->pid)));
 	  }
 
       uiout->text ("\n");
diff --git a/gdb/remote.c b/gdb/remote.c
index b72a27e62a..0eea37a176 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -2439,7 +2439,7 @@  remote_target::remote_notice_new_inferior (ptid_t currthread, int executing)
 	     stub doesn't support qC.  This is the first stop reported
 	     after an attach, so this is the main thread.  Update the
 	     ptid in the thread list.  */
-	  if (in_thread_list (pid_to_ptid (pid)))
+	  if (in_thread_list (ptid_t (pid)))
 	    thread_change_ptid (inferior_ptid, currthread);
 	  else
 	    {
@@ -5684,7 +5684,7 @@  remote_target::remote_detach_1 (int from_tty, inferior *inf)
     {
       /* Save the pid as a string before mourning, since that will
 	 unpush the remote target, and we need the string after.  */
-      std::string infpid = target_pid_to_str (pid_to_ptid (pid));
+      std::string infpid = target_pid_to_str (ptid_t (pid));
 
       target_mourn_inferior (inferior_ptid);
       if (print_inferior_events)
@@ -5806,10 +5806,10 @@  extended_remote_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_unfiltered (_("Attaching to program: %s, %s\n"), exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
       else
 	printf_unfiltered (_("Attaching to %s\n"),
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }
@@ -5830,19 +5830,19 @@  extended_remote_target::attach (const char *args, int from_tty)
 	}
       else if (strcmp (rs->buf, "OK") != 0)
 	error (_("Attaching to %s failed with: %s"),
-	       target_pid_to_str (pid_to_ptid (pid)),
+	       target_pid_to_str (ptid_t (pid)),
 	       rs->buf);
       break;
     case PACKET_UNKNOWN:
       error (_("This target does not support attaching to a process"));
     default:
       error (_("Attaching to %s failed"),
-	     target_pid_to_str (pid_to_ptid (pid)));
+	     target_pid_to_str (ptid_t (pid)));
     }
 
   set_current_inferior (remote_add_inferior (0, pid, 1, 0));
 
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
 
   if (target_is_non_stop_p ())
     {
@@ -5855,7 +5855,7 @@  extended_remote_target::attach (const char *args, int from_tty)
       if (thread)
 	inferior_ptid = thread->ptid;
       else
-	inferior_ptid = pid_to_ptid (pid);
+	inferior_ptid = ptid_t (pid);
 
       /* Invalidate our notion of the remote current thread.  */
       record_currthread (rs, minus_one_ptid);
@@ -6577,7 +6577,7 @@  remote_target::commit_resume ()
 	    {
 	      if (get_remote_inferior (inf)->may_wildcard_vcont)
 		{
-		  vcont_builder.push_action (pid_to_ptid (inf->pid),
+		  vcont_builder.push_action (ptid_t (inf->pid),
 					     false, GDB_SIGNAL_0);
 		}
 	    }
@@ -7532,7 +7532,7 @@  Packet: '%s'\n"),
 	  }
 	else
 	  error (_("unknown stop reply packet: %s"), buf);
-	event->ptid = pid_to_ptid (pid);
+	event->ptid = ptid_t (pid);
       }
       break;
     case 'N':
diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c
index 31677c24c5..8a9a0ed81f 100644
--- a/gdb/rs6000-nat.c
+++ b/gdb/rs6000-nat.c
@@ -543,7 +543,7 @@  rs6000_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
   else
     store_waitstatus (ourstatus, status);
 
-  return pid_to_ptid (pid);
+  return ptid_t (pid);
 }
 
 
diff --git a/gdb/s390-linux-nat.c b/gdb/s390-linux-nat.c
index 8d3ed55ed0..74cab71420 100644
--- a/gdb/s390-linux-nat.c
+++ b/gdb/s390-linux-nat.c
@@ -848,7 +848,7 @@  s390_refresh_per_info_cb (struct lwp_info *lp, void *arg)
 static int
 s390_refresh_per_info (void)
 {
-  ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (current_lwp_ptid ()));
+  ptid_t pid_ptid = ptid_t (ptid_get_pid (current_lwp_ptid ()));
 
   iterate_over_lwps (pid_ptid, s390_refresh_per_info_cb, NULL);
   return 0;
diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c
index d67fd8352f..85d3ad92ff 100644
--- a/gdb/sol-thread.c
+++ b/gdb/sol-thread.c
@@ -307,20 +307,20 @@  thread_to_lwp (ptid_t thread_id, int default_lwp)
 
   val = p_td_ta_map_id2thr (main_ta, ptid_get_tid (thread_id), &th);
   if (val == TD_NOTHR)
-    return pid_to_ptid (-1);	/* Thread must have terminated.  */
+    return ptid_t (-1);	/* Thread must have terminated.  */
   else if (val != TD_OK)
     error (_("thread_to_lwp: td_ta_map_id2thr %s"), td_err_string (val));
 
   val = p_td_thr_get_info (&th, &ti);
   if (val == TD_NOTHR)
-    return pid_to_ptid (-1);	/* Thread must have terminated.  */
+    return ptid_t (-1);	/* Thread must have terminated.  */
   else if (val != TD_OK)
     error (_("thread_to_lwp: td_thr_get_info: %s"), td_err_string (val));
 
   if (ti.ti_state != TD_THR_ACTIVE)
     {
       if (default_lwp != -1)
-	return pid_to_ptid (default_lwp);
+	return ptid_t (default_lwp);
       error (_("thread_to_lwp: thread state not active: %s"),
 	     td_state_string (ti.ti_state));
     }
@@ -346,11 +346,11 @@  lwp_to_thread (ptid_t lwp)
   /* It's an LWP.  Convert it to a thread ID.  */
 
   if (!target_thread_alive (lwp))
-    return pid_to_ptid (-1);	/* Must be a defunct LPW.  */
+    return ptid_t (-1);	/* Must be a defunct LPW.  */
 
   val = p_td_ta_map_lwp2thr (main_ta, ptid_get_lwp (lwp), &th);
   if (val == TD_NOTHR)
-    return pid_to_ptid (-1);	/* Thread must have terminated.  */
+    return ptid_t (-1);	/* Thread must have terminated.  */
   else if (val != TD_OK)
     error (_("lwp_to_thread: td_ta_map_lwp2thr: %s."), td_err_string (val));
 
@@ -362,7 +362,7 @@  lwp_to_thread (ptid_t lwp)
 
   val = p_td_thr_get_info (&th, &ti);
   if (val == TD_NOTHR)
-    return pid_to_ptid (-1);	/* Thread must have terminated.  */
+    return ptid_t (-1);	/* Thread must have terminated.  */
   else if (val != TD_OK)
     error (_("lwp_to_thread: td_thr_get_info: %s."), td_err_string (val));
 
@@ -387,7 +387,7 @@  sol_thread_target::detach (inferior *inf, int from_tty)
   target_ops *beneath = this->beneath ();
 
   sol_thread_active = 0;
-  inferior_ptid = pid_to_ptid (ptid_get_pid (main_ph.ptid));
+  inferior_ptid = ptid_t (ptid_get_pid (main_ph.ptid));
   unpush_target (this);
   beneath->detach (inf, from_tty);
 }
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index 96cda7274d..18c1856f7b 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -503,7 +503,7 @@  spu_linux_nat_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
     }
 
   store_waitstatus (ourstatus, status);
-  return pid_to_ptid (pid);
+  return ptid_t (pid);
 }
 
 /* Override the fetch_inferior_register routine.  */
diff --git a/gdb/target.c b/gdb/target.c
index 080480c609..66db4b278c 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -3243,7 +3243,7 @@  target_announce_detach (int from_tty)
 
   pid = ptid_get_pid (inferior_ptid);
   printf_unfiltered (_("Detaching from program: %s, %s\n"), exec_file,
-		     target_pid_to_str (pid_to_ptid (pid)));
+		     target_pid_to_str (ptid_t (pid)));
   gdb_flush (gdb_stdout);
 }
 
diff --git a/gdb/top.c b/gdb/top.c
index 8e0a39494e..c68f8d36ec 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1543,11 +1543,11 @@  print_inferior_quit_action (struct inferior *inf, void *arg)
   if (inf->attach_flag)
     fprintf_filtered (stb,
 		      _("\tInferior %d [%s] will be detached.\n"), inf->num,
-		      target_pid_to_str (pid_to_ptid (inf->pid)));
+		      target_pid_to_str (ptid_t (inf->pid)));
   else
     fprintf_filtered (stb,
 		      _("\tInferior %d [%s] will be killed.\n"), inf->num,
-		      target_pid_to_str (pid_to_ptid (inf->pid)));
+		      target_pid_to_str (ptid_t (inf->pid)));
 
   return 0;
 }
diff --git a/gdb/tracefile-tfile.c b/gdb/tracefile-tfile.c
index 28abdcdbe9..7e46b182ba 100644
--- a/gdb/tracefile-tfile.c
+++ b/gdb/tracefile-tfile.c
@@ -555,7 +555,7 @@  tfile_target_open (const char *arg, int from_tty)
   END_CATCH
 
   inferior_appeared (current_inferior (), TFILE_PID);
-  inferior_ptid = pid_to_ptid (TFILE_PID);
+  inferior_ptid = ptid_t (TFILE_PID);
   add_thread_silent (inferior_ptid);
 
   if (ts->traceframe_count <= 0)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 5eaa98af02..890cd06c07 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -1824,7 +1824,7 @@  do_initial_windows_stuff (struct target_ops *ops, DWORD pid, int attaching)
      can rely on it.  When attaching, we don't know about any thread
      id here, but that's OK --- nothing should be referencing the
      current thread until we report an event out of windows_wait.  */
-  inferior_ptid = pid_to_ptid (pid);
+  inferior_ptid = ptid_t (pid);
 
   target_terminal::init ();
   target_terminal::inferior ();
@@ -1959,10 +1959,10 @@  windows_nat_target::attach (const char *args, int from_tty)
 
       if (exec_file)
 	printf_unfiltered ("Attaching to program `%s', %s\n", exec_file,
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
       else
 	printf_unfiltered ("Attaching to %s\n",
-			   target_pid_to_str (pid_to_ptid (pid)));
+			   target_pid_to_str (ptid_t (pid)));
 
       gdb_flush (gdb_stdout);
     }