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 RFC] process/thread/lwp id patch - phase 1


The patch below represents phase 1 of the FYI patch that I posted
recently:

    http://sources.redhat.com/ml/gdb-patches/2001-04/msg00240.html

Unless there is serious disagreement regarding this phase 1 patch, I
plan to commit it on Thursday, May 3rd, 2001.  I'll create pre- and
post-commit tags for this activity.  Phase 2 will be some
consolidation of the save_inferior_pid/restore_inferior_pid logic. 
Phase 3 will actually change the representation of the combined
process/thread id type.  I don't expect anyone to have any serious
concerns over phase 2, but I expect that phase 3 will generate some
healthy debate.

As for what phase 1 does...

This patch introduces a new type called ptid_t which is intended to
represent a combined process id and thread id (and in some cases, lwp
id).  This patch is conservative in that it defines it exactly as it
is defined now in GDB, namely as an "int".  It is not terribly useful
as such, but phase 3 will introduce a new representation.  (See the
"FYI" patch referenced above to see what the new representation
might look like.)

In addition to introducing a new type which *mostly* preserves the
current representation (more on this in a moment), it renames
identifiers which formerly represented a combined pid/tid to a
slightly different name.  Thus, for example, foo_pid becomes foo_ptid. 
There are at least two reasons for this renaming:

    - First, the "ptid" portion of the name indicates to the
      programmer that the variable in question represents a combined
      pid/tid whereas the remaining "pid" identifiers represent things
      that truly are process ids.  These frequently occur in code
      together and I think it is useful to be able to distinguish them
      based upon their name.

    - Second, the string "ptid" doesn't occur anywhere in the current
      GDB sources.  By giving each variable that represents one of
      these combined identifiers a name that may be easily searched
      for, it makes it much easier to perform future cleanups.  E.g,
      one of the problems with making the representation of ptid_t
      be the thread object is that ptids are much longer lived.  They
      are created before a thread object is created and will also
      typically outlive the thread object that they correspond too. 
      (And, in fact, spurious ids may be created in the course of
      manipulating threads.)  It would be nice to get these issues
      under control and having search string which will quickly
      pinpoint all of the potential problem areas should prove useful.

In addition to the renaming of identifiers, I also performed a type
analysis and introduced calls to PIDGET (which is an existing macro
which extracts a pid from a combined pid/tid) in cases where a pid
was needed and calls to pid_to_ptid in cases where a pid needed to
be converted into one of the combined objects.  I ran into two
problems with the current representation:

    - First, when -1 is converted to a ptid and then extracted again,
      it came out as 0xffff instead of -1.  To circumvent this problem,
      I renamed the versions of PIDGET which perform a masking operation
      to PIDGET0.  I then defined PIDGET in terms of PIDGET0 so that
      0xffff properly gets mapped to -1.

    - Second, I saw some regressions on Solaris due to the fact that
      corelow.c was storing some corefile thread identifiers
      in inferior_pid.  On Solaris 8, more than 16 bits are needed to
      represent these identifiers.  For this case, I introduced some
      #ifdefs in corelow.c which use inferior_ptid (renamed from
      inferior_pid) "as is" without any masking.  I plan to eliminate
      these ifdefs as part of phase 3.  (Or I could even do it as a
      phase 4, if desired.)

Other concerns:

    - This patch introduces some new macros, pid_to_ptid, null_ptid,
      minus_one_ptid, and ptid_equal.  These macros will be eliminated
      in phase 3.  In their place will be functions (for pid_to_ptid
      and ptid_equal) and variables (for null_ptid and minus_one_ptid).
      Other ptid accessors an a ptid constructor will be introduced at
      the same time.

    - minus_one_ptid is not used everywhere that it could be.  I would
      appreciate feedback concerning minus_one_ptid since it seems to me
      that ``pid_to_ptid (-1)'' is just about as readable.  (I consider
      this a minor concern though and certainly not something that should
      hold up committing the patch below.  I would prefer to address this
      and similar issues after committing phase 1.)

    - The name for ``ptid_t'' is possibly inconsistent with current GDB
      naming conventions.  In a private conversation, Andrew pointed
      out that the "_t" is not widely used in the GDB sources.  But he
      also observed that GDB doesn't really have a convention
      regarding type names at all.  (Again, I'd prefer to make
      adjustments to the type name after committing phase 1 since it
      could take a while to agree on a convention.)

