This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH FYI] Revamped process/thread/lwp identifier mega-patch


The patch below is a revamped version of a patch that I had previously
sent to this list:

    http://sources.redhat.com/ml/gdb-patches/2000-10/msg00014.html

This previous patch has been approved and Andrew suggested that I
commit it to a branch for a week's worth of testing before merging it
into the mainline sources.  But, by that time, I began to have second
thoughts about some of the decisions that were made in the
implementation of the previous patch.  Plus, it no longer applied
cleanly.

Anyway, the main structural difference between this patch and the
previous one is that the old one used a pointer to a struct to
represent the pid/tid/lwp identifier object whereas the current one
uses a struct that's been typedef'd to have the name ``ptid_t''.  I'm
open to suggestions for more a more suitable name.  I chose ``ptid_t''
because the type in question is supposed to represent both a pid
(process id) and a tid (thread id) and the string "ptid" seems to fit
nicely.  It's also reasonably short and the string "ptid" does not
presently appear anywhere in the sources.

The reason for using a struct instead of a pointer to a struct
has been discussed elsewhere.  (I don't have a reference handy
at the moment, but can dig some up if needed.)  The primary reason
for not using a pointer is to avoid the memory management issues
associated with pointers.  Basically, if we use a pointer, we will
either need to significantly restructure GDB so that it is more
disciplined with pid/tid/lwp identifiers or introduce some sort
of garbage collector.  (For those folks that think GDB ought to be
restructured, my patch helps out in that it shows you all of those
places that will need to be fixed.  This is also one of the reasons
for picking a type/identifier name string (ptid) that doesn't
presently exist in the sources.)

I'm posting this patch for two reasons...

First, I've received a number of requests for updated patches from
various folks who've found my previous patch to be useful for getting
past the "32 thread" limit when debugging on GNU/Linux/x86.  This
patch should satisfy everyone who's been waiting for an updated patch
due to the old one not applying cleanly any longer.

The second reason for posting this patch is to show (roughly) where
we'll end up after I've committed things in stages.  I doubt that what
I'm posting here will be precisely what we'll end up with in a few
weeks or so, but it should serve as a good reference for upcoming
patches in which it isn't immediately obvious why I'm doing a
particular transformation.

I've done a fair amount of testing of this patch.  I'm sure that we'll
find a problem or two after it all gets committed, but I've tried to
eliminate as many of them as I could by doing building and testing on
as many platforms as I could get access to.  Here is the current list:

    Native builds, tested w/ no regressions:

	i686-pc-linux-gnu
	i386-unknown-netbsd1.4
	ia64-unknown-linux
	i586-sco-sysv5uw7.1.1
	i386-unknown-freebsd4.2
	i386-pc-solaris2.8
	powerpc-unknown-linux-gnu
	i386-unknown-netbsdelf1.5
	sparc-sun-solaris2.8
	sparc-sun-sunos4.1.4
	powerpc-ibm-aix4.3.3.0
	alphaev6-unknown-linux-gnu
	armv4l-unknown-linux-gnu

    Native builds, no testing:
        (Problems which prevented the running of the testsuite were
	present in both the base and patched versions.)

	i686-pc-cygwin		- testsuite problems (SIGINT kills the
	                          testing framework.)
	hppa2.0-hp-hpux10.20	- gdb hangs when starting a program
	mips-sgi-irix6.3	- assertion failure:
                                  regcache.c:282: gdb-internal-error:
				  legacy_read_register_gen: Assertion
				  `regnum >= 0 && regnum < (NUM_REGS +
				  NUM_PSEUDO_REGS)' failed.

    Build only, cross debugger, --host=i686-pc-linux-gnu:

	--target=a29k-amd-udi
	--target=alpha-dec-osf4.0a
	--target=arc-elf
	--target=d10v-elf
	--target=d30v-elf
	--target=fr30-elf
	--target=h8300hms
	--target=h8500hms
	--target=i386-aout
	--target=i386-elf
	--target=i586-pc-msdosdjgpp
	--target=i960-coff
	--target=ia64-linux
	--target=m32r-elf
	--target=m68hc11-elf
	--target=m68k-aout
	--target=m68k-coff
	--target=m68k-elf
	--target=m88k
	--target=mcore-elf
	--target=mcore-pe
	--target=mips64-elf
	--target=mips-elf
	--target=mn10200-elf
	--target=mn10300-elf
	--target=ns32k-netbsd
	--target=powerpc-eabi
	--target=powerpcle-eabi
	--target=rs6000-ibm-aix3.2
	--target=rs6000-ibm-aix4.1
	--target=sh-elf
	--target=sh-hms
	--target=sparc64-elf
	--target=sparc-elf
	--target=v850-elf
	--target=vax-dec-vms5.5

I discussed this patch earlier this week with other GDB engineers who
have misgivings about some of the decisions that I made.  So, even
though it is significantly more work for me, I will break this patch
up into a number of different pieces.  I'll try to do the
non-controversial ones first and get them in place quickly since
they're also the ones that tend to be the most fragile from the
standpoint of not applying cleanly over time.  The controversy centers
around how (and where) the pid/tid/lwp ought to be represented. 
Fortunately, having a typedef in place will allow us to do some
experimentation if the choice that I made is deemed unsuitable.

I don't have ChangeLog entries yet for this patch, though the ones
provided with my old patch ought to be fairly close.  I will, of
course, generate new and accurate ChangeLog entries for each of the
upcoming intermediate patches that I actually plan to commit.  I'll
post RFCs (with a one to three day waiting period) for what I think
are the non-controversial patches and I'll post RFAs for the rest.

As usual, feedback on this (and upcoming) patches will be very much
appreciated.

Kevin

Index: a68v-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/a68v-nat.c,v
retrieving revision 1.4
diff -u -p -r1.4 a68v-nat.c
--- a68v-nat.c	2001/03/06 08:21:05	1.4
+++ a68v-nat.c	2001/04/25 21:34:55
@@ -43,19 +43,19 @@ fetch_inferior_registers (int ignored)
 
   registers_fetched ();
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_registers,
 	  ptrace_$data_set,
 	  (PTRACE_ARG3_TYPE) & inferior_registers,
 	  ptrace_$data_set);
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k);
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
 	  ptrace_$control_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
@@ -82,13 +82,13 @@ store_inferior_registers (int regno)
   ptrace_$init_control (&inferior_control_registers);
   inferior_fp_registers.size = sizeof (inferior_fp_registers);
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k);
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
 	  ptrace_$control_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
@@ -102,19 +102,19 @@ store_inferior_registers (int regno)
   inferior_control_registers.sr = *(int *) &registers[REGISTER_BYTE (PS_REGNUM)];
   inferior_control_registers.pc = *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
 
-  ptrace (PTRACE_SETREGS, inferior_pid,
+  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_registers,
 	  ptrace_$data_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_registers,
 	  ptrace_$data_set_m68k);
 
-  ptrace (PTRACE_SETREGS, inferior_pid,
+  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers,
 	  ptrace_$floating_set_m68k);
 
-  ptrace (PTRACE_SETREGS, inferior_pid,
+  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
 	  ptrace_$control_set_m68k,
 	  (PTRACE_ARG3_TYPE) & inferior_control_registers,
Index: alphabsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/alphabsd-nat.c,v
retrieving revision 1.4
diff -u -p -r1.4 alphabsd-nat.c
--- alphabsd-nat.c	2001/03/01 01:39:20	1.4
+++ alphabsd-nat.c	2001/04/25 21:34:55
@@ -135,7 +135,8 @@ fetch_inferior_registers (int regno)
 {
   gregset_t gregs;
 
-  if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't get registers");
 
   supply_gregset (&gregs);
@@ -144,7 +145,7 @@ fetch_inferior_registers (int regno)
     {
       fpregset_t fpregs;
 
-      if (ptrace (PT_GETFPREGS, inferior_pid,
+      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't get floating point status");
 
@@ -163,25 +164,27 @@ store_inferior_registers (int regno)
 {
   gregset_t gregs;
 
-  if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't get registers");
 
   fill_gregset (&gregs, regno);
 
-  if (ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't write registers");
 
   if (regno == -1 || regno >= FP0_REGNUM)
     {
       fpregset_t fpregs;
 
-      if (ptrace (PT_GETFPREGS, inferior_pid,
+      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't get floating point status");
 
       fill_fpregset (&fpregs, regno);
 
-      if (ptrace (PT_SETFPREGS, inferior_pid,
+      if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't write floating point status");
     }
Index: arch-utils.c
===================================================================
RCS file: /cvs/src/src/gdb/arch-utils.c,v
retrieving revision 1.25
diff -u -p -r1.25 arch-utils.c
--- arch-utils.c	2001/04/19 00:37:24	1.25
+++ arch-utils.c	2001/04/25 21:34:56
@@ -252,11 +252,11 @@ default_prepare_to_proceed (int select_i
 int
 generic_prepare_to_proceed (int select_it)
 {
-  int wait_pid;
+  ptid_t wait_ptid;
   struct target_waitstatus wait_status;
 
   /* Get the last target status returned by target_wait().  */
-  get_last_target_status (&wait_pid, &wait_status);
+  get_last_target_status (&wait_ptid, &wait_status);
 
   /* Make sure we were stopped at a breakpoint.  */
   if (wait_status.kind != TARGET_WAITKIND_STOPPED
@@ -265,10 +265,11 @@ generic_prepare_to_proceed (int select_i
       return 0;
     }
 
-  if (wait_pid != -1 && inferior_pid != wait_pid)
+  if (!ptid_equal (wait_ptid, minus_one_ptid)
+      && !ptid_equal (inferior_ptid, wait_ptid))
     {
       /* Switched over from WAIT_PID.  */
-      CORE_ADDR wait_pc = read_pc_pid (wait_pid);
+      CORE_ADDR wait_pc = read_pc_pid (wait_ptid);
 
       /* Avoid switching where it wouldn't do any good, i.e. if both
          threads are at the same breakpoint.  */
@@ -278,7 +279,7 @@ generic_prepare_to_proceed (int select_i
 	    {
 	      /* User hasn't deleted the breakpoint.  Switch back to
 		 WAIT_PID and return non-zero.  */
-	      inferior_pid = wait_pid;
+	      inferior_ptid = wait_ptid;
 
 	      /* FIXME: This stuff came from switch_to_thread() in
 		 thread.c (which should probably be a public function).  */
Index: arm-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-linux-nat.c,v
retrieving revision 1.9
diff -u -p -r1.9 arm-linux-nat.c
--- arm-linux-nat.c	2001/03/01 01:39:20	1.9
+++ arm-linux-nat.c	2001/04/25 21:34:56
@@ -78,24 +78,19 @@ static unsigned int os_version, os_major
 
 /* On Linux, threads are implemented as pseudo-processes, in which
    case we may be tracing more than one process at a time.  In that
-   case, inferior_pid will contain the main process ID and the
-   individual thread (process) ID mashed together.  These macros are
-   used to separate them out.  These definitions should be overridden
-   if thread support is included.  */
-
-#if !defined (PIDGET)	/* Default definition for PIDGET/TIDGET.  */
-#define PIDGET(PID)	PID
-#define TIDGET(PID)	0
-#endif
+   case, inferior_ptid will contain the main process ID and the
+   individual thread (process) ID.  get_thread_id () is used to
+   get the thread id if it's available, and the process id otherwise. */
 
 int
-get_thread_id (int inferior_pid)
+get_thread_id (ptid_t ptid)
 {
-  int tid = TIDGET (inferior_pid);
-  if (0 == tid) tid = inferior_pid;
+  int tid = TIDGET (ptid);
+  if (0 == tid)
+    tid = PIDGET (ptid);
   return tid;
 }
-#define GET_THREAD_ID(PID)	get_thread_id ((PID));
+#define GET_THREAD_ID(PTID)	get_thread_id ((PTID));
 
 static void
 fetch_nwfpe_single (unsigned int fn, FPA11 * fpa11)
@@ -230,7 +225,7 @@ fetch_fpregister (int regno)
   FPA11 fp;
   
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
 
   /* Read the floating point state.  */
   ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@@ -279,7 +274,7 @@ fetch_fpregs (void)
   FPA11 fp;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   /* Read the floating point state.  */
   ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@@ -327,7 +322,7 @@ store_fpregister (int regno)
   FPA11 fp;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   /* Read the floating point state.  */
   ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@@ -365,7 +360,7 @@ store_fpregs (void)
   FPA11 fp;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   /* Read the floating point state.  */
   ret = ptrace (PT_GETFPREGS, tid, 0, &fp);
@@ -403,7 +398,7 @@ fetch_register (int regno)
   struct pt_regs regs;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
   if (ret < 0)
@@ -440,7 +435,7 @@ fetch_regs (void)
   struct pt_regs regs;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
   if (ret < 0)
@@ -474,7 +469,7 @@ store_register (int regno)
     return;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   /* Get the general registers from the process.  */
   ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
@@ -502,7 +497,7 @@ store_regs (void)
   struct pt_regs regs;
 
   /* Get the thread id for the ptrace call.  */
-  tid = GET_THREAD_ID (inferior_pid);
+  tid = GET_THREAD_ID (inferior_ptid);
   
   /* Fetch the general registers.  */
   ret = ptrace (PTRACE_GETREGS, tid, 0, &regs);
Index: blockframe.c
===================================================================
RCS file: /cvs/src/src/gdb/blockframe.c,v
retrieving revision 1.13
diff -u -p -r1.13 blockframe.c
--- blockframe.c	2001/03/06 08:21:05	1.13
+++ blockframe.c	2001/04/25 21:34:58
@@ -265,8 +265,8 @@ reinit_frame_cache (void)
 {
   flush_cached_frames ();
 
-  /* FIXME: The inferior_pid test is wrong if there is a corefile.  */
-  if (inferior_pid != 0)
+  /* FIXME: The inferior_ptid test is wrong if there is a corefile.  */
+  if (PIDGET (inferior_ptid) != 0)
     {
       select_frame (get_current_frame (), 0);
     }
Index: breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.31
diff -u -p -r1.31 breakpoint.c
--- breakpoint.c	2001/04/17 20:16:30	1.31
+++ breakpoint.c	2001/04/25 21:35:06
@@ -988,13 +988,13 @@ insert_breakpoints (void)
 	switch (b->type)
 	  {
 	  case bp_catch_fork:
-	    val = target_insert_fork_catchpoint (inferior_pid);
+	    val = target_insert_fork_catchpoint (PIDGET (inferior_ptid));
 	    break;
 	  case bp_catch_vfork:
-	    val = target_insert_vfork_catchpoint (inferior_pid);
+	    val = target_insert_vfork_catchpoint (PIDGET (inferior_ptid));
 	    break;
 	  case bp_catch_exec:
-	    val = target_insert_exec_catchpoint (inferior_pid);
+	    val = target_insert_exec_catchpoint (PIDGET (inferior_ptid));
 	    break;
 	  default:
 	    warning ("Internal error, %s line %d.", __FILE__, __LINE__);
@@ -1061,10 +1061,10 @@ reattach_breakpoints (int pid)
 {
   register struct breakpoint *b;
   int val;
-  int saved_inferior_pid = inferior_pid;
+  struct cleanup *old_chain = save_inferior_ptid ();
 
-  /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
-  inferior_pid = pid;	/* Because remove_breakpoint will use this global. */
+  /* Set inferior_ptid; remove_breakpoint uses this global.  */
+  inferior_ptid = pid_to_ptid (pid);
   ALL_BREAKPOINTS (b)
   {
     if (b->inserted)
@@ -1076,12 +1076,12 @@ reattach_breakpoints (int pid)
 	  val = target_insert_breakpoint (b->address, b->shadow_contents);
 	if (val != 0)
 	  {
-	    inferior_pid = saved_inferior_pid;
+	    do_cleanups (old_chain);
 	    return val;
 	  }
       }
   }
-  inferior_pid = saved_inferior_pid;
+  do_cleanups (old_chain);
   return 0;
 }
 
@@ -1205,13 +1205,13 @@ detach_breakpoints (int pid)
 {
   register struct breakpoint *b;
   int val;
-  int saved_inferior_pid = inferior_pid;
+  struct cleanup *old_chain = save_inferior_ptid ();
 
-  if (pid == inferior_pid)
-    error ("Cannot detach breakpoints of inferior_pid");
+  if (pid == PIDGET (inferior_ptid))
+    error ("Cannot detach breakpoints of inferior_ptid");
 
-  /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
-  inferior_pid = pid;	/* Because remove_breakpoint will use this global. */
+  /* Set inferior_ptid; remove_breakpoint uses this global.  */
+  inferior_ptid = pid_to_ptid (pid);
   ALL_BREAKPOINTS (b)
   {
     if (b->inserted)
@@ -1219,12 +1219,12 @@ detach_breakpoints (int pid)
 	val = remove_breakpoint (b, mark_inserted);
 	if (val != 0)
 	  {
-	    inferior_pid = saved_inferior_pid;
+	    do_cleanups (old_chain);
 	    return val;
 	  }
       }
   }
-  inferior_pid = saved_inferior_pid;
+  do_cleanups (old_chain);
   return 0;
 }
 
@@ -1347,13 +1347,13 @@ remove_breakpoint (struct breakpoint *b,
       switch (b->type)
 	{
 	case bp_catch_fork:
-	  val = target_remove_fork_catchpoint (inferior_pid);
+	  val = target_remove_fork_catchpoint (PIDGET (inferior_ptid));
 	  break;
 	case bp_catch_vfork:
-	  val = target_remove_vfork_catchpoint (inferior_pid);
+	  val = target_remove_vfork_catchpoint (PIDGET (inferior_ptid));
 	  break;
 	case bp_catch_exec:
-	  val = target_remove_exec_catchpoint (inferior_pid);
+	  val = target_remove_exec_catchpoint (PIDGET (inferior_ptid));
 	  break;
 	default:
 	  warning ("Internal error, %s line %d.", __FILE__, __LINE__);
@@ -1565,12 +1565,12 @@ frame_in_dummy (struct frame_info *frame
    PC is valid for process/thread PID.  */
 
 int
-breakpoint_thread_match (CORE_ADDR pc, int pid)
+breakpoint_thread_match (CORE_ADDR pc, ptid_t ptid)
 {
   struct breakpoint *b;
   int thread;
 
-  thread = pid_to_thread_id (pid);
+  thread = pid_to_thread_id (ptid);
 
   ALL_BREAKPOINTS (b)
     if (b->enable != disabled
@@ -2422,10 +2422,11 @@ bpstat_stop_status (CORE_ADDR *pc, int n
        ignore it. */
     if ((b->type == bp_catch_load)
 #if defined(SOLIB_HAVE_LOAD_EVENT)
-	&& (!SOLIB_HAVE_LOAD_EVENT (inferior_pid)
+	&& (!SOLIB_HAVE_LOAD_EVENT (PIDGET (inferior_ptid))
 	    || ((b->dll_pathname != NULL)
 		&& (strcmp (b->dll_pathname, 
-			    SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid)) 
+			    SOLIB_LOADED_LIBRARY_PATHNAME (
+			      PIDGET (inferior_ptid)))
 		    != 0)))
 #endif
       )
@@ -2433,25 +2434,28 @@ bpstat_stop_status (CORE_ADDR *pc, int n
 
     if ((b->type == bp_catch_unload)
 #if defined(SOLIB_HAVE_UNLOAD_EVENT)
-	&& (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid)
+	&& (!SOLIB_HAVE_UNLOAD_EVENT (PIDGET (inferior_ptid))
 	    || ((b->dll_pathname != NULL)
 		&& (strcmp (b->dll_pathname, 
-			    SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid)) 
+			    SOLIB_UNLOADED_LIBRARY_PATHNAME (
+			      PIDGET (inferior_ptid)))
 		    != 0)))
 #endif
       )
       continue;
 
     if ((b->type == bp_catch_fork)
-	&& !target_has_forked (inferior_pid, &b->forked_inferior_pid))
+	&& !target_has_forked (PIDGET (inferior_ptid),
+	                       &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_vfork)
-	&& !target_has_vforked (inferior_pid, &b->forked_inferior_pid))
+	&& !target_has_vforked (PIDGET (inferior_ptid),
+	                        &b->forked_inferior_pid))
       continue;
 
     if ((b->type == bp_catch_exec)
-	&& !target_has_execd (inferior_pid, &b->exec_pathname))
+	&& !target_has_execd (PIDGET (inferior_ptid), &b->exec_pathname))
       continue;
 
     if (ep_is_exception_catchpoint (b) &&
@@ -3034,9 +3038,11 @@ bpstat_get_triggered_catchpoints (bpstat
       if (ep->triggered_dll_pathname != NULL)
 	xfree (ep->triggered_dll_pathname);
       if (ep->type == bp_catch_load)
-	dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid);
+	dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (
+	                 PIDGET (inferior_ptid));
       else
-	dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid);
+	dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (
+	                 PIDGET (inferior_ptid));
 #else
       dll_pathname = NULL;
 #endif
@@ -4319,8 +4325,8 @@ set_momentary_breakpoint (struct symtab_
   /* If we're debugging a multi-threaded program, then we
      want momentary breakpoints to be active in only a 
      single thread of control.  */
-  if (in_thread_list (inferior_pid))
-    b->thread = pid_to_thread_id (inferior_pid);
+  if (in_thread_list (inferior_ptid))
+    b->thread = pid_to_thread_id (inferior_ptid);
 
   return b;
 }
@@ -5324,7 +5330,7 @@ watch_command_1 (char *arg, int accessfl
      startup sequence by the dynamic linker.
 
      However, I tried avoiding that by having HP-UX's implementation of
-     TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_pid
+     TARGET_CAN_USE_HW_WATCHPOINT return FALSE if there was no inferior_ptid
      yet, which forced slow watches before a "run" or "attach", and it
      still fails somewhere in the startup code.
 
@@ -6056,7 +6062,7 @@ catch_load_command_1 (char *arg, int tem
   /* Create a load breakpoint that only triggers when a load of
      the specified dll (or any dll, if no pathname was specified)
      occurs. */
-  SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag, 
+  SOLIB_CREATE_CATCH_LOAD_HOOK (PIDGET (inferior_ptid), tempflag, 
 				dll_pathname, cond_string);
 }
 
@@ -6098,7 +6104,7 @@ catch_unload_command_1 (char *arg, int t
   /* Create an unload breakpoint that only triggers when an unload of
      the specified dll (or any dll, if no pathname was specified)
      occurs. */
-  SOLIB_CREATE_CATCH_UNLOAD_HOOK (inferior_pid, tempflag, 
+  SOLIB_CREATE_CATCH_UNLOAD_HOOK (PIDGET (inferior_ptid), tempflag, 
 				  dll_pathname, cond_string);
 }
 #endif /* SOLIB_ADD */
@@ -7138,14 +7144,14 @@ breakpoint_re_set (void)
 /* Reset the thread number of this breakpoint:
 
    - If the breakpoint is for all threads, leave it as-is.
-   - Else, reset it to the current thread for inferior_pid. */
+   - Else, reset it to the current thread for inferior_ptid. */
 void
 breakpoint_re_set_thread (struct breakpoint *b)
 {
   if (b->thread != -1)
     {
-      if (in_thread_list (inferior_pid))
-	b->thread = pid_to_thread_id (inferior_pid);
+      if (in_thread_list (inferior_ptid))
+	b->thread = pid_to_thread_id (inferior_ptid);
     }
 }
 
Index: breakpoint.h
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.h,v
retrieving revision 1.6
diff -u -p -r1.6 breakpoint.h
--- breakpoint.h	2001/03/06 08:21:06	1.6
+++ breakpoint.h	2001/04/25 21:35:07
@@ -521,7 +521,7 @@ extern int breakpoint_inserted_here_p (C
 
 extern int frame_in_dummy (struct frame_info *);
 
-extern int breakpoint_thread_match (CORE_ADDR, int);
+extern int breakpoint_thread_match (CORE_ADDR, ptid_t);
 
 extern void until_break_command (char *, int);
 
@@ -598,7 +598,7 @@ extern void update_breakpoints_after_exe
    be detached and allowed to run free.
 
    It is an error to use this function on the process whose id is
-   inferior_pid.  */
+   inferior_ptid.  */
 extern int detach_breakpoints (int);
 
 extern void enable_longjmp_breakpoint (void);
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.15
diff -u -p -r1.15 corelow.c
--- corelow.c	2001/04/14 19:23:02	1.15
+++ corelow.c	2001/04/25 21:35:08
@@ -77,7 +77,7 @@ static void add_to_thread_list (bfd *, a
 
 static int ignore (CORE_ADDR, char *);
 
-static int core_file_thread_alive (int tid);
+static int core_file_thread_alive (ptid_t tid);
 
 static void init_core_ops (void);
 
@@ -185,7 +185,7 @@ core_close (int quitting)
 
   if (core_bfd)
     {
-      inferior_pid = 0;		/* Avoid confusion from thread stuff */
+      inferior_ptid = null_ptid;	/* Avoid confusion from thread stuff */
 
       /* Clear out solib state while the bfd is still open. See
          comments in clear_solib in solib.c. */
@@ -242,13 +242,13 @@ add_to_thread_list (bfd *abfd, asection 
 
   thread_id = atoi (bfd_section_name (abfd, asect) + 5);
 
-  add_thread (thread_id);
+  add_thread (pid_to_ptid (thread_id));
 
 /* Warning, Will Robinson, looking at BFD private data! */
 
   if (reg_sect != NULL
       && asect->filepos == reg_sect->filepos)	/* Did we find .reg? */
-    inferior_pid = thread_id;	/* Yes, make it current */
+    inferior_ptid = pid_to_ptid (thread_id);	/* Yes, make it current */
 }
 
 /* This routine opens and sets up the core file bfd.  */
@@ -384,10 +384,10 @@ core_detach (char *args, int from_tty)
    them to core_vec->core_read_registers, as the register set numbered
    WHICH.
 
-   If inferior_pid is zero, do the single-threaded thing: look for a
-   section named NAME.  If inferior_pid is non-zero, do the
+   If inferior_ptid is zero, do the single-threaded thing: look for a
+   section named NAME.  If inferior_ptid is non-zero, do the
    multi-threaded thing: look for a section named "NAME/PID", where
-   PID is the shortest ASCII decimal representation of inferior_pid.
+   PID is the shortest ASCII decimal representation of inferior_ptid.
 
    HUMAN_NAME is a human-readable name for the kind of registers the
    NAME section contains, for use in error messages.
@@ -406,8 +406,8 @@ get_core_register_section (char *name,
   bfd_size_type size;
   char *contents;
 
-  if (inferior_pid)
-    sprintf (section_name, "%s/%d", name, inferior_pid);
+  if (PIDGET (inferior_ptid))
+    sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
   else
     strcpy (section_name, name);
 
@@ -485,7 +485,7 @@ ignore (CORE_ADDR addr, char *contents)
    behaviour.
  */
 static int
-core_file_thread_alive (int tid)
+core_file_thread_alive (ptid_t tid)
 {
   return 1;
 }
Index: cxux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/cxux-nat.c,v
retrieving revision 1.8
diff -u -p -r1.8 cxux-nat.c
--- cxux-nat.c	2001/03/06 08:21:06	1.8
+++ cxux-nat.c	2001/04/25 21:35:09
@@ -80,7 +80,7 @@ fetch_inferior_registers (int regno)
   offset = (char *) &u.pt_r0 - (char *) &u;
   regaddr = offset;		/* byte offset to r0; */
 
-/*  offset = ptrace (3, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
+/*  offset = ptrace (3, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) offset, 0) - KERNEL_U_ADDR; */
   for (regno = 0; regno < PC_REGNUM; regno++)
     {
       /*regaddr = register_addr (regno, offset); */
@@ -88,29 +88,29 @@ fetch_inferior_registers (int regno)
 
       for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
 	{
-	  *(int *) &buf[i] = ptrace (3, inferior_pid,
+	  *(int *) &buf[i] = ptrace (3, PIDGET (inferior_ptid),
 				     (PTRACE_ARG3_TYPE) regaddr, 0);
 	  regaddr += sizeof (int);
 	}
       supply_register (regno, buf);
     }
   /* now load up registers 32-37; special pc registers */
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) PSR_OFFSET, 0);
   supply_register (PSR_REGNUM, buf);
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) FPSR_OFFSET, 0);
   supply_register (FPSR_REGNUM, buf);
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) FPCR_OFFSET, 0);
   supply_register (FPCR_REGNUM, buf);
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) SXIP_OFFSET, 0);
   supply_register (SXIP_REGNUM, buf);
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) SNIP_OFFSET, 0);
   supply_register (SNIP_REGNUM, buf);
-  *(int *) &buf[0] = ptrace (3, inferior_pid,
+  *(int *) &buf[0] = ptrace (3, PIDGET (inferior_ptid),
 			     (PTRACE_ARG3_TYPE) SFIP_OFFSET, 0);
   supply_register (SFIP_REGNUM, buf);
 
@@ -122,13 +122,13 @@ fetch_inferior_registers (int regno)
 	{
 	  X_REGISTER_RAW_TYPE xval;
 
-	  *(int *) &xval.w1 = ptrace (3, inferior_pid,
+	  *(int *) &xval.w1 = ptrace (3, PIDGET (inferior_ptid),
 				      (PTRACE_ARG3_TYPE) regaddr, 0);
-	  *(int *) &xval.w2 = ptrace (3, inferior_pid,
+	  *(int *) &xval.w2 = ptrace (3, PIDGET (inferior_ptid),
 				      (PTRACE_ARG3_TYPE) (regaddr + 4), 0);
-	  *(int *) &xval.w3 = ptrace (3, inferior_pid,
+	  *(int *) &xval.w3 = ptrace (3, PIDGET (inferior_ptid),
 				      (PTRACE_ARG3_TYPE) (regaddr + 8), 0);
-	  *(int *) &xval.w4 = ptrace (3, inferior_pid,
+	  *(int *) &xval.w4 = ptrace (3, PIDGET (inferior_ptid),
 				      (PTRACE_ARG3_TYPE) (regaddr + 12), 0);
 	  supply_register (regno, (void *) &xval);
 	}
@@ -161,7 +161,7 @@ store_inferior_registers (int regno)
 	{
 	  regaddr = offset + regno * sizeof (int);
 	  errno = 0;
-	  ptrace (6, inferior_pid,
+	  ptrace (6, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) regaddr, read_register (regno));
 	  if (errno != 0)
 	    {
@@ -170,22 +170,22 @@ store_inferior_registers (int regno)
 	    }
 	}
       else if (regno == PSR_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) PSR_OFFSET, read_register (regno));
       else if (regno == FPSR_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) FPSR_OFFSET, read_register (regno));
       else if (regno == FPCR_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) FPCR_OFFSET, read_register (regno));
       else if (regno == SXIP_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (regno));
       else if (regno == SNIP_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (regno));
       else if (regno == SFIP_REGNUM)
-	ptrace (6, inferior_pid,
+	ptrace (6, PIDGET (inferior_ptid),
 		(PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (regno));
       else if (target_is_m88110 && regno < NUM_REGS)
 	{
@@ -194,10 +194,10 @@ store_inferior_registers (int regno)
 	  read_register_bytes (REGISTER_BYTE (regno), (char *) &xval,
 			       sizeof (X_REGISTER_RAW_TYPE));
 	  regaddr = XREGADDR (regno);
-	  ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
-	  ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 4, xval.w2);
-	  ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 8, xval.w3);
-	  ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr + 12, xval.w4);
+	  ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, xval.w1);
+	  ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 4, xval.w2);
+	  ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 8, xval.w3);
+	  ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr + 12, xval.w4);
 	}
       else
 	printf_unfiltered ("Bad register number for store_inferior routine\n");
@@ -209,7 +209,7 @@ store_inferior_registers (int regno)
 	  /*      regaddr = register_addr (regno, offset); */
 	  errno = 0;
 	  regaddr = offset + regno * sizeof (int);
-	  ptrace (6, inferior_pid,
+	  ptrace (6, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) regaddr, read_register (regno));
 	  if (errno != 0)
 	    {
@@ -217,17 +217,17 @@ store_inferior_registers (int regno)
 	      perror_with_name (buf);
 	    }
 	}
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) PSR_OFFSET, read_register (regno));
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) FPSR_OFFSET, read_register (regno));
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) FPCR_OFFSET, read_register (regno));
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) SXIP_OFFSET, read_register (SXIP_REGNUM));
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) SNIP_OFFSET, read_register (SNIP_REGNUM));
-      ptrace (6, inferior_pid,
+      ptrace (6, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) SFIP_OFFSET, read_register (SFIP_REGNUM));
       if (target_is_m88110)
 	{
@@ -238,10 +238,10 @@ store_inferior_registers (int regno)
 	      read_register_bytes (REGISTER_BYTE (regno), (char *) &xval,
 				   sizeof (X_REGISTER_RAW_TYPE));
 	      regaddr = XREGADDR (regno);
-	      ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, xval.w1);
-	      ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 4), xval.w2);
-	      ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 8), xval.w3);
-	      ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) (regaddr + 12), xval.w4);
+	      ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, xval.w1);
+	      ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 4), xval.w2);
+	      ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 8), xval.w3);
+	      ptrace (6, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (regaddr + 12), xval.w4);
 	    }
 	}
     }
@@ -361,7 +361,7 @@ add_shared_symbol_files (void)
   struct objfile *objfile;
   char *path_name;
 
-  if (!inferior_pid)
+  if (ptid_equal (inferior_ptid, null_ptid))
     {
       warning ("The program has not yet been started.");
       return;
Index: d10v-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/d10v-tdep.c,v
retrieving revision 1.17
diff -u -p -r1.17 d10v-tdep.c
--- d10v-tdep.c	2001/03/06 08:21:06	1.17
+++ d10v-tdep.c	2001/04/25 21:35:10
@@ -885,29 +885,29 @@ show_regs (char *args, int from_tty)
 }
 
 CORE_ADDR
-d10v_read_pc (int pid)
+d10v_read_pc (ptid_t ptid)
 {
-  int save_pid;
+  ptid_t save_ptid;
   CORE_ADDR pc;
   CORE_ADDR retval;
 
-  save_pid = inferior_pid;
-  inferior_pid = pid;
+  save_ptid = inferior_ptid;
+  inferior_ptid = ptid;
   pc = (int) read_register (PC_REGNUM);
-  inferior_pid = save_pid;
+  inferior_ptid = save_ptid;
   retval = D10V_MAKE_IADDR (pc);
   return retval;
 }
 
 void
-d10v_write_pc (CORE_ADDR val, int pid)
+d10v_write_pc (CORE_ADDR val, ptid_t ptid)
 {
-  int save_pid;
+  ptid_t save_ptid;
 
-  save_pid = inferior_pid;
-  inferior_pid = pid;
+  save_ptid = inferior_ptid;
+  inferior_ptid = ptid;
   write_register (PC_REGNUM, D10V_CONVERT_IADDR_TO_RAW (val));
-  inferior_pid = save_pid;
+  inferior_ptid = save_ptid;
 }
 
 CORE_ADDR
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.48
diff -u -p -r1.48 defs.h
--- defs.h	2001/03/23 23:39:57	1.48
+++ defs.h	2001/04/25 21:35:12
@@ -843,6 +843,27 @@ enum val_prettyprint
     /* Use the default setting which the user has specified.  */
     Val_pretty_default
   };
+
+/* A collection of the various "ids" necessary for identifying
+   the inferior.  This consists of the process id (pid), thread
+   id (tid), and other fields necessary for uniquely identifying
+   the inferior process/thread being debugged.  See inferior.h
+   for access methods. */
+
+struct ptid
+  {
+    /* Process id */
+    int pid;
+
+    /* Lightweight process id */
+    long lwp;
+
+    /* Thread id */
+    long tid;
+  };
+
+typedef struct ptid ptid_t;
+
 
 
 /* Optional host machine definition.  Pure autoconf targets will not
@@ -1302,7 +1323,8 @@ extern void (*readline_end_hook) (void);
 extern void (*register_changed_hook) (int regno);
 extern void (*memory_changed_hook) (CORE_ADDR addr, int len);
 extern void (*context_hook) (int);
-extern int (*target_wait_hook) (int pid, struct target_waitstatus * status);
+extern ptid_t (*target_wait_hook) (ptid_t ptid,
+                                         struct target_waitstatus * status);
 
 extern void (*attach_hook) (void);
 extern void (*detach_hook) (void);
@@ -1358,15 +1380,16 @@ extern int use_windows;
 #define ROOTED_P(X) (SLASH_P((X)[0]))
 #endif
 
-/* On some systems, PIDGET is defined to extract the inferior pid from
-   an internal pid that has the thread id and pid in seperate bit
-   fields.  If not defined, then just use the entire internal pid as
-   the actual pid. */
+/* Provide default definitions of PIDGET, TIDGET, and MERGEPID.
+   The name ``TIDGET'' is a historical accident.  Most uses of TIDGET
+   in the code actually refer to a lightweight process id, i.e,
+   something that can be considered a process id in its own right for
+   certain purposes.  */
 
 #ifndef PIDGET
-#define PIDGET(PID) (PID)
-#define TIDGET(PID) 0
-#define MERGEPID(PID, TID) (PID)
+#define PIDGET(PTID) (ptid_get_pid (PTID))
+#define TIDGET(PTID) (ptid_get_lwp (PTID))
+#define MERGEPID(PID, TID) ptid_build (PID, TID, 0)
 #endif
 
 /* Define well known filenos if the system does not define them.  */
Index: dink32-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/dink32-rom.c,v
retrieving revision 1.6
diff -u -p -r1.6 dink32-rom.c
--- dink32-rom.c	2001/03/06 08:21:06	1.6
+++ dink32-rom.c	2001/04/25 21:35:13
@@ -99,15 +99,13 @@ dink32_supply_register (char *regname, i
 static void
 dink32_load (struct monitor_ops *monops, char *filename, int from_tty)
 {
-  extern int inferior_pid;
-
   generic_load (filename, from_tty);
 
   /* Finally, make the PC point at the start address */
   if (exec_bfd)
     write_pc (bfd_get_start_address (exec_bfd));
 
-  inferior_pid = 0;		/* No process now */
+  inferior_ptid = null_ptid;		/* No process now */
 }
 
 
Index: dve3900-rom.c
===================================================================
RCS file: /cvs/src/src/gdb/dve3900-rom.c,v
retrieving revision 1.7
diff -u -p -r1.7 dve3900-rom.c
--- dve3900-rom.c	2001/03/06 08:21:07	1.7
+++ dve3900-rom.c	2001/04/25 21:35:14
@@ -927,7 +927,7 @@ r3900_load (char *filename, int from_tty
   if (exec_bfd)
     write_pc (bfd_get_start_address (exec_bfd));
 
-  inferior_pid = 0;		/* No process now */
+  inferior_ptid = null_ptid;		/* No process now */
 
   /* This is necessary because many things were based on the PC at the
      time that we attached to the monitor, which is no longer valid
Index: fork-child.c
===================================================================
RCS file: /cvs/src/src/gdb/fork-child.c,v
retrieving revision 1.12
diff -u -p -r1.12 fork-child.c
--- fork-child.c	2001/04/08 18:26:03	1.12
+++ fork-child.c	2001/04/25 21:35:14
@@ -89,7 +89,7 @@ breakup_args (char *scratch, char **argv
 }
 
 
-/* Start an inferior Unix child process and sets inferior_pid to its pid.
+/* Start an inferior Unix child process and sets inferior_ptid to its pid.
    EXEC_FILE is the file to run.
    ALLARGS is a string containing the arguments to the program.
    ENV is the environment vector to pass.  SHELL_FILE is the shell file,
@@ -355,7 +355,7 @@ fork_inferior (char *exec_file_arg, char
 
   init_thread_list ();
 
-  inferior_pid = pid;		/* Needed for wait_for_inferior stuff below */
+  inferior_ptid = pid_to_ptid (pid);	/* Needed for wait_for_inferior stuff below */
 
   /* Now that we have a child process, make it our target, and
      initialize anything target-vector-specific that needs initializing.  */
@@ -462,7 +462,7 @@ clone_and_follow_inferior (int child_pid
 	sleep (debug_fork);
 
       /* The child (i.e., the cloned debugger) must now attach to
-         CHILD_PID.  inferior_pid is presently set to the parent process
+         CHILD_PID.  inferior_ptid is presently set to the parent process
          of the fork, while CHILD_PID should be the child process of the
          fork.
 
@@ -471,10 +471,10 @@ clone_and_follow_inferior (int child_pid
        */
       read (handoff_semaphore[SEM_LISTEN], &listen_value, sizeof (listen_value));
 
-      /* Note that we DON'T want to actually detach from inferior_pid,
+      /* Note that we DON'T want to actually detach from inferior_ptid,
          because that would allow it to run free.  The original
          debugger wants to retain control of the process.  So, we
-         just reset inferior_pid to CHILD_PID, and then ensure that all
+         just reset inferior_ptid to CHILD_PID, and then ensure that all
          breakpoints are really set in CHILD_PID.
        */
       target_mourn_inferior ();
Index: frame.c
===================================================================
RCS file: /cvs/src/src/gdb/frame.c,v
retrieving revision 1.3
diff -u -p -r1.3 frame.c
--- frame.c	2001/03/06 08:21:07	1.3
+++ frame.c	2001/04/25 21:35:15
@@ -23,7 +23,7 @@
 #include "frame.h"
 #include "target.h"
 #include "value.h"
-#include "inferior.h"	/* for inferior_pid */
+#include "inferior.h"	/* for inferior_ptid */
 #include "regcache.h"
 
 /* FIND_SAVED_REGISTER ()
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.57
diff -u -p -r1.57 gdbarch.c
--- gdbarch.c	2001/04/06 17:53:39	1.57
+++ gdbarch.c	2001/04/25 21:35:18
@@ -849,15 +849,15 @@ gdbarch_dump (struct gdbarch *gdbarch, s
 #ifdef TARGET_READ_PC
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
-                      "TARGET_READ_PC(pid)",
-                      XSTRING (TARGET_READ_PC (pid)));
+                      "TARGET_READ_PC(ptid)",
+                      XSTRING (TARGET_READ_PC (ptid)));
 #endif
 #if defined (TARGET_WRITE_PC) && GDB_MULTI_ARCH
   /* Macro might contain `[{}]' when not multi-arch */
   fprintf_unfiltered (file,
                       "gdbarch_dump: %s # %s\n",
-                      "TARGET_WRITE_PC(val, pid)",
-                      XSTRING (TARGET_WRITE_PC (val, pid)));
+                      "TARGET_WRITE_PC(val, ptid)",
+                      XSTRING (TARGET_WRITE_PC (val, ptid)));
 #endif
 #ifdef TARGET_READ_FP
   fprintf_unfiltered (file,
@@ -2392,14 +2392,14 @@ set_gdbarch_ieee_float (struct gdbarch *
 }
 
 CORE_ADDR
-gdbarch_read_pc (struct gdbarch *gdbarch, int pid)
+gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid)
 {
   if (gdbarch->read_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_read_pc invalid");
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_read_pc called\n");
-  return gdbarch->read_pc (pid);
+  return gdbarch->read_pc (ptid);
 }
 
 void
@@ -2410,14 +2410,14 @@ set_gdbarch_read_pc (struct gdbarch *gdb
 }
 
 void
-gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, int pid)
+gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, ptid_t ptid)
 {
   if (gdbarch->write_pc == 0)
     internal_error (__FILE__, __LINE__,
                     "gdbarch: gdbarch_write_pc invalid");
   if (gdbarch_debug >= 2)
     fprintf_unfiltered (gdb_stdlog, "gdbarch_write_pc called\n");
-  gdbarch->write_pc (val, pid);
+  gdbarch->write_pc (val, ptid);
 }
 
 void
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.47
diff -u -p -r1.47 gdbarch.h
--- gdbarch.h	2001/04/06 17:53:39	1.47
+++ gdbarch.h	2001/04/25 21:35:20
@@ -257,29 +257,29 @@ extern void set_gdbarch_ieee_float (stru
 
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (TARGET_READ_PC)
-#define TARGET_READ_PC(pid) (generic_target_read_pc (pid))
+#define TARGET_READ_PC(ptid) (generic_target_read_pc (ptid))
 #endif
 
-typedef CORE_ADDR (gdbarch_read_pc_ftype) (int pid);
-extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, int pid);
+typedef CORE_ADDR (gdbarch_read_pc_ftype) (ptid_t ptid);
+extern CORE_ADDR gdbarch_read_pc (struct gdbarch *gdbarch, ptid_t ptid);
 extern void set_gdbarch_read_pc (struct gdbarch *gdbarch, gdbarch_read_pc_ftype *read_pc);
 #if GDB_MULTI_ARCH
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_READ_PC)
-#define TARGET_READ_PC(pid) (gdbarch_read_pc (current_gdbarch, pid))
+#define TARGET_READ_PC(ptid) (gdbarch_read_pc (current_gdbarch, ptid))
 #endif
 #endif
 
 /* Default (function) for non- multi-arch platforms. */
 #if (!GDB_MULTI_ARCH) && !defined (TARGET_WRITE_PC)