Comments?

	* defs.h (ptid_t): New typedef.
	(pid_to_ptid, null_ptid, minus_one_ptid, ptid_equal): New macros.

	* a68v-nat.c, alphabsd-nat.c, arch-utils.c, arm-linux-nat.c,
	blockframe.c, breakpoint.c, breakpoint.h,
	config/i386/nm-i386sol2.h, config/i386/tm-i386sco5.h,
	config/ia64/nm-linux.h, config/m68k/nm-hp300bsd.h,
	config/mips/nm-irix4.h, config/mips/nm-irix5.h,
	config/pa/nm-hppah.h, config/pa/tm-hppa.h,
	config/rs6000/nm-rs6000.h, config/sparc/nm-sun4sol2.h,
	corelow.c, cxux-nat.c, d10v-tdep.c, dink32-rom.c,
	dve3900-rom.c, fork-child.c, frame.c, gnu-nat.c, go32-nat.c,
	hp300ux-nat.c, hppa-tdep.c, hppab-nat.c, hppah-nat.c,
	hpux-thread.c, i386-linux-nat.c, i386aix-nat.c, i386b-nat.c,
	i386bsd-nat.c, i386gnu-nat.c, i386mach-nat.c, i386nbsd-nat.c,
	infcmd.c, inferior.h, inflow.c, infptrace.c, infrun.c,
	inftarg.c, infttrace.c, lin-lwp.c, lin-thread.c,
	linux-thread.c, lynx-nat.c, m3-nat.c, m32r-rom.c,
	m68knbsd-nat.c, m88k-nat.c, mac-nat.c, mips-nat.c,
	mon960-rom.c, monitor.c, ns32knbsd-nat.c, ocd.c, ppc-bdm.c,
	ppcnbsd-nat.c, proc-service.c, procfs.c, ptx4-nat.c,
	regcache.c, remote-adapt.c, remote-array.c, remote-bug.c,
	remote-e7000.c, remote-es.c, remote-mips.c, remote-mm.c,
	remote-nindy.c, remote-os9k.c, remote-rdi.c, remote-rdp.c,
	remote-sds.c, remote-sim.c, remote-st.c, remote-udi.c,
	remote-vx.c, remote.c, rs6000-nat.c, sol-thread.c,
	solib-aix5.c, solib-svr4.c, somsolib.c, sparc-nat.c,
	standalone.c, sun3-nat.c, sun386-nat.c, symm-nat.c, target.c,
	target.h, thread-db.c, thread.c, top.c, ultra3-nat.c,
	uw-thread.c, v850ice.c, win32-nat.c, wince.c, xcoffsolib.c
	(inferior_pid):  Rename to inferior_ptid everywhere - even in
	comments and obsolete ports.  In cases where this variable
	really is supposed to be used as a process id, use PIDGET() to
	extract the process id component from inferior_ptid.  The
	other cases, either involving other variables whose types had
	to be changed or functions whose signatures had to changed
	are listed separately below.

	* arm-linux-nat.c (get_thread_id): Change type of argument
	representing a combined process/thread id from ``int'' to
	``ptid_t''.  Also change parameter name to ptid.
	* breakpoint.h, breakpoint.c (breakpoint_thread_match): Likewise.
	* corelow.c (core_file_thread_alive): Likewise.
	* d10v-tdep.c (d10v_read_pc, d10v_write_pc): Likewise.
	* defs.h (*target_wait_hook): Likewise.
	* gdbthread.h (thread_info, delete_thread, pid_to_thread_id)
	(find_thread_pid, save_infrun_state, load_infrun_state): Likewise.
	* gnu-nat.c (gnu_thread_alive, gnu_pid_to_str, gnu_wait)
	(gnu_resume): Likewise.
	* go32-nat.c (go32_wait, go32_resume): Likewise.
	* h8500-tdep.c (h8500_read_pc, h8500_write_pc): Likewise.
	* hppa-tdep.c (target_read_pc, target_write_pc): Likewise.
	* hppah-nat.c (child_pid_to_str, hppa_tid_to_str,
	(hppa_pid_or_tid_to_str, child_post_startup_inferior)
	(child_thread_alive): Likewise.
	* hpux-thread.c (hpux_thread_notice_signals, hpux_thread_alive)
	(hpux_pid_to_str, hpux_thread_wait, hpux_thread_resume): Likewise.
	* i386-linux-nat.c (child_resume): Likewise.
	* ia64-linux-nat.c (enable_watchpoints_in_psr, fetch_debug_register)
	(store_debug_register, fetch_debug_register_pair)
	(store_debug_register_pair, ia64_linux_insert_watchpoint)
	(ia64_linux_remove_watchpoint, ia64_linux_stopped_by_watchpoint):
	Likewise.
	* ia64-tdep.c (ia64_read_pc, ia64_write_pc): Likewise.
	* inferior.h (read_pc_pid, generic_target_read_pc, write_pc_pid)
	(generic_target_write_pc, ptrace_wait, child_resume)
	(get_last_target_status): Likewise.
	* infptrace.c (ptrace_wait, child_resume): Likewise.
	* inftarg.c (child_wait, child_post_wait, child_thread_live)
	(child_pid_to_str): Likewise.
	* infttrace.c (ptrace_wait, child_thread_alive, child_resume)
	(hppa_pid_or_tid_to_str, child_post_startup_inferior): Likewise.
	* lin-lwp.c (add_lwp, delete_lwp, find_lwp_pid, lin_lwp_attach_lwp)
	(lin_lwp_resume, lin_lwp_wait, lin_lwp_thread_alive)
	(lin_lwp_pid_to_str): Likewise.
	* lin-thread.c (thread_db_alive, thread_db_pid_to_str)
	(thread_db_resume, thread_db_wait): Likewise.
	* linux-thread.c (linuxthreads_thread_alive, linuxthreads_pid_to_str)
	(linuxthreads_resume, linuxthreads_wait): Likewise.
	* lynx-nat.c (child_wait, child_thread_alive, child_resume)
	(child_pid_to_str): Likewise.
	* m3-nat.c (mach_really_wait, m3_resume): Likewise.
	* mac-nat.c (child_wait, child_resume): Likewise.
	* mips-tdep.c (mips_read_pc): Likewise.
	* monitor.c (monitor_wait, monitor_resume): Likewise.
	* ocd.c, ocd.h (ocd_thread_alive, ocd_resume): Likewise.
	* ppc-bdm.c (bdm_ppc_wait): Likewise.
	* procfs.c (do_attach, procfs_wait, procfs_resume)
	(procfs_notice_signals, procfs_thread_alive, procfs_pid_to_str)
	(procfs_set_watchpoint, procfs_stopped_by_watchpoint)
	(procfs_find_LDT_entry): Likewise.
	* regcache.c (read_register_pid, read_signed_register_pid)
	(write_register_pid, generic_target_read_pc, read_pc_pid)
	(generic_target_write_pc, write_pc_pid): Likewise.
	* regcache.h (read_register_pid, read_signed_register_pid)
	(write_register_pid): Likewise.
	* remote-adapt.c (adapt_wait, adapt_resume): Likewise.
	* remote-array.c (array_wait, array_resume): Likewise.
	* remote-bug.c (bug_wait, bug_resume): Likewise.
	* remote-e7000.c (e7000_wait, e7000_resume): Likewise.
	* remote-eb.c (eb_wait, eb_resume): Likewise.
	* remote-es.c (es1800_wait, es1800_resume): Likewise.
	* remote-mips.c (mips_wait, mips_resume): Likewise.
	* remote-mm.c (mm_wait, mm_resume): Likewise.
	* remote-nindy.c (nindy_wait, nindy_resume): Likewise.
	* remote-os9k.c (rombug_wait, rombug_resume): Likewise.
	* remote-rdi.c (arm_rdi_wait, arm_rdi_resume): Likewise.
	* remote-rdp.c (remote_rdp_resume, remote_rdp_wait): Likewise.
	* remote-sds.c (sds_wait, sds_resume): Likewise.
	* remote-sim.c (gdbsim_wait, gdbsim_resume): Likewise.
	* remote-st.c (st2000_wait, st2000_resume): Likewise.
	* remote-udi.c (udi_wait, udi_resume): Likewise.
	* remote-vx.c (vx_wait, vx_resume): Likewise.
	* remote.c (remote_current_thread, remote_resume, remote_wait)
	(remote_async_resume, remote_async_wait, remote_cisco_wait)
	(remote_thread_alive): Likewise.
	* sol-thread.c (thread_to_lwp, lwp_to_thread, sol_thread_resume)
	(sol_thread_wait, sol_thread_notice_signals, sol_thread_alive)
	(solaris_pid_to_str): Likewise.
	* symm-nat.c (child_wait, child_resume): Likewise.
	* target.c (debug_to_resume, debug_to_wait, debug_to_post_wait)
	(debug_to_notice_signals, debug_to_thread_alive)
	(normal_target_post_startup_inferior, normal_pid_to_str)
	(debug_to_post_startup_inferior): Likewise.
	* target.h (to_resume, to_wait, to_post_wait)
	(to_post_startup_inferior, to_notice_signals, to_thread_alive)
	(to_pid_to_str [all in struct target_ops]): Likewise.
	(child_post_wait, child_thread_alive, normal_pid_to_str): Likewise.
	* thread-db.c (thread_from_lwp, lwp_from_thread, thread_db_wait)
	(attach_thread, detach_thread, thread_db_resume, check_event)
	(thread_db_post_startup_inferior, thread_db_thread_alive)
	(thread_db_pid_to_str): Likewise.
	* thread.c (add_thread, delete_thread, find_thread_pid)
	(pid_to_thread_id, in_thread_list, load_infrun_state)
	(save_infrun_state, switch_to_thread, restore_current_thread)
	(make_cleanup_restore_current_thread): Likewise.
	* top.c (target_wait_hook): Likewise.
	* uw-thread.c (dbgpid, thr_to_lwp, lwp_to_thr, add_thread_uw)
	(uw_thread_resume, libtrhead_stub, uw_thread_wait, uw_thread_alive)
	(uw_thread_pid_to_str): Likewise.
	* v850ice.c (v850ice_wait, v850ice_resume): Likewise.
	* win32-nat.c (child_wait, child_resume, win32_child_thread_alive)
	(cywin_pid_to_str): Likewise.
	* wince.c (child_wait, child_resume, win32_child_thread_alive):
	Likewise.
	* config/nm-linux.h (linuxthreads_pid_to_str): Likewise.
	* config/nm-lynx.h (child_wait, lynx_pid_to_str): Likewise.
	* config/alpha/nm-linux.h (lin_lwp_attach_lwp): Likewise.
	* config/arm/nm-linux.h (lin_lwp_attach_lwp): Likewise.
	* config/h8500/tm-h8500.h (h8500_read_pc, h8500_write_pc): Likewise.
	* config/i386/nm-i386sol2.h (procfs_stopped_by_watchpoint)
	(procfs_set_watchpoint): Likewise.
	* config/i386/nm-linux.h (lin_lwp_attach_lwp): Likewise.
	* config/i386/nm-ptx4.h (child_wait): Likewise.
	* config/i386/nm-symmetry.h (child_wait): Likewise.
	* config/i386/tm-cygwin.h (cygwin_pid_to_str): Likewise.
	* config/ia64/nm-linux.h (ia64_linux_stopped_by_watchpoint)
	(ia64_linux_insert_watchpoint, ia64_linux_remove_watchpoint)
	(lin_lwp_attach_lwp): Likewise.
	* config/mips/nm-irix4.h, config/mips/nm-irix5.h
	(procfs_stopped_by_watchpoint, procfs_set_watchpoint): Likewise.
	* config/pa/nm-hppah.h (child_pid_to_str, hppa_tid_to_str)
	(hppa_pid_or_tid_to_str): Likewise.
	* config/pa/tm-hppa.h (target_read_pc, target_write_pc): Likewise.
	* config/powerpc/nm-linux.h (lin_lwp_attach_lwp): Likewise.
	* config/sparc/nm-sun4sol2.h (procfs_stopped_by_watchpoint)
	(procfs_set_watchpoint): Likewise.

	* gdbthread.h (thread_id_to_pid): Change return type which
	represents a combined process/thread id from ``int'' to
	``ptid_t''.
	* gnu-nat.c (gnu_wait): Likewise.
	* go32-nat.c (go32_wait): Likewise.
	* hpux-thread.c (hpux_thread_wait): Likewise.
	* inferior.h (procfs_first_available): Likewise.
	* inftarg.c (child_wait): Likewise.
	* infttrace.c (ptrace_wait): Likewise.
	* lin-lwp.c (lin_lwp_wait): Likewise.
	* lin-thread.c (thread_db_wait): Likewise.
	* linux-thread.c (linuxthreads_wait): Likewise.
	* lynx-nat.c (child_wait): Likewise.
	* m3-nat.c (mach_really_wait): Likewise.
	* mac-nat.c (child_wait): Likewise.
	* monitor.c (monitor_wait): Likewise.
	* ppc-bdm.c (bdm_ppc_wait): Likewise.
	* procfs.c (do_attach, procfs_wait, procfs_first_available): Likewise.
	* remote-adapt.c (adapt_wait): Likewise.
	* remote-array.c (array_wait): Likewise.
	* remote-bug.c (bug_wait): Likewise.
	* remote-e7000.c (e7000_wait): Likewise.
	* remote-eb.c (eb_wait): Likewise.
	* remote-es.c (es1800_wait): Likewise.
	* remote-mips.c (mips_wait): Likewise.
	* remote-mm.c (mm_wait): Likewise.
	* remote-nindy.c (nindy_wait): Likewise.
	* remote-os9k (rombug_wait): Likewise.
	* remote-rdi.c (arm_rdi_wait): Likewise.
	* remote-rdp.c (remote_rdp_wait): Likewise.
	* remote-sds.c (sds_wait): Likewise.
	* remote-sim.c (gdbsim_wait): Likewise.
	* remote-st.c (st2000_wait): Likewise.
	* remote-udi.c (udi_wait): Likewise.
	* remote-vx.c (vx_wait): Likewise.
	* remote.c (remote_wait, remote_async_wait, remote_current_thread)
	(remote_cisco_wait): Likewise.
	* sol-thread.c (thread_to_lwp, lwp_to_thread, sol_thread_wait):
	Likewise.
	* symm-nat.c (child_wait): Likewise.
	* target.c (debug_to_wait): Likewise.
	* target.h (to_wait [in struct target_ops]): Likewise.
	* thread.c (thread_id_to_pid): Likewise.
	* thread-db.c (thread_from_lwp, lwp_from_thread, thread_db_wait):
	Likewise.
	* top.c (*target_wait_hook): Likewise.
	* uw-thread.c (lwp_to_thr, uw_thread_wait): Likewise.
	* v850ice.c (v850ice_wait): Likewise.
	* win32-nat.c (child_wait): Likewise.
	* wince.c (child_wait): Likewise.
	* config/nm-lynx.h (child_wait): Likewise.
	* config/i386/nm-ptx4.h (child_wait): Likewise.
	* config/i386/nm-symmetry.h (child_wait): Likewise.

	* arch-utils.c (generic_prepare_to_proceed): Rename wait_pid
	to wait_ptid and change its type from ``int'' to ``ptid_t''.
	* breakpoint.c (reattach_breakpoints, detach_breakpoints): Likewise,
	but rename saved_inferior_pid to saved_inferior_ptid.
	* d10v-tdep.c (d10v_read_pc, d10_write_pc): Likewise, but rename
	save_pid to save_ptid.
	* gdbthread.h (struct thread_info): Likewise, but rename pid to ptid.
	* hppah-nat.c (child_pid_to_exec): Likewise, but rename
	saved_inferior_pid to saved_inferior_ptid.
	* hpux-thread.c (main_ptid): Likewise, but rename from main_pid.
	* infrun.c (previous_inferior_pid [static global]): Likewise,
	but rename to previous_inferior_ptid.
	(resume): Likewise, but rename resume_pid to resume_ptid.
	(struct execution_control_state): Likewise, but rename
	pid to ptid, saved_inferior_pid to saved_inferior_ptid,
	and waiton_pid to waiton_ptid.
	(target_last_wait_pid): Likewise, but rename to
	target_last_wait_ptid.
	* infttrace.c (saved_real_pid): Likewise, but rename to
	saved_real_ptid.
	(child_pid_to_exec_file): Likewise, but rename saved_inferior_pid
	to saved_inferior_ptid.
	* lin-lwp.c (struct lwp_info): Likewise, but rename pid to ptid.
	(trap_ptid): Likewise, but renamed from trap_pid.
	* lin-thread.c (handle_new_thread): Likewise, but rename gdb_pid
	to gdb_ptid.
	* linux-thread.c (detach_thread): Likewise, but rename pid to ptid.
	(thread_db_wait): Likewise, but rename ret_pid to retptid.
	* procfs.c (procfs_wait): Likewise, for retval whose name
	doesn't change.  Also, ``temp'' becomes two separate variables,
	one named temp_tid (an int) and the other temp_ptid.
	(procfs_notice_thread): Likewise (type change) for gdb_threadid
	whose name does not change.
	* regcache.c (registers_ptid): Likewise, but renamed from
	registers_pid.
	(read_register_pid, read_signed_register_pid, write_register_pid):
	Likewise, but rename save_pid to save_ptid.
	(read_pc_pid, write_pc_pid): Likewise, but rename saved_inferior_pid
	to saved_inferior_ptid.
	* remote.c (remote_newthread_step): Likewise, but rename pid to ptid.
	* sol-thread.c (struct ps_prochandle): Likewise.
	(sol_thread_resume): Likewise, for save_pid which becomes save_ptid.
	(sol_thread_wait): Likewise, for rtnval whose name does not
	change, and for save_pid which becomes save_ptid.
	(solaris_pid_to_str): Likewise for lwp whose name does not change.
	(sol_find_new_threads_callback): Likewise, for pid which becomes
	ptid.
	* target.h (target_resume, target_wait, target_post_wait)
	(target_post_startup_inferior, target_notice_signals)
	(target_thread_alive): Likewise.
	* thread.c (info_threads_command): Likewise, but rename
	current_pid to current_ptid.
	(struct current_thread_cleanup): Likewise, but rename field
	inferior_pid to inferior_ptid.
	* thread-db.c (find_new_threads_callback): Likewise, but rename
	pid to ptid.
	* uw-thread.c (thr_to_lwp): Likewise for lid whose name does not
	change.
	(lwp_to_tr): Likewise fo tid whose name remains unchanged.
	(thr_infpid, lwp_infpid, notice_thread, libthread_stub): Likewise,
	but rename pid to ptid.
	* config/alpha/nm-linux.h (ATTACH_LWP): Likewise.
	* config/arm/nm-linux.h (ATTACH_LWP): Likewise.
	* config/i386/nm-linux.h (ATTACH_LWP): Likewise.
	* config/ia64/nm-linux.h (ATTACH_LWP): Likewise.
	* config/pa/nm-hppah.h (target_tid_to_str): Likewise.
	* config/powerpc/nm-linux.h (ATTACH_LWP): Likewise.

	* arch-utils.c (generic_prepare_to_proceed):  Test for the
	"zero" ptid by using ptid_equal() to test to see if variable
	in question is the same as null_ptid.  This replaces a direct
	test against zero.
	* cxux-nat.c (add_shared_symbol_files): Likewise.
	* i386aix-nat.c, i386b-nat.c (i386_float_info): Likewise.
	* infcmd.c (run_command): Likewise.
	* inflow.c (kill_command): Likewise.
	* infttrace.c (call_ttrace): Likewise.
	* lin-lwp.c (lin_lwp_prepare_to_proceed): Likewise.
	* lin-thread.c (thread_db_kill): Likewise.
	* procfs.c (procfs_kill_inferior, procfs_mourn_inferior): Likewise.
	* remote-es.c (es1800_kill): Likewise.
	* sol-thread.c (sol_thread_create_inferior): Likewise.
	* solib.c (locate_base): Likewise.
	* target.c (nosupport_runtime): Likewise.
	* thread-db.c (thread_db_wait): Likewise.
	* top.c (quit_confirm, quit_force): Likewise.
	* uw-thread (lwp_infpid, uw_thread_resume): Likewise.

	* infrun.c (handle_inferior_event, stop_stepping, normal_stop):
	Use ptid_equal to compare value of process/thread ids instead of
	``=='' and ``!='' operators.
	lin-lwp.c (delete_lwp, lin_lwp_prepare_to_proceed)
	(stop_wait_callback, lin_lwp_wait): Likewise.
	* procfs.c (procfs_wait): Likewise.
	* regcache.c (read_register_bytes, read_register_gen)
	(write_register_gen, read_register, read_register_pid)
	(read_signed_register, read_signed_register_pid, write_register)
	(write_register_pid, supply_register): Likewise.
	* remote-vx.c (vx_resume): Likewise.
	* sol-thread.c (sol_thread_wait): Likewise.
	* symm-nat.c (kill_inferior): Likewise.
	* thread.c (delete_thread, find_thread_pid, pid_to_thread_id)
	(in_thread_list, info_threads_command, switch_to_thread)
	(restore_current_thread): Likewise.
	* uw-thread (libtread_stub): Likewise.

	* arm-linux-nat.c (GET_THREAD_ID): Change PID to PTID.

	* corelow.c (add_to_thread_list): Convert argument in add_thread()
	call to a ptid_t.
	* gnu-nat.c (inf_validate_procs): Likewise.
	* linux-thread.c (stop_thread, update_stop_threads): Likewise.
	* remote.c (record_currthread, remote_threads_info): Likewise.
	* win32-nat.c (child_add_thread): Likewise.

	* hpux-thread.c (save_inferior_pid, restore_inferior_pid): Rename,
	respectively, to save_inferior_ptid() and restore_inferior_ptid().
	Adjust implementations to operate on ``ptid_t'' instead of ``int''.
	* lin-lwp.c (save_inferior_pid, restore_inferior_pid): Likewise.
	* lin-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
	* linux-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
	* proc-service.c (save_inferior_pid, restore_inferior_pid): Likewise.
	* sol-thread.c (save_inferior_pid, restore_inferior_pid): Likewise.
	* thread-db.c (save_inferior_pid, restore_inferior_pid): Likewise.

	* infrun.c (RESUME_ALL): New macro representing the -1 ptid
	to be passed to target_resume() when all threads should resume.
	(resume): Set resume_ptid to RESUME_ALL rather than -1.
	(handle_inferior_event): Invoke target_resume() with RESUME_ALL
	instead of -1.
	* irix5-nat.c (solib_create_inferior_hook): Convert -1 to
	a ptid_t in target_resume() call.
	* osfsolib.c (solib_create_inferior_hook): Likewise.
	* solib-svr4.c (solib_create_inferior_hook): Likewise.

	* lin-lwp.c (PIDGET, PIDGET0): Rename original PIDGET macro to
	PIDGET0.  Define new PIDGET macro which uses PIDGET0, the only
	difference being that the 0xffff pattern will be interpreted
	as -1.
	* lin-thread.c (PIDGET, PIDGET0): Likewise.
	* thread-db.c (PIDGET, PIDGET0): Likewise.
	* config/nm-linux.h (PIDGET, PIDGET0): Likewise.
	* config/i386/tm-i386sol2.h (PIDGET, PIDGET0): Likewise.
	* config/i386/tm-i386v42mp.h (PIDGET, PIDGET0): Likewise.
	* config/sparc/tm-sun4sol2.h (PIDGET, PIDGET0): Likewise.

	* m3-nat.c (init_m3_ops): Fix typo; initialize to_wait field to
	mach_really_wait rather than mach_really__wait.
	* lin-thread.c (check_for_thread_event): Fix warning; make function
	actually return a value.

	* gdbarch.sh (TARGET_READ_PC, TARGET_WRITE_PC): Change type of
	``pid'' arguments from ``int'' to ``ptid_t''.  Also renamed
	pid to ptid.
	* gdbarch.h, gdbarch.c: Regenerated.

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/30 08:36:24
@@ -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/30 08:36:25
@@ -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/30 08:36:25
@@ -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/30 08:36:26
@@ -78,7 +78,7 @@ 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
+   case, inferior_ptid 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.  */
@@ -89,13 +89,14 @@ static unsigned int os_version, os_major
 #endif
 
 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 +231,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 +280,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 +328,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 +366,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 +404,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 +441,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 +475,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 +503,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/30 08:36:27
@@ -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/30 08:36:37
@@ -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;
+  ptid_t saved_inferior_ptid = inferior_ptid;
 
-  /* FIXME: use a cleanup, to insure that inferior_pid gets replaced! */
-  inferior_pid = pid;	/* Because remove_breakpoint will use this global. */
+  /* FIXME: use a cleanup, to insure that inferior_ptid gets replaced! */
+  inferior_ptid = pid_to_ptid (pid);	/* Because remove_breakpoint will use this global. */
   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;
+	    inferior_ptid = saved_inferior_ptid;
 	    return val;
 	  }
       }
   }
-  inferior_pid = saved_inferior_pid;
+  inferior_ptid = saved_inferior_ptid;
   return 0;
 }
 
@@ -1205,13 +1205,13 @@ detach_breakpoints (int pid)
 {
   register struct breakpoint *b;
   int val;
-  int saved_inferior_pid = inferior_pid;
+  ptid_t saved_inferior_ptid = 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. */
+  /* FIXME: use a cleanup, to insure that inferior_ptid gets replaced! */
+  inferior_ptid = pid_to_ptid (pid);	/* Because remove_breakpoint will use this global. */
   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;
+	    inferior_ptid = saved_inferior_ptid;
 	    return val;
 	  }
       }
   }
-  inferior_pid = saved_inferior_pid;
+  inferior_ptid = saved_inferior_ptid;
   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/30 08:36:39
@@ -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/30 08:36:39
@@ -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,20 @@ 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 */
+#ifdef pid_to_ptid
+    /* Needed to prevent regressions in ptid conversion phase 1.  This
+       bit of code will be deleted in favor of the #else branch in
+       phase 3.  */
+    inferior_ptid = thread_id;	/* Yes, make it current */
+#else
+    inferior_ptid = pid_to_ptid (thread_id);	/* Yes, make it current */
+#endif
 }
 
 /* This routine opens and sets up the core file bfd.  */