-#define TARGET_WRITE_PC(val, pid) (generic_target_write_pc (val, pid))
+#define TARGET_WRITE_PC(val, ptid) (generic_target_write_pc (val, ptid))
 #endif
 
-typedef void (gdbarch_write_pc_ftype) (CORE_ADDR val, int pid);
-extern void gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, int pid);
+typedef void (gdbarch_write_pc_ftype) (CORE_ADDR val, ptid_t ptid);
+extern void gdbarch_write_pc (struct gdbarch *gdbarch, CORE_ADDR val, ptid_t ptid);
 extern void set_gdbarch_write_pc (struct gdbarch *gdbarch, gdbarch_write_pc_ftype *write_pc);
 #if GDB_MULTI_ARCH
 #if (GDB_MULTI_ARCH > GDB_MULTI_ARCH_PARTIAL) || !defined (TARGET_WRITE_PC)
-#define TARGET_WRITE_PC(val, pid) (gdbarch_write_pc (current_gdbarch, val, pid))
+#define TARGET_WRITE_PC(val, ptid) (gdbarch_write_pc (current_gdbarch, val, ptid))
 #endif
 #endif
 
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.60
diff -u -p -r1.60 gdbarch.sh
--- gdbarch.sh	2001/04/06 17:53:39	1.60
+++ gdbarch.sh	2001/04/25 21:35:22
@@ -376,8 +376,8 @@ v::TARGET_BFD_VMA_BIT:int:bfd_vma_bit:::
 #
 v::IEEE_FLOAT:int:ieee_float::::0:0::0:::
 #
-f::TARGET_READ_PC:CORE_ADDR:read_pc:int pid:pid::0:generic_target_read_pc::0
-f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, int pid:val, pid::0:generic_target_write_pc::0
+f::TARGET_READ_PC:CORE_ADDR:read_pc:ptid_t ptid:ptid::0:generic_target_read_pc::0
+f::TARGET_WRITE_PC:void:write_pc:CORE_ADDR val, ptid_t ptid:val, ptid::0:generic_target_write_pc::0
 f::TARGET_READ_FP:CORE_ADDR:read_fp:void:::0:generic_target_read_fp::0
 f::TARGET_WRITE_FP:void:write_fp:CORE_ADDR val:val::0:generic_target_write_fp::0
 f::TARGET_READ_SP:CORE_ADDR:read_sp:void:::0:generic_target_read_sp::0
Index: gdbthread.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbthread.h,v
retrieving revision 1.2
diff -u -p -r1.2 gdbthread.h
--- gdbthread.h	2001/03/06 08:21:07	1.2
+++ gdbthread.h	2001/04/25 21:35:22
@@ -31,7 +31,7 @@
 struct thread_info
 {
   struct thread_info *next;
-  int pid;			/* "Actual process id";
+  ptid_t ptid;			/* "Actual process id";
 				    In fact, this may be overloaded with 
 				    kernel thread id, etc.  */
   int num;			/* Convenient handle (GDB thread id) */
@@ -73,29 +73,29 @@ extern void init_thread_list (void);
 /* Add a thread to the thread list.
    Note that add_thread now returns the handle of the new thread,
    so that the caller may initialize the private thread data.  */
-extern struct thread_info *add_thread (int pid);
+extern struct thread_info *add_thread (ptid_t ptid);
 
 /* Delete an existing thread list entry.  */
-extern void delete_thread (int);
+extern void delete_thread (ptid_t);
 
 /* Translate the integer thread id (GDB's homegrown id, not the system's)
    into a "pid" (which may be overloaded with extra thread information).  */
-extern int thread_id_to_pid (int);
+extern ptid_t thread_id_to_pid (int);
 
 /* Translate a 'pid' (which may be overloaded with extra thread information) 
    into the integer thread id (GDB's homegrown id, not the system's).  */
-extern int pid_to_thread_id (int pid);
+extern int pid_to_thread_id (ptid_t ptid);
 
 /* Boolean test for an already-known pid (which may be overloaded with
    extra thread information).  */
-extern int in_thread_list (int pid);
+extern int in_thread_list (ptid_t ptid);
 
 /* Boolean test for an already-known thread id (GDB's homegrown id, 
    not the system's).  */
 extern int valid_thread_id (int thread);
 
 /* Search function to lookup a thread by 'pid'.  */
-extern struct thread_info *find_thread_pid (int pid);
+extern struct thread_info *find_thread_pid (ptid_t ptid);
 
 /* Iterator function to call a user-provided callback function
    once for each known thread.  */
@@ -103,7 +103,7 @@ typedef int (*thread_callback_func) (str
 extern struct thread_info *iterate_over_threads (thread_callback_func, void *);
 
 /* infrun context switch: save the debugger state for the given thread.  */
-extern void save_infrun_state (int       pid,
+extern void save_infrun_state (ptid_t ptid,
 			       CORE_ADDR prev_pc,
 			       CORE_ADDR prev_func_start,
 			       char     *prev_func_name,
@@ -121,7 +121,7 @@ extern void save_infrun_state (int      
 
 /* infrun context switch: load the debugger state previously saved
    for the given thread.  */
-extern void load_infrun_state (int        pid,
+extern void load_infrun_state (ptid_t ptid,
 			       CORE_ADDR *prev_pc,
 			       CORE_ADDR *prev_func_start,
 			       char     **prev_func_name,
Index: gnu-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-nat.c,v
retrieving revision 1.14
diff -u -p -r1.14 gnu-nat.c
--- gnu-nat.c	2001/04/14 19:23:02	1.14
+++ gnu-nat.c	2001/04/25 21:35:26
@@ -1064,7 +1064,7 @@ inf_validate_procs (struct inf *inf)
 	    (last ? last->next : inf->threads) = thread;
 	    last = thread;
 	    proc_debug (thread, "new thread: %d", threads[i]);
-	    add_thread (thread->tid);	/* Tell GDB's generic thread code.  */
+	    add_thread (pid_to_ptid (thread->tid));	/* Tell GDB's generic thread code.  */
 	  }
       }
 
@@ -1408,8 +1408,8 @@ struct inf *current_inferior = 0;
 struct inf *waiting_inf;
 
 /* Wait for something to happen in the inferior, returning what in STATUS. */
-static int
-gnu_wait (int tid, struct target_waitstatus *status)
+static ptid_t
+gnu_wait (ptid_t tid, struct target_waitstatus *status)
 {
   struct msg
     {
@@ -1440,7 +1440,7 @@ gnu_wait (int tid, struct target_waitsta
 
   waiting_inf = inf;
 
-  inf_debug (inf, "waiting for: %d", tid);
+  inf_debug (inf, "waiting for: %d", PIDGET (tid));
 
 rewait:
   if (proc_wait_pid != inf->pid && !inf->no_wait)
@@ -1576,20 +1576,20 @@ rewait:
 
   thread = inf->wait.thread;
   if (thread)
-    tid = thread->tid;
+    tid = pid_to_ptid (thread->tid);
   else
-    thread = inf_tid_to_thread (inf, tid);
+    thread = inf_tid_to_thread (inf, PIDGET (tid));
 
   if (!thread || thread->port == MACH_PORT_NULL)
     {
       /* TID is dead; try and find a new thread.  */
       if (inf_update_procs (inf) && inf->threads)
-	tid = inf->threads->tid; /* The first available thread.  */
+	tid = pid_to_ptid (inf->threads->tid); /* The first available thread.  */
       else
-	tid = inferior_pid;	/* let wait_for_inferior handle exit case */
+	tid = inferior_ptid;	/* let wait_for_inferior handle exit case */
     }
 
-  if (thread && tid >= 0 && status->kind != TARGET_WAITKIND_SPURIOUS
+  if (thread && PIDGET (tid) >= 0 && status->kind != TARGET_WAITKIND_SPURIOUS
       && inf->pause_sc == 0 && thread->pause_sc == 0)
     /* If something actually happened to THREAD, make sure we
        suspend it.  */
@@ -1598,7 +1598,7 @@ rewait:
       inf_update_suspends (inf);
     }
 
-  inf_debug (inf, "returning tid = %d, status = %s (%d)", tid,
+  inf_debug (inf, "returning tid = %d, status = %s (%d)", PIDGET (tid),
 	     status->kind == TARGET_WAITKIND_EXITED ? "EXITED"
 	     : status->kind == TARGET_WAITKIND_STOPPED ? "STOPPED"
 	     : status->kind == TARGET_WAITKIND_SIGNALLED ? "SIGNALLED"
@@ -1925,12 +1925,12 @@ port_msgs_queued (mach_port_t port)
    in multiple events returned by wait).
  */
 static void
-gnu_resume (int tid, int step, enum target_signal sig)
+gnu_resume (ptid_t tid, int step, enum target_signal sig)
 {
   struct proc *step_thread = 0;
   struct inf *inf = current_inferior;
 
-  inf_debug (inf, "tid = %d, step = %d, sig = %d", tid, step, sig);
+  inf_debug (inf, "tid = %d, step = %d, sig = %d", PIDGET (tid), step, sig);
 
   inf_validate_procinfo (inf);
 
@@ -1958,17 +1958,17 @@ gnu_resume (int tid, int step, enum targ
 
   inf_update_procs (inf);
 
-  if (tid < 0)
+  if (PIDGET (tid) < 0)
     /* Allow all threads to run, except perhaps single-stepping one.  */
     {
-      inf_debug (inf, "running all threads; tid = %d", inferior_pid);
-      tid = inferior_pid;	/* What to step. */
+      inf_debug (inf, "running all threads; tid = %d", PIDGET (inferior_ptid));
+      tid = inferior_ptid;	/* What to step. */
       inf_set_threads_resume_sc (inf, 0, 1);
     }
   else
     /* Just allow a single thread to run.  */
     {
-      struct proc *thread = inf_tid_to_thread (inf, tid);
+      struct proc *thread = inf_tid_to_thread (inf, PIDGET (tid));
       if (!thread)
 	error ("Can't run single thread id %d: no such thread!");
       inf_debug (inf, "running one thread: %d/%d", inf->pid, thread->tid);
@@ -1977,9 +1977,9 @@ gnu_resume (int tid, int step, enum targ
 
   if (step)
     {
-      step_thread = inf_tid_to_thread (inf, tid);
+      step_thread = inf_tid_to_thread (inf, PIDGET (tid));
       if (!step_thread)
-	warning ("Can't step thread id %d: no such thread.", tid);
+	warning ("Can't step thread id %d: no such thread.", PIDGET (tid));
       else
 	inf_debug (inf, "stepping thread: %d/%d", inf->pid, step_thread->tid);
     }
@@ -2066,7 +2066,7 @@ gnu_create_inferior (char *exec_file, ch
     /* Now let the child run again, knowing that it will stop immediately
        because of the ptrace. */
     inf_resume (inf);
-    inferior_pid = inf_pick_first_thread ();
+    inferior_ptid = pid_to_ptid (inf_pick_first_thread ());
 
     startup_inferior (inf->pending_execs);
   }
@@ -2137,7 +2137,7 @@ gnu_attach (char *args, int from_tty)
   inf_attach (inf, pid);
   inf_update_procs (inf);
 
-  inferior_pid = inf_pick_first_thread ();
+  inferior_ptid = pid_to_ptid (inf_pick_first_thread ());
 
   attach_flag = 1;
   push_target (&gnu_ops);
@@ -2182,7 +2182,7 @@ gnu_detach (char *args, int from_tty)
 
   inf_detach (current_inferior);
 
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
 
   unpush_target (&gnu_ops);	/* Pop out of handling an inferior */
 }
@@ -2230,10 +2230,10 @@ gnu_pid_to_exec_file (void)
 
 
 static int
-gnu_thread_alive (int tid)
+gnu_thread_alive (ptid_t tid)
 {
   inf_update_procs (current_inferior);
-  return !!inf_tid_to_thread (current_inferior, tid);
+  return !!inf_tid_to_thread (current_inferior, PIDGET (tid));
 }
 
 
@@ -2481,9 +2481,10 @@ proc_string (struct proc *proc)
 }
 
 static char *
-gnu_pid_to_str (int tid)
+gnu_pid_to_str (ptid_t ptid)
 {
   struct inf *inf = current_inferior;
+  int tid = PIDGET (ptid);
   struct proc *thread = inf_tid_to_thread (inf, tid);
 
   if (thread)
@@ -2653,7 +2654,7 @@ static struct proc *
 cur_thread (void)
 {
   struct inf *inf = cur_inf ();
-  struct proc *thread = inf_tid_to_thread (inf, inferior_pid);
+  struct proc *thread = inf_tid_to_thread (inf, PIDGET (inferior_ptid));
   if (!thread)
     error ("No current thread.");
   return thread;
Index: go32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/go32-nat.c,v
retrieving revision 1.13
diff -u -p -r1.13 go32-nat.c
--- go32-nat.c	2001/04/01 14:01:52	1.13
+++ go32-nat.c	2001/04/25 21:35:27
@@ -164,8 +164,10 @@ static void go32_open (char *name, int f
 static void go32_close (int quitting);
 static void go32_attach (char *args, int from_tty);
 static void go32_detach (char *args, int from_tty);
-static void go32_resume (int pid, int step, enum target_signal siggnal);
-static int go32_wait (int pid, struct target_waitstatus *status);
+static void go32_resume (ptid_t ptid, int step,
+                         enum target_signal siggnal);
+static ptid_t go32_wait (ptid_t ptid,
+                               struct target_waitstatus *status);
 static void go32_fetch_registers (int regno);
 static void store_register (int regno);
 static void go32_store_registers (int regno);
@@ -315,7 +317,7 @@ static int resume_is_step;
 static int resume_signal = -1;
 
 static void
-go32_resume (int pid, int step, enum target_signal siggnal)
+go32_resume (ptid_t ptid, int step, enum target_signal siggnal)
 {
   int i;
 
@@ -339,7 +341,7 @@ go32_resume (int pid, int step, enum tar
 static char child_cwd[FILENAME_MAX];
 
 static int
-go32_wait (int pid, struct target_waitstatus *status)
+go32_wait (ptid_t ptid, struct target_waitstatus *status)
 {
   int i;
   unsigned char saved_opcode;
@@ -558,7 +560,7 @@ go32_stop (void)
 {
   normal_stop ();
   cleanup_client ();
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
   prog_has_started = 0;
 }
 
@@ -632,7 +634,7 @@ go32_create_inferior (char *exec_file, c
   save_npx ();
 #endif
 
-  inferior_pid = SOME_PID;
+  inferior_ptid = pid_to_ptid (SOME_PID);
   push_target (&go32_ops);
   clear_proceed_status ();
   insert_breakpoints ();
Index: h8500-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/h8500-tdep.c,v
retrieving revision 1.7
diff -u -p -r1.7 h8500-tdep.c
--- h8500-tdep.c	2001/03/06 08:21:08	1.7
+++ h8500-tdep.c	2001/04/25 21:35:27
@@ -586,13 +586,13 @@ h8500_write_sp (CORE_ADDR v)
 }
 
 CORE_ADDR
-h8500_read_pc (int pid)
+h8500_read_pc (ptid_t ptid)
 {
   return read_register (PC_REGNUM);
 }
 
 void
-h8500_write_pc (CORE_ADDR v, int pid)
+h8500_write_pc (CORE_ADDR v, ptid_t ptid)
 {
   write_register (PC_REGNUM, v);
 }
Index: hp300ux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hp300ux-nat.c,v
retrieving revision 1.5
diff -u -p -r1.5 hp300ux-nat.c
--- hp300ux-nat.c	2001/03/06 08:21:08	1.5
+++ hp300ux-nat.c	2001/04/25 21:35:28
@@ -74,8 +74,8 @@ _initialize_hp300ux_nat (void)
 
 #define INFERIOR_AR0(u)							\
   ((ptrace								\
-    (PT_RUAREA, inferior_pid,						\
-     (PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0))		\
+    (PT_RUAREA, PIDGET (inferior_ptid),					\
+     (PTRACE_ARG3_TYPE) ((char *) &u.u_ar0 - (char *) &u), 0, 0))	\
    - kernel_u_addr)
 
 static void
@@ -92,8 +92,8 @@ fetch_inferior_register (register int re
       ps_val;
       int regval;
 
-      ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
-			  0, 0));
+      ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
+                          (PTRACE_ARG3_TYPE) regaddr, 0, 0));
       regval = ps_val.s[0];
       supply_register (regno, (char *) &regval);
     }
@@ -105,7 +105,7 @@ fetch_inferior_register (register int re
 
       for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
 	{
-	  *(int *) &buf[i] = ptrace (PT_RUAREA, inferior_pid,
+	  *(int *) &buf[i] = ptrace (PT_RUAREA, PIDGET (inferior_ptid),
 				     (PTRACE_ARG3_TYPE) regaddr, 0, 0);
 	  regaddr += sizeof (int);
 	}
@@ -118,7 +118,8 @@ static void
 store_inferior_register_1 (int regno, unsigned int regaddr, int val)
 {
   errno = 0;
-  ptrace (PT_WUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, val, 0);
+  ptrace (PT_WUAREA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
+          val, 0);
 #if 0
   /* HP-UX randomly sets errno to non-zero for regno == 25.
      However, the value is correctly written, so ignore errno. */
@@ -146,8 +147,8 @@ store_inferior_register (register int re
 	}
       ps_val;
 
-      ps_val.i = (ptrace (PT_RUAREA, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
-			  0, 0));
+      ps_val.i = (ptrace (PT_RUAREA, PIDGET (inferior_ptid),
+                          (PTRACE_ARG3_TYPE) regaddr, 0, 0));
       ps_val.s[0] = (read_register (regno));
       store_inferior_register_1 (regno, regaddr, ps_val.i);
     }
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.12
diff -u -p -r1.12 hppa-tdep.c
--- hppa-tdep.c	2001/04/06 17:53:39	1.12
+++ hppa-tdep.c	2001/04/25 21:35:34
@@ -1397,7 +1397,7 @@ push_dummy_frame (struct inferior_status
      We also need a number of horrid hacks to deal with lossage in the
      PC queue registers (apparently they're not valid when the in syscall
      bit is set).  */
-  pc = target_read_pc (inferior_pid);
+  pc = target_read_pc (inferior_ptid);
   int_buffer = read_register (FLAGS_REGNUM);
   if (int_buffer & 0x2)
     {
@@ -1631,7 +1631,7 @@ restore_pc_queue (struct frame_saved_reg
          any other choice?  Is there *any* way to do this stuff with
          ptrace() or some equivalent?).  */
       resume (1, 0);
-      target_wait (inferior_pid, &w);
+      target_wait (inferior_ptid, &w);
 
       if (w.kind == TARGET_WAITKIND_SIGNALLED)
 	{
@@ -2076,9 +2076,9 @@ hppa_fix_call_dummy (char *dummy, CORE_A
 	   such that it points to the PC value written immediately above
 	   (ie the call dummy).  */
         resume (1, 0);
-        target_wait (inferior_pid, &w);
+        target_wait (inferior_ptid, &w);
         resume (1, 0);
-        target_wait (inferior_pid, &w);
+        target_wait (inferior_ptid, &w);
 
 	/* Restore the two instructions at the old PC locations.  */
         *((int *) buf) = inst1;
@@ -2162,7 +2162,7 @@ hppa_fix_call_dummy (char *dummy, CORE_A
          stub rather than the export stub or real function for lazy binding
          to work correctly
 
-         /* If we are using the gcc PLT call routine, then we need to
+         If we are using the gcc PLT call routine, then we need to
          get the import stub for the target function.  */
       if (using_gcc_plt_call && som_solib_get_got_by_pc (fun))
 	{
@@ -2370,7 +2370,7 @@ hppa_fix_call_dummy (char *dummy, CORE_A
   if (flags & 2)
     return pc;
 #ifndef GDB_TARGET_IS_PA_ELF
-  else if (som_solib_get_got_by_pc (target_read_pc (inferior_pid)))
+  else if (som_solib_get_got_by_pc (target_read_pc (inferior_ptid)))
     return pc;
 #endif
   else
@@ -2404,26 +2404,26 @@ target_read_fp (int pid)
    bits.  */
 
 CORE_ADDR
-target_read_pc (int pid)
+target_read_pc (ptid_t ptid)
 {
-  int flags = read_register_pid (FLAGS_REGNUM, pid);
+  int flags = read_register_pid (FLAGS_REGNUM, ptid);
 
   /* The following test does not belong here.  It is OS-specific, and belongs
      in native code.  */
   /* Test SS_INSYSCALL */
   if (flags & 2)
-    return read_register_pid (31, pid) & ~0x3;
+    return read_register_pid (31, ptid) & ~0x3;
 
-  return read_register_pid (PC_REGNUM, pid) & ~0x3;
+  return read_register_pid (PC_REGNUM, ptid) & ~0x3;
 }
 
 /* Write out the PC.  If currently in a syscall, then also write the new
    PC value into %r31.  */
 
 void
-target_write_pc (CORE_ADDR v, int pid)
+target_write_pc (CORE_ADDR v, ptid_t ptid)
 {
-  int flags = read_register_pid (FLAGS_REGNUM, pid);
+  int flags = read_register_pid (FLAGS_REGNUM, ptid);
 
   /* The following test does not belong here.  It is OS-specific, and belongs
      in native code.  */
@@ -2431,10 +2431,10 @@ target_write_pc (CORE_ADDR v, int pid)
      privilege bits set correctly.  */
   /* Test SS_INSYSCALL */
   if (flags & 2)
-    write_register_pid (31, v | 0x3, pid);
+    write_register_pid (31, v | 0x3, ptid);
 
-  write_register_pid (PC_REGNUM, v, pid);
-  write_register_pid (NPC_REGNUM, v + 4, pid);
+  write_register_pid (PC_REGNUM, v, ptid);
+  write_register_pid (NPC_REGNUM, v + 4, ptid);
 }
 
 /* return the alignment of a type in bytes. Structures have the maximum
@@ -2645,7 +2645,7 @@ pa_register_look_aside (char *raw_regs, 
   for (i = start; i < 2; i++)
     {
       errno = 0;
-      raw_val[i] = call_ptrace (PT_RUREGS, inferior_pid,
+      raw_val[i] = call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
 				(PTRACE_ARG3_TYPE) regaddr, 0);
       if (errno != 0)
 	{
@@ -4026,7 +4026,7 @@ hppa_frame_find_saved_regs (struct frame
 	    }
 	}
 
-      /* Quit if we hit any kind of branch the previous iteration.
+      /* Quit if we hit any kind of branch the previous iteration. */
       if (final_iteration)
 	break;
 
@@ -4108,7 +4108,7 @@ setup_d_pid_in_inferior (void)
     }
 
   anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
-  store_unsigned_integer (buf, 4, inferior_pid);	/* FIXME 32x64? */
+  store_unsigned_integer (buf, 4, PIDGET (inferior_ptid)); /* FIXME 32x64? */
   if (target_write_memory (anaddr, buf, 4))	/* FIXME 32x64? */
     {
       warning ("Unable to write __d_pid");
@@ -4378,7 +4378,7 @@ child_enable_exception_callback (enum ex
   if (enable)
     {
       /* Ensure that __d_pid is set up correctly -- end.c code checks this. :-( */
-      if (inferior_pid > 0)
+      if (PIDGET (inferior_ptid) > 0)
 	{
 	  if (setup_d_pid_in_inferior ())
 	    return (struct symtab_and_line *) -1;
@@ -4601,7 +4601,7 @@ hppa_prepare_to_proceed (void)
   pid_t old_thread;
   pid_t current_thread;
 
-  old_thread = hppa_switched_threads (inferior_pid);
+  old_thread = hppa_switched_threads (PIDGET (inferior_ptid));
   if (old_thread != 0)
     {
       /* Switched over from "old_thread".  Try to do
@@ -4612,8 +4612,8 @@ hppa_prepare_to_proceed (void)
 
       /* Yuk, shouldn't use global to specify current
          thread.  But that's how gdb does it. */
-      current_thread = inferior_pid;
-      inferior_pid = old_thread;
+      current_thread = PIDGET (inferior_ptid);
+      inferior_ptid = pid_to_ptid (old_thread);
 
       new_pc = read_pc ();
       if (new_pc != old_pc	/* If at same pc, no need */
@@ -4625,14 +4625,14 @@ hppa_prepare_to_proceed (void)
 	  registers_changed ();
 #if 0
 	  printf ("---> PREPARE_TO_PROCEED (was %d, now %d)!\n",
-		  current_thread, inferior_pid);
+		  current_thread, PIDGET (inferior_ptid));
 #endif
 
 	  return 1;
 	}
 
       /* Otherwise switch back to the user-chosen thread. */
-      inferior_pid = current_thread;
+      inferior_ptid = pid_to_ptid (current_thread);
       new_pc = read_pc ();	/* Re-prime register cache */
     }
 
Index: hppab-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppab-nat.c,v
retrieving revision 1.5
diff -u -p -r1.5 hppab-nat.c
--- hppab-nat.c	2001/03/06 08:21:08	1.5
+++ hppab-nat.c	2001/04/25 21:35:34
@@ -44,7 +44,7 @@
 /* U_REGS_OFFSET is the offset of the registers within the u area.  */
 #if !defined (U_REGS_OFFSET)
 #define U_REGS_OFFSET \
-  ptrace (PT_READ_U, inferior_pid, \
+  ptrace (PT_READ_U, PIDGET (inferior_ptid), \
           (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
     - KERNEL_U_ADDR
 #endif
@@ -67,7 +67,7 @@ fetch_register (int regno)
   for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
     {
       errno = 0;
-      *(int *) &buf[i] = ptrace (PT_RUREGS, inferior_pid,
+      *(int *) &buf[i] = ptrace (PT_RUREGS, PIDGET (inferior_ptid),
 				 (PTRACE_ARG3_TYPE) regaddr, 0);
       regaddr += sizeof (int);
       if (errno != 0)
@@ -119,7 +119,7 @@ store_inferior_registers (int regno)
       if (regno == PCOQ_HEAD_REGNUM || regno == PCOQ_TAIL_REGNUM)
 	{
 	  scratch = *(int *) &registers[REGISTER_BYTE (regno)] | 0x3;
-	  ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+	  ptrace (PT_WUREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr,
 		  scratch);
 	  if (errno != 0)
 	    {
@@ -133,7 +133,8 @@ store_inferior_registers (int regno)
 	for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int))
 	  {
 	    errno = 0;
-	    ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) regaddr,
+	    ptrace (PT_WUREGS, PIDGET (inferior_ptid),
+	            (PTRACE_ARG3_TYPE) regaddr,
 		    *(int *) &registers[REGISTER_BYTE (regno) + i]);
 	    if (errno != 0)
 	      {
@@ -209,5 +210,5 @@ hppa_set_watchpoint (int addr, int len, 
   pt_args[1] <<= 12;
 
   /* Do it.  */
-  return ptrace (PT_PROT, inferior_pid, (PTRACE_ARG3_TYPE) pt_args, 0);
+  return ptrace (PT_PROT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) pt_args, 0);
 }
Index: hppah-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/hppah-nat.c,v
retrieving revision 1.10
diff -u -p -r1.10 hppah-nat.c
--- hppah-nat.c	2001/03/06 08:21:08	1.10
+++ hppah-nat.c	2001/04/25 21:35:35
@@ -126,7 +126,8 @@ store_inferior_registers (int regno)
 	  /* Set the priv level (stored in the low two bits of the PC.  */
 	  temp |= 0x3;
 
-	  ttrace_write_reg_64 (inferior_pid, (CORE_ADDR)addr, (CORE_ADDR)&temp);
+	  ttrace_write_reg_64 (PIDGET (inferior_ptid), (CORE_ADDR)addr,
+	                       (CORE_ADDR)&temp);
 
 	  /* If we fail to write the PC, give a true error instead of
 	     just a warning.  */
@@ -151,7 +152,8 @@ store_inferior_registers (int regno)
       for (i = 0; i < len; i += sizeof (int))
 	{
 	  errno = 0;
-	  call_ptrace (PT_WUREGS, inferior_pid, (PTRACE_ARG3_TYPE) addr + i,
+	  call_ptrace (PT_WUREGS, PIDGET (inferior_ptid),
+	               (PTRACE_ARG3_TYPE) addr + i,
 		       *(int *) &registers[REGISTER_BYTE (regno) + i]);
 	  if (errno != 0)
 	    {
@@ -234,7 +236,7 @@ fetch_register (int regno)
       /* Copy an int from the U area to buf.  Fill the least
          significant end if len != raw_size.  */
       * (int *) &buf[offset + i] =
-	  call_ptrace (PT_RUREGS, inferior_pid,
+	  call_ptrace (PT_RUREGS, PIDGET (inferior_ptid),
 		       (PTRACE_ARG3_TYPE) addr + i, 0);
       if (errno != 0)
 	{
@@ -297,14 +299,15 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	{
 	  /* Need part of initial word -- fetch it.  */
 	  buffer[0] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-				   inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+				   PIDGET (inferior_ptid),
+				   (PTRACE_ARG3_TYPE) addr, 0);
 	}
 
       if (count > 1)		/* FIXME, avoid if even boundary */
 	{
 	  buffer[count - 1]
 	    = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-			   inferior_pid,
+			   PIDGET (inferior_ptid),
 			   (PTRACE_ARG3_TYPE) (addr
 					       + (count - 1) * sizeof (int)),
 			   0);
@@ -326,7 +329,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	  errno = 0;
 	  pt_request = (addr < text_end) ? PT_WIUSER : PT_WDUSER;
 	  pt_status = call_ptrace (pt_request,
-				   inferior_pid,
+				   PIDGET (inferior_ptid),
 				   (PTRACE_ARG3_TYPE) addr,
 				   buffer[i]);
 
@@ -338,7 +341,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	      errno = 0;
 	      pt_request = (pt_request == PT_WIUSER) ? PT_WDUSER : PT_WIUSER;
 	      pt_status = call_ptrace (pt_request,
-				       inferior_pid,
+				       PIDGET (inferior_ptid),
 				       (PTRACE_ARG3_TYPE) addr,
 				       buffer[i]);
 
@@ -358,7 +361,8 @@ child_xfer_memory (CORE_ADDR memaddr, ch
 	{
 	  errno = 0;
 	  buffer[i] = call_ptrace (addr < text_end ? PT_RIUSER : PT_RDUSER,
-				   inferior_pid, (PTRACE_ARG3_TYPE) addr, 0);
+				   PIDGET (inferior_ptid),
+				   (PTRACE_ARG3_TYPE) addr, 0);
 	  if (errno)
 	    {
 	      xfree (buffer);
@@ -389,7 +393,7 @@ child_post_follow_inferior_by_clone (voi
      At this point, the clone has attached to the child.  Because of
      the SIGSTOP, we must now deliver a SIGCONT to the child, or it
      won't behave properly. */
-  status = kill (inferior_pid, SIGCONT);
+  status = kill (PIDGET (inferior_ptid), SIGCONT);
 }
 
 
@@ -433,10 +437,11 @@ child_post_follow_vfork (int parent_pid,
 /* Format a process id, given PID.  Be sure to terminate
    this with a null--it's going to be printed via a "%s".  */
 char *
-child_pid_to_str (pid_t pid)
+child_pid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
+  pid_t pid = PIDGET (ptid);
 
   /* Extra NULLs for paranoia's sake */
   sprintf (buf, "process %d\0\0\0\0", pid);
@@ -450,10 +455,13 @@ child_pid_to_str (pid_t pid)
    Note: This is a core-gdb tid, not the actual system tid.
    See infttrace.c for details.  */
 char *
-hppa_tid_to_str (pid_t tid)
+hppa_tid_to_str (ptid_t ptid)
 {
   /* Static because address returned */
   static char buf[30];
+  /* This seems strange, but when I did the ptid conversion, it looked
+     as though a pid was always being passed.  - Kevin Buettner  */
+  pid_t tid = PIDGET (ptid);
 
   /* Extra NULLs for paranoia's sake */
   sprintf (buf, "system thread %d\0\0\0\0", tid);
@@ -626,7 +634,7 @@ hppa_range_profitable_for_hw_watchpoint 
 }
 
 char *
-hppa_pid_or_tid_to_str (pid_t id)
+hppa_pid_or_tid_to_str (ptid_t id)
 {
   /* In the ptrace world, there are only processes. */
   return child_pid_to_str (id);
@@ -814,9 +822,9 @@ child_acknowledge_created_inferior (int 
 }
 
 void
-child_post_startup_inferior (int pid)
+child_post_startup_inferior (ptid_t ptid)
 {
-  require_notification_of_events (pid);
+  require_notification_of_events (PIDGET (ptid));
 }
 
 void
@@ -1040,7 +1048,7 @@ child_pid_to_exec_file (int pid)
   char four_chars[4];
   int name_index;
   int i;
-  int saved_inferior_pid;
+  ptid_t saved_inferior_ptid;
   boolean done;
 
 #ifdef PT_GET_PROCESS_PATHNAME
@@ -1062,19 +1070,19 @@ child_pid_to_exec_file (int pid)
   name_index = 0;
   done = 0;
 
-  /* On the chance that pid != inferior_pid, set inferior_pid
-     to pid, so that (grrrr!) implicit uses of inferior_pid get
+  /* On the chance that pid != inferior_ptid, set inferior_ptid
+     to pid, so that (grrrr!) implicit uses of inferior_ptid get
      the right id.  */
 
-  saved_inferior_pid = inferior_pid;
-  inferior_pid = pid;
+  saved_inferior_ptid = inferior_ptid;
+  inferior_ptid = pid_to_ptid (pid);
 
   /* Try to grab a null-terminated string. */
   while (!done)
     {
       if (target_read_memory (top_of_stack, four_chars, 4) != 0)
 	{
-	  inferior_pid = saved_inferior_pid;
+	  inferior_ptid = saved_inferior_ptid;
 	  return NULL;
 	}
       for (i = 0; i < 4; i++)
@@ -1089,11 +1097,11 @@ child_pid_to_exec_file (int pid)
 
   if (exec_file_buffer[0] == '\0')
     {
-      inferior_pid = saved_inferior_pid;
+      inferior_ptid = saved_inferior_ptid;
       return NULL;
     }
 
-  inferior_pid = saved_inferior_pid;
+  inferior_ptid = saved_inferior_ptid;
   return exec_file_buffer;
 }
 
@@ -1124,7 +1132,7 @@ pre_fork_inferior (void)
    return "TRUE".  */
 
 int
-child_thread_alive (int pid)
+child_thread_alive (ptid_t ptid)
 {
   return 1;
 }
Index: hpux-thread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpux-thread.c,v
retrieving revision 1.8
diff -u -p -r1.8 hpux-thread.c
--- hpux-thread.c	2001/03/06 08:21:08	1.8
+++ hpux-thread.c	2001/04/25 21:35:36
@@ -57,61 +57,18 @@ struct string_map
 
 static int hpux_thread_active = 0;
 
-static int main_pid;		/* Real process ID */
+static ptid_t main_ptid;		/* Real process ID */
 
 static CORE_ADDR P_cma__g_known_threads;
 static CORE_ADDR P_cma__g_current_thread;
 
-static struct cleanup *save_inferior_pid (void);
+static void hpux_thread_resume (ptid_t ptid, int step,
+                                enum target_signal signo);
 
-static void restore_inferior_pid (int pid);
-
-static void hpux_thread_resume (int pid, int step, enum target_signal signo);
-
 static void init_hpux_thread_ops (void);
 
 static struct target_ops hpux_thread_ops;
 
-/*
-
-   LOCAL FUNCTION
-
-   save_inferior_pid - Save inferior_pid on the cleanup list
-   restore_inferior_pid - Restore inferior_pid from the cleanup list
-
-   SYNOPSIS
-
-   struct cleanup *save_inferior_pid ()
-   void restore_inferior_pid (int pid)
-
-   DESCRIPTION
-
-   These two functions act in unison to restore inferior_pid in
-   case of an error.
-
-   NOTES
-
-   inferior_pid is a global variable that needs to be changed by many of
-   these routines before calling functions in procfs.c.  In order to
-   guarantee that inferior_pid gets restored (in case of errors), you
-   need to call save_inferior_pid before changing it.  At the end of the
-   function, you should invoke do_cleanups to restore it.
-
- */
-
-
-static struct cleanup *
-save_inferior_pid (void)
-{
-  return make_cleanup (restore_inferior_pid, inferior_pid);
-}
-
-static void
-restore_inferior_pid (int pid)
-{
-  inferior_pid = pid;
-}
-
 static int find_active_thread (void);
 
 static int cached_thread;
@@ -133,7 +90,8 @@ find_active_thread (void)
 
   read_memory (tcb_ptr, (char *) &tcb, sizeof tcb);
 
-  return (cma_thread_get_unique (&tcb.prolog.client_thread) << 16) | main_pid;
+  return (cma_thread_get_unique (&tcb.prolog.client_thread) << 16) 
+         | PIDGET (main_ptid);
 }
 
 static cma__t_int_tcb *find_tcb (int thread);
@@ -214,13 +172,14 @@ hpux_thread_detach (char *args, int from
    for procfs.  */
 
 static void
-hpux_thread_resume (int pid, int step, enum target_signal signo)
+hpux_thread_resume (ptid_t ptid, int step, enum target_signal signo)
 {
   struct cleanup *old_chain;
 
-  old_chain = save_inferior_pid ();
+  old_chain = save_inferior_ptid ();
 
-  pid = inferior_pid = main_pid;
+  ptid = main_ptid;
+  inferior_ptid = main_ptid;
 
 #if 0
   if (pid != -1)
@@ -231,7 +190,7 @@ hpux_thread_resume (int pid, int step, e
     }
 #endif
 
-  child_ops.to_resume (pid, step, signo);
+  child_ops.to_resume (ptid, step, signo);
 
   cached_thread = 0;
   cached_active_thread = 0;
@@ -242,20 +201,20 @@ hpux_thread_resume (int pid, int step, e
 /* Wait for any threads to stop.  We may have to convert PID from a thread id
    to a LWP id, and vice versa on the way out.  */
 
-static int
-hpux_thread_wait (int pid, struct target_waitstatus *ourstatus)
+static ptid_t
+hpux_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
 {
-  int rtnval;
+  ptid_t rtnval;
   struct cleanup *old_chain;
 
-  old_chain = save_inferior_pid ();
+  old_chain = save_inferior_ptid ();
 
-  inferior_pid = main_pid;
+  inferior_ptid = main_ptid;
 
-  if (pid != -1)
-    pid = main_pid;
+  if (!ptid_equal (ptid, minus_one_ptid))
+    ptid = main_ptid;
 
-  rtnval = child_ops.to_wait (pid, ourstatus);
+  rtnval = child_ops.to_wait (ptid, ourstatus);
 
   rtnval = find_active_thread ();
 
@@ -298,11 +257,11 @@ hpux_thread_fetch_registers (int regno)
   int i;
   int first_regno, last_regno;
 
-  tcb_ptr = find_tcb (inferior_pid);
+  tcb_ptr = find_tcb (PIDGET (inferior_ptid));
 
-  old_chain = save_inferior_pid ();
+  old_chain = save_inferior_ptid ();
 
-  inferior_pid = main_pid;
+  inferior_ptid = main_ptid;
 
   if (tcb_ptr->state == cma__c_state_running)
     {
@@ -360,11 +319,11 @@ hpux_thread_store_registers (int regno)
   int i;
   int first_regno, last_regno;
 
-  tcb_ptr = find_tcb (inferior_pid);
+  tcb_ptr = find_tcb (PIDGET (inferior_ptid));
 
-  old_chain = save_inferior_pid ();
+  old_chain = save_inferior_ptid ();
 
-  inferior_pid = main_pid;
+  inferior_ptid = main_ptid;
 
   if (tcb_ptr->state == cma__c_state_running)
     {
@@ -441,9 +400,9 @@ hpux_thread_xfer_memory (CORE_ADDR memad
   int retval;
   struct cleanup *old_chain;
 
-  old_chain = save_inferior_pid ();
+  old_chain = save_inferior_ptid ();
 
-  inferior_pid = main_pid;
+  inferior_ptid = main_ptid;
 
   retval = 
     child_ops.to_xfer_memory (memaddr, myaddr, len, dowrite, attribs, target);
@@ -468,9 +427,9 @@ hpux_thread_kill_inferior (void)
 }
 
 static void
-hpux_thread_notice_signals (int pid)
+hpux_thread_notice_signals (ptid_t ptid)
 {
-  child_ops.to_notice_signals (pid);
+  child_ops.to_notice_signals (ptid);
 }
 
 /* Fork an inferior process, and start debugging it with /proc.  */
@@ -482,13 +441,13 @@ hpux_thread_create_inferior (char *exec_
 
   if (hpux_thread_active)
     {
-      main_pid = inferior_pid;
+      main_ptid = inferior_ptid;
 
       push_target (&hpux_thread_ops);
 
-      inferior_pid = find_active_thread ();
+      inferior_ptid = find_active_thread ();
 
-      add_thread (inferior_pid);
+      add_thread (inferior_ptid);
     }
 }
 
@@ -554,7 +513,7 @@ hpux_thread_can_run (void)
 }
 
 static int
-hpux_thread_alive (int pid)
+hpux_thread_alive (ptid_t ptid)
 {
   return 1;
 }
@@ -568,9 +527,10 @@ hpux_thread_stop (void)
 /* Convert a pid to printable form. */
 
 char *
-hpux_pid_to_str (int pid)
+hpux_pid_to_str (ptid_t ptid)
 {
   static char buf[100];
+  int pid = PIDGET (ptid);
 
   sprintf (buf, "Thread %d", pid >> 16);
 
Index: i386-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-linux-nat.c,v
retrieving revision 1.26
diff -u -p -r1.26 i386-linux-nat.c
--- i386-linux-nat.c	2001/04/01 10:48:48	1.26
+++ i386-linux-nat.c	2001/04/25 21:35:37
@@ -61,17 +61,6 @@
 /* Prototypes for local functions.  */
 static void dummy_sse_values (void);
 
-/* On Linux, threads are implemented as pseudo-processes, in which
-   case we may be tracing more than one process at a time.  In that
-   case, inferior_pid will contain the main process ID and the
-   individual thread (process) ID mashed together.  These macros are
-   used to separate them out.  These definitions should be overridden
-   if thread support is included.  */
-
-#if !defined (PIDGET)	/* Default definition for PIDGET/TIDGET.  */
-#define PIDGET(PID)	PID
-#define TIDGET(PID)	0
-#endif
 
 
 /* The register sets used in Linux ELF core-dumps are identical to the
@@ -198,8 +187,8 @@ fetch_register (int regno)
     }
 
   /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* no thread id, just use process id */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);	/* no thread id, just use process id */
 
   offset = U_REGS_OFFSET;
 
@@ -261,8 +250,8 @@ store_register (int regno)
     }
 
   /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* no thread id, just use process id */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);	/* no thread id, just use process id */
 
   offset = U_REGS_OFFSET;
 
@@ -597,8 +586,8 @@ fetch_inferior_registers (int regno)
     }
 
   /* Linux LWP ID's are process ID's.  */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* Not a threaded program.  */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);		/* Not a threaded program.  */
 
   /* Use the PTRACE_GETFPXREGS request whenever possible, since it
      transfers more registers in one system call, and we'll cache the
@@ -663,8 +652,8 @@ store_inferior_registers (int regno)
     }
 
   /* Linux LWP ID's are process ID's.  */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* Not a threaded program.  */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);	/* Not a threaded program.  */
 
   /* Use the PTRACE_SETFPXREGS requests whenever possible, since it
      transfers more registers in one system call.  But remember that
@@ -710,7 +699,7 @@ i386_linux_dr_get (int regnum)
   /* FIXME: kettenis/2001-01-29: It's not clear what we should do with
      multi-threaded processes here.  For now, pretend there is just
      one thread.  */
-  tid = PIDGET (inferior_pid);
+  tid = PIDGET (inferior_ptid);
 
   /* FIXME: kettenis/2001-03-27: Calling perror_with_name if the
      ptrace call fails breaks debugging remote targets.  The correct
@@ -738,7 +727,7 @@ i386_linux_dr_set (int regnum, unsigned 
   /* FIXME: kettenis/2001-01-29: It's not clear what we should do with
      multi-threaded processes here.  For now, pretend there is just
      one thread.  */
-  tid = PIDGET (inferior_pid);
+  tid = PIDGET (inferior_ptid);
 
   errno = 0;
   ptrace (PT_WRITE_U, tid,
@@ -879,19 +868,21 @@ static const unsigned char linux_syscall
    If SIGNAL is nonzero, give it that signal.  */
 
 void
-child_resume (int pid, int step, enum target_signal signal)
+child_resume (ptid_t ptid, int step, enum target_signal signal)
 {
+  int pid = PIDGET (ptid);
+
   int request = PTRACE_CONT;
 
   if (pid == -1)
     /* Resume all threads.  */
     /* I think this only gets used in the non-threaded case, where "resume
-       all threads" and "resume inferior_pid" are the same.  */
-    pid = inferior_pid;
+       all threads" and "resume inferior_ptid" are the same.  */
+    pid = PIDGET (inferior_ptid);
 
   if (step)
     {
-      CORE_ADDR pc = read_pc_pid (pid);
+      CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid));
       unsigned char buf[LINUX_SYSCALL_LEN];
 
       request = PTRACE_SINGLESTEP;
@@ -908,7 +899,8 @@ child_resume (int pid, int step, enum ta
       if (read_memory_nobpt (pc, (char *) buf, LINUX_SYSCALL_LEN) == 0
 	  && memcmp (buf, linux_syscall, LINUX_SYSCALL_LEN) == 0)
 	{
-	  int syscall = read_register_pid (LINUX_SYSCALL_REGNUM, pid);
+	  int syscall = read_register_pid (LINUX_SYSCALL_REGNUM,
+	                                   pid_to_ptid (pid));
 
 	  /* Then check the system call number.  */
 	  if (syscall == SYS_sigreturn || syscall == SYS_rt_sigreturn)
Index: i386aix-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386aix-nat.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386aix-nat.c
--- i386aix-nat.c	2001/03/06 08:21:08	1.6
+++ i386aix-nat.c	2001/04/25 21:35:37
@@ -190,12 +190,13 @@ i386_float_info (void)
   struct env387 fps_fixed;
   int i;
 
-  if (inferior_pid)
+  if (! ptid_equal (inferior_ptid, null_ptid))
     {
       char buf[10];
       unsigned short status;
 
-      ptrace (PT_READ_FPR, inferior_pid, buf, offsetof (struct env387, status));
+      ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
+              offsetof (struct env387, status));
       memcpy (&status, buf, sizeof (status));
       fpsaved = status;
     }
@@ -211,13 +212,13 @@ i386_float_info (void)
       return;
     }
 
-  if (inferior_pid)
+  if (! ptid_equal (inferior_ptid, null_ptid))
     {
       int offset;
       for (offset = 0; offset < sizeof (fps); offset += 10)
 	{
 	  char buf[10];
-	  ptrace (PT_READ_FPR, inferior_pid, buf, offset);
+	  ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf, offset);
 	  memcpy ((char *) &fps.control + offset, buf,
 		  MIN (10, sizeof (fps) - offset));
 	}
@@ -234,10 +235,10 @@ fetch_register (int regno)
 {
   char buf[MAX_REGISTER_RAW_SIZE];
   if (regno < FP0_REGNUM)
-    *(int *) buf = ptrace (PT_READ_GPR, inferior_pid,
+    *(int *) buf = ptrace (PT_READ_GPR, PIDGET (inferior_ptid),
 			   PT_REG (regmap[regno]), 0, 0);
   else
-    ptrace (PT_READ_FPR, inferior_pid, buf,
+    ptrace (PT_READ_FPR, PIDGET (inferior_ptid), buf,
 	    (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
   supply_register (regno, buf);
 }
@@ -259,10 +260,11 @@ store_register (int regno)
   char buf[80];
   errno = 0;
   if (regno < FP0_REGNUM)
-    ptrace (PT_WRITE_GPR, inferior_pid, PT_REG (regmap[regno]),
+    ptrace (PT_WRITE_GPR, PIDGET (inferior_ptid), PT_REG (regmap[regno]),
 	    *(int *) &registers[REGISTER_BYTE (regno)], 0);
   else
-    ptrace (PT_WRITE_FPR, inferior_pid, &registers[REGISTER_BYTE (regno)],
+    ptrace (PT_WRITE_FPR, PIDGET (inferior_ptid),
+            &registers[REGISTER_BYTE (regno)],
 	    (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs));
 
   if (errno != 0)
Index: i386b-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386b-nat.c,v
retrieving revision 1.4
diff -u -p -r1.4 i386b-nat.c
--- i386b-nat.c	2001/03/06 08:21:08	1.4
+++ i386b-nat.c	2001/04/25 21:35:37
@@ -35,7 +35,8 @@ fetch_inferior_registers (int regno)
 {
   struct reg inferior_registers;
 
-  ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+  ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+          (PTRACE_ARG3_TYPE) & inferior_registers, 0);
   memcpy (&registers[REGISTER_BYTE (0)], &inferior_registers, 4 * NUM_REGS);
   registers_fetched ();
 }
@@ -46,7 +47,8 @@ store_inferior_registers (int regno)
   struct reg inferior_registers;
 
   memcpy (&inferior_registers, &registers[REGISTER_BYTE (0)], 4 * NUM_REGS);
-  ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & inferior_registers, 0);
+  ptrace (PT_SETREGS, PIDGET (inferior_ptid),
+          (PTRACE_ARG3_TYPE) & inferior_registers, 0);
 }
 
 struct md_core
@@ -245,10 +247,9 @@ i386_float_info (void)
   unsigned int rounded_size;
   /*extern int corechan; */
   int skip;
-  extern int inferior_pid;
 
   uaddr = (char *) &U_FPSTATE (u) - (char *) &u;
-  if (inferior_pid)
+  if (! ptid_equal (inferior_ptid, null_ptid))
     {
       int *ip;
 
@@ -260,7 +261,8 @@ i386_float_info (void)
       ip = (int *) buf;
       for (i = 0; i < rounded_size; i++)
 	{
-	  *ip++ = ptrace (PT_READ_U, inferior_pid, (caddr_t) rounded_addr, 0);
+	  *ip++ = ptrace (PT_READ_U, PIDGET (inferior_ptid),
+	                  (caddr_t) rounded_addr, 0);
 	  rounded_addr += sizeof (int);
 	}
     }
Index: i386bsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386bsd-nat.c,v
retrieving revision 1.6
diff -u -p -r1.6 i386bsd-nat.c
--- i386bsd-nat.c	2001/03/31 18:09:03	1.6
+++ i386bsd-nat.c	2001/04/25 21:35:38
@@ -166,7 +166,8 @@ fetch_inferior_registers (int regno)
 {
   gregset_t gregs;
 
-  if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't get registers");
 
   supply_gregset (&gregs);
@@ -175,7 +176,7 @@ fetch_inferior_registers (int regno)
     {
       fpregset_t fpregs;
 
-      if (ptrace (PT_GETFPREGS, inferior_pid,
+      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't get floating point status");
 
@@ -191,25 +192,26 @@ store_inferior_registers (int regno)
 {
   gregset_t gregs;
 
-  if (ptrace (PT_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_GETREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't get registers");
 
   fill_gregset (&gregs, regno);
 
-  if (ptrace (PT_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
+  if (ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &gregs, 0) == -1)
     perror_with_name ("Couldn't write registers");
 
   if (regno == -1 || regno >= FP0_REGNUM)
     {
       fpregset_t fpregs;
 
-      if (ptrace (PT_GETFPREGS, inferior_pid,
+      if (ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't get floating point status");
 
       fill_fpregset (&fpregs, regno);
   
-      if (ptrace (PT_SETFPREGS, inferior_pid,
+      if (ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
 		  (PTRACE_ARG3_TYPE) &fpregs, 0) == -1)
 	perror_with_name ("Couldn't write floating point status");
     }
@@ -231,7 +233,8 @@ i386bsd_dr_set (int regnum, unsigned int
 {
   struct dbreg dbregs;
 
-  if (ptrace (PT_GETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
     perror_with_name ("Couldn't get debug registers");
 
   /* For some mysterious reason, some of the reserved bits in the
@@ -241,7 +244,8 @@ i386bsd_dr_set (int regnum, unsigned int
 
   DBREG_DRX ((&dbregs), regnum) = value;
 
-  if (ptrace (PT_SETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
+  if (ptrace (PT_SETDBREGS, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
     perror_with_name ("Couldn't write debug registers");
 }
 
@@ -277,7 +281,8 @@ i386bsd_dr_get_status (void)
      way to fix this is to add the hardware breakpoint and watchpoint
      stuff to the target vectore.  For now, just return zero if the
      ptrace call fails.  */
-  if (ptrace (PT_GETDBREGS, inferior_pid, (PTRACE_ARG3_TYPE) &dbregs, 0) == -1)
+  if (ptrace (PT_GETDBREGS, PIDGET (inferior_ptid),
+	      (PTRACE_ARG3_TYPE) & dbregs, 0) == -1)
 #if 0
     perror_with_name ("Couldn't read debug registers");
 #else
Index: i386gnu-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386gnu-nat.c,v
retrieving revision 1.5
diff -u -p -r1.5 i386gnu-nat.c
--- i386gnu-nat.c	2001/03/06 08:21:08	1.5
+++ i386gnu-nat.c	2001/04/25 21:35:38
@@ -132,10 +132,10 @@ gnu_fetch_registers (int regno)
   /* Make sure we know about new threads.  */
   inf_update_procs (current_inferior);
 
-  thread = inf_tid_to_thread (current_inferior, inferior_pid);
+  thread = inf_tid_to_thread (current_inferior, PIDGET (inferior_ptid));
   if (!thread)
     error ("Can't fetch registers from thread %d: No such thread",
-	   inferior_pid);
+	   PIDGET (inferior_ptid));
 
   if (regno < NUM_GREGS || regno == -1)
     {
@@ -256,10 +256,10 @@ gnu_store_registers (int regno)
   /* Make sure we know about new threads.  */
   inf_update_procs (current_inferior);
 
-  thread = inf_tid_to_thread (current_inferior, inferior_pid);
+  thread = inf_tid_to_thread (current_inferior, PIDGET (inferior_ptid));
   if (!thread)
     error ("Couldn't store registers into thread %d: No such thread",
-	   inferior_pid);
+	   PIDGET (inferior_ptid));
 
   if (regno < NUM_GREGS || regno == -1)
     {
Index: i386mach-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386mach-nat.c,v
retrieving revision 1.7
diff -u -p -r1.7 i386mach-nat.c
--- i386mach-nat.c	2001/03/06 08:21:08	1.7
+++ i386mach-nat.c	2001/04/25 21:35:38
@@ -49,9 +49,9 @@ fetch_inferior_registers (int regno)
 
   registers_fetched ();
 
-  ptrace (PTRACE_GETREGS, inferior_pid,
+  ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_registers);
-  ptrace (PTRACE_GETFPREGS, inferior_pid,
+  ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
 
   memcpy (registers, &inferior_registers, sizeof inferior_registers);
@@ -88,23 +88,26 @@ store_inferior_registers (int regno)
        instruction that moves eax into ebp gets single-stepped.  */
     {
       int stack = inferior_registers.r_reg[SP_REGNUM];
-      int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid,
+      int stuff = ptrace (PTRACE_PEEKDATA, PIDGET (inferior_ptid),
 			  (PTRACE_ARG3_TYPE) stack);
       int reg = inferior_registers.r_reg[EAX];
       inferior_registers.r_reg[EAX] =
 	inferior_registers.r_reg[FP_REGNUM];
-      ptrace (PTRACE_SETREGS, inferior_pid,
+      ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
 	      (PTRACE_ARG3_TYPE) & inferior_registers);
-      ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0xc589);
-      ptrace (PTRACE_SINGLESTEP, inferior_pid, (PTRACE_ARG3_TYPE) stack, 0);
+      ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) stack, 0xc589);
+      ptrace (PTRACE_SINGLESTEP, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) stack, 0);
       wait (0);
-      ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, stuff);
+      ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid),
+              (PTRACE_ARG3_TYPE) stack, stuff);
       inferior_registers.r_reg[EAX] = reg;
     }
 #endif
-  ptrace (PTRACE_SETREGS, inferior_pid,
+  ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_registers);
-  ptrace (PTRACE_SETFPREGS, inferior_pid,
+  ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) & inferior_fp_registers);
 }
 
Index: i386nbsd-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/i386nbsd-nat.c,v
retrieving revision 1.7
diff -u -p -r1.7 i386nbsd-nat.c
--- i386nbsd-nat.c	2001/03/06 08:21:08	1.7
+++ i386nbsd-nat.c	2001/04/25 21:35:38
@@ -57,9 +57,9 @@ fetch_inferior_registers (int regno)
   struct reg inferior_registers;
   struct env387 inferior_fpregisters;
 
-  ptrace (PT_GETREGS, inferior_pid,
+  ptrace (PT_GETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-  ptrace (PT_GETFPREGS, inferior_pid,
+  ptrace (PT_GETFPREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
 
   RF ( 0, inferior_registers.r_eax);
@@ -142,9 +142,9 @@ store_inferior_registers (int regno)
   RS (FDOFF_REGNUM,   inferior_fpregisters.operand);
   RS (FOP_REGNUM,     inferior_fpregisters.opcode);
   
-  ptrace (PT_SETREGS, inferior_pid,
+  ptrace (PT_SETREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) &inferior_registers, 0);
-  ptrace (PT_SETFPREGS, inferior_pid,
+  ptrace (PT_SETFPREGS, PIDGET (inferior_ptid),
 	  (PTRACE_ARG3_TYPE) &inferior_fpregisters, 0);
 }
 
Index: ia64-linux-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-linux-nat.c,v
retrieving revision 1.10
diff -u -p -r1.10 ia64-linux-nat.c
--- ia64-linux-nat.c	2001/04/16 21:26:46	1.10
+++ ia64-linux-nat.c	2001/04/25 21:35:39
@@ -474,28 +474,28 @@ fill_fpregset (fpregset_t *fpregsetp, in
 #define IA64_PSR_DD (1UL << 39)
 
 static void
-enable_watchpoints_in_psr (int pid)
+enable_watchpoints_in_psr (ptid_t ptid)
 {
   CORE_ADDR psr;
 
-  psr = read_register_pid (IA64_PSR_REGNUM, pid);
+  psr = read_register_pid (IA64_PSR_REGNUM, ptid);
   if (!(psr & IA64_PSR_DB))
     {
       psr |= IA64_PSR_DB;	/* Set the db bit - this enables hardware
 			           watchpoints and breakpoints. */
-      write_register_pid (IA64_PSR_REGNUM, psr, pid);
+      write_register_pid (IA64_PSR_REGNUM, psr, ptid);
     }
 }
 
 static long
-fetch_debug_register (int pid, int idx)
+fetch_debug_register (ptid_t ptid, int idx)
 {
   long val;
   int tid;
 
-  tid = TIDGET(pid);
+  tid = TIDGET (ptid);
   if (tid == 0)
-    tid = pid;
+    tid = PIDGET (ptid);
 
   val = ptrace (PT_READ_U, tid, (PTRACE_ARG3_TYPE) (PT_DBR + 8 * idx), 0);
 
@@ -503,33 +503,33 @@ fetch_debug_register (int pid, int idx)
 }
 
 static void
-store_debug_register (int pid, int idx, long val)
+store_debug_register (ptid_t ptid, int idx, long val)
 {
   int tid;
 
-  tid = TIDGET(pid);
+  tid = TIDGET (ptid);
   if (tid == 0)
-    tid = pid;
+    tid = PIDGET (ptid);
 
   (void) ptrace (PT_WRITE_U, tid, (PTRACE_ARG3_TYPE) (PT_DBR + 8 * idx), val);
 }
 
 static void
-fetch_debug_register_pair (int pid, int idx, long *dbr_addr, long *dbr_mask)
+fetch_debug_register_pair (ptid_t ptid, int idx, long *dbr_addr, long *dbr_mask)
 {
   if (dbr_addr)
-    *dbr_addr = fetch_debug_register (pid, 2 * idx);
+    *dbr_addr = fetch_debug_register (ptid, 2 * idx);
   if (dbr_mask)
-    *dbr_mask = fetch_debug_register (pid, 2 * idx + 1);
+    *dbr_mask = fetch_debug_register (ptid, 2 * idx + 1);
 }
 
 static void
-store_debug_register_pair (int pid, int idx, long *dbr_addr, long *dbr_mask)
+store_debug_register_pair (ptid_t ptid, int idx, long *dbr_addr, long *dbr_mask)
 {
   if (dbr_addr)
-    store_debug_register (pid, 2 * idx, *dbr_addr);
+    store_debug_register (ptid, 2 * idx, *dbr_addr);
   if (dbr_mask)
-    store_debug_register (pid, 2 * idx + 1, *dbr_mask);
+    store_debug_register (ptid, 2 * idx + 1, *dbr_mask);
 }
 
 static int
@@ -546,7 +546,7 @@ is_power_of_2 (int val)
 }
 
 int
-ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr, int len, int rw)
+ia64_linux_insert_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rw)
 {
   int idx;
   long dbr_addr, dbr_mask;
@@ -557,7 +557,7 @@ ia64_linux_insert_watchpoint (int pid, C
 
   for (idx = 0; idx < max_watchpoints; idx++)
     {
-      fetch_debug_register_pair (pid, idx, NULL, &dbr_mask);
+      fetch_debug_register_pair (ptid, idx, NULL, &dbr_mask);
       if ((dbr_mask & (0x3UL << 62)) == 0)
 	{
 	  /* Exit loop if both r and w bits clear */
@@ -586,14 +586,14 @@ ia64_linux_insert_watchpoint (int pid, C
       return -1;
     }
 
-  store_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
-  enable_watchpoints_in_psr (pid);
+  store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
+  enable_watchpoints_in_psr (ptid);
 
   return 0;
 }
 
 int
-ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len)
+ia64_linux_remove_watchpoint (ptid_t ptid, CORE_ADDR addr, int len)
 {
   int idx;
   long dbr_addr, dbr_mask;
@@ -604,12 +604,12 @@ ia64_linux_remove_watchpoint (int pid, C
 
   for (idx = 0; idx < max_watchpoints; idx++)
     {
-      fetch_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
+      fetch_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
       if ((dbr_mask & (0x3UL << 62)) && addr == (CORE_ADDR) dbr_addr)
 	{
 	  dbr_addr = 0;
 	  dbr_mask = 0;
-	  store_debug_register_pair (pid, idx, &dbr_addr, &dbr_mask);
+	  store_debug_register_pair (ptid, idx, &dbr_addr, &dbr_mask);
 	  return 0;
 	}
     }
@@ -617,15 +617,15 @@ ia64_linux_remove_watchpoint (int pid, C
 }
 
 CORE_ADDR
-ia64_linux_stopped_by_watchpoint (int pid)
+ia64_linux_stopped_by_watchpoint (ptid_t ptid)
 {
   CORE_ADDR psr;
   int tid;
   struct siginfo siginfo;
 
-  tid = TIDGET(pid);
+  tid = TIDGET(ptid);
   if (tid == 0)
-    tid = pid;
+    tid = PIDGET (ptid);
   
   errno = 0;
   ptrace (PTRACE_GETSIGINFO, tid, (PTRACE_ARG3_TYPE) 0, &siginfo);
@@ -633,10 +633,10 @@ ia64_linux_stopped_by_watchpoint (int pi
   if (errno != 0 || (siginfo.si_code & 0xffff) != 0x0004 /* TRAP_HWBKPT */)
     return 0;
 
-  psr = read_register_pid (IA64_PSR_REGNUM, pid);
+  psr = read_register_pid (IA64_PSR_REGNUM, ptid);
   psr |= IA64_PSR_DD;	/* Set the dd bit - this will disable the watchpoint
                            for the next instruction */
-  write_register_pid (IA64_PSR_REGNUM, psr, pid);
+  write_register_pid (IA64_PSR_REGNUM, psr, ptid);
 
   return (CORE_ADDR) siginfo.si_addr;
 }
Index: ia64-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/ia64-tdep.c,v
retrieving revision 1.17
diff -u -p -r1.17 ia64-tdep.c
--- ia64-tdep.c	2001/03/27 02:45:54	1.17
+++ ia64-tdep.c	2001/04/25 21:35:41
@@ -612,27 +612,27 @@ ia64_breakpoint_from_pc (CORE_ADDR *pcpt
 }
 
 CORE_ADDR
-ia64_read_pc (int pid)
+ia64_read_pc (ptid_t ptid)
 {
-  CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, pid);
-  CORE_ADDR pc_value   = read_register_pid (IA64_IP_REGNUM, pid);
+  CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, ptid);
+  CORE_ADDR pc_value   = read_register_pid (IA64_IP_REGNUM, ptid);
   int slot_num = (psr_value >> 41) & 3;
 
   return pc_value | (slot_num * SLOT_MULTIPLIER);
 }
 
 void
-ia64_write_pc (CORE_ADDR new_pc, int pid)
+ia64_write_pc (CORE_ADDR new_pc, ptid_t ptid)
 {
   int slot_num = (int) (new_pc & 0xf) / SLOT_MULTIPLIER;
-  CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, pid);
+  CORE_ADDR psr_value = read_register_pid (IA64_PSR_REGNUM, ptid);
   psr_value &= ~(3LL << 41);
   psr_value |= (CORE_ADDR)(slot_num & 0x3) << 41;
 
   new_pc &= ~0xfLL;
 
-  write_register_pid (IA64_PSR_REGNUM, psr_value, pid);
-  write_register_pid (IA64_IP_REGNUM, new_pc, pid);
+  write_register_pid (IA64_PSR_REGNUM, psr_value, ptid);
+  write_register_pid (IA64_IP_REGNUM, new_pc, ptid);
 }
 
 #define IS_NaT_COLLECTION_ADDR(addr) ((((addr) >> 3) & 0x3f) == 0x3f)
Index: infcmd.c
===================================================================
RCS file: /cvs/src/src/gdb/infcmd.c,v
retrieving revision 1.26
diff -u -p -r1.26 infcmd.c
--- infcmd.c	2001/03/27 20:36:23	1.26
+++ infcmd.c	2001/04/25 21:35:43
@@ -131,7 +131,7 @@ char *inferior_io_terminal;
    being debugged it should be nonzero (currently 3 is used) for remote
    debugging.  */
 
-int inferior_pid;
+ptid_t inferior_ptid;
 
 /* Last signal that the inferior received (why it stopped).  */
 
@@ -258,7 +258,7 @@ run_command (char *args, int from_tty)
 
   dont_repeat ();
 
-  if (inferior_pid != 0 && target_has_execution)
+  if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
     {
       if (from_tty
 	  && !query ("The program being debugged has been started already.\n\
@@ -1690,7 +1690,7 @@ attach_command (char *args, int from_tty
   exec_file = (char *) get_exec_file (0);
   if (!exec_file)
     {
-      exec_file = target_pid_to_exec_file (inferior_pid);
+      exec_file = target_pid_to_exec_file (PIDGET (inferior_ptid));
       if (exec_file)
 	{
 	  /* It's possible we don't have a full path, but rather just a
@@ -1720,7 +1720,7 @@ attach_command (char *args, int from_tty
 
   /* Take any necessary post-attaching actions for this platform.
    */
-  target_post_attach (inferior_pid);
+  target_post_attach (PIDGET (inferior_ptid));
 
   normal_stop ();
 
Index: inferior.h
===================================================================
RCS file: /cvs/src/src/gdb/inferior.h,v
retrieving revision 1.20
diff -u -p -r1.20 inferior.h
--- inferior.h	2001/04/06 17:53:39	1.20
+++ inferior.h	2001/04/25 21:35:44
@@ -51,6 +51,38 @@ extern void write_inferior_status_regist
 					    *inf_status, int regno,
 					    LONGEST val);
 
+/* The -1 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 null or zero ptid, often used to indicate no process. */
+extern ptid_t null_ptid;
+
+/* Attempt to find and return an existing ptid with the given PID, LWP,
+   and TID components.  If none exists, create a new one and return
+   that.  */
+ptid_t ptid_build (int pid, long lwp, long tid);
+
+/* Find/Create a ptid from just a pid. */
+ptid_t pid_to_ptid (int pid);
+
+/* Fetch the pid (process id) component from a ptid. */
+int ptid_get_pid (ptid_t ptid);
+
+/* Fetch the lwp (lightweight process) component from a ptid. */
+long ptid_get_lwp (ptid_t ptid);
+
+/* Fetch the tid (thread id) component from a ptid. */
+long ptid_get_tid (ptid_t ptid);
+
+/* Compare two ptids to see if they are equal */
+extern int ptid_equal (ptid_t p1, ptid_t p2);
+
+/* Save value of inferior_ptid so that it may be restored by
+   a later call to do_cleanups().  Returns the struct cleanup
+   pointer needed for later doing the cleanup.  */
+extern struct cleanup * save_inferior_ptid (void);
+
 extern void set_sigint_trap (void);
 
 extern void clear_sigint_trap (void);
@@ -63,9 +95,10 @@ extern void clear_sigio_trap (void);
 
 extern char *inferior_io_terminal;
 
-/* Pid of our debugged inferior, or 0 if no inferior now.  */
+/* Collected pid, tid, etc. of the debugged inferior.  When there's
+   no inferior, PIDGET (inferior_ptid) will be 0. */
 
-extern int inferior_pid;
+extern ptid_t inferior_ptid;
 
 /* Is the inferior running right now, as a result of a 'run&',
    'continue&' etc command? This is used in asycn gdb to determine
@@ -78,7 +111,7 @@ extern int target_executing;
    redisplay the prompt until the execution is actually over. */
 extern int sync_execution;
 
-/* This is only valid when inferior_pid is non-zero.
+/* This is only valid when inferior_ptid is non-zero.
 
    If this is 0, then exec events should be noticed and responded to
    by the debugger (i.e., be reported to the user).
@@ -122,15 +155,15 @@ extern int run_stack_dummy (CORE_ADDR, c
 
 extern CORE_ADDR read_pc (void);
 
-extern CORE_ADDR read_pc_pid (int);
+extern CORE_ADDR read_pc_pid (ptid_t);
 
-extern CORE_ADDR generic_target_read_pc (int);
+extern CORE_ADDR generic_target_read_pc (ptid_t);
 
 extern void write_pc (CORE_ADDR);
 
-extern void write_pc_pid (CORE_ADDR, int);
+extern void write_pc_pid (CORE_ADDR, ptid_t);
 
-extern void generic_target_write_pc (CORE_ADDR, int);
+extern void generic_target_write_pc (CORE_ADDR, ptid_t);
 
 extern CORE_ADDR read_sp (void);
 
@@ -208,9 +241,9 @@ extern int attach (int);
 extern void detach (int);
 
 /* PTRACE method of waiting for inferior process.  */
-int ptrace_wait (int, int *);
+int ptrace_wait (ptid_t, int *);
 
-extern void child_resume (int, int, enum target_signal);
+extern void child_resume (ptid_t, int, enum target_signal);
 
 #ifndef PTRACE_ARG3_TYPE
 #define PTRACE_ARG3_TYPE int	/* Correct definition for most systems. */
@@ -224,7 +257,7 @@ extern void pre_fork_inferior (void);
 
 extern int proc_iterate_over_mappings (int (*)(int, CORE_ADDR));
 
-extern int procfs_first_available (void);
+extern ptid_t procfs_first_available (void);
 
 /* From fork-child.c */
 
@@ -261,7 +294,8 @@ extern int signal_print_update (int, int
 
 extern int signal_pass_update (int, int);
 
-extern void get_last_target_status(int *pid, struct target_waitstatus *status);
+extern void get_last_target_status(ptid_t *ptid,
+                                   struct target_waitstatus *status);
 
 /* From infcmd.c */
 
@@ -362,7 +396,7 @@ extern int proceed_to_finish;
 
 extern char *stop_registers;
 
-/* Nonzero if the child process in inferior_pid was attached rather
+/* Nonzero if the child process in inferior_ptid was attached rather
    than forked.  */
 
 extern int attach_flag;
Index: inflow.c
===================================================================
RCS file: /cvs/src/src/gdb/inflow.c,v
retrieving revision 1.8
diff -u -p -r1.8 inflow.c
--- inflow.c	2001/03/06 08:21:08	1.8
+++ inflow.c	2001/04/25 21:35:45
@@ -207,9 +207,9 @@ terminal_init_inferior (void)
      debugging target with a version of target_terminal_init_inferior which
      passes in the process group to a generic routine which does all the work
      (and the non-threaded child_terminal_init_inferior can just pass in
-     inferior_pid to the same routine).  */
+     inferior_ptid to the same routine).  */
   /* We assume INFERIOR_PID is also the child's process group.  */
-  terminal_init_inferior_with_pgrp (PIDGET (inferior_pid));
+  terminal_init_inferior_with_pgrp (PIDGET (inferior_ptid));
 #endif /* PROCESS_GROUP_TYPE */
 }
 
@@ -573,11 +573,11 @@ new_tty (void)
 static void
 kill_command (char *arg, int from_tty)
 {
-  /* FIXME:  This should not really be inferior_pid (or target_has_execution).
+  /* FIXME:  This should not really be inferior_ptid (or target_has_execution).
      It should be a distinct flag that indicates that a target is active, cuz
      some targets don't have processes! */
 
-  if (inferior_pid == 0)
+  if (ptid_equal (inferior_ptid, null_ptid))
     error ("The program is not being run.");
   if (!query ("Kill the program being debugged? "))
     error ("Not confirmed.");
@@ -605,7 +605,7 @@ static void
 pass_signal (int signo)
 {
 #ifndef _WIN32
-  kill (PIDGET (inferior_pid), SIGINT);
+  kill (PIDGET (inferior_ptid), SIGINT);
 #endif
 }
 
@@ -647,7 +647,7 @@ handle_sigio (int signo)
     {
 #ifndef _WIN32
       if ((*target_activity_function) ())
-	kill (inferior_pid, SIGINT);
+	kill (PIDGET (inferior_ptid), SIGINT);
 #endif
     }
 }
@@ -735,7 +735,7 @@ _initialize_inflow (void)
   add_com ("kill", class_run, kill_command,
 	   "Kill execution of program being debugged.");
 
-  inferior_pid = 0;
+  inferior_ptid = null_ptid;
 
   terminal_is_ours = 1;
 
Index: infptrace.c
===================================================================
RCS file: /cvs/src/src/gdb/infptrace.c,v
retrieving revision 1.13
diff -u -p -r1.13 infptrace.c
--- infptrace.c	2001/03/20 18:16:10	1.13
+++ infptrace.c	2001/04/25 21:35:46
@@ -110,22 +110,6 @@ static void fetch_register (int);
 static void store_register (int);
 #endif
 
-/*
- * Some systems (Linux) may have threads implemented as pseudo-processes, 
- * in which case we may be tracing more than one process at a time.
- * In that case, inferior_pid will contain the main process ID and the 
- * individual thread (process) id mashed together.  These macros are 
- * used to separate them out.  The definitions may be overridden in tm.h
- *
- * NOTE: default definitions here are for systems with no threads.
- * Useful definitions MUST be provided in tm.h
- */
-
-#if !defined (PIDGET)	/* Default definition for PIDGET/TIDGET.  */
-#define PIDGET(PID)	PID
-#define TIDGET(PID)	0
-#endif
-
 void _initialize_kernel_u_addr (void);
 void _initialize_infptrace (void);
 
@@ -215,12 +199,12 @@ call_ptrace (int request, int pid, PTRAC
    hook before returning.  */
 
 int
-ptrace_wait (int pid, int *status)
+ptrace_wait (ptid_t ptid, int *status)
 {
   int wstate;
 
   wstate = wait (status);
-  target_post_wait (wstate, *status);
+  target_post_wait (pid_to_ptid (wstate), *status);
   return wstate;
 }
 
@@ -228,8 +212,9 @@ void
 kill_inferior (void)
 {
   int status;
+  int pid =  PIDGET (inferior_ptid);
 
-  if (inferior_pid == 0)
+  if (pid == 0)
     return;
 
   /* This once used to call "kill" to kill the inferior just in case
@@ -240,8 +225,8 @@ kill_inferior (void)
 
      The kill call causes problems under hpux10, so it's been removed;
      if this causes problems we'll deal with them as they arise.  */
-  ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0);
-  ptrace_wait (0, &status);
+  ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0);
+  ptrace_wait (null_ptid, &status);
   target_mourn_inferior ();
 }
 
@@ -252,15 +237,17 @@ kill_inferior (void)
    If SIGNAL is nonzero, give it that signal.  */
 
 void
-child_resume (int pid, int step, enum target_signal signal)
+child_resume (ptid_t ptid, int step, enum target_signal signal)
 {
+  int pid = PIDGET (ptid);
+
   errno = 0;
 
   if (pid == -1)
     /* Resume all threads.  */
     /* I think this only gets used in the non-threaded case, where "resume
-       all threads" and "resume inferior_pid" are the same.  */
-    pid = inferior_pid;
+       all threads" and "resume inferior_ptid" are the same.  */
+    pid = PIDGET (inferior_ptid);
 
   /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where
      it was.  (If GDB wanted it to start some other way, we have already
@@ -312,7 +299,8 @@ void
 detach (int signal)
 {
   errno = 0;
-  ptrace (PT_DETACH, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal);
+  ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1,
+          signal);
   if (errno)
     perror_with_name ("ptrace");
   attach_flag = 0;
@@ -356,7 +344,7 @@ _initialize_kernel_u_addr (void)
 /* U_REGS_OFFSET is the offset of the registers within the u area.  */
 #if !defined (U_REGS_OFFSET)
 #define U_REGS_OFFSET \
-  ptrace (PT_READ_U, inferior_pid, \
+  ptrace (PT_READ_U, PIDGET (inferior_ptid), \
 	  (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \
     - KERNEL_U_ADDR
 #endif
@@ -387,8 +375,8 @@ fetch_register (int regno)
     }
 
   /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* no thread id, just use process id */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);	/* no thread id, just use process id */
 
   offset = U_REGS_OFFSET;
 
@@ -453,8 +441,8 @@ store_register (int regno)
     }
 
   /* Overload thread id onto process id */
-  if ((tid = TIDGET (inferior_pid)) == 0)
-    tid = inferior_pid;		/* no thread id, just use process id */
+  if ((tid = TIDGET (inferior_ptid)) == 0)
+    tid = PIDGET (inferior_ptid);	/* no thread id, just use process id */
 
   offset = U_REGS_OFFSET;
 
@@ -535,14 +523,14 @@ child_xfer_memory (CORE_ADDR memaddr, ch
       if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE))
 	{
 	  /* Need part of initial word -- fetch it.  */
-	  buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_pid), 
+	  buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid), 
 			      (PTRACE_ARG3_TYPE) addr, 0);
 	}
 
       if (count > 1)		/* FIXME, avoid if even boundary */
 	{
 	  buffer[count - 1] 
-	    = ptrace (PT_READ_I, PIDGET (inferior_pid),
+	    = ptrace (PT_READ_I, PIDGET (inferior_ptid),
 		      ((PTRACE_ARG3_TYPE)
 		       (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))),
 		      0);
@@ -559,14 +547,14 @@ child_xfer_memory (CORE_ADDR memaddr, ch
       for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
 	{
 	  errno = 0;
-	  ptrace (PT_WRITE_D, PIDGET (inferior_pid), 
+	  ptrace (PT_WRITE_D, PIDGET (inferior_ptid), 
 		  (PTRACE_ARG3_TYPE) addr, buffer[i]);
 	  if (errno)
 	    {
 	      /* Using the appropriate one (I or D) is necessary for
 	         Gould NP1, at least.  */
 	      errno = 0;
-	      ptrace (PT_WRITE_I, PIDGET (inferior_pid), 
+	      ptrace (PT_WRITE_I, PIDGET (inferior_ptid), 
 		      (PTRACE_ARG3_TYPE) addr, buffer[i]);
 	    }
 	  if (errno)
@@ -582,7 +570,7 @@ child_xfer_memory (CORE_ADDR memaddr, ch
       for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE))
 	{
 	  errno = 0;
-	  buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_pid),
+	  buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid),
 			      (PTRACE_ARG3_TYPE) addr, 0);
 	  if (errno)
 	    return 0;
@@ -632,7 +620,7 @@ udot_info (char *dummy1, int dummy2)
 	    }
 	  printf_filtered ("%04x:", udot_off);
 	}
-      udot_val = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) udot_off, 0);
+      udot_val = ptrace (PT_READ_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) udot_off, 0);
       if (errno != 0)
 	{
 	  sprintf (mess, "\nreading user struct at offset 0x%x", udot_off);
Index: infrun.c
===================================================================
RCS file: /cvs/src/src/gdb/infrun.c,v
retrieving revision 1.30
diff -u -p -r1.30 infrun.c
--- infrun.c	2001/04/06 17:53:39	1.30
+++ infrun.c	2001/04/25 21:35:52
@@ -99,7 +99,7 @@ int sync_execution = 0;
    when the inferior stopped in a different thread than it had been
    running in.  */
 
-static int previous_inferior_pid;
+static ptid_t previous_inferior_ptid;
 
 /* This is true for configurations that may follow through execl() and
    similar functions.  At present this is only true for HP-UX native.  */
@@ -332,7 +332,10 @@ static unsigned char *signal_program;
 	(flags)[signum] = 0; \
   } while (0)
 
+/* Value to pass to target_resume() to cause all threads to resume */
 
+#define RESUME_ALL (pid_to_ptid (-1))
+
 /* Command list pointer for the "stop" placeholder.  */
 
 static struct cmd_list_element *stop_command;
@@ -409,7 +412,7 @@ static int number_of_threads_in_syscalls
 /* This is a cached copy of the pid/waitstatus of the last event
    returned by target_wait()/target_wait_hook().  This information is
    returned by get_last_target_status(). */
-static int target_last_wait_pid = -1;
+static ptid_t target_last_wait_ptid;
 static struct target_waitstatus target_last_waitstatus;
 
 /* This is used to remember when a fork, vfork or exec event
@@ -441,7 +444,7 @@ pending_follow;
    set to 1, a vfork event has been seen, but cannot be followed
    until the exec is seen.
 
-   (In the latter case, inferior_pid is still the parent of the
+   (In the latter case, inferior_ptid is still the parent of the
    vfork, and pending_follow.fork_event.child_pid is the child.  The
    appropriate process is followed, according to the setting of
    follow-fork-mode.) */
@@ -513,7 +516,7 @@ follow_inferior_fork (int parent_pid, in
     }
 
   /* If we're to be following the child, then attach to it, detach
-     from inferior_pid, and set inferior_pid to child_pid. */
+     from inferior_ptid, and set inferior_ptid to child_pid. */
   else if (follow_mode == follow_fork_mode_child)
     {
       char child_pid_spelling[100];	/* Arbitrary length. */
@@ -536,7 +539,7 @@ follow_inferior_fork (int parent_pid, in
 
       /* Also reset the solib inferior hook from the parent. */
 #ifdef SOLIB_REMOVE_INFERIOR_HOOK
-      SOLIB_REMOVE_INFERIOR_HOOK (inferior_pid);
+      SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid));
 #endif
 
       /* Detach from the parent. */
@@ -544,7 +547,7 @@ follow_inferior_fork (int parent_pid, in
       target_detach (NULL, 1);
 
       /* Attach to the child. */
-      inferior_pid = child_pid;
+      inferior_ptid = pid_to_ptid (child_pid);
       sprintf (child_pid_spelling, "%d", child_pid);
       dont_repeat ();
 
@@ -588,7 +591,7 @@ follow_inferior_fork (int parent_pid, in
 
       /* We continue to follow the parent.  To help distinguish the two
          debuggers, though, both we and our clone will reset our prompts. */
-      sprintf (pid_suffix, "[%d] ", inferior_pid);
+      sprintf (pid_suffix, "[%d] ", PIDGET (inferior_ptid));
       set_prompt (strcat (get_prompt (), pid_suffix));
     }
 
@@ -650,11 +653,12 @@ follow_vfork (int parent_pid, int child_
   follow_inferior_fork (parent_pid, child_pid, 0, 1);
 
   /* Did we follow the child?  Had it exec'd before we saw the parent vfork? */
-  if (pending_follow.fork_event.saw_child_exec && (inferior_pid == child_pid))
+  if (pending_follow.fork_event.saw_child_exec
+      && (PIDGET (inferior_ptid) == child_pid))
     {
       pending_follow.fork_event.saw_child_exec = 0;
       pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
-      follow_exec (inferior_pid, pending_follow.execd_pathname);
+      follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname);
       xfree (pending_follow.execd_pathname);
     }
 }
@@ -676,13 +680,14 @@ follow_exec (int pid, char *execd_pathna
       (pending_follow.kind == TARGET_WAITKIND_VFORKED))
     {
       pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
-      follow_vfork (inferior_pid, pending_follow.fork_event.child_pid);
+      follow_vfork (PIDGET (inferior_ptid),
+                    pending_follow.fork_event.child_pid);
       follow_vfork_when_exec = 0;
-      saved_pid = inferior_pid;
+      saved_pid = PIDGET (inferior_ptid);
 
       /* Did we follow the parent?  If so, we're done.  If we followed
          the child then we must also follow its exec(). */
-      if (inferior_pid == pending_follow.fork_event.parent_pid)
+      if (PIDGET (inferior_ptid) == pending_follow.fork_event.parent_pid)
 	return;
     }
 
@@ -731,7 +736,8 @@ follow_exec (int pid, char *execd_pathna
 
   gdb_flush (gdb_stdout);
   target_mourn_inferior ();
-  inferior_pid = saved_pid;	/* Because mourn_inferior resets inferior_pid. */
+  inferior_ptid = pid_to_ptid (saved_pid);
+  			/* Because mourn_inferior resets inferior_ptid. */
   push_target (tgt);
 
   /* That a.out is now the one to use. */
@@ -747,7 +753,7 @@ follow_exec (int pid, char *execd_pathna
   SOLIB_RESTART ();
 #endif
 #ifdef SOLIB_CREATE_INFERIOR_HOOK
-  SOLIB_CREATE_INFERIOR_HOOK (inferior_pid);
+  SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid));
 #endif
 
   /* Reinsert all breakpoints.  (Those which were symbolic have
@@ -866,7 +872,8 @@ resume (int step, enum target_signal sig
     {
     case (TARGET_WAITKIND_FORKED):
       pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
-      follow_fork (inferior_pid, pending_follow.fork_event.child_pid);
+      follow_fork (PIDGET (inferior_ptid),
+                   pending_follow.fork_event.child_pid);
       break;
 
     case (TARGET_WAITKIND_VFORKED):
@@ -874,14 +881,15 @@ resume (int step, enum target_signal sig
 	int saw_child_exec = pending_follow.fork_event.saw_child_exec;
 
 	pending_follow.kind = TARGET_WAITKIND_SPURIOUS;
-	follow_vfork (inferior_pid, pending_follow.fork_event.child_pid);
+	follow_vfork (PIDGET (inferior_ptid),
+	              pending_follow.fork_event.child_pid);
 
 	/* Did we follow the child, but not yet see the child's exec event?
 	   If so, then it actually ought to be waiting for us; we respond to
 	   parent vfork events.  We don't actually want to resume the child
 	   in this situation; we want to just get its exec event. */
 	if (!saw_child_exec &&
-	    (inferior_pid == pending_follow.fork_event.child_pid))
+	    (PIDGET (inferior_ptid) == pending_follow.fork_event.child_pid))
 	  should_resume = 0;
       }
       break;
@@ -902,7 +910,7 @@ resume (int step, enum target_signal sig
 
   if (should_resume)
     {
-      int resume_pid;
+      ptid_t resume_ptid;
 
       if (use_thread_step_needed && thread_step_needed)
 	{
@@ -915,7 +923,7 @@ resume (int step, enum target_signal sig
 	    {
 	      /* Breakpoint deleted: ok to do regular resume
 	         where all the threads either step or continue. */
-	      resume_pid = -1;
+	      resume_ptid = RESUME_ALL;
 	    }
 	  else
 	    {
@@ -927,7 +935,7 @@ resume (int step, enum target_signal sig
 		  trap_expected = 1;
 		  step = 1;
 		}
-	      resume_pid = inferior_pid;
+	      resume_ptid = inferior_ptid;
 	    }
 	}
       else
@@ -935,11 +943,11 @@ resume (int step, enum target_signal sig
 	  /* Vanilla resume. */
 	  if ((scheduler_mode == schedlock_on) ||
 	      (scheduler_mode == schedlock_step && step != 0))
-	    resume_pid = inferior_pid;
+	    resume_ptid = inferior_ptid;
 	  else
-	    resume_pid = -1;
+	    resume_ptid = RESUME_ALL;
 	}
-      target_resume (resume_pid, step, sig);
+      target_resume (resume_ptid, step, sig);
     }
 
   discard_cleanups (old_cleanups);
@@ -1230,8 +1238,8 @@ struct execut