@@ -384,10 +391,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 +413,16 @@ get_core_register_section (char *name,
   bfd_size_type size;
   char *contents;
 
-  if (inferior_pid)
-    sprintf (section_name, "%s/%d", name, inferior_pid);
+#ifdef pid_to_ptid
+    /* Needed to prevent regressions in ptid conversion phase 1.  This
+       bit of code will be deleted in favor of the #else branch in
+       phase 3.  */
+  if (inferior_ptid)
+    sprintf (section_name, "%s/%d", name, inferior_ptid);
+#else
+  if (PIDGET (inferior_ptid))
+    sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid));
+#endif
   else
     strcpy (section_name, name);
 
@@ -485,7 +500,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/30 08:36:40
@@ -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/30 08:36:43
@@ -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/30 08:36:43
@@ -843,6 +843,38 @@ 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.
+
+   The present typedef is obviously quite naive with respect to
+   the magnitudes that real life pids and tids can take on and
+   will be replaced with something more robust shortly.  */
+
+typedef int ptid_t;
+
+/* Convert a pid to a ptid_t.  This macro is temporary and will
+   be replaced shortly.  */
+
+#define pid_to_ptid(PID) ((ptid_t) MERGEPID ((PID),0))
+
+/* Define a value for the null (or zero) pid.  This macro is temporary
+   and will go away shortly.  */
+
+#define null_ptid (pid_to_ptid (0))
+
+/* Define a value for the -1 pid.  This macro is temporary and will go
+   away shortly.  */
+
+#define minus_one_ptid (pid_to_ptid (-1))
+
+/* Define a ptid comparison operator.  This macro is temporary and will
+   be replaced with a real function shortly.  */
+
+#define ptid_equal(PTID1,PTID2) ((PTID1) == (PTID2))
+
 
 
 /* Optional host machine definition.  Pure autoconf targets will not
@@ -1302,7 +1334,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);
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/30 08:36:43
@@ -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/30 08:36:44
@@ -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/30 08:36:44
@@ -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/30 08:36:44
@@ -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/30 08:36:46
@@ -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/30 08:36:47
@@ -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/30 08:36:48
@@ -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/30 08:36:48
@@ -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/30 08:36:50
@@ -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/30 08:36:50
@@ -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/30 08:36:51
@@ -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/30 08:36:51
@@ -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/30 08:36:54
@@ -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/30 08:36:54
@@ -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/30 08:36:55
@@ -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/30 08:36:55
@@ -57,16 +57,17 @@ 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 struct cleanup *save_inferior_ptid (void);
 
-static void restore_inferior_pid (int pid);
+static void restore_inferior_ptid (ptid_t pid);
 
-static void hpux_thread_resume (int pid, int step, enum target_signal signo);
+static void hpux_thread_resume (ptid_t ptid, int step,
+                                enum target_signal signo);
 
 static void init_hpux_thread_ops (void);
 
@@ -76,40 +77,40 @@ 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
+   save_inferior_ptid - Save inferior_ptid on the cleanup list
+   restore_inferior_ptid - Restore inferior_ptid from the cleanup list
 
    SYNOPSIS
 
-   struct cleanup *save_inferior_pid ()
-   void restore_inferior_pid (int pid)
+   struct cleanup *save_inferior_ptid ()
+   void restore_inferior_ptid (int pid)
 
    DESCRIPTION
 
-   These two functions act in unison to restore inferior_pid in
+   These two functions act in unison to restore inferior_ptid in
    case of an error.
 
    NOTES
 
-   inferior_pid is a global variable that needs to be changed by many of
+   inferior_ptid 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
+   guarantee that inferior_ptid gets restored (in case of errors), you
+   need to call save_inferior_ptid before changing it.  At the end of the
    function, you should invoke do_cleanups to restore it.
 
  */
 
 
 static struct cleanup *
-save_inferior_pid (void)
+save_inferior_ptid (void)
 {
-  return make_cleanup (restore_inferior_pid, inferior_pid);
+  return make_cleanup (restore_inferior_ptid, inferior_ptid);
 }
 
 static void
-restore_inferior_pid (int pid)
+restore_inferior_ptid (ptid_t ptid)
 {
-  inferior_pid = pid;
+  inferior_ptid = ptid;
 }
 
 static int find_active_thread (void);
@@ -133,7 +134,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 +216,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 +234,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 +245,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 +301,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 +363,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 +444,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 +471,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 +485,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 +557,7 @@ hpux_thread_can_run (void)
 }
 
 static int
-hpux_thread_alive (int pid)
+hpux_thread_alive (ptid_t ptid)
 {
   return 1;
 }
@@ -568,9 +571,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/30 08:36:56
@@ -63,7 +63,7 @@ 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
+   case, inferior_ptid 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.  */
@@ -198,8 +198,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 +261,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 +597,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 +663,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 +710,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 +738,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 +879,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 +910,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/30 08:36:56
@@ -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/30 08:36:56
@@ -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/30 08:36:56
@@ -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/30 08:36:56
@@ -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/30 08:36:56
@@ -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/30 08:36:56
@@ -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/30 08:36:57
@@ -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/30 08:36:58
@@ -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/30 08:36:59
@@ -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/30 08:37:00
@@ -63,9 +63,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 +79,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 +123,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_writ