From 39f770628a4eaf018fec8d55684bf2ec16ada9cc Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Fri, 4 May 2001 04:15:33 +0000 Subject: Phase 1 of the ptid_t changes. --- gdb/ChangeLog | 380 +++++++++++++++++++++++++++++++++++++++++ gdb/a68v-nat.c | 16 +- gdb/alphabsd-nat.c | 15 +- gdb/arch-utils.c | 11 +- gdb/arm-linux-nat.c | 27 +-- gdb/blockframe.c | 4 +- gdb/breakpoint.c | 80 +++++---- gdb/breakpoint.h | 4 +- gdb/config/alpha/nm-linux.h | 4 +- gdb/config/arm/nm-linux.h | 4 +- gdb/config/h8500/tm-h8500.h | 4 +- gdb/config/i386/nm-i386sol2.h | 10 +- gdb/config/i386/nm-linux.h | 4 +- gdb/config/i386/nm-ptx4.h | 2 +- gdb/config/i386/nm-symmetry.h | 2 +- gdb/config/i386/tm-cygwin.h | 2 +- gdb/config/i386/tm-i386sco5.h | 6 +- gdb/config/i386/tm-i386sol2.h | 3 +- gdb/config/i386/tm-i386v42mp.h | 3 +- gdb/config/ia64/nm-linux.h | 17 +- gdb/config/m68k/nm-hp300bsd.h | 2 +- gdb/config/mips/nm-irix4.h | 10 +- gdb/config/mips/nm-irix5.h | 10 +- gdb/config/nm-linux.h | 5 +- gdb/config/nm-lynx.h | 5 +- gdb/config/pa/nm-hppah.h | 14 +- gdb/config/pa/tm-hppa.h | 6 +- gdb/config/powerpc/nm-linux.h | 4 +- gdb/config/rs6000/nm-rs6000.h | 4 +- gdb/config/sparc/nm-sun4sol2.h | 10 +- gdb/config/sparc/tm-sun4sol2.h | 3 +- gdb/corelow.c | 35 ++-- gdb/cxux-nat.c | 70 ++++---- gdb/d10v-tdep.c | 20 +-- gdb/defs.h | 35 +++- gdb/dink32-rom.c | 4 +- gdb/dve3900-rom.c | 2 +- gdb/fork-child.c | 10 +- gdb/frame.c | 2 +- gdb/gdbarch.c | 16 +- gdb/gdbarch.h | 16 +- gdb/gdbarch.sh | 4 +- gdb/gdbthread.h | 18 +- gdb/gnu-nat.c | 51 +++--- gdb/go32-nat.c | 14 +- gdb/h8500-tdep.c | 4 +- gdb/hp300ux-nat.c | 17 +- gdb/hppa-tdep.c | 48 +++--- gdb/hppab-nat.c | 11 +- gdb/hppah-nat.c | 54 +++--- gdb/hpux-thread.c | 92 +++++----- gdb/i386-linux-nat.c | 35 ++-- gdb/i386aix-nat.c | 18 +- gdb/i386b-nat.c | 12 +- gdb/i386bsd-nat.c | 23 ++- gdb/i386gnu-nat.c | 8 +- gdb/i386mach-nat.c | 21 ++- gdb/i386nbsd-nat.c | 8 +- gdb/ia64-linux-nat.c | 54 +++--- gdb/ia64-tdep.c | 14 +- gdb/infcmd.c | 8 +- gdb/inferior.h | 26 +-- gdb/inflow.c | 14 +- gdb/infptrace.c | 44 ++--- gdb/infrun.c | 209 ++++++++++++----------- gdb/inftarg.c | 74 ++++---- gdb/infttrace.c | 104 +++++------ gdb/irix5-nat.c | 2 +- gdb/lin-lwp.c | 220 +++++++++++++----------- gdb/lin-thread.c | 237 ++++++++++++------------- gdb/linux-thread.c | 191 +++++++++++---------- gdb/lynx-nat.c | 74 ++++---- gdb/m3-nat.c | 54 +++--- gdb/m32r-rom.c | 6 +- gdb/m68knbsd-nat.c | 8 +- gdb/m88k-nat.c | 26 +-- gdb/mac-nat.c | 23 +-- gdb/mips-nat.c | 4 +- gdb/mips-tdep.c | 4 +- gdb/mon960-rom.c | 4 +- gdb/monitor.c | 16 +- gdb/ns32knbsd-nat.c | 8 +- gdb/ocd.c | 8 +- gdb/ocd.h | 4 +- gdb/osfsolib.c | 2 +- gdb/ppc-bdm.c | 11 +- gdb/ppcnbsd-nat.c | 8 +- gdb/proc-service.c | 36 ++-- gdb/procfs.c | 222 ++++++++++++------------ gdb/ptx4-nat.c | 4 +- gdb/regcache.c | 102 +++++------ gdb/regcache.h | 6 +- gdb/remote-adapt.c | 10 +- gdb/remote-array.c | 13 +- gdb/remote-bug.c | 10 +- gdb/remote-e7000.c | 10 +- gdb/remote-eb.c | 6 +- gdb/remote-es.c | 24 +-- gdb/remote-mips.c | 20 ++- gdb/remote-mm.c | 10 +- gdb/remote-nindy.c | 10 +- gdb/remote-os9k.c | 8 +- gdb/remote-rdi.c | 21 +-- gdb/remote-rdp.c | 10 +- gdb/remote-sds.c | 18 +- gdb/remote-sim.c | 22 +-- gdb/remote-st.c | 8 +- gdb/remote-udi.c | 20 +-- gdb/remote-vx.c | 55 +++--- gdb/remote.c | 104 +++++------ gdb/rs6000-nat.c | 27 +-- gdb/sol-thread.c | 267 ++++++++++++++--------------- gdb/solib-aix5.c | 10 +- gdb/solib-svr4.c | 4 +- gdb/somsolib.c | 12 +- gdb/sparc-nat.c | 8 +- gdb/standalone.c | 4 +- gdb/sun3-nat.c | 8 +- gdb/sun386-nat.c | 18 +- gdb/symm-nat.c | 53 +++--- gdb/target.c | 74 ++++---- gdb/target.h | 52 +++--- gdb/thread-db.c | 185 ++++++++++---------- gdb/thread.c | 118 ++++++------- gdb/top.c | 7 +- gdb/ultra3-nat.c | 12 +- gdb/uw-thread.c | 161 ++++++++--------- gdb/v850ice.c | 20 ++- gdb/win32-nat.c | 51 +++--- gdb/wince.c | 36 ++-- gdb/windows-nat.c | 51 +++--- gdb/xcoffsolib.c | 8 +- 132 files changed, 2659 insertions(+), 2052 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5d09573..bf35ec0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,383 @@ +2001-05-03 Kevin Buettner + + * 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. + 2001-05-03 Jonathan Larmour * rdi-share/devsw.c: Include for struct tm diff --git a/gdb/a68v-nat.c b/gdb/a68v-nat.c index 851c0fc..4cc25ce 100644 --- a/gdb/a68v-nat.c +++ b/gdb/a68v-nat.c @@ -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 *) ®isters[REGISTER_BYTE (PS_REGNUM)]; inferior_control_registers.pc = *(int *) ®isters[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, diff --git a/gdb/alphabsd-nat.c b/gdb/alphabsd-nat.c index e77b31b..5e7a361 100644 --- a/gdb/alphabsd-nat.c +++ b/gdb/alphabsd-nat.c @@ -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"); } diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c index 0fde5db..2b9325e 100644 --- a/gdb/arch-utils.c +++ b/gdb/arch-utils.c @@ -252,11 +252,11 @@ default_prepare_to_proceed (int select_it) 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_it) 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_it) { /* 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). */ diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 5d1487e..96c7834 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -78,7 +78,7 @@ static unsigned int os_version, os_major, os_minor, os_release; /* 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, os_minor, os_release; #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, ®s); 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, ®s); 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, ®s); @@ -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, ®s); diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 94ccb29..d35c24a 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -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); } diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 2d18f9d..805079f 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -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, insertion_state_t is) 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 not_a_breakpoint) 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 not_a_breakpoint) 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 ep_list, bpstat *cp_list) 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_and_line sal, struct frame_info *frame, /* 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 accessflag, int from_tty) 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 tempflag, int from_tty) /* 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 tempflag, int from_tty) /* 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); } } diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index c89058c..cd9d1b7 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -521,7 +521,7 @@ extern int breakpoint_inserted_here_p (CORE_ADDR); 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_exec (void); 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); diff --git a/gdb/config/alpha/nm-linux.h b/gdb/config/alpha/nm-linux.h index d50d977..2cb2db6 100644 --- a/gdb/config/alpha/nm-linux.h +++ b/gdb/config/alpha/nm-linux.h @@ -74,8 +74,8 @@ extern int lin_lwp_prepare_to_proceed (void); #undef PREPARE_TO_PROCEED #define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed () -extern void lin_lwp_attach_lwp (int pid, int verbose); -#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose)) +extern void lin_lwp_attach_lwp (ptid_t pid, int verbose); +#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose)) #include diff --git a/gdb/config/arm/nm-linux.h b/gdb/config/arm/nm-linux.h index 3de162e..ce4e5ff 100644 --- a/gdb/config/arm/nm-linux.h +++ b/gdb/config/arm/nm-linux.h @@ -38,8 +38,8 @@ extern int lin_lwp_prepare_to_proceed (void); #undef PREPARE_TO_PROCEED #define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed () -extern void lin_lwp_attach_lwp (int pid, int verbose); -#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose)) +extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose); +#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose)) #include diff --git a/gdb/config/h8500/tm-h8500.h b/gdb/config/h8500/tm-h8500.h index 846401b..f040680 100644 --- a/gdb/config/h8500/tm-h8500.h +++ b/gdb/config/h8500/tm-h8500.h @@ -283,8 +283,8 @@ extern void h8500_write_sp (CORE_ADDR); extern CORE_ADDR h8500_read_fp (void); extern void h8500_write_fp (CORE_ADDR); -extern CORE_ADDR h8500_read_pc (int); -extern void h8500_write_pc (CORE_ADDR, int); +extern CORE_ADDR h8500_read_pc (ptid_t); +extern void h8500_write_pc (CORE_ADDR, ptid_t); #define TARGET_READ_SP() h8500_read_sp() #define TARGET_WRITE_SP(x) h8500_write_sp(x) diff --git a/gdb/config/i386/nm-i386sol2.h b/gdb/config/i386/nm-i386sol2.h index 68e890d..0e6b3ef 100644 --- a/gdb/config/i386/nm-i386sol2.h +++ b/gdb/config/i386/nm-i386sol2.h @@ -44,17 +44,17 @@ step anyway. */ #define CANNOT_STEP_HW_WATCHPOINTS -extern int procfs_stopped_by_watchpoint (int); +extern int procfs_stopped_by_watchpoint (ptid_t); #define STOPPED_BY_WATCHPOINT(W) \ - procfs_stopped_by_watchpoint(inferior_pid) + procfs_stopped_by_watchpoint(inferior_ptid) /* Use these macros for watchpoint insertion/deletion. */ /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ -extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int); +extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int); #define target_insert_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1) + procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1) #define target_remove_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0) + procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0) #endif /* NEW_PROC_API */ diff --git a/gdb/config/i386/nm-linux.h b/gdb/config/i386/nm-linux.h index dcdbc03..1ba216b 100644 --- a/gdb/config/i386/nm-linux.h +++ b/gdb/config/i386/nm-linux.h @@ -90,8 +90,8 @@ extern int lin_lwp_prepare_to_proceed (void); #undef PREPARE_TO_PROCEED #define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed () -extern void lin_lwp_attach_lwp (int pid, int verbose); -#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose)) +extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose); +#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose)) #include diff --git a/gdb/config/i386/nm-ptx4.h b/gdb/config/i386/nm-ptx4.h index 2f0d2da..32b76d2 100644 --- a/gdb/config/i386/nm-ptx4.h +++ b/gdb/config/i386/nm-ptx4.h @@ -42,7 +42,7 @@ #define CHILD_WAIT struct target_waitstatus; -extern int child_wait (int, struct target_waitstatus *); +extern ptid_t child_wait (ptid_t, struct target_waitstatus *); /* * ptx does attach as of ptx version 2.1. Prior to that, the interface diff --git a/gdb/config/i386/nm-symmetry.h b/gdb/config/i386/nm-symmetry.h index da9ed81..a589a3d 100644 --- a/gdb/config/i386/nm-symmetry.h +++ b/gdb/config/i386/nm-symmetry.h @@ -32,7 +32,7 @@ #ifdef _SEQUENT_ #define CHILD_WAIT -extern int child_wait (int, struct target_waitstatus *); +extern ptid_t child_wait (ptid_t, struct target_waitstatus *); #endif /* This is the amount to subtract from u.u_ar0 diff --git a/gdb/config/i386/tm-cygwin.h b/gdb/config/i386/tm-cygwin.h index b66e3c7..287b8e0 100644 --- a/gdb/config/i386/tm-cygwin.h +++ b/gdb/config/i386/tm-cygwin.h @@ -38,7 +38,7 @@ extern CORE_ADDR skip_trampoline_code (CORE_ADDR pc, char *name); #define ADD_SHARED_SYMBOL_FILES dll_symbol_command struct target_ops; -char *cygwin_pid_to_str (int pid); +char *cygwin_pid_to_str (ptid_t ptid); void child_solib_add (char *, int, struct target_ops *); char *child_solib_loaded_library_pathname(int); void child_clear_solibs (void); diff --git a/gdb/config/i386/tm-i386sco5.h b/gdb/config/i386/tm-i386sco5.h index 0fcf177..e4cb014 100644 --- a/gdb/config/i386/tm-i386sco5.h +++ b/gdb/config/i386/tm-i386sco5.h @@ -52,12 +52,12 @@ #define HAVE_STEPPABLE_WATCHPOINT #define STOPPED_BY_WATCHPOINT(W) \ - i386_stopped_by_watchpoint (inferior_pid) + i386_stopped_by_watchpoint (PIDGET (inferior_ptid)) #define target_insert_watchpoint(addr, len, type) \ - i386_insert_watchpoint (inferior_pid, addr, len, type) + i386_insert_watchpoint (PIDGET (inferior_ptid), addr, len, type) #define target_remove_watchpoint(addr, len, type) \ - i386_remove_watchpoint (inferior_pid, addr, len) + i386_remove_watchpoint (PIDGET (inferior_ptid), addr, len) #endif /* ifndef TM_I386SCO5_H */ diff --git a/gdb/config/i386/tm-i386sol2.h b/gdb/config/i386/tm-i386sol2.h index 50d869d..f3ebcd9 100644 --- a/gdb/config/i386/tm-i386sol2.h +++ b/gdb/config/i386/tm-i386sol2.h @@ -54,7 +54,8 @@ extern char *sunpro_static_transform_name (char *); /* Macros to extract process id and thread id from a composite pid/tid. Allocate lower 16 bits for process id, next 15 bits for thread id, and one bit for a flag to indicate a user thread vs. a kernel thread. */ -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) diff --git a/gdb/config/i386/tm-i386v42mp.h b/gdb/config/i386/tm-i386v42mp.h index e6588e4..e70bc4d 100644 --- a/gdb/config/i386/tm-i386v42mp.h +++ b/gdb/config/i386/tm-i386v42mp.h @@ -43,7 +43,8 @@ #define PIDBITS 16 /* Return the process id stored in composite PID. */ -#define PIDGET(PID) (((PID) & ((1 << PIDBITS) - 1))) +#define PIDGET0(PID) (((PID) & ((1 << PIDBITS) - 1))) +#define PIDGET(PID) ((PIDGET0 (PID) == ((1 << PIDBITS) -1)) ? -1 : PIDGET0 (PID)) /* Return the thread or lwp id stored in composite PID. */ #define TIDGET(PID) (((PID) & 0x3fffffff) >> PIDBITS) diff --git a/gdb/config/ia64/nm-linux.h b/gdb/config/ia64/nm-linux.h index 232db3c..3d55b36 100644 --- a/gdb/config/ia64/nm-linux.h +++ b/gdb/config/ia64/nm-linux.h @@ -63,17 +63,18 @@ extern int ia64_register_u_addr(int, int); #define HAVE_STEPPABLE_WATCHPOINT 1 #define STOPPED_BY_WATCHPOINT(W) \ - ia64_linux_stopped_by_watchpoint (inferior_pid) -extern CORE_ADDR ia64_linux_stopped_by_watchpoint (int); + ia64_linux_stopped_by_watchpoint (inferior_ptid) +extern CORE_ADDR ia64_linux_stopped_by_watchpoint (ptid_t ptid); #define target_insert_watchpoint(addr, len, type) \ - ia64_linux_insert_watchpoint (inferior_pid, addr, len, type) -extern int ia64_linux_insert_watchpoint (int pid, CORE_ADDR addr, + ia64_linux_insert_watchpoint (inferior_ptid, addr, len, type) +extern int ia64_linux_insert_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rw); #define target_remove_watchpoint(addr, len, type) \ - ia64_linux_remove_watchpoint (inferior_pid, addr, len) -extern int ia64_linux_remove_watchpoint (int pid, CORE_ADDR addr, int len); + ia64_linux_remove_watchpoint (inferior_ptid, addr, len) +extern int ia64_linux_remove_watchpoint (ptid_t ptid, CORE_ADDR addr, + int len); /* FIXME: kettenis/2000-09-03: This should be moved to ../nm-linux.h once we have converted all Linux targets to use the new threads @@ -83,8 +84,8 @@ extern int lin_lwp_prepare_to_proceed (void); #undef PREPARE_TO_PROCEED #define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed () -extern void lin_lwp_attach_lwp (int pid, int verbose); -#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose)) +extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose); +#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose)) #include diff --git a/gdb/config/m68k/nm-hp300bsd.h b/gdb/config/m68k/nm-hp300bsd.h index 2e1b69e..e0f7a11 100644 --- a/gdb/config/m68k/nm-hp300bsd.h +++ b/gdb/config/m68k/nm-hp300bsd.h @@ -40,7 +40,7 @@ /* U_REGS_OFFSET is the offset of the registers within the u area for ptrace purposes. */ #define U_REGS_OFFSET \ - ptrace (PT_READ_U, inferior_pid, \ + ptrace (PT_READ_U, PIDGET (inferior_ptid), \ (PTRACE_ARG3_TYPE) \ (offsetof (struct user, u_kproc.kp_proc.p_md.md_regs)), 0) \ - USRSTACK diff --git a/gdb/config/mips/nm-irix4.h b/gdb/config/mips/nm-irix4.h index 894d33f..9c02eb3 100644 --- a/gdb/config/mips/nm-irix4.h +++ b/gdb/config/mips/nm-irix4.h @@ -51,17 +51,17 @@ GDB to step over the watchpoint. */ #define STOPPED_BY_WATCHPOINT(W) \ - procfs_stopped_by_watchpoint(inferior_pid) -extern int procfs_stopped_by_watchpoint (int); + procfs_stopped_by_watchpoint(inferior_ptid) +extern int procfs_stopped_by_watchpoint (ptid_t); #define HAVE_NONSTEPPABLE_WATCHPOINT /* Use these macros for watchpoint insertion/deletion. */ /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ #define target_insert_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 0) + procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0) #define target_remove_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0) -extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int); + procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0) +extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int); #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1 diff --git a/gdb/config/mips/nm-irix5.h b/gdb/config/mips/nm-irix5.h index 1b22e17..bed3144 100644 --- a/gdb/config/mips/nm-irix5.h +++ b/gdb/config/mips/nm-irix5.h @@ -31,17 +31,17 @@ GDB to step over the watchpoint. */ #define STOPPED_BY_WATCHPOINT(W) \ - procfs_stopped_by_watchpoint(inferior_pid) -extern int procfs_stopped_by_watchpoint (int); + procfs_stopped_by_watchpoint(inferior_ptid) +extern int procfs_stopped_by_watchpoint (ptid_t); #define HAVE_NONSTEPPABLE_WATCHPOINT /* Use these macros for watchpoint insertion/deletion. */ /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ #define target_insert_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 0) + procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 0) #define target_remove_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0) -extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int); + procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0) +extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int); #define TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT(SIZE) 1 diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h index 131fd50..19d6857 100644 --- a/gdb/config/nm-linux.h +++ b/gdb/config/nm-linux.h @@ -41,7 +41,7 @@ struct objfile; extern void linuxthreads_new_objfile (struct objfile *objfile); /* Method to print a human-readable thread description */ -extern char *linuxthreads_pid_to_str (int pid); +extern char *linuxthreads_pid_to_str (ptid_t ptid); extern int linuxthreads_prepare_to_proceed (int step); #define PREPARE_TO_PROCEED(select_it) linuxthreads_prepare_to_proceed (1) @@ -52,7 +52,8 @@ extern int linuxthreads_prepare_to_proceed (int step); /* Macros to extract process id and thread id from a composite pid/tid. Allocate lower 19 bits for process id, next 12 bits for thread id, and one bit for a flag to indicate a user thread vs. a kernel thread. */ -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) diff --git a/gdb/config/nm-lynx.h b/gdb/config/nm-lynx.h index 034d2a0..1cd2bd1 100644 --- a/gdb/config/nm-lynx.h +++ b/gdb/config/nm-lynx.h @@ -71,7 +71,8 @@ #include "target.h" -extern int child_wait (int pid, struct target_waitstatus *status); +extern ptid_t child_wait (ptid_t ptid, + struct target_waitstatus *status); /* Lynx needs a special definition of this so that we can print out the pid and thread number seperately. */ @@ -79,6 +80,6 @@ extern int child_wait (int pid, struct target_waitstatus *status); /* override child_pid_to_str in inftarg.c */ #define CHILD_PID_TO_STR -extern char *lynx_pid_to_str (int pid); +extern char *lynx_pid_to_str (ptid_t ptid); #endif /* NM_LYNX_H */ diff --git a/gdb/config/pa/nm-hppah.h b/gdb/config/pa/nm-hppah.h index f03a52b..4894a04 100644 --- a/gdb/config/pa/nm-hppah.h +++ b/gdb/config/pa/nm-hppah.h @@ -219,21 +219,21 @@ extern void hppa_disable_page_protection_events (int); /* Use these macros for watchpoint insertion/deletion. */ #define target_insert_watchpoint(addr, len, type) \ - hppa_insert_hw_watchpoint (inferior_pid, addr, (LONGEST)(len), type) + hppa_insert_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type) #define target_remove_watchpoint(addr, len, type) \ - hppa_remove_hw_watchpoint (inferior_pid, addr, (LONGEST)(len), type) + hppa_remove_hw_watchpoint (PIDGET (inferior_ptid), addr, (LONGEST)(len), type) /* We call our k-thread processes "threads", rather * than processes. So we need a new way to print * the string. Code is in hppah-nat.c. */ -extern char *child_pid_to_str (pid_t); +extern char *child_pid_to_str (ptid_t); -#define target_tid_to_str( pid ) \ - hppa_tid_to_str( pid ) -extern char *hppa_tid_to_str (pid_t); +#define target_tid_to_str( ptid ) \ + hppa_tid_to_str( ptid ) +extern char *hppa_tid_to_str (ptid_t); /* For this, ID can be either a process or thread ID, and the function will describe it appropriately, returning the description as a printable @@ -244,7 +244,7 @@ extern char *hppa_tid_to_str (pid_t); */ #define target_pid_or_tid_to_str(ID) \ hppa_pid_or_tid_to_str (ID) -extern char *hppa_pid_or_tid_to_str (pid_t); +extern char *hppa_pid_or_tid_to_str (ptid_t); /* This is used when handling events caused by a call to vfork(). On ptrace- based HP-UXs, when you resume the vforked child, the parent automagically diff --git a/gdb/config/pa/tm-hppa.h b/gdb/config/pa/tm-hppa.h index 4067ed3..65b2bbf 100644 --- a/gdb/config/pa/tm-hppa.h +++ b/gdb/config/pa/tm-hppa.h @@ -767,12 +767,12 @@ extern CORE_ADDR skip_trampoline_code (CORE_ADDR, char *); #endif #define TARGET_READ_PC(pid) target_read_pc (pid) -extern CORE_ADDR target_read_pc (int); +extern CORE_ADDR target_read_pc (ptid_t); #define TARGET_WRITE_PC(v,pid) target_write_pc (v,pid) -extern void target_write_pc (CORE_ADDR, int); +extern void target_write_pc (CORE_ADDR, ptid_t); -#define TARGET_READ_FP() target_read_fp (inferior_pid) +#define TARGET_READ_FP() target_read_fp (PIDGET (inferior_ptid)) extern CORE_ADDR target_read_fp (int); /* For a number of horrible reasons we may have to adjust the location diff --git a/gdb/config/powerpc/nm-linux.h b/gdb/config/powerpc/nm-linux.h index b0e8a2b..f37c58c 100644 --- a/gdb/config/powerpc/nm-linux.h +++ b/gdb/config/powerpc/nm-linux.h @@ -45,8 +45,8 @@ extern int lin_lwp_prepare_to_proceed (void); #undef PREPARE_TO_PROCEED #define PREPARE_TO_PROCEED(select_it) lin_lwp_prepare_to_proceed () -extern void lin_lwp_attach_lwp (int pid, int verbose); -#define ATTACH_LWP(pid, verbose) lin_lwp_attach_lwp ((pid), (verbose)) +extern void lin_lwp_attach_lwp (ptid_t ptid, int verbose); +#define ATTACH_LWP(ptid, verbose) lin_lwp_attach_lwp ((ptid), (verbose)) #include diff --git a/gdb/config/rs6000/nm-rs6000.h b/gdb/config/rs6000/nm-rs6000.h index e4ee51c..441b381 100644 --- a/gdb/config/rs6000/nm-rs6000.h +++ b/gdb/config/rs6000/nm-rs6000.h @@ -44,9 +44,9 @@ and figure out where the shared libraries have got to. */ #define SOLIB_ADD(a, b, c) \ - if (inferior_pid) \ + if (PIDGET (inferior_ptid)) \ /* Attach to process. */ \ - xcoff_relocate_symtab (inferior_pid); \ + xcoff_relocate_symtab (PIDGET (inferior_ptid)); \ else \ /* Core file. */ \ xcoff_relocate_core (c); diff --git a/gdb/config/sparc/nm-sun4sol2.h b/gdb/config/sparc/nm-sun4sol2.h index 51b5471..adc8231 100644 --- a/gdb/config/sparc/nm-sun4sol2.h +++ b/gdb/config/sparc/nm-sun4sol2.h @@ -53,17 +53,17 @@ It will *NOT* be necessary for GDB to step over the watchpoint. */ #define HAVE_CONTINUABLE_WATCHPOINT -extern int procfs_stopped_by_watchpoint (int); +extern int procfs_stopped_by_watchpoint (ptid_t); #define STOPPED_BY_WATCHPOINT(W) \ - procfs_stopped_by_watchpoint(inferior_pid) + procfs_stopped_by_watchpoint(inferior_ptid) /* Use these macros for watchpoint insertion/deletion. */ /* type can be 0: write watch, 1: read watch, 2: access watch (read/write) */ -extern int procfs_set_watchpoint (int, CORE_ADDR, int, int, int); +extern int procfs_set_watchpoint (ptid_t, CORE_ADDR, int, int, int); #define target_insert_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, LEN, TYPE, 1) + procfs_set_watchpoint (inferior_ptid, ADDR, LEN, TYPE, 1) #define target_remove_watchpoint(ADDR, LEN, TYPE) \ - procfs_set_watchpoint (inferior_pid, ADDR, 0, 0, 0) + procfs_set_watchpoint (inferior_ptid, ADDR, 0, 0, 0) #endif /* NEW_PROC_API */ diff --git a/gdb/config/sparc/tm-sun4sol2.h b/gdb/config/sparc/tm-sun4sol2.h index 7642fe3..09f36bb 100644 --- a/gdb/config/sparc/tm-sun4sol2.h +++ b/gdb/config/sparc/tm-sun4sol2.h @@ -82,6 +82,7 @@ extern char *sunpro_static_transform_name (char *); #define HANDLE_SVR4_EXEC_EMULATORS /* Macros to extract process id and thread id from a composite pid/tid */ -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) diff --git a/gdb/corelow.c b/gdb/corelow.c index 127b891..e0a4b6a 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -77,7 +77,7 @@ static void add_to_thread_list (bfd *, asection *, PTR); 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 *asect, PTR reg_sect_arg) 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; } diff --git a/gdb/cxux-nat.c b/gdb/cxux-nat.c index 4fafc8e..742f89c 100644 --- a/gdb/cxux-nat.c +++ b/gdb/cxux-nat.c @@ -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; diff --git a/gdb/d10v-tdep.c b/gdb/d10v-tdep.c index 5f9c644..ee0a802 100644 --- a/gdb/d10v-tdep.c +++ b/gdb/d10v-tdep.c @@ -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 diff --git a/gdb/defs.h b/gdb/defs.h index 72f5184..166dde8 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -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); diff --git a/gdb/dink32-rom.c b/gdb/dink32-rom.c index 32e3279..f62e712 100644 --- a/gdb/dink32-rom.c +++ b/gdb/dink32-rom.c @@ -99,15 +99,13 @@ dink32_supply_register (char *regname, int regnamelen, char *val, int vallen) 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 */ } diff --git a/gdb/dve3900-rom.c b/gdb/dve3900-rom.c index 1239d16..feb8e12 100644 --- a/gdb/dve3900-rom.c +++ b/gdb/dve3900-rom.c @@ -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 diff --git a/gdb/fork-child.c b/gdb/fork-child.c index 1c19b83..de148c6 100644 --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -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 *allargs, char **env, 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, int *followed_child) 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, int *followed_child) */ 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 (); diff --git a/gdb/frame.c b/gdb/frame.c index 206955f..ea59eba 100644 --- a/gdb/frame.c +++ b/gdb/frame.c @@ -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 () diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c index d84e41d..bc2070a 100644 --- a/gdb/gdbarch.c +++ b/gdb/gdbarch.c @@ -849,15 +849,15 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file *file) #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 *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 *gdbarch, } 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 diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h index 548d5a0..e298274 100644 --- a/gdb/gdbarch.h +++ b/gdb/gdbarch.h @@ -257,29 +257,29 @@ extern void set_gdbarch_ieee_float (struct gdbarch *gdbarch, int ieee_float); /* 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 diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh index 7517e41..ed7b878 100755 --- a/gdb/gdbarch.sh +++ b/gdb/gdbarch.sh @@ -376,8 +376,8 @@ v::TARGET_BFD_VMA_BIT:int:bfd_vma_bit::::8 * sizeof (void*):TARGET_ARCHITECTURE- # 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 diff --git a/gdb/gdbthread.h b/gdb/gdbthread.h index 5eec828..7483a53 100644 --- a/gdb/gdbthread.h +++ b/gdb/gdbthread.h @@ -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) (struct thread_info *, void *); 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 pid, /* 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, diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index 7feac1c..0939931 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -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_waitstatus *status) 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 target_signal sig) 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 target_signal sig) 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, char *allargs, char **env) /* 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; diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 98eb7f2..c77a9fc 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -164,8 +164,10 @@ static void go32_open (char *name, int from_tty); 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 target_signal siggnal) 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, char *args, char **env) save_npx (); #endif - inferior_pid = SOME_PID; + inferior_ptid = pid_to_ptid (SOME_PID); push_target (&go32_ops); clear_proceed_status (); insert_breakpoints (); diff --git a/gdb/h8500-tdep.c b/gdb/h8500-tdep.c index f0226b5..33cd1f3 100644 --- a/gdb/h8500-tdep.c +++ b/gdb/h8500-tdep.c @@ -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); } diff --git a/gdb/hp300ux-nat.c b/gdb/hp300ux-nat.c index 26aa80f..ecb8a35 100644 --- a/gdb/hp300ux-nat.c +++ b/gdb/hp300ux-nat.c @@ -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 regno, register unsigned int regaddr) 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 *) ®val); } @@ -105,7 +105,7 @@ fetch_inferior_register (register int regno, register unsigned int regaddr) 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 regno, register unsigned int regaddr) } 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); } diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c index 855fcb3..d6fa71c 100644 --- a/gdb/hppa-tdep.c +++ b/gdb/hppa-tdep.c @@ -1397,7 +1397,7 @@ push_dummy_frame (struct inferior_status *inf_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_regs *fsr) 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_ADDR pc, CORE_ADDR fun, int nargs, 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_ADDR pc, CORE_ADDR fun, int nargs, 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_ADDR pc, CORE_ADDR fun, int nargs, 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, int regnum, long *raw_val) 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_info *frame_info, } } - /* 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 exception_event_kind kind, int enable) 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 */ } diff --git a/gdb/hppab-nat.c b/gdb/hppab-nat.c index e812807..51dde60 100644 --- a/gdb/hppab-nat.c +++ b/gdb/hppab-nat.c @@ -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 *) ®isters[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 *) ®isters[REGISTER_BYTE (regno) + i]); if (errno != 0) { @@ -209,5 +210,5 @@ hppa_set_watchpoint (int addr, int len, int flag) 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); } diff --git a/gdb/hppah-nat.c b/gdb/hppah-nat.c index e89648b..c5c431d 100644 --- a/gdb/hppah-nat.c +++ b/gdb/hppah-nat.c @@ -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 *) ®isters[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, char *myaddr, int len, int write, { /* 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, char *myaddr, int len, int write, 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, char *myaddr, int len, int write, 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, char *myaddr, int len, int write, { 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 (void) 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, int followed_parent, int child_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 (int pid, CORE_ADDR start, LONGEST len) } 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 pid) } 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; } diff --git a/gdb/hpux-thread.c b/gdb/hpux-thread.c index d7172eb..4efeb4a 100644 --- a/gdb/hpux-thread.c +++ b/gdb/hpux-thread.c @@ -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_tty) 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, enum target_signal signo) } #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, enum target_signal signo) /* 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 memaddr, char *myaddr, int len, 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_file, char *allargs, char **env) 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); diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index 114e4ce..eb222fd 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -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 long value) /* 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[] = { 0xcd, 0x80 }; 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 target_signal signal) 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) diff --git a/gdb/i386aix-nat.c b/gdb/i386aix-nat.c index 4fef032..2d8d7b9 100644 --- a/gdb/i386aix-nat.c +++ b/gdb/i386aix-nat.c @@ -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 *) ®isters[REGISTER_BYTE (regno)], 0); else - ptrace (PT_WRITE_FPR, inferior_pid, ®isters[REGISTER_BYTE (regno)], + ptrace (PT_WRITE_FPR, PIDGET (inferior_ptid), + ®isters[REGISTER_BYTE (regno)], (regno - FP0_REGNUM) * 10 + offsetof (struct env387, regs)); if (errno != 0) diff --git a/gdb/i386b-nat.c b/gdb/i386b-nat.c index dcfd626..be8fd45 100644 --- a/gdb/i386b-nat.c +++ b/gdb/i386b-nat.c @@ -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 (®isters[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, ®isters[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); } } diff --git a/gdb/i386bsd-nat.c b/gdb/i386bsd-nat.c index 3fdda7b..c903837 100644 --- a/gdb/i386bsd-nat.c +++ b/gdb/i386bsd-nat.c @@ -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 value) { 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 value) 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 diff --git a/gdb/i386gnu-nat.c b/gdb/i386gnu-nat.c index e51a725..da5ef0e 100644 --- a/gdb/i386gnu-nat.c +++ b/gdb/i386gnu-nat.c @@ -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) { diff --git a/gdb/i386mach-nat.c b/gdb/i386mach-nat.c index 1dfa7a5..6d4980b 100644 --- a/gdb/i386mach-nat.c +++ b/gdb/i386mach-nat.c @@ -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); } diff --git a/gdb/i386nbsd-nat.c b/gdb/i386nbsd-nat.c index 2fa83e1..d8537fa 100644 --- a/gdb/i386nbsd-nat.c +++ b/gdb/i386nbsd-nat.c @@ -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); } diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c index 1a000ea..338adbe 100644 --- a/gdb/ia64-linux-nat.c +++ b/gdb/ia64-linux-nat.c @@ -474,28 +474,28 @@ fill_fpregset (fpregset_t *fpregsetp, int regno) #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, CORE_ADDR addr, int len, int rw) 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, CORE_ADDR addr, int len, int rw) 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, CORE_ADDR addr, int len) 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, CORE_ADDR addr, int len) } 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 pid) 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; } diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index dca7ba1..2a1b351 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -612,27 +612,27 @@ ia64_breakpoint_from_pc (CORE_ADDR *pcptr, int *lenptr) } 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) diff --git a/gdb/infcmd.c b/gdb/infcmd.c index 32a5954..0309464 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -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 (); diff --git a/gdb/inferior.h b/gdb/inferior.h index b41e941..35ac96e 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -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, char *); extern CORE_ADDR read_pc (void); -extern CORE_ADDR read_pc_pid (int); +extern CORE_ADDR read_pc_pid (ptid_t); -extern CORE_ADDR generic_target_read_pc (int); +extern CORE_ADDR generic_target_read_pc (ptid_t); extern void write_pc (CORE_ADDR); -extern void write_pc_pid (CORE_ADDR, int); +extern void write_pc_pid (CORE_ADDR, ptid_t); -extern void generic_target_write_pc (CORE_ADDR, int); +extern void generic_target_write_pc (CORE_ADDR, ptid_t); extern CORE_ADDR read_sp (void); @@ -208,9 +209,9 @@ extern int attach (int); extern void detach (int); /* PTRACE method of waiting for inferior process. */ -int ptrace_wait (int, int *); +int ptrace_wait (ptid_t, int *); -extern void child_resume (int, int, enum target_signal); +extern void child_resume (ptid_t, int, enum target_signal); #ifndef PTRACE_ARG3_TYPE #define PTRACE_ARG3_TYPE int /* Correct definition for most systems. */ @@ -224,7 +225,7 @@ extern void pre_fork_inferior (void); extern int proc_iterate_over_mappings (int (*)(int, CORE_ADDR)); -extern int procfs_first_available (void); +extern ptid_t procfs_first_available (void); /* From fork-child.c */ @@ -261,7 +262,8 @@ extern int signal_print_update (int, int); extern int signal_pass_update (int, int); -extern void get_last_target_status(int *pid, struct target_waitstatus *status); +extern void get_last_target_status(ptid_t *ptid, + struct target_waitstatus *status); /* From infcmd.c */ @@ -362,7 +364,7 @@ extern int proceed_to_finish; extern char *stop_registers; -/* Nonzero if the child process in inferior_pid was attached rather +/* Nonzero if the child process in inferior_ptid was attached rather than forked. */ extern int attach_flag; diff --git a/gdb/inflow.c b/gdb/inflow.c index d9a0439..28ebf7d 100644 --- a/gdb/inflow.c +++ b/gdb/inflow.c @@ -207,9 +207,9 @@ terminal_init_inferior (void) debugging target with a version of target_terminal_init_inferior which passes in the process group to a generic routine which does all the work (and the non-threaded child_terminal_init_inferior can just pass in - inferior_pid to the same routine). */ + inferior_ptid to the same routine). */ /* We assume INFERIOR_PID is also the child's process group. */ - terminal_init_inferior_with_pgrp (PIDGET (inferior_pid)); + terminal_init_inferior_with_pgrp (PIDGET (inferior_ptid)); #endif /* PROCESS_GROUP_TYPE */ } @@ -573,11 +573,11 @@ new_tty (void) static void kill_command (char *arg, int from_tty) { - /* FIXME: This should not really be inferior_pid (or target_has_execution). + /* FIXME: This should not really be inferior_ptid (or target_has_execution). It should be a distinct flag that indicates that a target is active, cuz some targets don't have processes! */ - if (inferior_pid == 0) + if (ptid_equal (inferior_ptid, null_ptid)) error ("The program is not being run."); if (!query ("Kill the program being debugged? ")) error ("Not confirmed."); @@ -605,7 +605,7 @@ static void pass_signal (int signo) { #ifndef _WIN32 - kill (PIDGET (inferior_pid), SIGINT); + kill (PIDGET (inferior_ptid), SIGINT); #endif } @@ -647,7 +647,7 @@ handle_sigio (int signo) { #ifndef _WIN32 if ((*target_activity_function) ()) - kill (inferior_pid, SIGINT); + kill (PIDGET (inferior_ptid), SIGINT); #endif } } @@ -735,7 +735,7 @@ _initialize_inflow (void) add_com ("kill", class_run, kill_command, "Kill execution of program being debugged."); - inferior_pid = 0; + inferior_ptid = null_ptid; terminal_is_ours = 1; diff --git a/gdb/infptrace.c b/gdb/infptrace.c index e41ca03..d9eee36 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -215,12 +215,12 @@ call_ptrace (int request, int pid, PTRACE_ARG3_TYPE addr, int data) hook before returning. */ int -ptrace_wait (int pid, int *status) +ptrace_wait (ptid_t ptid, int *status) { int wstate; wstate = wait (status); - target_post_wait (wstate, *status); + target_post_wait (pid_to_ptid (wstate), *status); return wstate; } @@ -228,8 +228,9 @@ void kill_inferior (void) { int status; + int pid = PIDGET (inferior_ptid); - if (inferior_pid == 0) + if (pid == 0) return; /* This once used to call "kill" to kill the inferior just in case @@ -240,8 +241,8 @@ kill_inferior (void) The kill call causes problems under hpux10, so it's been removed; if this causes problems we'll deal with them as they arise. */ - ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0); - ptrace_wait (0, &status); + ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0); + ptrace_wait (null_ptid, &status); target_mourn_inferior (); } @@ -252,15 +253,17 @@ kill_inferior (void) If SIGNAL is nonzero, give it that signal. */ void -child_resume (int pid, int step, enum target_signal signal) +child_resume (ptid_t ptid, int step, enum target_signal signal) { + int pid = PIDGET (ptid); + errno = 0; if (pid == -1) /* Resume all threads. */ /* I think this only gets used in the non-threaded case, where "resume - all threads" and "resume inferior_pid" are the same. */ - pid = inferior_pid; + all threads" and "resume inferior_ptid" are the same. */ + pid = PIDGET (inferior_ptid); /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where it was. (If GDB wanted it to start some other way, we have already @@ -312,7 +315,8 @@ void detach (int signal) { errno = 0; - ptrace (PT_DETACH, inferior_pid, (PTRACE_ARG3_TYPE) 1, signal); + ptrace (PT_DETACH, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 1, + signal); if (errno) perror_with_name ("ptrace"); attach_flag = 0; @@ -356,7 +360,7 @@ _initialize_kernel_u_addr (void) /* U_REGS_OFFSET is the offset of the registers within the u area. */ #if !defined (U_REGS_OFFSET) #define U_REGS_OFFSET \ - ptrace (PT_READ_U, inferior_pid, \ + ptrace (PT_READ_U, PIDGET (inferior_ptid), \ (PTRACE_ARG3_TYPE) (offsetof (struct user, u_ar0)), 0) \ - KERNEL_U_ADDR #endif @@ -387,8 +391,8 @@ fetch_register (int regno) } /* Overload thread id onto process id */ - if ((tid = TIDGET (inferior_pid)) == 0) - tid = inferior_pid; /* no thread id, just use process id */ + if ((tid = TIDGET (inferior_ptid)) == 0) + tid = PIDGET (inferior_ptid); /* no thread id, just use process id */ offset = U_REGS_OFFSET; @@ -453,8 +457,8 @@ store_register (int regno) } /* Overload thread id onto process id */ - if ((tid = TIDGET (inferior_pid)) == 0) - tid = inferior_pid; /* no thread id, just use process id */ + if ((tid = TIDGET (inferior_ptid)) == 0) + tid = PIDGET (inferior_ptid); /* no thread id, just use process id */ offset = U_REGS_OFFSET; @@ -535,14 +539,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE)) { /* Need part of initial word -- fetch it. */ - buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_pid), + buffer[0] = ptrace (PT_READ_I, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, 0); } if (count > 1) /* FIXME, avoid if even boundary */ { buffer[count - 1] - = ptrace (PT_READ_I, PIDGET (inferior_pid), + = ptrace (PT_READ_I, PIDGET (inferior_ptid), ((PTRACE_ARG3_TYPE) (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))), 0); @@ -559,14 +563,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - ptrace (PT_WRITE_D, PIDGET (inferior_pid), + ptrace (PT_WRITE_D, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, buffer[i]); if (errno) { /* Using the appropriate one (I or D) is necessary for Gould NP1, at least. */ errno = 0; - ptrace (PT_WRITE_I, PIDGET (inferior_pid), + ptrace (PT_WRITE_I, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, buffer[i]); } if (errno) @@ -582,7 +586,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_pid), + buffer[i] = ptrace (PT_READ_I, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, 0); if (errno) return 0; @@ -632,7 +636,7 @@ udot_info (char *dummy1, int dummy2) } printf_filtered ("%04x:", udot_off); } - udot_val = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) udot_off, 0); + udot_val = ptrace (PT_READ_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) udot_off, 0); if (errno != 0) { sprintf (mess, "\nreading user struct at offset 0x%x", udot_off); diff --git a/gdb/infrun.c b/gdb/infrun.c index 028fe09..a62a72c 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -99,7 +99,7 @@ int sync_execution = 0; when the inferior stopped in a different thread than it had been running in. */ -static int previous_inferior_pid; +static ptid_t previous_inferior_ptid; /* This is true for configurations that may follow through execl() and similar functions. At present this is only true for HP-UX native. */ @@ -332,6 +332,9 @@ static unsigned char *signal_program; (flags)[signum] = 0; \ } while (0) +/* Value to pass to target_resume() to cause all threads to resume */ + +#define RESUME_ALL (pid_to_ptid (-1)) /* Command list pointer for the "stop" placeholder. */ @@ -409,7 +412,7 @@ static int number_of_threads_in_syscalls; /* This is a cached copy of the pid/waitstatus of the last event returned by target_wait()/target_wait_hook(). This information is returned by get_last_target_status(). */ -static int target_last_wait_pid = -1; +static ptid_t target_last_wait_ptid; static struct target_waitstatus target_last_waitstatus; /* This is used to remember when a fork, vfork or exec event @@ -441,7 +444,7 @@ pending_follow; set to 1, a vfork event has been seen, but cannot be followed until the exec is seen. - (In the latter case, inferior_pid is still the parent of the + (In the latter case, inferior_ptid is still the parent of the vfork, and pending_follow.fork_event.child_pid is the child. The appropriate process is followed, according to the setting of follow-fork-mode.) */ @@ -513,7 +516,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, } /* If we're to be following the child, then attach to it, detach - from inferior_pid, and set inferior_pid to child_pid. */ + from inferior_ptid, and set inferior_ptid to child_pid. */ else if (follow_mode == follow_fork_mode_child) { char child_pid_spelling[100]; /* Arbitrary length. */ @@ -536,7 +539,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, /* Also reset the solib inferior hook from the parent. */ #ifdef SOLIB_REMOVE_INFERIOR_HOOK - SOLIB_REMOVE_INFERIOR_HOOK (inferior_pid); + SOLIB_REMOVE_INFERIOR_HOOK (PIDGET (inferior_ptid)); #endif /* Detach from the parent. */ @@ -544,7 +547,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, target_detach (NULL, 1); /* Attach to the child. */ - inferior_pid = child_pid; + inferior_ptid = pid_to_ptid (child_pid); sprintf (child_pid_spelling, "%d", child_pid); dont_repeat (); @@ -588,7 +591,7 @@ follow_inferior_fork (int parent_pid, int child_pid, int has_forked, /* We continue to follow the parent. To help distinguish the two debuggers, though, both we and our clone will reset our prompts. */ - sprintf (pid_suffix, "[%d] ", inferior_pid); + sprintf (pid_suffix, "[%d] ", PIDGET (inferior_ptid)); set_prompt (strcat (get_prompt (), pid_suffix)); } @@ -650,11 +653,12 @@ follow_vfork (int parent_pid, int child_pid) follow_inferior_fork (parent_pid, child_pid, 0, 1); /* Did we follow the child? Had it exec'd before we saw the parent vfork? */ - if (pending_follow.fork_event.saw_child_exec && (inferior_pid == child_pid)) + if (pending_follow.fork_event.saw_child_exec + && (PIDGET (inferior_ptid) == child_pid)) { pending_follow.fork_event.saw_child_exec = 0; pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - follow_exec (inferior_pid, pending_follow.execd_pathname); + follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname); xfree (pending_follow.execd_pathname); } } @@ -676,13 +680,14 @@ follow_exec (int pid, char *execd_pathname) (pending_follow.kind == TARGET_WAITKIND_VFORKED)) { pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - follow_vfork (inferior_pid, pending_follow.fork_event.child_pid); + follow_vfork (PIDGET (inferior_ptid), + pending_follow.fork_event.child_pid); follow_vfork_when_exec = 0; - saved_pid = inferior_pid; + saved_pid = PIDGET (inferior_ptid); /* Did we follow the parent? If so, we're done. If we followed the child then we must also follow its exec(). */ - if (inferior_pid == pending_follow.fork_event.parent_pid) + if (PIDGET (inferior_ptid) == pending_follow.fork_event.parent_pid) return; } @@ -731,7 +736,8 @@ follow_exec (int pid, char *execd_pathname) gdb_flush (gdb_stdout); target_mourn_inferior (); - inferior_pid = saved_pid; /* Because mourn_inferior resets inferior_pid. */ + inferior_ptid = pid_to_ptid (saved_pid); + /* Because mourn_inferior resets inferior_ptid. */ push_target (tgt); /* That a.out is now the one to use. */ @@ -747,7 +753,7 @@ follow_exec (int pid, char *execd_pathname) SOLIB_RESTART (); #endif #ifdef SOLIB_CREATE_INFERIOR_HOOK - SOLIB_CREATE_INFERIOR_HOOK (inferior_pid); + SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); #endif /* Reinsert all breakpoints. (Those which were symbolic have @@ -866,7 +872,8 @@ resume (int step, enum target_signal sig) { case (TARGET_WAITKIND_FORKED): pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - follow_fork (inferior_pid, pending_follow.fork_event.child_pid); + follow_fork (PIDGET (inferior_ptid), + pending_follow.fork_event.child_pid); break; case (TARGET_WAITKIND_VFORKED): @@ -874,14 +881,15 @@ resume (int step, enum target_signal sig) int saw_child_exec = pending_follow.fork_event.saw_child_exec; pending_follow.kind = TARGET_WAITKIND_SPURIOUS; - follow_vfork (inferior_pid, pending_follow.fork_event.child_pid); + follow_vfork (PIDGET (inferior_ptid), + pending_follow.fork_event.child_pid); /* Did we follow the child, but not yet see the child's exec event? If so, then it actually ought to be waiting for us; we respond to parent vfork events. We don't actually want to resume the child in this situation; we want to just get its exec event. */ if (!saw_child_exec && - (inferior_pid == pending_follow.fork_event.child_pid)) + (PIDGET (inferior_ptid) == pending_follow.fork_event.child_pid)) should_resume = 0; } break; @@ -902,7 +910,7 @@ resume (int step, enum target_signal sig) if (should_resume) { - int resume_pid; + ptid_t resume_ptid; if (use_thread_step_needed && thread_step_needed) { @@ -915,7 +923,7 @@ resume (int step, enum target_signal sig) { /* Breakpoint deleted: ok to do regular resume where all the threads either step or continue. */ - resume_pid = -1; + resume_ptid = RESUME_ALL; } else { @@ -927,7 +935,7 @@ resume (int step, enum target_signal sig) trap_expected = 1; step = 1; } - resume_pid = inferior_pid; + resume_ptid = inferior_ptid; } } else @@ -935,11 +943,11 @@ resume (int step, enum target_signal sig) /* Vanilla resume. */ if ((scheduler_mode == schedlock_on) || (scheduler_mode == schedlock_step && step != 0)) - resume_pid = inferior_pid; + resume_ptid = inferior_ptid; else - resume_pid = -1; + resume_ptid = RESUME_ALL; } - target_resume (resume_pid, step, sig); + target_resume (resume_ptid, step, sig); } discard_cleanups (old_cleanups); @@ -1230,8 +1238,8 @@ struct execution_control_state int current_line; struct symtab *current_symtab; int handling_longjmp; /* FIXME */ - int pid; - int saved_inferior_pid; + ptid_t ptid; + ptid_t saved_inferior_ptid; int update_step_sp; int stepping_through_solib_after_catch; bpstat stepping_through_solib_catchpoints; @@ -1240,7 +1248,7 @@ struct execution_control_state int new_thread_event; struct target_waitstatus tmpstatus; enum infwait_states infwait_state; - int waiton_pid; + ptid_t waiton_ptid; int wait_some_more; }; @@ -1284,7 +1292,7 @@ wait_for_inferior (void) thread_step_needed = 0; /* We'll update this if & when we switch to a new thread. */ - previous_inferior_pid = inferior_pid; + previous_inferior_ptid = inferior_ptid; overlay_cache_invalid = 1; @@ -1299,9 +1307,9 @@ wait_for_inferior (void) while (1) { if (target_wait_hook) - ecs->pid = target_wait_hook (ecs->waiton_pid, ecs->wp); + ecs->ptid = target_wait_hook (ecs->waiton_ptid, ecs->wp); else - ecs->pid = target_wait (ecs->waiton_pid, ecs->wp); + ecs->ptid = target_wait (ecs->waiton_ptid, ecs->wp); /* Now figure out what to do with the result of the result. */ handle_inferior_event (ecs); @@ -1344,7 +1352,7 @@ fetch_inferior_event (void *client_data) thread_step_needed = 0; /* We'll update this if & when we switch to a new thread. */ - previous_inferior_pid = inferior_pid; + previous_inferior_ptid = inferior_ptid; overlay_cache_invalid = 1; @@ -1358,9 +1366,9 @@ fetch_inferior_event (void *client_data) } if (target_wait_hook) - async_ecs->pid = target_wait_hook (async_ecs->waiton_pid, async_ecs->wp); + async_ecs->ptid = target_wait_hook (async_ecs->waiton_ptid, async_ecs->wp); else - async_ecs->pid = target_wait (async_ecs->waiton_pid, async_ecs->wp); + async_ecs->ptid = target_wait (async_ecs->waiton_ptid, async_ecs->wp); /* Now figure out what to do with the result of the result. */ handle_inferior_event (async_ecs); @@ -1398,7 +1406,7 @@ init_execution_control_state (struct execution_control_state *ecs) ecs->current_line = ecs->sal.line; ecs->current_symtab = ecs->sal.symtab; ecs->infwait_state = infwait_normal_state; - ecs->waiton_pid = -1; + ecs->waiton_ptid = pid_to_ptid (-1); ecs->wp = &(ecs->ws); } @@ -1419,9 +1427,9 @@ check_for_old_step_resume_breakpoint (void) target_wait()/target_wait_hook(). */ void -get_last_target_status(int *pid, struct target_waitstatus *status) +get_last_target_status(ptid_t *ptidp, struct target_waitstatus *status) { - *pid = target_last_wait_pid; + *ptidp = target_last_wait_ptid; *status = target_last_waitstatus; } @@ -1436,7 +1444,7 @@ handle_inferior_event (struct execution_control_state *ecs) int stepped_after_stopped_by_watchpoint; /* Cache the last pid/waitstatus. */ - target_last_wait_pid = ecs->pid; + target_last_wait_ptid = ecs->ptid; target_last_waitstatus = *ecs->wp; /* Keep this extra brace for now, minimizes diffs. */ @@ -1453,7 +1461,7 @@ handle_inferior_event (struct execution_control_state *ecs) is serviced in this loop, below. */ if (ecs->enable_hw_watchpoints_after_wait) { - TARGET_ENABLE_HW_WATCHPOINTS (inferior_pid); + TARGET_ENABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid)); ecs->enable_hw_watchpoints_after_wait = 0; } stepped_after_stopped_by_watchpoint = 0; @@ -1467,9 +1475,9 @@ handle_inferior_event (struct execution_control_state *ecs) * FIXME: shouldn't we look at currently_stepping ()? */ if (scheduler_mode == schedlock_on) - target_resume (ecs->pid, 0, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 0, TARGET_SIGNAL_0); else - target_resume (-1, 0, TARGET_SIGNAL_0); + target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0); ecs->infwait_state = infwait_normal_state; prepare_to_wait (ecs); return; @@ -1492,20 +1500,21 @@ handle_inferior_event (struct execution_control_state *ecs) /* If it's a new process, add it to the thread database */ - ecs->new_thread_event = ((ecs->pid != inferior_pid) && !in_thread_list (ecs->pid)); + ecs->new_thread_event = (! ptid_equal (ecs->ptid, inferior_ptid) + && ! in_thread_list (ecs->ptid)); if (ecs->ws.kind != TARGET_WAITKIND_EXITED && ecs->ws.kind != TARGET_WAITKIND_SIGNALLED && ecs->new_thread_event) { - add_thread (ecs->pid); + add_thread (ecs->ptid); #ifdef UI_OUT ui_out_text (uiout, "[New "); - ui_out_text (uiout, target_pid_or_tid_to_str (ecs->pid)); + ui_out_text (uiout, target_pid_or_tid_to_str (ecs->ptid)); ui_out_text (uiout, "]\n"); #else - printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->pid)); + printf_filtered ("[New %s]\n", target_pid_or_tid_to_str (ecs->ptid)); #endif #if 0 @@ -1528,7 +1537,7 @@ handle_inferior_event (struct execution_control_state *ecs) Therefore we need to continue all threads in order to make progress. */ - target_resume (-1, 0, TARGET_SIGNAL_0); + target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0); prepare_to_wait (ecs); return; #endif @@ -1616,10 +1625,10 @@ handle_inferior_event (struct execution_control_state *ecs) interested in reacting to forks of the child. Note that we expect the child's fork event to be available if we waited for it now. */ - if (inferior_pid == ecs->pid) + if (ptid_equal (inferior_ptid, ecs->ptid)) { pending_follow.fork_event.saw_parent_fork = 1; - pending_follow.fork_event.parent_pid = ecs->pid; + pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid); pending_follow.fork_event.child_pid = ecs->ws.value.related_pid; prepare_to_wait (ecs); return; @@ -1627,16 +1636,16 @@ handle_inferior_event (struct execution_control_state *ecs) else { pending_follow.fork_event.saw_child_fork = 1; - pending_follow.fork_event.child_pid = ecs->pid; + pending_follow.fork_event.child_pid = PIDGET (ecs->ptid); pending_follow.fork_event.parent_pid = ecs->ws.value.related_pid; } - stop_pc = read_pc_pid (ecs->pid); - ecs->saved_inferior_pid = inferior_pid; - inferior_pid = ecs->pid; + stop_pc = read_pc_pid (ecs->ptid); + ecs->saved_inferior_ptid = inferior_ptid; + inferior_ptid = ecs->ptid; stop_bpstat = bpstat_stop_status (&stop_pc, currently_stepping (ecs)); ecs->random_signal = !bpstat_explains_signal (stop_bpstat); - inferior_pid = ecs->saved_inferior_pid; + inferior_ptid = ecs->saved_inferior_ptid; goto process_event_stop_test; /* If this a platform which doesn't allow a debugger to touch a @@ -1656,10 +1665,10 @@ handle_inferior_event (struct execution_control_state *ecs) it execs, and the child has not yet exec'd. We probably should warn the user to that effect when the catchpoint triggers...) */ - if (ecs->pid == inferior_pid) + if (ptid_equal (ecs->ptid, inferior_ptid)) { pending_follow.fork_event.saw_parent_fork = 1; - pending_follow.fork_event.parent_pid = ecs->pid; + pending_follow.fork_event.parent_pid = PIDGET (ecs->ptid); pending_follow.fork_event.child_pid = ecs->ws.value.related_pid; } @@ -1669,13 +1678,14 @@ handle_inferior_event (struct execution_control_state *ecs) else { pending_follow.fork_event.saw_child_fork = 1; - pending_follow.fork_event.child_pid = ecs->pid; + pending_follow.fork_event.child_pid = PIDGET (ecs->ptid); pending_follow.fork_event.parent_pid = ecs->ws.value.related_pid; - target_post_startup_inferior (pending_follow.fork_event.child_pid); + target_post_startup_inferior ( + pid_to_ptid (pending_follow.fork_event.child_pid)); follow_vfork_when_exec = !target_can_follow_vfork_prior_to_exec (); if (follow_vfork_when_exec) { - target_resume (ecs->pid, 0, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 0, TARGET_SIGNAL_0); prepare_to_wait (ecs); return; } @@ -1698,7 +1708,7 @@ handle_inferior_event (struct execution_control_state *ecs) inferior_ignoring_leading_exec_events--; if (pending_follow.kind == TARGET_WAITKIND_VFORKED) ENSURE_VFORKING_PARENT_REMAINS_STOPPED (pending_follow.fork_event.parent_pid); - target_resume (ecs->pid, 0, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 0, TARGET_SIGNAL_0); prepare_to_wait (ecs); return; } @@ -1709,7 +1719,7 @@ handle_inferior_event (struct execution_control_state *ecs) savestring (ecs->ws.value.execd_pathname, strlen (ecs->ws.value.execd_pathname)); - /* Did inferior_pid exec, or did a (possibly not-yet-followed) + /* Did inferior_ptid exec, or did a (possibly not-yet-followed) child of a vfork exec? ??rehrauer: This is unabashedly an HP-UX specific thing. On @@ -1733,7 +1743,7 @@ handle_inferior_event (struct execution_control_state *ecs) the parent vfork event is delivered. A single-step suffices. */ if (RESUME_EXECD_VFORKING_CHILD_TO_GET_PARENT_VFORK ()) - target_resume (ecs->pid, 1, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); /* We expect the parent vfork event to be available now. */ prepare_to_wait (ecs); return; @@ -1741,15 +1751,15 @@ handle_inferior_event (struct execution_control_state *ecs) /* This causes the eventpoints and symbol table to be reset. Must do this now, before trying to determine whether to stop. */ - follow_exec (inferior_pid, pending_follow.execd_pathname); + follow_exec (PIDGET (inferior_ptid), pending_follow.execd_pathname); xfree (pending_follow.execd_pathname); - stop_pc = read_pc_pid (ecs->pid); - ecs->saved_inferior_pid = inferior_pid; - inferior_pid = ecs->pid; + stop_pc = read_pc_pid (ecs->ptid); + ecs->saved_inferior_ptid = inferior_ptid; + inferior_ptid = ecs->ptid; stop_bpstat = bpstat_stop_status (&stop_pc, currently_stepping (ecs)); ecs->random_signal = !bpstat_explains_signal (stop_bpstat); - inferior_pid = ecs->saved_inferior_pid; + inferior_ptid = ecs->saved_inferior_ptid; goto process_event_stop_test; /* These syscall events are returned on HP-UX, as part of its @@ -1773,7 +1783,7 @@ handle_inferior_event (struct execution_control_state *ecs) number_of_threads_in_syscalls++; if (number_of_threads_in_syscalls == 1) { - TARGET_DISABLE_HW_WATCHPOINTS (inferior_pid); + TARGET_DISABLE_HW_WATCHPOINTS (PIDGET (inferior_ptid)); } resume (0, TARGET_SIGNAL_0); prepare_to_wait (ecs); @@ -1794,7 +1804,7 @@ handle_inferior_event (struct execution_control_state *ecs) here, which will be serviced immediately after the target is waited on. */ case TARGET_WAITKIND_SYSCALL_RETURN: - target_resume (ecs->pid, 1, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); if (number_of_threads_in_syscalls > 0) { @@ -1830,12 +1840,12 @@ handle_inferior_event (struct execution_control_state *ecs) all threads in order to make progress. */ if (ecs->new_thread_event) { - target_resume (-1, 0, TARGET_SIGNAL_0); + target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0); prepare_to_wait (ecs); return; } - stop_pc = read_pc_pid (ecs->pid); + stop_pc = read_pc_pid (ecs->ptid); /* See if a thread hit a thread-specific breakpoint that was meant for another thread. If so, then step that thread past the breakpoint, @@ -1850,13 +1860,13 @@ handle_inferior_event (struct execution_control_state *ecs) { ecs->random_signal = 0; if (!breakpoint_thread_match (stop_pc - DECR_PC_AFTER_BREAK, - ecs->pid)) + ecs->ptid)) { int remove_status; /* Saw a breakpoint, but it was hit by the wrong thread. Just continue. */ - write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK, ecs->pid); + write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK, ecs->ptid); remove_status = remove_breakpoints (); /* Did we fail to remove breakpoints? If so, try @@ -1868,15 +1878,15 @@ handle_inferior_event (struct execution_control_state *ecs) then either :-) or execs. */ if (remove_status != 0) { - write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK + 4, ecs->pid); + write_pc_pid (stop_pc - DECR_PC_AFTER_BREAK + 4, ecs->ptid); } else { /* Single step */ - target_resume (ecs->pid, 1, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); /* FIXME: What if a signal arrives instead of the single-step happening? */ - ecs->waiton_pid = ecs->pid; + ecs->waiton_ptid = ecs->ptid; ecs->wp = &(ecs->ws); ecs->infwait_state = infwait_thread_hop_state; prepare_to_wait (ecs); @@ -1888,9 +1898,9 @@ handle_inferior_event (struct execution_control_state *ecs) * FIXME: shouldn't we look at currently_stepping ()? */ if (scheduler_mode == schedlock_on) - target_resume (ecs->pid, 0, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 0, TARGET_SIGNAL_0); else - target_resume (-1, 0, TARGET_SIGNAL_0); + target_resume (RESUME_ALL, 0, TARGET_SIGNAL_0); prepare_to_wait (ecs); return; } @@ -1914,7 +1924,7 @@ handle_inferior_event (struct execution_control_state *ecs) Note that if there's any kind of pending follow (i.e., of a fork, vfork or exec), we don't want to do this now. Rather, we'll let the next resume handle it. */ - if ((ecs->pid != inferior_pid) && + if (! ptid_equal (ecs->ptid, inferior_ptid) && (pending_follow.kind == TARGET_WAITKIND_SPURIOUS)) { int printed = 0; @@ -1957,7 +1967,7 @@ handle_inferior_event (struct execution_control_state *ecs) if (signal_program[stop_signal] == 0) stop_signal = TARGET_SIGNAL_0; - target_resume (ecs->pid, 0, stop_signal); + target_resume (ecs->ptid, 0, stop_signal); prepare_to_wait (ecs); return; } @@ -1971,10 +1981,10 @@ handle_inferior_event (struct execution_control_state *ecs) be lost. This may happen as a result of the target module mishandling thread creation. */ - if (in_thread_list (inferior_pid) && in_thread_list (ecs->pid)) + if (in_thread_list (inferior_ptid) && in_thread_list (ecs->ptid)) { /* Perform infrun state context switch: */ /* Save infrun state for the old thread. */ - save_infrun_state (inferior_pid, prev_pc, + save_infrun_state (inferior_ptid, prev_pc, prev_func_start, prev_func_name, trap_expected, step_resume_breakpoint, through_sigtramp_breakpoint, @@ -1986,7 +1996,7 @@ handle_inferior_event (struct execution_control_state *ecs) ecs->stepping_through_sigtramp); /* Load infrun state for the new thread. */ - load_infrun_state (ecs->pid, &prev_pc, + load_infrun_state (ecs->ptid, &prev_pc, &prev_func_start, &prev_func_name, &trap_expected, &step_resume_breakpoint, &through_sigtramp_breakpoint, @@ -1998,10 +2008,10 @@ handle_inferior_event (struct execution_control_state *ecs) &ecs->stepping_through_sigtramp); } - inferior_pid = ecs->pid; + inferior_ptid = ecs->ptid; if (context_hook) - context_hook (pid_to_thread_id (ecs->pid)); + context_hook (pid_to_thread_id (ecs->ptid)); flush_cached_frames (); } @@ -2021,14 +2031,14 @@ handle_inferior_event (struct execution_control_state *ecs) if (INSTRUCTION_NULLIFIED) { registers_changed (); - target_resume (ecs->pid, 1, TARGET_SIGNAL_0); + target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); /* We may have received a signal that we want to pass to the inferior; therefore, we must not clobber the waitstatus in WS. */ ecs->infwait_state = infwait_nullified_state; - ecs->waiton_pid = ecs->pid; + ecs->waiton_ptid = ecs->ptid; ecs->wp = &(ecs->tmpstatus); prepare_to_wait (ecs); return; @@ -2070,9 +2080,9 @@ handle_inferior_event (struct execution_control_state *ecs) remove_breakpoints (); registers_changed (); - target_resume (ecs->pid, 1, TARGET_SIGNAL_0); /* Single step */ + target_resume (ecs->ptid, 1, TARGET_SIGNAL_0); /* Single step */ - ecs->waiton_pid = ecs->pid; + ecs->waiton_ptid = ecs->ptid; ecs->wp = &(ecs->ws); ecs->infwait_state = infwait_nonstep_watch_state; prepare_to_wait (ecs); @@ -2558,7 +2568,7 @@ handle_inferior_event (struct execution_control_state *ecs) { #if defined(SOLIB_ADD) /* Have we reached our destination? If not, keep going. */ - if (SOLIB_IN_DYNAMIC_LINKER (ecs->pid, stop_pc)) + if (SOLIB_IN_DYNAMIC_LINKER (PIDGET (ecs->ptid), stop_pc)) { ecs->another_trap = 1; keep_going (ecs); @@ -3119,26 +3129,26 @@ stop_stepping (struct execution_control_state *ecs) { /* Are we stopping for a vfork event? We only stop when we see the child's event. However, we may not yet have seen the - parent's event. And, inferior_pid is still set to the + parent's event. And, inferior_ptid is still set to the parent's pid, until we resume again and follow either the parent or child. - To ensure that we can really touch inferior_pid (aka, the + To ensure that we can really touch inferior_ptid (aka, the parent process) -- which calls to functions like read_pc implicitly do -- wait on the parent if necessary. */ if ((pending_follow.kind == TARGET_WAITKIND_VFORKED) && !pending_follow.fork_event.saw_parent_fork) { - int parent_pid; + ptid_t parent_ptid; do { if (target_wait_hook) - parent_pid = target_wait_hook (-1, &(ecs->ws)); + parent_ptid = target_wait_hook (pid_to_ptid (-1), &(ecs->ws)); else - parent_pid = target_wait (-1, &(ecs->ws)); + parent_ptid = target_wait (pid_to_ptid (-1), &(ecs->ws)); } - while (parent_pid != inferior_pid); + while (! ptid_equal (parent_ptid, inferior_ptid)); } /* Assuming the inferior still exists, set these up for next @@ -3283,7 +3293,7 @@ prepare_to_wait (struct execution_control_state *ecs) as part of their normal status mechanism. */ registers_changed (); - ecs->waiton_pid = -1; + ecs->waiton_ptid = pid_to_ptid (-1); ecs->wp = &(ecs->ws); } /* This is the old end of the while loop. Let everybody know we @@ -3433,13 +3443,13 @@ normal_stop (void) (Note that there's no point in saying anything if the inferior has exited!) */ - if ((previous_inferior_pid != inferior_pid) + if (! ptid_equal (previous_inferior_ptid, inferior_ptid) && target_has_execution) { target_terminal_ours_for_output (); printf_filtered ("[Switching to %s]\n", - target_pid_or_tid_to_str (inferior_pid)); - previous_inferior_pid = inferior_pid; + target_pid_or_tid_to_str (inferior_ptid)); + previous_inferior_ptid = inferior_ptid; } /* Make sure that the current_frame's pc is correct. This @@ -3559,7 +3569,8 @@ and/or watchpoints.\n"); #ifdef UI_OUT if (interpreter_p && strcmp (interpreter_p, "mi") == 0) - ui_out_field_int (uiout, "thread-id", pid_to_thread_id (inferior_pid)); + ui_out_field_int (uiout, "thread-id", + pid_to_thread_id (inferior_ptid)); #endif /* The behavior of this routine with respect to the source flag is: @@ -3842,7 +3853,7 @@ Are you sure you want to change it? ", argv++; } - target_notice_signals (inferior_pid); + target_notice_signals (inferior_ptid); if (from_tty) { diff --git a/gdb/inftarg.c b/gdb/inftarg.c index 18a42f1..6b37030 100644 --- a/gdb/inftarg.c +++ b/gdb/inftarg.c @@ -47,11 +47,11 @@ extern void _initialize_inftarg (void); static void child_prepare_to_store (void); #ifndef CHILD_WAIT -static int child_wait (int, struct target_waitstatus *); +static ptid_t child_wait (ptid_t, struct target_waitstatus *); #endif /* CHILD_WAIT */ #if !defined(CHILD_POST_WAIT) -void child_post_wait (int, int); +void child_post_wait (ptid_t, int); #endif static void child_open (char *, int); @@ -87,7 +87,7 @@ static int child_can_run (void); static void child_stop (void); #ifndef CHILD_THREAD_ALIVE -int child_thread_alive (int); +int child_thread_alive (ptid_t); #endif static void init_child_ops (void); @@ -116,8 +116,8 @@ int not_same_real_pid = 1; /* Wait for child to do something. Return pid of child, or -1 in case of error; store status through argument pointer OURSTATUS. */ -static int -child_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { int save_errno; int status; @@ -126,6 +126,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) int related_pid; int syscall_id; enum target_waitkind kind; + int pid; do { @@ -133,7 +134,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) attached process. */ set_sigio_trap (); - pid = ptrace_wait (inferior_pid, &status); + pid = ptrace_wait (inferior_ptid, &status); save_errno = errno; @@ -152,7 +153,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) /* Claim it exited with unknown signal. */ ourstatus->kind = TARGET_WAITKIND_SIGNALLED; ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; - return -1; + return pid_to_ptid (-1); } /* Did it exit? @@ -163,26 +164,28 @@ child_wait (int pid, struct target_waitstatus *ourstatus) continue; } - if (!target_thread_alive (pid)) + if (!target_thread_alive (pid_to_ptid (pid))) { ourstatus->kind = TARGET_WAITKIND_SPURIOUS; - return pid; + return pid_to_ptid (pid); } if (target_has_forked (pid, &related_pid) - && ((pid == inferior_pid) || (related_pid == inferior_pid))) + && ((pid == PIDGET (inferior_ptid)) + || (related_pid == PIDGET (inferior_ptid)))) { ourstatus->kind = TARGET_WAITKIND_FORKED; ourstatus->value.related_pid = related_pid; - return pid; + return pid_to_ptid (pid); } if (target_has_vforked (pid, &related_pid) - && ((pid == inferior_pid) || (related_pid == inferior_pid))) + && ((pid == PIDGET (inferior_ptid)) + || (related_pid == PIDGET (inferior_ptid)))) { ourstatus->kind = TARGET_WAITKIND_VFORKED; ourstatus->value.related_pid = related_pid; - return pid; + return pid_to_ptid (pid); } if (target_has_execd (pid, &execd_pathname)) @@ -200,7 +203,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) { ourstatus->kind = TARGET_WAITKIND_EXECD; ourstatus->value.execd_pathname = execd_pathname; - return pid; + return pid_to_ptid (pid); } } @@ -211,23 +214,23 @@ child_wait (int pid, struct target_waitstatus *ourstatus) { ourstatus->kind = kind; ourstatus->value.syscall_id = syscall_id; - return pid; + return pid_to_ptid (pid); } - /*## } while (pid != inferior_pid); ## *//* Some other child died or stopped */ + /*## } while (pid != PIDGET (inferior_ptid)); ## *//* Some other child died or stopped */ /* hack for thread testing */ } - while ((pid != inferior_pid) && not_same_real_pid); + while ((pid != PIDGET (inferior_ptid)) && not_same_real_pid); /*## */ store_waitstatus (ourstatus, status); - return pid; + return pid_to_ptid (pid); } #endif /* CHILD_WAIT */ #if !defined(CHILD_POST_WAIT) void -child_post_wait (int pid, int wait_status) +child_post_wait (ptid_t ptid, int wait_status) { /* This version of Unix doesn't require a meaningful "post wait" operation. @@ -244,8 +247,10 @@ child_post_wait (int pid, int wait_status) for now we're going to try and be compatable with the old thread code. */ int -child_thread_alive (int pid) +child_thread_alive (ptid_t ptid) { + pid_t pid = PIDGET (ptid); + return (kill (pid, 0) != -1); } @@ -280,12 +285,13 @@ child_attach_to_process (char *args, int from_tty, int after_fork) if (after_fork) printf_unfiltered ("Attaching after fork to %s\n", - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else if (exec_file) printf_unfiltered ("Attaching to program: %s, %s\n", exec_file, - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else - printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid)); + printf_unfiltered ("Attaching to %s\n", + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } @@ -295,7 +301,7 @@ child_attach_to_process (char *args, int from_tty, int after_fork) else REQUIRE_ATTACH (pid); - inferior_pid = pid; + inferior_ptid = pid_to_ptid (pid); push_target (&child_ops); } #endif /* ATTACH_DETACH */ @@ -339,10 +345,10 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork) exec_file = ""; if (after_fork) printf_unfiltered ("Detaching after fork from %s\n", - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else printf_unfiltered ("Detaching from program: %s, %s\n", exec_file, - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } if (args) @@ -369,8 +375,8 @@ child_detach_from_process (int pid, char *args, int from_tty, int after_fork) static void child_detach (char *args, int from_tty) { - child_detach_from_process (inferior_pid, args, from_tty, 0); - inferior_pid = 0; + child_detach_from_process (PIDGET (inferior_ptid), args, from_tty, 0); + inferior_ptid = null_ptid; unpush_target (&child_ops); } @@ -401,7 +407,7 @@ static void child_files_info (struct target_ops *ignore) { printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid)); + attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } /* ARGSUSED */ @@ -446,10 +452,10 @@ ptrace_him (int pid) /* On some targets, there must be some explicit actions taken after the inferior has been started up. */ - target_post_startup_inferior (pid); + target_post_startup_inferior (pid_to_ptid (pid)); } -/* 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. Errors reported with error(). */ @@ -469,7 +475,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env) #if !defined(CHILD_POST_STARTUP_INFERIOR) void -child_post_startup_inferior (int pid) +child_post_startup_inferior (ptid_t ptid) { /* This version of Unix doesn't require a meaningful "post startup inferior" operation by a debugger. @@ -736,9 +742,9 @@ child_core_file_to_sym_file (char *core) #if !defined(CHILD_PID_TO_STR) char * -child_pid_to_str (int pid) +child_pid_to_str (ptid_t ptid) { - return normal_pid_to_str (pid); + return normal_pid_to_str (ptid); } #endif diff --git a/gdb/infttrace.c b/gdb/infttrace.c index 3229f35..ffcbd20 100644 --- a/gdb/infttrace.c +++ b/gdb/infttrace.c @@ -383,7 +383,7 @@ static thread_info_header thread_head = static thread_info_header deleted_threads = {0, NULL, NULL}; -static saved_real_pid = 0; +static ptid_t saved_real_ptid; /************************************************* @@ -623,7 +623,7 @@ create_thread_info (int pid, lwpid_t tid) if (debug_on) printf ("First thread, pid %d tid %d!\n", pid, tid); #endif - saved_real_pid = inferior_pid; + saved_real_ptid = inferior_ptid; } else { @@ -1238,7 +1238,7 @@ update_thread_list (void) for (p = thread_head.head; p; p = p->next) { /* Is this an "unseen" thread which really happens to be a process? - If so, is it inferior_pid and is a vfork in flight? If yes to + If so, is it inferior_ptid and is a vfork in flight? If yes to all, then DON'T REMOVE IT! We're in the midst of moving a vfork operation, which is a multiple step thing, to the point where we can touch the parent again. We've most likely stopped to examine @@ -1625,14 +1625,15 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr, * in the multi-process future. Use tid as thread, * probably dooming this to failure. FIX! */ - if (saved_real_pid != 0) + if (! ptid_equal (saved_real_ptid, null_ptid)) { #ifdef THREAD_DEBUG if (debug_on) - printf ("...using saved pid %d\n", saved_real_pid); + printf ("...using saved pid %d\n", + PIDGET (saved_real_ptid)); #endif - real_pid = saved_real_pid; + real_pid = PIDGET (saved_real_ptid); real_tid = gdb_tid; } @@ -1653,14 +1654,14 @@ call_ttrace (ttreq_t request, int gdb_tid, TTRACE_ARG_TYPE addr, if (debug_on) { printf ("Translated thread request to process request\n"); - if (saved_real_pid == 0) + if (ptid_equal (saved_real_ptid, null_ptid)) printf ("...but there's no saved pid\n"); else { - if (gdb_tid != saved_real_pid) + if (gdb_tid != PIDGET (saved_real_ptid)) printf ("...but have the wrong pid (%d rather than %d)\n", - gdb_tid, saved_real_pid); + gdb_tid, PIDGET (saved_real_ptid)); } } #endif @@ -1747,11 +1748,11 @@ stop_all_threads_of_process (pid_t real_pid) have its threads examined. */ #define CHILD_VFORKED(evt,pid) \ - (((evt) == TTEVT_VFORK) && ((pid) != inferior_pid)) + (((evt) == TTEVT_VFORK) && ((pid) != PIDGET (inferior_ptid))) #define CHILD_URPED(evt,pid) \ ((((evt) == TTEVT_EXEC) || ((evt) == TTEVT_EXIT)) && ((pid) != vforking_child_pid)) #define PARENT_VFORKED(evt,pid) \ - (((evt) == TTEVT_VFORK) && ((pid) == inferior_pid)) + (((evt) == TTEVT_VFORK) && ((pid) == PIDGET (inferior_ptid))) static int can_touch_threads_of_process (int pid, ttevents_t stopping_event) @@ -2595,8 +2596,8 @@ count_unhandled_events (int real_pid, lwpid_t real_tid) * * Note: used by core gdb and so uses the pseudo-pid (really tid). */ -int -ptrace_wait (int pid, int *status) +ptid_t +ptrace_wait (ptid_t ptid, int *status) { ttstate_t tsp; int ttwait_return; @@ -2620,13 +2621,13 @@ ptrace_wait (int pid, int *status) if (errno == ESRCH) { *status = 0; /* WIFEXITED */ - return inferior_pid; + return inferior_ptid; } warning ("Call of ttrace_wait returned with errno %d.", errno); *status = ttwait_return; - return inferior_pid; + return inferior_ptid; } real_pid = tsp.tts_pid; @@ -2688,7 +2689,7 @@ ptrace_wait (int pid, int *status) #ifdef THREAD_DEBUG if (debug_on) printf ("Pid %d has zero'th thread %d; inferior pid is %d\n", - real_pid, real_tid, inferior_pid); + real_pid, real_tid, PIDGET (inferior_ptid)); #endif add_tthread (real_pid, real_tid); @@ -2851,7 +2852,7 @@ ptrace_wait (int pid, int *status) * a new thread if for some reason it's never * seen the main thread before. */ - inferior_pid = map_to_gdb_tid (real_tid); /* HACK, FIX */ + inferior_ptid = pid_to_ptid (map_to_gdb_tid (real_tid)); /* HACK, FIX */ *status = 0 | (tsp.tts_u.tts_exit.tts_exitcode); } @@ -2904,7 +2905,7 @@ ptrace_wait (int pid, int *status) /* Remember this for later use in "hppa_prepare_to_proceed". */ - old_gdb_pid = inferior_pid; + old_gdb_pid = PIDGET (inferior_ptid); reported_pid = return_pid; reported_bpt = ((tsp.tts_event & TTEVT_SIGNAL) && (5 == tsp.tts_u.tts_signal.tts_signo)); @@ -2913,7 +2914,7 @@ ptrace_wait (int pid, int *status) warning ("Internal error: process-wait failed."); } - return return_pid; + return pid_to_ptid (return_pid); } @@ -3150,9 +3151,9 @@ child_acknowledge_created_inferior (int pid) * calling require_notification_of_events. */ void -child_post_startup_inferior (int real_pid) +child_post_startup_inferior (ptid_t ptid) { - require_notification_of_events (real_pid); + require_notification_of_events (PIDGET (ptid)); } /* From here on, we should expect tids rather than pids. @@ -3582,8 +3583,9 @@ child_has_syscall_event (int pid, enum target_waitkind *kind, int *syscall_id) * May need a FIXME for that reason. */ int -child_thread_alive (lwpid_t gdb_tid) +child_thread_alive (ptid_t ptid) { + lwpid_t gdp_tid = PIDGET (ptid); lwpid_t tid; /* This spins down the lists twice. @@ -3815,11 +3817,11 @@ kill_inferior (void) thread_info **paranoia; int para_count, i; - if (inferior_pid == 0) + if (PIDGET (inferior_ptid) == 0) return; /* Walk the list of "threads", some of which are "pseudo threads", - aka "processes". For each that is NOT inferior_pid, stop it, + aka "processes". For each that is NOT inferior_ptid, stop it, and detach it. You see, we may not have just a single process to kill. If we're @@ -3849,7 +3851,7 @@ kill_inferior (void) } para_count++; - if (t->am_pseudo && (t->pid != inferior_pid)) + if (t->am_pseudo && (t->pid != PIDGET (inferior_ptid))) { /* TT_PROC_STOP doesn't require a subsequent ttrace_wait, as it * generates no event. @@ -3872,7 +3874,7 @@ kill_inferior (void) xfree (paranoia); call_ttrace (TT_PROC_STOP, - inferior_pid, + PIDGET (inferior_ptid), TT_NIL, TT_NIL, TT_NIL); @@ -4313,7 +4315,7 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal) * -1 | Step current Continue all threads * | thread and (but which gets any * | continue others signal?--We look at - * | "inferior_pid") + * | "inferior_ptid") * | * N | Step _this_ thread Continue _this_ thread * | and leave others and leave others @@ -4323,11 +4325,12 @@ threads_continue_one_with_signal (lwpid_t gdb_tid, int signal) * | user command. */ void -child_resume (lwpid_t gdb_tid, int step, enum target_signal signal) +child_resume (ptid_t ptid, int step, enum target_signal signal) { int resume_all_threads; lwpid_t tid; process_state_t new_process_state; + lwpid_t gdb_tid = PIDGET (ptid); resume_all_threads = (gdb_tid == INFTTRACE_ALL_THREADS) || @@ -4342,7 +4345,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal) if (vfork_in_flight) tid = vforking_child_pid; else - tid = map_from_gdb_tid (inferior_pid); + tid = map_from_gdb_tid (PIDGET (inferior_ptid)); } else tid = map_from_gdb_tid (gdb_tid); @@ -4648,7 +4651,7 @@ child_resume (lwpid_t gdb_tid, int step, enum target_signal signal) /* * Like it says. * - * One worry is that we may not be attaching to "inferior_pid" + * One worry is that we may not be attaching to "inferior_ptid" * and thus may not want to clear out our data. FIXME? * */ @@ -4702,7 +4705,7 @@ update_thread_state_after_attach (int pid, attach_continue_t kind_of_go) * * We don't need to do mapping here, as we know this * is the first thread and thus gets the real pid - * (and is "inferior_pid"). + * (and is "inferior_ptid"). * * NOTE: it probably isn't the originating thread, * but that doesn't matter (we hope!). @@ -4876,7 +4879,7 @@ detach (int signal) { errno = 0; call_ttrace (TT_PROC_DETACH, - inferior_pid, + PIDGET (inferior_ptid), TT_NIL, (TTRACE_ARG_TYPE) signal, TT_NIL); @@ -4939,7 +4942,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, { /* Need part of initial word -- fetch it. */ buffer[0] = call_ttrace (TT_LWP_RDTEXT, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, TT_NIL, TT_NIL); @@ -4948,7 +4951,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, if (count > 1) /* FIXME, avoid if even boundary */ { buffer[count - 1] = call_ttrace (TT_LWP_RDTEXT, - inferior_pid, + PIDGET (inferior_ptid), ((TTRACE_ARG_TYPE) (addr + (count - 1) * sizeof (TTRACE_XFER_TYPE))), TT_NIL, @@ -4967,7 +4970,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, { errno = 0; call_ttrace (TT_LWP_WRDATA, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, (TTRACE_ARG_TYPE) buffer[i], TT_NIL); @@ -4977,7 +4980,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, Gould NP1, at least. */ errno = 0; call_ttrace (TT_LWP_WRTEXT, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, (TTRACE_ARG_TYPE) buffer[i], TT_NIL); @@ -4993,7 +4996,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, { errno = 0; buffer[i] = call_ttrace (TT_LWP_RDTEXT, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) addr, TT_NIL, TT_NIL); @@ -5044,7 +5047,7 @@ udot_info (void) printf_filtered ("%04x:", udot_off); } udot_val = call_ttrace (TT_LWP_RUREGS, - inferior_pid, + PIDGET (inferior_ptid), (TTRACE_ARG_TYPE) udot_off, TT_NIL, TT_NIL); @@ -5074,7 +5077,7 @@ child_pid_to_exec_file (int tid) int name_index; int i; int done; - int saved_inferior_pid; + ptid_t saved_inferior_ptid; /* As of 10.x HP-UX, there's an explicit request to get the *pathname. @@ -5100,19 +5103,19 @@ child_pid_to_exec_file (int tid) 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 = tid; + saved_inferior_ptid = inferior_ptid; + inferior_ptid = pid_to_ptid (tid); /* 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++) @@ -5127,11 +5130,11 @@ child_pid_to_exec_file (int tid) 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; } @@ -5626,17 +5629,18 @@ hppa_range_profitable_for_hw_watchpoint (int pid, CORE_ADDR start, LONGEST len) char * -hppa_pid_or_tid_to_str (pid_t id) +hppa_pid_or_tid_to_str (ptid_t ptid) { static char buf[100]; /* Static because address returned. */ + pid_t id = PIDGET (ptid); /* Does this appear to be a process? If so, print it that way. */ if (is_process_id (id)) - return child_pid_to_str (id); + return child_pid_to_str (ptid); /* Else, print both the GDB thread number and the system thread id. */ - sprintf (buf, "thread %d (", pid_to_thread_id (id)); - strcat (buf, hppa_tid_to_str (id)); + sprintf (buf, "thread %d (", pid_to_thread_id (ptid)); + strcat (buf, hppa_tid_to_str (ptid)); strcat (buf, ")\0"); return buf; diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c index 20c05f3..c1549fc 100644 --- a/gdb/irix5-nat.c +++ b/gdb/irix5-nat.c @@ -1224,7 +1224,7 @@ solib_create_inferior_hook (void) stop_signal = TARGET_SIGNAL_0; do { - target_resume (-1, 0, stop_signal); + target_resume (pid_to_ptid (-1), 0, stop_signal); wait_for_inferior (); } while (stop_signal != TARGET_SIGNAL_TRAP); diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index a9d8f37..6df4d0d 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -73,7 +73,7 @@ struct lwp_info { /* The process id of the LWP. This is a combination of the LWP id and overall process id. */ - int pid; + ptid_t ptid; /* Non-zero if we sent this LWP a SIGSTOP (but the LWP didn't report it back yet). */ @@ -104,7 +104,8 @@ static int threaded; #ifndef TIDGET #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) #endif @@ -118,7 +119,7 @@ static int threaded; /* If the last reported event was a SIGTRAP, this variable is set to the process id of the LWP/thread that got it. */ -int trap_pid; +ptid_t trap_ptid; /* This module's target-specific operations. */ @@ -176,17 +177,17 @@ init_lwp_list (void) Return a pointer to the structure describing the new LWP. */ static struct lwp_info * -add_lwp (int pid) +add_lwp (ptid_t ptid) { struct lwp_info *lp; - gdb_assert (is_lwp (pid)); + gdb_assert (is_lwp (ptid)); lp = (struct lwp_info *) xmalloc (sizeof (struct lwp_info)); memset (lp, 0, sizeof (struct lwp_info)); - lp->pid = pid; + lp->ptid = ptid; lp->next = lwp_list; lwp_list = lp; @@ -199,14 +200,14 @@ add_lwp (int pid) /* Remove the LWP specified by PID from the list. */ static void -delete_lwp (int pid) +delete_lwp (ptid_t ptid) { struct lwp_info *lp, *lpprev; lpprev = NULL; for (lp = lwp_list; lp; lpprev = lp, lp = lp->next) - if (lp->pid == pid) + if (ptid_equal (lp->ptid, ptid)) break; if (!lp) @@ -228,15 +229,18 @@ delete_lwp (int pid) to PID. If no corresponding LWP could be found, return NULL. */ static struct lwp_info * -find_lwp_pid (int pid) +find_lwp_pid (ptid_t ptid) { struct lwp_info *lp; + int lwp; - if (is_lwp (pid)) - pid = GET_LWP (pid); + if (is_lwp (ptid)) + lwp = GET_LWP (ptid); + else + lwp = GET_PID (ptid); for (lp = lwp_list; lp; lp = lp->next) - if (pid == GET_LWP (lp->pid)) + if (lwp == GET_LWP (lp->ptid)) return lp; return NULL; @@ -263,21 +267,21 @@ iterate_over_lwps (int (*callback) (struct lwp_info *, void *), void *data) /* Helper functions. */ static void -restore_inferior_pid (void *arg) +restore_inferior_ptid (void *arg) { - int *saved_pid_ptr = arg; - inferior_pid = *saved_pid_ptr; + ptid_t *saved_ptid_ptr = arg; + inferior_ptid = *saved_ptid_ptr; xfree (arg); } static struct cleanup * -save_inferior_pid (void) +save_inferior_ptid (void) { - int *saved_pid_ptr; + ptid_t *saved_ptid_ptr; - saved_pid_ptr = xmalloc (sizeof (int)); - *saved_pid_ptr = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid_ptr); + saved_ptid_ptr = xmalloc (sizeof (ptid_t)); + *saved_ptid_ptr = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid_ptr); } @@ -290,7 +294,8 @@ save_inferior_pid (void) int lin_lwp_prepare_to_proceed (void) { - if (trap_pid && inferior_pid != trap_pid) + if (! ptid_equal (trap_ptid, null_ptid) + && ! ptid_equal (inferior_ptid, trap_ptid)) { /* Switched over from TRAP_PID. */ CORE_ADDR stop_pc = read_pc (); @@ -298,12 +303,12 @@ lin_lwp_prepare_to_proceed (void) /* Avoid switching where it wouldn't do any good, i.e. if both threads are at the same breakpoint. */ - trap_pc = read_pc_pid (trap_pid); + trap_pc = read_pc_pid (trap_ptid); if (trap_pc != stop_pc && breakpoint_here_p (trap_pc)) { /* User hasn't deleted the breakpoint. Return non-zero, and switch back to TRAP_PID. */ - inferior_pid = trap_pid; + inferior_ptid = trap_ptid; /* FIXME: Is this stuff really necessary? */ flush_cached_frames (); @@ -330,19 +335,19 @@ lin_lwp_open (char *args, int from_tty) process. */ void -lin_lwp_attach_lwp (int pid, int verbose) +lin_lwp_attach_lwp (ptid_t ptid, int verbose) { struct lwp_info *lp; - gdb_assert (is_lwp (pid)); + gdb_assert (is_lwp (ptid)); if (verbose) - printf_filtered ("[New %s]\n", target_pid_to_str (pid)); + printf_filtered ("[New %s]\n", target_pid_to_str (ptid)); - if (ptrace (PTRACE_ATTACH, GET_LWP (pid), 0, 0) < 0) - error ("Can't attach %s: %s", target_pid_to_str (pid), strerror (errno)); + if (ptrace (PTRACE_ATTACH, GET_LWP (ptid), 0, 0) < 0) + error ("Can't attach %s: %s", target_pid_to_str (ptid), strerror (errno)); - lp = add_lwp (pid); + lp = add_lwp (ptid); lp->signalled = 1; } @@ -375,7 +380,7 @@ find_lwp_callback (struct thread_info *tp, void *data) { struct lwp_info *lp = data; - if (tp->private->lwpid == GET_LWP (lp->pid)) + if (tp->private->lwpid == GET_LWP (lp->ptid)) return 1; return 0; @@ -394,7 +399,7 @@ resume_callback (struct lwp_info *lp, void *data) /* FIXME: kettenis/2000-08-26: This should really be handled properly by core GDB. */ - tp = find_thread_pid (lp->pid); + tp = find_thread_pid (lp->ptid); if (tp == NULL) tp = iterate_over_threads (find_lwp_callback, lp); gdb_assert (tp); @@ -411,7 +416,7 @@ resume_callback (struct lwp_info *lp, void *data) } #endif - child_resume (GET_LWP (lp->pid), 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (GET_LWP (lp->ptid)), 0, TARGET_SIGNAL_0); lp->stopped = 0; lp->step = 0; } @@ -420,7 +425,7 @@ resume_callback (struct lwp_info *lp, void *data) } static void -lin_lwp_resume (int pid, int step, enum target_signal signo) +lin_lwp_resume (ptid_t ptid, int step, enum target_signal signo) { struct lwp_info *lp; int resume_all; @@ -429,17 +434,17 @@ lin_lwp_resume (int pid, int step, enum target_signal signo) STEP is non-zero, a specific PID means `step only this process id'. But if STEP is zero, then PID means `continue *all* processes, but give the signal only to this one'. */ - resume_all = (pid == -1) || !step; + resume_all = (PIDGET (ptid) == -1) || !step; /* If PID is -1, it's the current inferior that should be handled special. */ - if (pid == -1) - pid = inferior_pid; + if (PIDGET (ptid) == -1) + ptid = inferior_ptid; - lp = find_lwp_pid (pid); + lp = find_lwp_pid (ptid); if (lp) { - pid = GET_LWP (lp->pid); + ptid = pid_to_ptid (GET_LWP (lp->ptid)); /* Remember if we're stepping. */ lp->step = step; @@ -462,7 +467,7 @@ lin_lwp_resume (int pid, int step, enum target_signal signo) if (resume_all) iterate_over_lwps (resume_callback, NULL); - child_resume (pid, step, signo); + child_resume (ptid, step, signo); } @@ -475,7 +480,7 @@ stop_callback (struct lwp_info *lp, void *data) { int ret; - ret = kill (GET_LWP (lp->pid), SIGSTOP); + ret = kill (GET_LWP (lp->ptid), SIGSTOP); gdb_assert (ret == 0); lp->signalled = 1; @@ -497,33 +502,33 @@ stop_wait_callback (struct lwp_info *lp, void *data) gdb_assert (lp->status == 0); - pid = waitpid (GET_LWP (lp->pid), &status, - is_cloned (lp->pid) ? __WCLONE : 0); + pid = waitpid (GET_LWP (lp->ptid), &status, + is_cloned (lp->ptid) ? __WCLONE : 0); if (pid == -1 && errno == ECHILD) /* OK, the proccess has disappeared. We'll catch the actual exit event in lin_lwp_wait. */ return 0; - gdb_assert (pid == GET_LWP (lp->pid)); + gdb_assert (pid == GET_LWP (lp->ptid)); if (WIFEXITED (status) || WIFSIGNALED (status)) { gdb_assert (num_lwps > 1); - if (in_thread_list (lp->pid)) + if (in_thread_list (lp->ptid)) { /* Core GDB cannot deal with us deleting the current thread. */ - if (lp->pid != inferior_pid) - delete_thread (lp->pid); + if (!ptid_equal (lp->ptid, inferior_ptid)) + delete_thread (lp->ptid); printf_unfiltered ("[%s exited]\n", - target_pid_to_str (lp->pid)); + target_pid_to_str (lp->ptid)); } if (debug_lin_lwp) fprintf_unfiltered (gdb_stdlog, - "%s exited.\n", target_pid_to_str (lp->pid)); + "%s exited.\n", target_pid_to_str (lp->ptid)); - delete_lwp (lp->pid); + delete_lwp (lp->ptid); return 0; } @@ -533,7 +538,7 @@ stop_wait_callback (struct lwp_info *lp, void *data) if (WSTOPSIG (status) != SIGSTOP) { if (WSTOPSIG (status) == SIGTRAP - && breakpoint_inserted_here_p (read_pc_pid (pid) + && breakpoint_inserted_here_p (read_pc_pid (pid_to_ptid (pid)) - DECR_PC_AFTER_BREAK)) { /* If a LWP other than the LWP that we're reporting an @@ -553,11 +558,13 @@ stop_wait_callback (struct lwp_info *lp, void *data) fprintf_unfiltered (gdb_stdlog, "Tripped breakpoint at %lx in LWP %d" " while waiting for SIGSTOP.\n", - (long) read_pc_pid (lp->pid), pid); + (long) read_pc_pid (lp->ptid), pid); /* Set the PC to before the trap. */ if (DECR_PC_AFTER_BREAK) - write_pc_pid (read_pc_pid (pid) - DECR_PC_AFTER_BREAK, pid); + write_pc_pid (read_pc_pid (pid_to_ptid (pid)) + - DECR_PC_AFTER_BREAK, + pid_to_ptid (pid)); } else { @@ -599,12 +606,13 @@ running_callback (struct lwp_info *lp, void *data) return (lp->stopped == 0); } -static int -lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +lin_lwp_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { struct lwp_info *lp = NULL; int options = 0; int status = 0; + pid_t pid = PIDGET (ptid); /* Make sure SIGCHLD is blocked. */ if (! sigismember (&blocked_mask, SIGCHLD)) @@ -625,7 +633,7 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) if (debug_lin_lwp) fprintf_unfiltered (gdb_stdlog, "Using pending wait status for LWP %d.\n", - GET_LWP (lp->pid)); + (int) GET_LWP (lp->ptid)); status = lp->status; lp->status = 0; @@ -636,14 +644,15 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) processes. */ options = __WCLONE | WNOHANG; } - else if (is_lwp (pid)) + else if (is_lwp (ptid)) { if (debug_lin_lwp) fprintf_unfiltered (gdb_stdlog, - "Waiting for specific LWP %d.\n", GET_LWP (pid)); + "Waiting for specific LWP %d.\n", + (int) GET_LWP (ptid)); /* We have a specific LWP to check. */ - lp = find_lwp_pid (GET_LWP (pid)); + lp = find_lwp_pid (ptid); gdb_assert (lp); status = lp->status; lp->status = 0; @@ -652,13 +661,13 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) if (status) fprintf_unfiltered (gdb_stdlog, "Using pending wait status for LWP %d.\n", - GET_LWP (lp->pid)); + GET_LWP (lp->ptid)); /* If we have to wait, take into account whether PID is a cloned process or not. And we have to convert it to something that the layer beneath us can understand. */ - options = is_cloned (lp->pid) ? __WCLONE : 0; - pid = GET_LWP (pid); + options = is_cloned (lp->ptid) ? __WCLONE : 0; + pid = GET_LWP (ptid); } if (status && lp->signalled) @@ -674,7 +683,8 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) /* Resume the thread. It should halt immediately returning the pending SIGSTOP. */ - child_resume (GET_LWP (lp->pid), lp->step, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, + TARGET_SIGNAL_0); lp->stopped = 0; /* This should catch the pending SIGSTOP. */ @@ -694,25 +704,26 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) { gdb_assert (pid == -1 || lwpid == pid); - lp = find_lwp_pid (lwpid); + lp = find_lwp_pid (pid_to_ptid (lwpid)); if (! lp) { - lp = add_lwp (BUILD_LWP (lwpid, inferior_pid)); + lp = add_lwp (BUILD_LWP (lwpid, GET_PID (inferior_ptid))); if (threaded) { gdb_assert (WIFSTOPPED (status) && WSTOPSIG (status) == SIGSTOP); lp->signalled = 1; - if (! in_thread_list (inferior_pid)) + if (! in_thread_list (inferior_ptid)) { - inferior_pid = BUILD_LWP (inferior_pid, inferior_pid); - add_thread (inferior_pid); + inferior_ptid = BUILD_LWP (GET_PID (inferior_ptid), + GET_PID (inferior_ptid)); + add_thread (inferior_ptid); } - add_thread (lp->pid); + add_thread (lp->ptid); printf_unfiltered ("[New %s]\n", - target_pid_to_str (lp->pid)); + target_pid_to_str (lp->ptid)); } } @@ -721,21 +732,21 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) left in the process. */ if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1) { - if (in_thread_list (lp->pid)) + if (in_thread_list (lp->ptid)) { /* Core GDB cannot deal with us deleting the current thread. */ - if (lp->pid != inferior_pid) - delete_thread (lp->pid); + if (! ptid_equal (lp->ptid, inferior_ptid)) + delete_thread (lp->ptid); printf_unfiltered ("[%s exited]\n", - target_pid_to_str (lp->pid)); + target_pid_to_str (lp->ptid)); } if (debug_lin_lwp) fprintf_unfiltered (gdb_stdlog, "%s exited.\n", - target_pid_to_str (lp->pid)); + target_pid_to_str (lp->ptid)); - delete_lwp (lp->pid); + delete_lwp (lp->ptid); /* Make sure there is at least one thread running. */ gdb_assert (iterate_over_lwps (running_callback, NULL)); @@ -753,12 +764,13 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) if (debug_lin_lwp) fprintf_unfiltered (gdb_stdlog, "Delayed SIGSTOP caught for %s.\n", - target_pid_to_str (lp->pid)); + target_pid_to_str (lp->ptid)); /* This is a delayed SIGSTOP. */ lp->signalled = 0; - child_resume (GET_LWP (lp->pid), lp->step, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, + TARGET_SIGNAL_0); lp->stopped = 0; /* Discard the event. */ @@ -803,7 +815,7 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) && signal_print_state (signo) == 0 && signal_pass_state (signo) == 1) { - child_resume (GET_LWP (lp->pid), lp->step, signo); + child_resume (pid_to_ptid (GET_LWP (lp->ptid)), lp->step, signo); lp->stopped = 0; status = 0; goto retry; @@ -824,18 +836,18 @@ lin_lwp_wait (int pid, struct target_waitstatus *ourstatus) process id. */ if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP) - trap_pid = (threaded ? lp->pid : GET_LWP (lp->pid)); + trap_ptid = (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid))); else - trap_pid = 0; + trap_ptid = null_ptid; store_waitstatus (ourstatus, status); - return (threaded ? lp->pid : GET_LWP (lp->pid)); + return (threaded ? lp->ptid : pid_to_ptid (GET_LWP (lp->ptid))); } static int kill_callback (struct lwp_info *lp, void *data) { - ptrace (PTRACE_KILL, GET_LWP (lp->pid), 0, 0); + ptrace (PTRACE_KILL, GET_LWP (lp->ptid), 0, 0); return 0; } @@ -851,22 +863,22 @@ kill_wait_callback (struct lwp_info *lp, void *data) /* For cloned processes we must check both with __WCLONE and without, since the exit status of a cloned process isn't reported with __WCLONE. */ - if (is_cloned (lp->pid)) + if (is_cloned (lp->ptid)) { do { - pid = waitpid (GET_LWP (lp->pid), NULL, __WCLONE); + pid = waitpid (GET_LWP (lp->ptid), NULL, __WCLONE); } - while (pid == GET_LWP (lp->pid)); + while (pid == GET_LWP (lp->ptid)); gdb_assert (pid == -1 && errno == ECHILD); } do { - pid = waitpid (GET_LWP (lp->pid), NULL, 0); + pid = waitpid (GET_LWP (lp->ptid), NULL, 0); } - while (pid == GET_LWP (lp->pid)); + while (pid == GET_LWP (lp->ptid)); gdb_assert (pid == -1 && errno == ECHILD); return 0; @@ -906,7 +918,7 @@ lin_lwp_mourn_inferior (void) init_lwp_list (); - trap_pid = 0; + trap_ptid = null_ptid; /* Restore the original signal mask. */ sigprocmask (SIG_SETMASK, &normal_mask, NULL); @@ -923,10 +935,10 @@ lin_lwp_mourn_inferior (void) static void lin_lwp_fetch_registers (int regno) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - if (is_lwp (inferior_pid)) - inferior_pid = GET_LWP (inferior_pid); + if (is_lwp (inferior_ptid)) + inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); fetch_inferior_registers (regno); @@ -936,10 +948,10 @@ lin_lwp_fetch_registers (int regno) static void lin_lwp_store_registers (int regno) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - if (is_lwp (inferior_pid)) - inferior_pid = GET_LWP (inferior_pid); + if (is_lwp (inferior_ptid)) + inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); store_inferior_registers (regno); @@ -951,11 +963,11 @@ lin_lwp_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); int xfer; - if (is_lwp (inferior_pid)) - inferior_pid = GET_LWP (inferior_pid); + if (is_lwp (inferior_ptid)) + inferior_ptid = pid_to_ptid (GET_LWP (inferior_ptid)); xfer = child_xfer_memory (memaddr, myaddr, len, write, attrib, target); @@ -964,12 +976,12 @@ lin_lwp_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, } static int -lin_lwp_thread_alive (int pid) +lin_lwp_thread_alive (ptid_t ptid) { - gdb_assert (is_lwp (pid)); + gdb_assert (is_lwp (ptid)); errno = 0; - ptrace (PTRACE_PEEKUSER, GET_LWP (pid), 0, 0); + ptrace (PTRACE_PEEKUSER, GET_LWP (ptid), 0, 0); if (errno) return 0; @@ -977,17 +989,17 @@ lin_lwp_thread_alive (int pid) } static char * -lin_lwp_pid_to_str (int pid) +lin_lwp_pid_to_str (ptid_t ptid) { static char buf[64]; - if (is_lwp (pid)) + if (is_lwp (ptid)) { - snprintf (buf, sizeof (buf), "LWP %d", GET_LWP (pid)); + snprintf (buf, sizeof (buf), "LWP %ld", GET_LWP (ptid)); return buf; } - return normal_pid_to_str (pid); + return normal_pid_to_str (ptid); } static void diff --git a/gdb/lin-thread.c b/gdb/lin-thread.c index 8c303fd..495fb43 100644 --- a/gdb/lin-thread.c +++ b/gdb/lin-thread.c @@ -127,11 +127,12 @@ #ifndef TIDGET #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) #endif -/* Macros for superimposing PID and TID into inferior_pid. */ +/* Macros for superimposing PID and TID into inferior_ptid. */ #define THREAD_FLAG 0x80000000 #define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0) #define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0) @@ -303,8 +304,8 @@ ps_ptwrite (gdb_ps_prochandle_t ph, /* write to text segment */ return rw_common (ph, addr, (char *) buf, size, PS_WRITE); } -static struct cleanup *save_inferior_pid (void); -static void restore_inferior_pid (void *saved_pid); +static struct cleanup *save_inferior_ptid (void); +static void restore_inferior_ptid (void *saved_pid); static char *thr_err_string (td_err_e); static char *thr_state_string (td_thr_state_e); @@ -315,10 +316,9 @@ td_thragent_t * main_threadagent; * Common proc_service routine for reading and writing memory. */ -/* FIXME: once we've munged the inferior_pid, why can't we +/* FIXME: once we've munged the inferior_ptid, why can't we simply call target_read/write_memory and return? */ - static ps_err_e rw_common (const struct ps_prochandle *ph, paddr_t addr, @@ -326,11 +326,11 @@ rw_common (const struct ps_prochandle *ph, int size, int write_p) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); int to_do = size; int done = 0; - inferior_pid = main_prochandle.pid; + inferior_ptid = pid_to_ptid (main_prochandle.pid); while (to_do > 0) { @@ -353,19 +353,19 @@ rw_common (const struct ps_prochandle *ph, } /* Cleanup functions used by the register callbacks - (which have to manipulate the global inferior_pid). */ + (which have to manipulate the global inferior_ptid). */ ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, /* Get LWP general regs */ lwpid_t lwpid, prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid); + inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid); current_target.to_fetch_registers (-1); - fill_gregset (gregset, -1); + fill_gregset ((gdb_gregset_t *) gregset, -1); do_cleanups (old_chain); return PS_OK; @@ -376,10 +376,10 @@ ps_lsetregs (gdb_ps_prochandle_t ph, /* Set LWP general regs */ lwpid_t lwpid, const prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid); - supply_gregset (gregset); + inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid); + supply_gregset ((gdb_gregset_t *) gregset); current_target.to_store_registers (-1); do_cleanups (old_chain); return PS_OK; @@ -390,9 +390,9 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, /* Get LWP float regs */ lwpid_t lwpid, gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid); + inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid); current_target.to_fetch_registers (-1); fill_fpregset (fpregset, -1); do_cleanups (old_chain); @@ -404,9 +404,9 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, /* Set LWP float regs */ lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, main_prochandle.pid); + inferior_ptid = BUILD_LWP (lwpid, main_prochandle.pid); supply_fpregset (fpregset); current_target.to_store_registers (-1); do_cleanups (old_chain); @@ -628,44 +628,44 @@ init_thread_db_library (void) 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); - void restore_inferior_pid (void *saved_pid); + struct cleanup *save_inferior_ptid (void); + void restore_inferior_ptid (void *saved_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 + 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 + to 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) { - int *saved_pid_ptr; + ptid_t *saved_ptid_ptr; - saved_pid_ptr = xmalloc (sizeof (int)); - *saved_pid_ptr = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid_ptr); + saved_ptid_ptr = xmalloc (sizeof (ptid_t)); + *saved_ptid_ptr = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid_ptr); } static void -restore_inferior_pid (void *arg) +restore_inferior_ptid (void *arg) { - int *saved_pid_ptr = arg; - inferior_pid = *saved_pid_ptr; + ptid_t *saved_ptid_ptr = arg; + inferior_ptid = *saved_ptid_ptr; xfree (arg); } @@ -920,10 +920,10 @@ enable_thread_event_reporting (td_thragent_t *ta) } /* Set up the breakpoint. */ - create_thread_event_breakpoint (notify.u.bptaddr); + create_thread_event_breakpoint ((CORE_ADDR) notify.u.bptaddr); /* Save it's location. */ - thread_creation_bkpt_address = notify.u.bptaddr; + thread_creation_bkpt_address = (CORE_ADDR) notify.u.bptaddr; /* thread death */ /* get breakpoint location */ @@ -933,10 +933,10 @@ enable_thread_event_reporting (td_thragent_t *ta) return; } /* Set up the breakpoint. */ - create_thread_event_breakpoint (notify.u.bptaddr); + create_thread_event_breakpoint ((CORE_ADDR) notify.u.bptaddr); /* Save it's location. */ - thread_death_bkpt_address = notify.u.bptaddr; + thread_death_bkpt_address = (CORE_ADDR) notify.u.bptaddr; } /* This function handles the global parts of disabling thread events. @@ -969,6 +969,7 @@ check_for_thread_event (struct target_waitstatus *tws, int event_pid) { /* FIXME: to be more efficient, we should keep a static list of threads, and update it only here (with td_ta_thr_iter). */ + return 0; } static void @@ -1044,7 +1045,7 @@ thread_db_new_objfile (struct objfile *objfile) goto quit; /* un-interesting object file */ /* Initialize our "main prochandle" with the main inferior pid. */ - main_prochandle.pid = PIDGET (inferior_pid); + main_prochandle.pid = PIDGET (inferior_ptid); /* Now attempt to open a thread_db connection to the thread library running in the child process. */ @@ -1058,7 +1059,7 @@ thread_db_new_objfile (struct objfile *objfile) break; case TD_OK: /* libthread detected in child: we go live now! */ thread_db_push_target (); - event_pid = inferior_pid; /* for resume */ + event_pid = PIDGET (inferior_ptid); /* for resume */ /* Now stop everyone else, and attach any new threads you find. */ p_td_ta_thr_iter (main_threadagent, @@ -1105,14 +1106,14 @@ quit: */ static int -thread_db_alive (int pid) +thread_db_alive (ptid_t ptid) { - if (is_thread (pid)) /* user-space (non-kernel) thread */ + if (is_thread (ptid)) /* user-space (non-kernel) thread */ { td_thrhandle_t th; td_err_e ret; + int pid = GET_THREAD (ptid); - pid = GET_THREAD (pid); if ((ret = p_td_ta_map_id2thr (main_threadagent, pid, &th)) != TD_OK) return 0; /* thread not found */ if ((ret = p_td_thr_validate (&th)) != TD_OK) @@ -1120,7 +1121,7 @@ thread_db_alive (int pid) return 1; /* known thread: return true */ } else if (target_beneath->to_thread_alive) - return target_beneath->to_thread_alive (pid); + return target_beneath->to_thread_alive (ptid); else return 0; /* default to "not alive" (shouldn't happen anyway) */ } @@ -1166,17 +1167,17 @@ get_lwp_from_thread_id (int tid /* thread_t? */) */ static char * -thread_db_pid_to_str (int pid) +thread_db_pid_to_str (ptid_t ptid) { static char buf[100]; td_thrhandle_t th; td_thrinfo_t ti; td_err_e ret; - if (is_thread (pid)) + if (is_thread (ptid)) { if ((ret = p_td_ta_map_id2thr (main_threadagent, - GET_THREAD (pid), + GET_THREAD (ptid), &th)) != TD_OK) error ("thread_db: map_id2thr failed: %s", thr_err_string (ret)); @@ -1185,14 +1186,14 @@ thread_db_pid_to_str (int pid) if (ti.ti_state == TD_THR_ACTIVE && ti.ti_lid != 0) - sprintf (buf, "Thread %d (LWP %d)", ti.ti_tid, ti.ti_lid); + sprintf (buf, "Thread %ld (LWP %d)", ti.ti_tid, ti.ti_lid); else - sprintf (buf, "Thread %d (%s)", ti.ti_tid, + sprintf (buf, "Thread %ld (%s)", ti.ti_tid, thr_state_string (ti.ti_state)); } - else if (GET_LWP (pid)) - sprintf (buf, "LWP %d", GET_LWP (pid)); - else return normal_pid_to_str (pid); + else if (GET_LWP (ptid)) + sprintf (buf, "LWP %ld", GET_LWP (ptid)); + else return normal_pid_to_str (ptid); return buf; } @@ -1210,7 +1211,7 @@ thread_db_files_info (struct target_ops *tgt_vector) } /* - * xfer_memory has to munge the inferior_pid before passing the call + * xfer_memory has to munge the inferior_ptid before passing the call * down to the target layer. */ @@ -1222,14 +1223,14 @@ thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite, struct cleanup *old_chain; int ret; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - if (is_thread (inferior_pid) || - !target_thread_alive (inferior_pid)) + if (is_thread (inferior_ptid) || + !target_thread_alive (inferior_ptid)) { /* FIXME: use the LID/LWP, so that underlying process layer can read memory from specific threads? */ - inferior_pid = main_prochandle.pid; + inferior_ptid = pid_to_ptid (main_prochandle.pid); } ret = target_beneath->to_xfer_memory (memaddr, myaddr, len, @@ -1239,7 +1240,7 @@ thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite, } /* - * fetch_registers has to determine if inferior_pid is a user-space thread. + * fetch_registers has to determine if inferior_ptid is a user-space thread. * If so, we use the thread_db API to get the registers. * And if not, we call the underlying process stratum. */ @@ -1253,15 +1254,15 @@ thread_db_fetch_registers (int regno) thread_t thread; td_err_e ret; - if (!is_thread (inferior_pid)) /* kernel thread */ + if (!is_thread (inferior_ptid)) /* kernel thread */ { /* pass the request on to the target underneath. */ target_beneath->to_fetch_registers (regno); return; } - /* convert inferior_pid into a td_thrhandle_t */ + /* convert inferior_ptid into a td_thrhandle_t */ - if ((thread = GET_THREAD (inferior_pid)) == 0) + if ((thread = GET_THREAD (inferior_ptid)) == 0) error ("fetch_registers: thread == 0"); if ((ret = p_td_ta_map_id2thr (main_threadagent, thread, &thandle)) != TD_OK) @@ -1283,13 +1284,13 @@ thread_db_fetch_registers (int regno) because the td routines call ps_lget* which affect the values stored in the registers array. */ - supply_gregset (gregset); + supply_gregset ((gdb_gregset_t *) gregset); supply_fpregset (&fpregset); } /* - * store_registers has to determine if inferior_pid is a user-space thread. + * store_registers has to determine if inferior_ptid is a user-space thread. * If so, we use the thread_db API to get the registers. * And if not, we call the underlying process stratum. */ @@ -1303,15 +1304,15 @@ thread_db_store_registers (int regno) thread_t thread; td_err_e ret; - if (!is_thread (inferior_pid)) /* Kernel thread: */ + if (!is_thread (inferior_ptid)) /* Kernel thread: */ { /* pass the request on to the underlying target vector. */ target_beneath->to_store_registers (regno); return; } - /* convert inferior_pid into a td_thrhandle_t */ + /* convert inferior_ptid into a td_thrhandle_t */ - if ((thread = GET_THREAD (inferior_pid)) == 0) + if ((thread = GET_THREAD (inferior_ptid)) == 0) error ("store_registers: thread == 0"); if ((ret = p_td_ta_map_id2thr (main_threadagent, thread, &thandle)) != TD_OK) @@ -1335,7 +1336,7 @@ thread_db_store_registers (int regno) } - fill_gregset (gregset, regno); + fill_gregset ((gdb_gregset_t *) gregset, regno); fill_fpregset (&fpregset, regno); if ((ret = p_td_thr_setgregs (&thandle, gregset)) != TD_OK) @@ -1350,12 +1351,12 @@ handle_new_thread (int tid, /* user thread id */ int lid, /* kernel thread id */ int verbose) { - int gdb_pid = BUILD_THREAD (tid, main_prochandle.pid); + ptid_t gdb_ptid = BUILD_THREAD (tid, main_prochandle.pid); int wait_pid, wait_status; if (verbose) - printf_filtered ("[New %s]\n", target_pid_to_str (gdb_pid)); - add_thread (gdb_pid); + printf_filtered ("[New %s]\n", target_pid_to_str (gdb_ptid)); + add_thread (gdb_ptid); if (lid != main_prochandle.pid) { @@ -1408,7 +1409,7 @@ find_new_threads_callback (const td_thrhandle_t *th, void *ignored) static void thread_db_find_new_threads (void) { - if (inferior_pid == -1) /* FIXME: still necessary? */ + if (PIDGET (inferior_ptid) == -1) /* FIXME: still necessary? */ { printf_filtered ("No process.\n"); return; @@ -1427,7 +1428,7 @@ thread_db_find_new_threads (void) /* * Resume all threads, or resume a single thread. * If step is true, then single-step the appropriate thread - * (or single-step inferior_pid, but continue everyone else). + * (or single-step inferior_ptid, but continue everyone else). * If signo is true, then send that signal to at least one thread. */ @@ -1467,7 +1468,7 @@ resume_thread_callback (const td_thrhandle_t *th, void *data) /* Unconditionally continue the thread with no signal. Only the event thread will get a signal of any kind. */ - target_beneath->to_resume (ti.ti_lid, 0, 0); + target_beneath->to_resume (pid_to_ptid (ti.ti_lid), 0, 0); } return 0; } @@ -1480,7 +1481,7 @@ new_resume_thread_callback (threadinfo *thread, void *data) { /* Unconditionally continue the thread with no signal (for now). */ - target_beneath->to_resume (thread->lid, 0, 0); + target_beneath->to_resume (pid_to_ptid (thread->lid), 0, 0); } return 0; } @@ -1490,29 +1491,29 @@ static int last_resume_step; static int last_resume_signo; static void -thread_db_resume (int pid, int step, enum target_signal signo) +thread_db_resume (ptid_t ptid, int step, enum target_signal signo) { - last_resume_pid = pid; + last_resume_pid = PIDGET (ptid); last_resume_step = step; last_resume_signo = signo; /* resuming a specific pid? */ - if (pid != -1) + if (PIDGET (ptid) != -1) { - if (is_thread (pid)) - pid = get_lwp_from_thread_id (GET_THREAD (pid)); - else if (GET_LWP (pid)) - pid = GET_LWP (pid); + if (is_thread (ptid)) + ptid = pid_to_ptid (get_lwp_from_thread_id (GET_THREAD (ptid))); + else if (GET_LWP (ptid)) + ptid = pid_to_ptid (GET_LWP (ptid)); } /* Apparently the interpretation of 'pid' is dependent on 'step': If step is true, then a specific pid means 'step only this pid'. But if step is not true, then pid means 'continue ALL pids, but give the signal only to this one'. */ - if (pid != -1 && step) + if (PIDGET (ptid) != -1 && step) { /* FIXME: is this gonna work in all circumstances? */ - target_beneath->to_resume (pid, step, signo); + target_beneath->to_resume (ptid, step, signo); } else { @@ -1529,11 +1530,11 @@ thread_db_resume (int pid, int step, enum target_signal signo) /* now resume event thread, and if necessary also main thread. */ if (event_pid) { - target_beneath->to_resume (event_pid, step, signo); + target_beneath->to_resume (pid_to_ptid (event_pid), step, signo); } if (event_pid != main_prochandle.pid) { - target_beneath->to_resume (main_prochandle.pid, 0, 0); + target_beneath->to_resume (pid_to_ptid (main_prochandle.pid), 0, 0); } } } @@ -1546,7 +1547,7 @@ stop_or_attach_thread_callback (const td_thrhandle_t *th, void *data) { td_thrinfo_t ti; td_err_e ret; - int gdb_pid; + ptid_t gdb_ptid; int on_off = 1; if ((ret = p_td_thr_get_info (th, &ti)) != TD_OK) @@ -1559,8 +1560,8 @@ stop_or_attach_thread_callback (const td_thrhandle_t *th, void *data) We build this list anew at every wait event. */ insert_thread (ti.ti_tid, ti.ti_lid, ti.ti_state, ti.ti_type); /* Now: if we've already seen it, stop it, else add it and attach it. */ - gdb_pid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid); - if (!in_thread_list (gdb_pid)) /* new thread */ + gdb_ptid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid); + if (!in_thread_list (gdb_ptid)) /* new thread */ { handle_new_thread (ti.ti_tid, ti.ti_lid, 1); /* Enable thread events */ @@ -1655,13 +1656,14 @@ wait_for_stop (int pid) if (retpid != event_pid && signo == SIGTRAP && - breakpoint_inserted_here_p (read_pc_pid (retpid) - + breakpoint_inserted_here_p (read_pc_pid (pid_to_ptid (retpid)) - DECR_PC_AFTER_BREAK)) { /* Set the pc to before the trap and DO NOT re-send the signal */ if (DECR_PC_AFTER_BREAK) - write_pc_pid (read_pc_pid (retpid) - DECR_PC_AFTER_BREAK, - retpid); + write_pc_pid (read_pc_pid (pid_to_ptid (retpid)) + - DECR_PC_AFTER_BREAK, + pid_to_ptid (retpid)); } /* Since SIGINT gets forwarded to the entire process group @@ -1676,7 +1678,7 @@ wait_for_stop (int pid) { wstatus [signo] = 1; } - child_resume (retpid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (retpid), 0, TARGET_SIGNAL_0); continue; } @@ -1732,14 +1734,15 @@ new_wait_thread_callback (threadinfo *thread, void *data) * user-space thread. */ -static int -thread_db_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { td_thrhandle_t thandle; td_thrinfo_t ti; td_err_e ret; lwpid_t lwp; int retpid; + ptid_t retptid; int status; int save_errno; @@ -1753,10 +1756,10 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus) /* FIXME: should I do the wait right here inline? */ #if 0 - if (pid == -1) + if (PIDGET (ptid) == -1) lwp = -1; else - lwp = get_lwp_from_thread_id (GET_THREAD (pid)); + lwp = get_lwp_from_thread_id (GET_THREAD (ptid)); #endif @@ -1767,7 +1770,7 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus) FIXME: do I have any killing to do? Can I get this event mistakenly from a thread? */ if (ourstatus->kind == TARGET_WAITKIND_EXITED) - return retpid; + return pid_to_ptid (retpid); /* OK, we got an event of interest. Go stop all threads and look for new ones. @@ -1809,44 +1812,46 @@ thread_db_wait (int pid, struct target_waitstatus *ourstatus) /* If the process layer does not furnish an lwp, then perhaps the returned pid IS the lwp... */ - if ((lwp = GET_LWP (retpid)) == 0) +#if 0 /* Always true (if it'd compile...) */ + if ((lwp = GET_LWP (pid_to_ptid (retpid))) == 0) +#endif lwp = retpid; if ((ret = p_td_ta_map_lwp2thr (main_threadagent, lwp, &thandle)) != TD_OK) - return retpid; /* LWP is not mapped onto a user-space thread. */ + return pid_to_ptid (retpid); /* LWP is not mapped onto a user-space thread. */ if ((ret = p_td_thr_validate (&thandle)) != TD_OK) - return retpid; /* LWP is not mapped onto a valid thread. */ + return pid_to_ptid (retpid); /* LWP is not mapped onto a valid thread. */ if ((ret = p_td_thr_get_info (&thandle, &ti)) != TD_OK) { warning ("thread_db: thr_get_info failed ('%s')", thr_err_string (ret)); - return retpid; + return pid_to_ptid (retpid); } - retpid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid); + retptid = BUILD_THREAD (ti.ti_tid, main_prochandle.pid); /* If this is a new user thread, notify GDB about it. */ - if (!in_thread_list (retpid)) + if (!in_thread_list (retptid)) { - printf_filtered ("[New %s]\n", target_pid_to_str (retpid)); - add_thread (retpid); + printf_filtered ("[New %s]\n", target_pid_to_str (retptid)); + add_thread (retptid); } #if 0 /* Now detect if this is a thread creation/deletion event: */ check_for_thread_event (ourstatus, retpid); #endif - return retpid; + return retptid; } /* * kill has to call the underlying kill. - * FIXME: I'm not sure if it's necessary to check inferior_pid any more, - * but we might need to fix inferior_pid up if it's a user thread. + * FIXME: I'm not sure if it's necessary to check inferior_ptid any more, + * but we might need to fix inferior_ptid up if it's a user thread. */ static int -kill_thread_callback (td_thrhandle_t *th, void *data) +kill_thread_callback (const td_thrhandle_t *th, void *data) { td_thrinfo_t ti; td_err_e ret; @@ -1874,7 +1879,7 @@ static void thread_db_kill (void) /* Fixme: For Linux, threads may need to be waited. */ - if (inferior_pid != 0) + if (! ptid_equal (inferior_ptid, null_ptid)) { /* Go kill the children first. Save the main thread for last. */ p_td_ta_thr_iter (main_threadagent, @@ -1891,7 +1896,7 @@ static void thread_db_kill (void) detach would not work. */ disable_thread_event_reporting (main_threadagent); - inferior_pid = main_prochandle.pid; + inferior_ptid = pid_to_ptid (main_prochandle.pid); /* * Since both procfs_kill and ptrace_kill call target_mourn, @@ -1936,7 +1941,7 @@ static void thread_db_mourn_inferior (void) */ static int -detach_thread_callback (td_thrhandle_t *th, void *data) +detach_thread_callback (const td_thrhandle_t *th, void *data) { /* Called once per thread. */ td_thrinfo_t ti; @@ -1969,8 +1974,8 @@ detach_thread_callback (td_thrhandle_t *th, void *data) /* Now cancel any pending SIGTRAPS. FIXME! */ /* Call underlying detach method. FIXME just detach it. */ - old_chain = save_inferior_pid (); - inferior_pid = ti.ti_lid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (ti.ti_lid); detach (TARGET_SIGNAL_0); do_cleanups (old_chain); } @@ -1999,7 +2004,7 @@ thread_db_detach (char *args, int from_tty) thread_db_unpush_target (); /* above call nullifies target_beneath, so don't use that! */ - inferior_pid = PIDGET (inferior_pid); + inferior_ptid = pid_to_ptid (PIDGET (inferior_ptid)); target_detach (args, from_tty); } diff --git a/gdb/linux-thread.c b/gdb/linux-thread.c index 8e73eb2..922a563 100644 --- a/gdb/linux-thread.c +++ b/gdb/linux-thread.c @@ -205,10 +205,11 @@ static CORE_ADDR linuxthreads_breakpoint_addr; #endif /* Check to see if the given thread is alive. */ static int -linuxthreads_thread_alive (int pid) +linuxthreads_thread_alive (ptid_t ptid) { errno = 0; - return ptrace (PT_READ_U, pid, (PTRACE_ARG3_TYPE)0, 0) >= 0 || errno == 0; + return ptrace (PT_READ_U, PIDGET (ptid), (PTRACE_ARG3_TYPE)0, 0) >= 0 + || errno == 0; } /* On detach(), find a SIGTRAP status. If stop is non-zero, find a @@ -308,7 +309,7 @@ linuxthreads_find_trap (int pid, int stop) for (;;) { /* resume the child every time... */ - child_resume (pid, 1, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (pid), 1, TARGET_SIGNAL_0); /* loop as long as errno == EINTR: waitpid syscall may be aborted due to GDB receiving a signal. @@ -373,24 +374,24 @@ linuxthreads_find_trap (int pid, int stop) return 1; } -/* Cleanup stub for save_inferior_pid. */ +/* Cleanup stub for save_inferior_ptid. */ static void -restore_inferior_pid (void *arg) +restore_inferior_ptid (void *arg) { - int *saved_pid_ptr = arg; - inferior_pid = *saved_pid_ptr; + ptid_t *saved_ptid_ptr = arg; + inferior_ptid = *saved_ptid_ptr; xfree (arg); } -/* Register a cleanup to restore the value of inferior_pid. */ +/* Register a cleanup to restore the value of inferior_ptid. */ static struct cleanup * -save_inferior_pid (void) +save_inferior_ptid (void) { - int *saved_pid_ptr; + ptid_t *saved_ptid_ptr; - saved_pid_ptr = xmalloc (sizeof (int)); - *saved_pid_ptr = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid_ptr); + saved_ptid_ptr = xmalloc (sizeof (ptid_t)); + *saved_ptid_ptr = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid_ptr); } static void @@ -633,9 +634,10 @@ remove_breakpoint (int pid) if (linuxthreads_breakpoint_zombie[j].pid == pid) break; - if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + if (in_thread_list (pid_to_ptid (pid)) + && linuxthreads_thread_alive (pid_to_ptid (pid))) { - CORE_ADDR pc = read_pc_pid (pid); + CORE_ADDR pc = read_pc_pid (pid_to_ptid (pid)); if (linuxthreads_breakpoint_addr == pc - DECR_PC_AFTER_BREAK && j > linuxthreads_breakpoint_last) { @@ -651,7 +653,7 @@ remove_breakpoint (int pid) static void kill_thread (int pid) { - if (in_thread_list (pid)) + if (in_thread_list (pid_to_ptid (pid))) { ptrace (PT_KILL, pid, (PTRACE_ARG3_TYPE) 0, 0); } @@ -665,17 +667,17 @@ kill_thread (int pid) static void resume_thread (int pid) { - if (pid != inferior_pid - && in_thread_list (pid) - && linuxthreads_thread_alive (pid)) + if (pid != PIDGET (inferior_ptid) + && in_thread_list (pid_to_ptid (pid)) + && linuxthreads_thread_alive (pid_to_ptid (pid))) { if (pid == linuxthreads_step_pid) { - child_resume (pid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (pid), 1, linuxthreads_step_signo); } else { - child_resume (pid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (pid), 0, TARGET_SIGNAL_0); } } } @@ -684,14 +686,16 @@ resume_thread (int pid) static void detach_thread (int pid) { - if (in_thread_list (pid) && linuxthreads_thread_alive (pid)) + ptid_t ptid = pid_to_ptid (pid); + + if (in_thread_list (ptid) && linuxthreads_thread_alive (ptid)) { /* Remove pending SIGTRAP and SIGSTOP */ linuxthreads_find_trap (pid, 1); - inferior_pid = pid; + inferior_ptid = ptid; detach (TARGET_SIGNAL_0); - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); } } @@ -707,17 +711,18 @@ attach_thread (int pid) static void stop_thread (int pid) { - if (pid != inferior_pid) + if (pid != PIDGET (inferior_ptid)) { - if (in_thread_list (pid)) + if (in_thread_list (pid_to_ptid (pid))) { kill (pid, SIGSTOP); } else if (ptrace (PT_ATTACH, pid, (PTRACE_ARG3_TYPE) 0, 0) == 0) { if (!linuxthreads_attach_pending) - printf_filtered ("[New %s]\n", target_pid_to_str (pid)); - add_thread (pid); + printf_filtered ("[New %s]\n", + target_pid_to_str (pid_to_ptid (pid))); + add_thread (pid_to_ptid (pid)); if (linuxthreads_sig_debug.signal) { /* After a new thread in glibc 2.1 signals gdb its existence, @@ -738,7 +743,7 @@ wait_thread (int pid) int status; int rpid; - if (pid != inferior_pid && in_thread_list (pid)) + if (pid != PIDGET (inferior_ptid) && in_thread_list (pid_to_ptid (pid))) { /* loop as long as errno == EINTR: waitpid syscall may be aborted if GDB receives a signal. @@ -778,7 +783,7 @@ wait_thread (int pid) { break; } - if (errno != EINTR && linuxthreads_thread_alive (pid)) + if (errno != EINTR && linuxthreads_thread_alive (pid_to_ptid (pid))) perror_with_name ("wait_thread/waitpid"); /* the thread is dead. */ @@ -805,20 +810,20 @@ update_stop_threads (int test_pid) { if (linuxthreads_manager) { - if (test_pid > 0 && test_pid != inferior_pid) + if (test_pid > 0 && test_pid != PIDGET (inferior_ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } read_memory (linuxthreads_manager, (char *)&linuxthreads_manager_pid, sizeof (pid_t)); } if (linuxthreads_initial) { - if (test_pid > 0 && test_pid != inferior_pid) + if (test_pid > 0 && test_pid != PIDGET (inferior_ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } read_memory(linuxthreads_initial, (char *)&linuxthreads_initial_pid, sizeof (pid_t)); @@ -828,13 +833,14 @@ update_stop_threads (int test_pid) if (linuxthreads_manager_pid != 0) { if (old_chain == NULL && test_pid > 0 && - test_pid != inferior_pid && linuxthreads_thread_alive (test_pid)) + test_pid != PIDGET (inferior_ptid) + && linuxthreads_thread_alive (pid_to_ptid (test_pid))) { - old_chain = save_inferior_pid (); - inferior_pid = test_pid; + old_chain = save_inferior_ptid (); + inferior_ptid = pid_to_ptid (test_pid); } - if (linuxthreads_thread_alive (inferior_pid)) + if (linuxthreads_thread_alive (inferior_ptid)) { if (test_pid > 0) { @@ -844,14 +850,14 @@ update_stop_threads (int test_pid) stop_thread (linuxthreads_manager_pid); wait_thread (linuxthreads_manager_pid); } - if (!in_thread_list (test_pid)) + if (!in_thread_list (pid_to_ptid (test_pid))) { if (!linuxthreads_attach_pending) printf_filtered ("[New %s]\n", - target_pid_to_str (test_pid)); - add_thread (test_pid); + target_pid_to_str (pid_to_ptid (test_pid))); + add_thread (pid_to_ptid (test_pid)); if (linuxthreads_sig_debug.signal - && inferior_pid == test_pid) + && PIDGET (inferior_ptid) == test_pid) { /* After a new thread in glibc 2.1 signals gdb its existence, it suspends itself and wait for @@ -1033,7 +1039,7 @@ any thread other than the main thread."); linuxthreads_breakpoint_zombie = (struct linuxthreads_breakpoint *) xmalloc (sizeof (struct linuxthreads_breakpoint) * (linuxthreads_max + 1)); - if (inferior_pid && + if (PIDGET (inferior_ptid) != 0 && !linuxthreads_attach_pending && !using_thread_db) /* suppressed by thread_db module */ { @@ -1041,7 +1047,7 @@ any thread other than the main thread."); target_write_memory (linuxthreads_debug, (char *)&on, sizeof (on)); linuxthreads_attach_pending = 1; - update_stop_threads (inferior_pid); + update_stop_threads (PIDGET (inferior_ptid)); linuxthreads_attach_pending = 0; } @@ -1062,13 +1068,14 @@ linuxthreads_prepare_to_proceed (int step) if (!linuxthreads_max || !linuxthreads_manager_pid || !linuxthreads_breakpoint_pid - || !breakpoint_here_p (read_pc_pid (linuxthreads_breakpoint_pid))) + || !breakpoint_here_p ( + read_pc_pid (pid_to_ptid (linuxthreads_breakpoint_pid)))) return 0; if (step) { /* Mark the current inferior as single stepping process. */ - linuxthreads_step_pid = inferior_pid; + linuxthreads_step_pid = PIDGET (inferior_ptid); } linuxthreads_inferior_pid = linuxthreads_breakpoint_pid; @@ -1078,9 +1085,10 @@ linuxthreads_prepare_to_proceed (int step) /* Convert a pid to printable form. */ char * -linuxthreads_pid_to_str (int pid) +linuxthreads_pid_to_str (ptid_t ptid) { static char buf[100]; + int pid = PIDGET (ptid); sprintf (buf, "%s %d%s", linuxthreads_max ? "Thread" : "Pid", pid, (pid == linuxthreads_manager_pid) ? " (manager thread)" @@ -1139,26 +1147,28 @@ linuxthreads_detach (char *args, int from_tty) continue; pid = linuxthreads_breakpoint_zombie[i].pid; - if (!linuxthreads_thread_alive (pid)) + if (!linuxthreads_thread_alive (pid_to_ptid (pid))) continue; - if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (pid)) + if (linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (pid))) continue; /* Continue in STEP mode until the thread pc has moved or until SIGTRAP is found on the same PC. */ if (linuxthreads_find_trap (pid, 0) - && linuxthreads_breakpoint_zombie[i].pc == read_pc_pid (pid)) + && linuxthreads_breakpoint_zombie[i].pc + == read_pc_pid (pid_to_ptid (pid))) write_pc_pid (linuxthreads_breakpoint_zombie[i].pc - - DECR_PC_AFTER_BREAK, pid); + - DECR_PC_AFTER_BREAK, pid_to_ptid (pid)); } /* Detach thread after thread. */ - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); iterate_active_threads (detach_thread, 1); /* Remove pending SIGTRAP and SIGSTOP */ - linuxthreads_find_trap (inferior_pid, 1); + linuxthreads_find_trap (PIDGET (inferior_ptid), 1); linuxthreads_wait_last = -1; WSETSTOP (linuxthreads_exit_status, 0); @@ -1184,11 +1194,11 @@ linuxthreads_detach (char *args, int from_tty) signal activated. */ static void -linuxthreads_resume (int pid, int step, enum target_signal signo) +linuxthreads_resume (ptid_t ptid, int step, enum target_signal signo) { if (!linuxthreads_max || stop_soon_quietly || linuxthreads_manager_pid == 0) { - child_ops.to_resume (pid, step, signo); + child_ops.to_resume (ptid, step, signo); } else { @@ -1205,28 +1215,28 @@ linuxthreads_resume (int pid, int step, enum target_signal signo) struct cleanup *old_chain = NULL; int i; - if (pid < 0) + if (PIDGET (ptid) < 0) { - linuxthreads_step_pid = step ? inferior_pid : 0; + linuxthreads_step_pid = step ? PIDGET (inferior_ptid) : 0; linuxthreads_step_signo = signo; - rpid = inferior_pid; + rpid = PIDGET (inferior_ptid); } else - rpid = pid; + rpid = PIDGET (ptid); - if (pid < 0 || !step) + if (PIDGET (ptid) < 0 || !step) { linuxthreads_breakpoints_inserted = 1; /* Walk through linuxthreads array in order to resume threads */ - if (pid >= 0 && inferior_pid != pid) + if (PIDGET (ptid) >= 0 && !ptid_equal (inferior_ptid, ptid)) { - old_chain = save_inferior_pid (); - inferior_pid = pid; + old_chain = save_inferior_ptid (); + inferior_ptid = ptid; } iterate_active_threads (resume_thread, 0); - if (linuxthreads_manager_pid != inferior_pid + if (linuxthreads_manager_pid != PIDGET (inferior_ptid) && !linuxthreads_pending_status (linuxthreads_manager_pid)) resume_thread (linuxthreads_manager_pid); } @@ -1237,7 +1247,8 @@ linuxthreads_resume (int pid, int step, enum target_signal signo) for (i = 0; i <= linuxthreads_breakpoint_last; i++) if (linuxthreads_breakpoint_zombie[i].pid == rpid) { - if (linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + if (linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (rpid))) { /* The current pc is out of zombie breakpoint. */ REMOVE_BREAKPOINT_ZOMBIE(i); @@ -1253,7 +1264,7 @@ linuxthreads_resume (int pid, int step, enum target_signal signo) /* [unles it has a wait event pending] */ if (!linuxthreads_pending_status (rpid)) { - child_ops.to_resume (rpid, step, signo); + child_ops.to_resume (pid_to_ptid (rpid), step, signo); } } } @@ -1313,14 +1324,15 @@ linux_child_wait (int pid, int *rpid, int *status) /* 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 -linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +linuxthreads_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { int status; int rpid; int i; int last; int *wstatus; + int pid = PIDGET (ptid); if (linuxthreads_max && !linuxthreads_breakpoints_inserted) wstatus = alloca (LINUXTHREAD_NSIG * sizeof (int)); @@ -1340,7 +1352,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) if (linuxthreads_inferior_pid) pid = linuxthreads_inferior_pid; else if (pid < 0) - pid = inferior_pid; + pid = PIDGET (inferior_ptid); last = rpid = 0; } else if (pid < 0 && linuxthreads_wait_last >= 0) @@ -1383,7 +1395,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) if (WIFEXITED(linuxthreads_exit_status)) { store_waitstatus (ourstatus, linuxthreads_exit_status); - return inferior_pid; + return inferior_ptid; } else { @@ -1393,7 +1405,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) /* Claim it exited with unknown signal. */ ourstatus->kind = TARGET_WAITKIND_SIGNALLED; ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; - return -1; + return pid_to_ptid (-1); } } @@ -1420,7 +1432,8 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) linuxthreads_breakpoint_zombie[i].pid = rpid; linuxthreads_breakpoint_last++; } - linuxthreads_breakpoint_zombie[i].pc = read_pc_pid (rpid); + linuxthreads_breakpoint_zombie[i].pc + = read_pc_pid (pid_to_ptid (rpid)); linuxthreads_breakpoint_zombie[i].step = 1; } else @@ -1435,7 +1448,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) wstatus[last++] = status; } } - child_resume (rpid, 1, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 1, TARGET_SIGNAL_0); continue; } if (linuxthreads_inferior_pid) @@ -1453,11 +1466,12 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) { if (linuxthreads_step_pid == rpid) { - child_resume (rpid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (rpid), 1, + linuxthreads_step_signo); } else { - child_resume (rpid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0); } } continue; @@ -1490,7 +1504,8 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) { /* There is a potential zombie breakpoint */ if (WIFEXITED(status) - || linuxthreads_breakpoint_zombie[i].pc != read_pc_pid (rpid)) + || linuxthreads_breakpoint_zombie[i].pc + != read_pc_pid (pid_to_ptid (rpid))) { /* The current pc is out of zombie breakpoint. */ REMOVE_BREAKPOINT_ZOMBIE(i); @@ -1500,14 +1515,14 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) { /* This is a real one ==> decrement PC and restart. */ write_pc_pid (linuxthreads_breakpoint_zombie[i].pc - - DECR_PC_AFTER_BREAK, rpid); + - DECR_PC_AFTER_BREAK, pid_to_ptid (rpid)); if (linuxthreads_step_pid == rpid) { - child_resume (rpid, 1, linuxthreads_step_signo); + child_resume (pid_to_ptid (rpid), 1, linuxthreads_step_signo); } else { - child_resume (rpid, 0, TARGET_SIGNAL_0); + child_resume (pid_to_ptid (rpid), 0, TARGET_SIGNAL_0); } continue; } @@ -1518,7 +1533,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) update_stop_threads (rpid); } - else if (rpid != inferior_pid) + else if (rpid != PIDGET (inferior_ptid)) continue; store_waitstatus (ourstatus, status); @@ -1542,7 +1557,7 @@ linuxthreads_wait (int pid, struct target_waitstatus *ourstatus) else if (linuxthreads_breakpoint_pid) linuxthreads_breakpoint_pid = 0; - return rpid; + return pid_to_ptid (rpid); } } @@ -1610,17 +1625,17 @@ linuxthreads_kill (void) int rpid; int status; - if (inferior_pid == 0) + if (PIDGET (inferior_ptid) == 0) return; if (linuxthreads_max && linuxthreads_manager_pid != 0) { /* Remove all threads status. */ - inferior_pid = linuxthreads_manager_pid; + inferior_ptid = pid_to_ptid (linuxthreads_manager_pid); iterate_active_threads (kill_thread, 1); } - kill_thread (inferior_pid); + kill_thread (PIDGET (inferior_ptid)); #if 0 /* doing_quit_force solves a real problem, but I think a properly @@ -1639,9 +1654,9 @@ linuxthreads_kill (void) kill_thread (rpid); } else - while ((rpid = waitpid (inferior_pid, &status, 0)) > 0) + while ((rpid = waitpid (PIDGET (inferior_ptid), &status, 0)) > 0) if (!WIFEXITED(status)) - ptrace (PT_KILL, inferior_pid, (PTRACE_ARG3_TYPE) 0, 0); + ptrace (PT_KILL, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) 0, 0); } #endif diff --git a/gdb/lynx-nat.c b/gdb/lynx-nat.c index 28ef6b6..e76406f 100644 --- a/gdb/lynx-nat.c +++ b/gdb/lynx-nat.c @@ -287,8 +287,8 @@ fetch_inferior_registers (int regno) int i; errno = 0; - retval = ptrace (PTRACE_GETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & ec, - 0); + retval = ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) & ec, 0); if (errno) perror_with_name ("ptrace(PTRACE_GETREGS)"); @@ -340,8 +340,8 @@ fetch_inferior_registers (int regno) int i; errno = 0; - retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc, - 0); + retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) & fc, 0); if (errno) perror_with_name ("ptrace(PTRACE_GETFPREGS)"); @@ -396,8 +396,8 @@ store_inferior_registers (int regno) 8 * REGISTER_RAW_SIZE (O0_REGNUM)); errno = 0; - retval = ptrace (PTRACE_SETREGS, inferior_pid, (PTRACE_ARG3_TYPE) & ec, - 0); + retval = ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) & ec, 0); if (errno) perror_with_name ("ptrace(PTRACE_SETREGS)"); } @@ -444,8 +444,8 @@ store_inferior_registers (int regno) /* We read fcontext first so that we can get good values for fq_t... */ errno = 0; - retval = ptrace (PTRACE_GETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc, - 0); + retval = ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) & fc, 0); if (errno) perror_with_name ("ptrace(PTRACE_GETFPREGS)"); @@ -455,8 +455,8 @@ store_inferior_registers (int regno) fc.fsr = read_register (FPS_REGNUM); errno = 0; - retval = ptrace (PTRACE_SETFPREGS, inferior_pid, (PTRACE_ARG3_TYPE) & fc, - 0); + retval = ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid), + (PTRACE_ARG3_TYPE) & fc, 0); if (errno) perror_with_name ("ptrace(PTRACE_SETFPREGS)"); } @@ -508,7 +508,7 @@ fetch_inferior_registers (int regno) else reglo = reghi = regno; - ecp = registers_addr (inferior_pid); + ecp = registers_addr (PIDGET (inferior_ptid)); for (regno = reglo; regno <= reghi; regno++) { @@ -524,7 +524,7 @@ fetch_inferior_registers (int regno) unsigned int reg; errno = 0; - reg = ptrace (ptrace_fun, inferior_pid, + reg = ptrace (ptrace_fun, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), 0); if (errno) perror_with_name ("ptrace(PTRACE_PEEKUSP)"); @@ -559,7 +559,7 @@ store_inferior_registers (int regno) else reglo = reghi = regno; - ecp = registers_addr (inferior_pid); + ecp = registers_addr (PIDGET (inferior_ptid)); for (regno = reglo; regno <= reghi; regno++) { @@ -579,7 +579,7 @@ store_inferior_registers (int regno) reg = *(unsigned int *) ®isters[REGISTER_BYTE (regno) + i]; errno = 0; - ptrace (ptrace_fun, inferior_pid, + ptrace (ptrace_fun, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) (ecp + regmap[regno] + i), reg); if (errno) perror_with_name ("ptrace(PTRACE_POKEUSP)"); @@ -591,12 +591,13 @@ store_inferior_registers (int regno) /* Wait for child to do something. Return pid of child, or -1 in case of error; store status through argument pointer OURSTATUS. */ -int -child_wait (int pid, struct target_waitstatus *ourstatus) +ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { int save_errno; int thread; union wait status; + int pid; while (1) { @@ -622,7 +623,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) return -1; } - if (pid != PIDGET (inferior_pid)) /* Some other process?!? */ + if (pid != PIDGET (inferior_ptid)) /* Some other process?!? */ continue; thread = status.w_tid; /* Get thread id from status */ @@ -630,26 +631,27 @@ child_wait (int pid, struct target_waitstatus *ourstatus) /* Initial thread value can only be acquired via wait, so we have to resort to this hack. */ - if (TIDGET (inferior_pid) == 0 && thread != 0) + if (TIDGET (inferior_ptid) == 0 && thread != 0) { - inferior_pid = BUILDPID (inferior_pid, thread); - add_thread (inferior_pid); + inferior_ptid = MERGEPID (PIDGET (inferior_ptid), thread); + add_thread (inferior_ptid); } - pid = BUILDPID (pid, thread); + ptid = BUILDPID (pid, thread); /* We've become a single threaded process again. */ if (thread == 0) - inferior_pid = pid; + inferior_ptid = ptid; /* Check for thread creation. */ if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP - && !in_thread_list (pid)) + && !in_thread_list (ptid)) { int realsig; - realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE) 0, 0); + realsig = ptrace (PTRACE_GETTRACESIG, PIDGET (ptid), + (PTRACE_ARG3_TYPE) 0, 0); if (realsig == SIGNEWTHREAD) { @@ -657,7 +659,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) realsig -- the code in wait_for_inferior expects SIGTRAP. */ ourstatus->kind = TARGET_WAITKIND_SPURIOUS; ourstatus->value.sig = TARGET_SIGNAL_0; - return pid; + return ptid; } else error ("Signal for unknown thread was not SIGNEWTHREAD"); @@ -666,15 +668,16 @@ child_wait (int pid, struct target_waitstatus *ourstatus) /* Check for thread termination. */ else if (WIFSTOPPED (status) && WSTOPSIG (status) == SIGTRAP - && in_thread_list (pid)) + && in_thread_list (ptid)) { int realsig; - realsig = ptrace (PTRACE_GETTRACESIG, pid, (PTRACE_ARG3_TYPE) 0, 0); + realsig = ptrace (PTRACE_GETTRACESIG, PIDGET (ptid), + (PTRACE_ARG3_TYPE) 0, 0); if (realsig == SIGTHREADEXIT) { - ptrace (PTRACE_CONT, PIDGET (pid), (PTRACE_ARG3_TYPE) 0, 0); + ptrace (PTRACE_CONT, PIDGET (ptid), (PTRACE_ARG3_TYPE) 0, 0); continue; } } @@ -705,14 +708,16 @@ child_wait (int pid, struct target_waitstatus *ourstatus) store_waitstatus (ourstatus, status.w_status); #endif - return pid; + return ptid; } } /* Return nonzero if the given thread is still alive. */ int -child_thread_alive (int pid) +child_thread_alive (ptid_t ptid) { + int pid = PIDGET (ptid); + /* Arggh. Apparently pthread_kill only works for threads within the process that calls pthread_kill. @@ -730,9 +735,10 @@ child_thread_alive (int pid) 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 func; + int pid = PIDGET (ptid); errno = 0; @@ -740,7 +746,7 @@ child_resume (int pid, int step, enum target_signal signal) we only want to step/continue a single thread. */ if (pid == -1) { - pid = inferior_pid; + pid = PIDGET (inferior_ptid); func = step ? PTRACE_SINGLESTEP : PTRACE_CONT; } else @@ -766,11 +772,11 @@ child_resume (int pid, int step, enum target_signal signal) buffer. */ char * -child_pid_to_str (int pid) +child_pid_to_str (ptid_t ptid) { static char buf[40]; - sprintf (buf, "process %d thread %d", PIDGET (pid), TIDGET (pid)); + sprintf (buf, "process %d thread %d", PIDGET (ptid), TIDGET (ptid)); return buf; } diff --git a/gdb/m3-nat.c b/gdb/m3-nat.c index 3ff9835..3ab160b 100644 --- a/gdb/m3-nat.c +++ b/gdb/m3-nat.c @@ -1232,10 +1232,10 @@ int mach_really_waiting; There is no other way to exit this loop. - Returns the inferior_pid for rest of gdb. + Returns the inferior_ptid for rest of gdb. Side effects: Set *OURSTATUS. */ -int -mach_really_wait (int pid, struct target_waitstatus *ourstatus) +ptid_t +mach_really_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { kern_return_t ret; int w; @@ -1311,7 +1311,7 @@ mach_really_wait (int pid, struct target_waitstatus *ourstatus) } } store_waitstatus (ourstatus, w); - return inferior_pid; + return inferior_ptid; } } @@ -1346,7 +1346,7 @@ mach_really_wait (int pid, struct target_waitstatus *ourstatus) mach3_exception_actions (&w, FALSE, "Task"); store_waitstatus (ourstatus, w); - return inferior_pid; + return inferior_ptid; } } } @@ -3815,14 +3815,14 @@ kill_inferior_fast (void) { WAITTYPE w; - if (inferior_pid == 0 || inferior_pid == 1) + if (PIDGET (inferior_ptid) == 0 || PIDGET (inferior_ptid) == 1) return; /* kill() it, since the Unix server does not otherwise notice when * killed with task_terminate(). */ - if (inferior_pid > 0) - kill (inferior_pid, SIGKILL); + if (PIDGET (inferior_ptid) > 0) + kill (PIDGET (inferior_ptid), SIGKILL); /* It's propably terminate already */ (void) task_terminate (inferior_task); @@ -3884,7 +3884,7 @@ ptrace (int a, int b, int c, int d) If SIGNAL is nonzero, give it that signal. */ void -m3_resume (int pid, int step, enum target_signal signal) +m3_resume (ptid_t ptid, int step, enum target_signal signal) { kern_return_t ret; @@ -3913,8 +3913,8 @@ m3_resume (int pid, int step, enum target_signal signal) vm_read_cache_valid = FALSE; - if (signal && inferior_pid > 0) /* Do not signal, if attached by MID */ - kill (inferior_pid, target_signal_to_host (signal)); + if (signal && PIDGET (inferior_ptid) > 0) /* Do not signal, if attached by MID */ + kill (PIDGET (inferior_ptid), target_signal_to_host (signal)); if (step) { @@ -4014,10 +4014,10 @@ m3_do_attach (int pid) { mid_attach (-(pid)); - /* inferior_pid will be NEGATIVE! */ - inferior_pid = pid; + /* inferior_ptid will be NEGATIVE! */ + inferior_ptid = pid_to_ptid (pid); - return inferior_pid; + return PIDGET (inferior_ptid); } inferior_task = task_by_pid (pid); @@ -4026,9 +4026,9 @@ m3_do_attach (int pid) task_attach (inferior_task); - inferior_pid = pid; + inferior_ptid = pid_to_ptid (pid); - return inferior_pid; + return PIDGET (inferior_ptid); } /* Attach to process PID, then initialize for debugging it @@ -4053,15 +4053,17 @@ m3_attach (char *args, int from_tty) exec_file = (char *) get_exec_file (0); if (exec_file) - printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, target_pid_to_str (pid)); + printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, + target_pid_to_str (pid_to_ptid (pid))); else - printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid)); + printf_unfiltered ("Attaching to %s\n", + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } - m3_do_attach (pid); - inferior_pid = pid; + m3_do_attach (pid_to_ptid (pid)); + inferior_ptid = pid_to_ptid (pid); push_target (&m3_ops); } @@ -4149,8 +4151,8 @@ m3_do_detach (int signal) if (remove_breakpoints ()) warning ("Could not remove breakpoints when detaching"); - if (signal && inferior_pid > 0) - kill (inferior_pid, signal); + if (signal && PIDGET (inferior_ptid) > 0) + kill (PIDGET (inferior_ptid), signal); /* the task might be dead by now */ (void) task_resume (inferior_task); @@ -4179,14 +4181,14 @@ m3_detach (char *args, int from_tty) if (exec_file == 0) exec_file = ""; printf_unfiltered ("Detaching from program: %s %s\n", - exec_file, target_pid_to_str (inferior_pid)); + exec_file, target_pid_to_str (inferior_ptid)); gdb_flush (gdb_stdout); } if (args) siggnal = atoi (args); m3_do_detach (siggnal); - inferior_pid = 0; + inferior_ptid = null_ptid; unpush_target (&m3_ops); /* Pop out of handling an inferior */ } #endif /* ATTACH_DETACH */ @@ -4212,7 +4214,7 @@ m3_files_info (struct target_ops *ignore) { /* FIXME: should print MID and all that crap. */ printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid)); + attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } static void @@ -4458,7 +4460,7 @@ init_m3_ops (void) m3_ops.to_attach = m3_attach; m3_ops.to_detach = m3_detach; m3_ops.to_resume = m3_resume; - m3_ops.to_wait = mach_really__wait; + m3_ops.to_wait = mach_really_wait; m3_ops.to_fetch_registers = fetch_inferior_registers; m3_ops.to_store_registers = store_inferior_registers; m3_ops.to_prepare_to_store = m3_prepare_to_store; diff --git a/gdb/m32r-rom.c b/gdb/m32r-rom.c index c95b16e5..ff9f5b5 100644 --- a/gdb/m32r-rom.c +++ b/gdb/m32r-rom.c @@ -110,7 +110,6 @@ m32r_load_1 (void *dummy) static void m32r_load (char *filename, int from_tty) { - extern int inferior_pid; bfd *abfd; asection *s; unsigned int i, data_count = 0; @@ -166,7 +165,7 @@ m32r_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 @@ -458,7 +457,6 @@ m32r_upload_command (char *args, int from_tty) bfd *abfd; asection *s; time_t start_time, end_time; /* for timing of download */ - extern int inferior_pid; int resp_len, data_count = 0; char buf[1024]; struct hostent *hostent; @@ -565,7 +563,7 @@ m32r_upload_command (char *args, int from_tty) report_transfer_performance (data_count, start_time, end_time); printf_filtered ("Start address 0x%lx\n", bfd_get_start_address (abfd)); } - 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 diff --git a/gdb/m68knbsd-nat.c b/gdb/m68knbsd-nat.c index 8612b96..ec986ee 100644 --- a/gdb/m68knbsd-nat.c +++ b/gdb/m68knbsd-nat.c @@ -34,12 +34,12 @@ fetch_inferior_registers (int regno) struct reg inferior_registers; struct fpreg inferior_fp_registers; - ptrace (PT_GETREGS, inferior_pid, + ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0); memcpy (®isters[REGISTER_BYTE (0)], &inferior_registers, sizeof (inferior_registers)); - ptrace (PT_GETFPREGS, inferior_pid, + ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], &inferior_fp_registers, sizeof (inferior_fp_registers)); @@ -55,12 +55,12 @@ store_inferior_registers (int regno) memcpy (&inferior_registers, ®isters[REGISTER_BYTE (0)], sizeof (inferior_registers)); - ptrace (PT_SETREGS, inferior_pid, + ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0); memcpy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], sizeof (inferior_fp_registers)); - ptrace (PT_SETFPREGS, inferior_pid, + ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); } diff --git a/gdb/m88k-nat.c b/gdb/m88k-nat.c index dca0c9b..b631cda 100644 --- a/gdb/m88k-nat.c +++ b/gdb/m88k-nat.c @@ -76,7 +76,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 < NUM_REGS; regno++) { /*regaddr = register_addr (regno, offset); */ @@ -84,20 +84,20 @@ 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 36 - 38; special pc registers */ - *(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); } @@ -128,7 +128,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) { @@ -137,13 +137,13 @@ store_inferior_registers (int 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 printf_unfiltered ("Bad register number for store_inferior routine\n"); @@ -155,7 +155,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) { @@ -163,11 +163,11 @@ store_inferior_registers (int regno) perror_with_name (buf); } } - 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)); } } diff --git a/gdb/mac-nat.c b/gdb/mac-nat.c index 23da860..22f5e01 100644 --- a/gdb/mac-nat.c +++ b/gdb/mac-nat.c @@ -78,8 +78,8 @@ child_store_inferior_registers (int r) } } -static int -child_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { } @@ -116,15 +116,16 @@ child_attach (char *args, int from_tty) if (exec_file) printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else - printf_unfiltered ("Attaching to %s\n", target_pid_to_str (pid)); + printf_unfiltered ("Attaching to %s\n", + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } /* Do we need to do anything special? */ attach_flag = 1; - inferior_pid = pid; + inferior_ptid = pid_to_ptid (pid); push_target (&child_ops); } } @@ -140,10 +141,10 @@ child_detach (char *args, int from_tty) if (exec_file == 0) exec_file = ""; printf_unfiltered ("Detaching from program: %s %s\n", exec_file, - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); gdb_flush (gdb_stdout); } - inferior_pid = 0; + inferior_ptid = null_ptid; unpush_target (&child_ops); } @@ -153,7 +154,7 @@ static void child_files_info (struct target_ops *ignore) { printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid)); + attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } /* ARGSUSED */ @@ -163,7 +164,7 @@ child_open (char *arg, int from_tty) error ("Use the \"run\" command to start a Mac application."); } -/* Start an inferior Mac program and sets inferior_pid to its pid. +/* Start an inferior Mac program 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. Errors reported with error(). */ @@ -202,7 +203,7 @@ child_create_inferior (char *exec_file, char *allargs, char **env) error ("Error launching %s, code %d\n", exec_file, launch_err); } - inferior_pid = launchparms.launchProcessSN.lowLongOfPSN; + inferior_ptid = pid_to_ptid (launchparms.launchProcessSN.lowLongOfPSN); /* FIXME be sure that high long of PSN is 0 */ push_target (&child_ops); @@ -251,7 +252,7 @@ child_kill_inferior (void) } void -child_resume (int pid, int step, enum target_signal signal) +child_resume (ptid_t ptid, int step, enum target_signal signal) { } diff --git a/gdb/mips-nat.c b/gdb/mips-nat.c index 2fa8816..545c741 100644 --- a/gdb/mips-nat.c +++ b/gdb/mips-nat.c @@ -83,7 +83,7 @@ fetch_inferior_registers (int regno) regaddr = REGISTER_PTRACE_ADDR (regno); for (i = 0; i < REGISTER_RAW_SIZE (regno); i += sizeof (int)) { - *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, + *(int *) &buf[i] = ptrace (PT_READ_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, 0); regaddr += sizeof (int); } @@ -114,7 +114,7 @@ store_inferior_registers (int regno) return; regaddr = REGISTER_PTRACE_ADDR (regno); errno = 0; - ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, + ptrace (PT_WRITE_U, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) regaddr, read_register (regno)); if (errno != 0) { diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index b29a33a..2b312f3 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -546,9 +546,9 @@ pc_is_mips16 (bfd_vma memaddr) all registers should be sign extended for simplicity? */ static CORE_ADDR -mips_read_pc (int pid) +mips_read_pc (ptid_t ptid) { - return read_signed_register_pid (PC_REGNUM, pid); + return read_signed_register_pid (PC_REGNUM, ptid); } /* This returns the PC of the first inst after the prologue. If we can't diff --git a/gdb/mon960-rom.c b/gdb/mon960-rom.c index 27c5092..847d4cf 100644 --- a/gdb/mon960-rom.c +++ b/gdb/mon960-rom.c @@ -42,14 +42,12 @@ static void mon960_open (char *args, int from_tty); static void mon960_load_gen (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 */ } #else diff --git a/gdb/monitor.c b/gdb/monitor.c index 15b11d5..4abb782 100644 --- a/gdb/monitor.c +++ b/gdb/monitor.c @@ -67,13 +67,13 @@ static void monitor_store_register (int regno); static void monitor_printable_string (char *newstr, char *oldstr, int len); static void monitor_error (char *function, char *message, CORE_ADDR memaddr, int len, char *string, int final_char); static void monitor_detach (char *args, int from_tty); -static void monitor_resume (int pid, int step, enum target_signal sig); +static void monitor_resume (ptid_t ptid, int step, enum target_signal sig); static void monitor_interrupt (int signo); static void monitor_interrupt_twice (int signo); static void monitor_interrupt_query (void); static void monitor_wait_cleanup (void *old_timeout); -static int monitor_wait (int pid, struct target_waitstatus *status); +static ptid_t monitor_wait (ptid_t ptid, struct target_waitstatus *status); static void monitor_fetch_registers (int regno); static void monitor_store_registers (int regno); static void monitor_prepare_to_store (void); @@ -833,7 +833,7 @@ monitor_open (char *args, struct monitor_ops *mon_ops, int from_tty) push_target (targ_ops); - inferior_pid = 42000; /* Make run command think we are busy... */ + inferior_ptid = pid_to_ptid (42000); /* Make run command think we are busy... */ /* Give monitor_wait something to read */ @@ -922,7 +922,7 @@ monitor_supply_register (int regno, char *valstr) /* Tell the remote machine to resume. */ static void -monitor_resume (int pid, int step, enum target_signal sig) +monitor_resume (ptid_t ptid, int step, enum target_signal sig) { /* Some monitors require a different command when starting a program */ monitor_debug ("MON resume\n"); @@ -1072,8 +1072,8 @@ monitor_wait_filter (char *buf, /* Wait until the remote machine stops, then return, storing status in status just as `wait' would. */ -static int -monitor_wait (int pid, struct target_waitstatus *status) +static ptid_t +monitor_wait (ptid_t ptid, struct target_waitstatus *status) { int old_timeout = timeout; char buf[TARGET_BUF_SIZE]; @@ -1149,7 +1149,7 @@ monitor_wait (int pid, struct target_waitstatus *status) in_monitor_wait = 0; - return inferior_pid; + return inferior_ptid; } /* Fetch register REGNO, or all registers if REGNO is -1. Returns @@ -2180,7 +2180,7 @@ monitor_load (char *file, 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 now that we have loaded diff --git a/gdb/ns32knbsd-nat.c b/gdb/ns32knbsd-nat.c index 7527d94..fd6e619 100644 --- a/gdb/ns32knbsd-nat.c +++ b/gdb/ns32knbsd-nat.c @@ -43,9 +43,9 @@ fetch_inferior_registers (int regno) struct reg inferior_registers; struct fpreg 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 (R0_REGNUM + 0, inferior_registers.r_r0); @@ -104,9 +104,9 @@ store_inferior_registers (int regno) RS (LP0_REGNUM + 5, inferior_fpregisters.r_freg[5]); RS (LP0_REGNUM + 7, inferior_fpregisters.r_freg[7]); - 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); } diff --git a/gdb/ocd.c b/gdb/ocd.c index 609edcd..f5962c0 100644 --- a/gdb/ocd.c +++ b/gdb/ocd.c @@ -151,7 +151,7 @@ ocd_error (char *s, int error_code) /* Return nonzero if the thread TH is still alive on the remote system. */ int -ocd_thread_alive (int th) +ocd_thread_alive (ptid_t th) { return 1; } @@ -344,7 +344,7 @@ device the OCD device is attached to (e.g. /dev/ttya)."); variables, especially since GDB will someday have a notion of debugging several processes. */ - inferior_pid = 42000; + inferior_ptid = pid_to_ptid (42000); /* Start the remote connection; if error (0), discard this target. In particular, if the user quits, be sure to discard it (we'd be in an inconsistent state otherwise). */ @@ -376,7 +376,7 @@ ocd_detach (char *args, int from_tty) /* Tell the remote machine to resume. */ void -ocd_resume (int pid, int step, enum target_signal siggnal) +ocd_resume (ptid_t ptid, int step, enum target_signal siggnal) { int pktlen; @@ -1251,7 +1251,7 @@ ocd_load (char *args, int from_tty) { generic_load (args, from_tty); - inferior_pid = 0; + inferior_ptid = null_ptid; /* 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 now that we have loaded diff --git a/gdb/ocd.h b/gdb/ocd.h index 6b299cb..5fa1fb9 100644 --- a/gdb/ocd.h +++ b/gdb/ocd.h @@ -93,7 +93,7 @@ void ocd_close (int quitting); void ocd_detach (char *args, int from_tty); -void ocd_resume (int pid, int step, enum target_signal siggnal); +void ocd_resume (ptid_t ptid, int step, enum target_signal siggnal); void ocd_prepare_to_store (void); @@ -111,7 +111,7 @@ void ocd_mourn (void); void ocd_create_inferior (char *exec_file, char *args, char **env); -int ocd_thread_alive (int th); +int ocd_thread_alive (ptid_t th); void ocd_error (char *s, int error_code); diff --git a/gdb/osfsolib.c b/gdb/osfsolib.c index 0173b63..b5a6151 100644 --- a/gdb/osfsolib.c +++ b/gdb/osfsolib.c @@ -876,7 +876,7 @@ solib_create_inferior_hook (void) stop_signal = TARGET_SIGNAL_0; do { - target_resume (-1, 0, stop_signal); + target_resume (minus_one_ptid, 0, stop_signal); wait_for_inferior (); } while (stop_signal != TARGET_SIGNAL_TRAP); diff --git a/gdb/ppc-bdm.c b/gdb/ppc-bdm.c index 7aae995..4468caa 100644 --- a/gdb/ppc-bdm.c +++ b/gdb/ppc-bdm.c @@ -40,7 +40,8 @@ static void bdm_ppc_open (char *name, int from_tty); -static int bdm_ppc_wait (int pid, struct target_waitstatus *target_status); +static ptid_t bdm_ppc_wait (ptid_t ptid, + struct target_waitstatus *target_status); static void bdm_ppc_fetch_registers (int regno); @@ -97,8 +98,8 @@ bdm_ppc_open (char *name, int from_tty) Returns "pid" (though it's not clear what, if anything, that means in the case of this target). */ -static int -bdm_ppc_wait (int pid, struct target_waitstatus *target_status) +static ptid_t +bdm_ppc_wait (ptid_t ptid, struct target_waitstatus *target_status) { int stop_reason; @@ -109,7 +110,7 @@ bdm_ppc_wait (int pid, struct target_waitstatus *target_status) if (stop_reason) { target_status->value.sig = TARGET_SIGNAL_INT; - return inferior_pid; + return inferior_ptid; } target_status->value.sig = TARGET_SIGNAL_TRAP; /* XXX for now */ @@ -124,7 +125,7 @@ bdm_ppc_wait (int pid, struct target_waitstatus *target_status) } #endif - return inferior_pid; + return inferior_ptid; } static int bdm_regmap[] = diff --git a/gdb/ppcnbsd-nat.c b/gdb/ppcnbsd-nat.c index 427f48f..b206110 100644 --- a/gdb/ppcnbsd-nat.c +++ b/gdb/ppcnbsd-nat.c @@ -45,7 +45,7 @@ fetch_inferior_registers (int regno) #endif int i; - ptrace (PT_GETREGS, inferior_pid, + ptrace (PT_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0); for (i = 0; i < 32; i++) RF (i, inferior_registers.fixreg[i]); @@ -56,7 +56,7 @@ fetch_inferior_registers (int regno) RF (PC_REGNUM, inferior_registers.pc); #ifdef PT_GETFPREGS - ptrace (PT_GETFPREGS, inferior_pid, + ptrace (PT_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) &inferior_fp_registers, 0); for (i = 0; i < 32; i++) RF (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]); @@ -82,13 +82,13 @@ store_inferior_registers (int regno) RS (PPC_CTR_REGNUM, inferior_registers.ctr); RS (PC_REGNUM, inferior_registers.pc); - ptrace (PT_SETREGS, inferior_pid, + ptrace (PT_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0); #ifdef PT_SETFPREGS for (i = 0; i < 32; i++) RS (FP0_REGNUM + i, inferior_fp_registers.fpreg[i]); - ptrace (PT_SETFPREGS, inferior_pid, + ptrace (PT_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0); #endif } diff --git a/gdb/proc-service.c b/gdb/proc-service.c index 3cebc63..74e81ae 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -61,21 +61,21 @@ typedef size_t gdb_ps_size_t; /* Helper functions. */ static void -restore_inferior_pid (void *arg) +restore_inferior_ptid (void *arg) { - int *saved_pid_ptr = arg; - inferior_pid = *saved_pid_ptr; + ptid_t *saved_pid_ptr = arg; + inferior_ptid = *saved_pid_ptr; xfree (arg); } static struct cleanup * -save_inferior_pid (void) +save_inferior_ptid (void) { - int *saved_pid_ptr; + ptid_t *saved_ptid_ptr; - saved_pid_ptr = xmalloc (sizeof (int)); - *saved_pid_ptr = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid_ptr); + saved_ptid_ptr = xmalloc (sizeof (ptid_t)); + *saved_ptid_ptr = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid_ptr); } /* Transfer LEN bytes of memory between BUF and address ADDR in the @@ -90,10 +90,10 @@ static ps_err_e ps_xfer_memory (const struct ps_prochandle *ph, paddr_t addr, char *buf, size_t len, int write) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); int ret; - inferior_pid = ph->pid; + inferior_ptid = pid_to_ptid (ph->pid); if (write) ret = target_write_memory (addr, buf, len); @@ -250,9 +250,9 @@ ps_ptwrite (gdb_ps_prochandle_t ph, paddr_t addr, ps_err_e ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, ph->pid); + inferior_ptid = BUILD_LWP (lwpid, ph->pid); target_fetch_registers (-1); fill_gregset ((gdb_gregset_t *) gregset, -1); @@ -267,9 +267,9 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, prgregset_t gregset) ps_err_e ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const prgregset_t gregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, ph->pid); + inferior_ptid = BUILD_LWP (lwpid, ph->pid); /* FIXME: We should really make supply_gregset const-correct. */ supply_gregset ((gdb_gregset_t *) gregset); @@ -286,9 +286,9 @@ ps_err_e ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, ph->pid); + inferior_ptid = BUILD_LWP (lwpid, ph->pid); target_fetch_registers (-1); fill_fpregset ((gdb_fpregset_t *) fpregset, -1); @@ -304,9 +304,9 @@ ps_err_e ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, const gdb_prfpregset_t *fpregset) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, ph->pid); + inferior_ptid = BUILD_LWP (lwpid, ph->pid); /* FIXME: We should really make supply_fpregset const-correct. */ supply_fpregset ((gdb_fpregset_t *) fpregset); diff --git a/gdb/procfs.c b/gdb/procfs.c index c0d3277..53f0489 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -106,26 +106,26 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ static void procfs_open (char *, int); static void procfs_attach (char *, int); static void procfs_detach (char *, int); -static void procfs_resume (int, int, enum target_signal); +static void procfs_resume (ptid_t, int, enum target_signal); static int procfs_can_run (void); static void procfs_stop (void); static void procfs_files_info (struct target_ops *); static void procfs_fetch_registers (int); static void procfs_store_registers (int); -static void procfs_notice_signals (int); +static void procfs_notice_signals (ptid_t); static void procfs_prepare_to_store (void); static void procfs_kill_inferior (void); static void procfs_mourn_inferior (void); static void procfs_create_inferior (char *, char *, char **); -static int procfs_wait (int, struct target_waitstatus *); +static ptid_t procfs_wait (ptid_t, struct target_waitstatus *); static int procfs_xfer_memory (CORE_ADDR, char *, int, int, struct mem_attrib *attrib, struct target_ops *); -static int procfs_thread_alive (int); +static int procfs_thread_alive (ptid_t); void procfs_find_new_threads (void); -char *procfs_pid_to_str (int); +char *procfs_pid_to_str (ptid_t); struct target_ops procfs_ops; /* the target vector */ @@ -2904,7 +2904,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR)) int funcstat = 0; int fd; - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); #ifdef NEW_PROC_API /* Open map fd. */ @@ -3450,7 +3450,7 @@ proc_iterate_over_threads (procinfo *pi, * Here are all of the gdb target vector functions and their friends. */ -static int do_attach (int pid); +static ptid_t do_attach (ptid_t ptid); static void do_detach (int signo); static int register_gdb_signals (procinfo *, gdb_sigset_t *); @@ -3602,13 +3602,14 @@ procfs_attach (char *args, int from_tty) if (exec_file) printf_filtered ("Attaching to program `%s', %s\n", - exec_file, target_pid_to_str (pid)); + exec_file, target_pid_to_str (pid_to_ptid (pid))); else - printf_filtered ("Attaching to %s\n", target_pid_to_str (pid)); + printf_filtered ("Attaching to %s\n", + target_pid_to_str (pid_to_ptid (pid))); fflush (stdout); } - inferior_pid = do_attach (pid); + inferior_ptid = do_attach (pid_to_ptid (pid)); push_target (&procfs_ops); } @@ -3624,31 +3625,31 @@ procfs_detach (char *args, int from_tty) if (exec_file == 0) exec_file = ""; printf_filtered ("Detaching from program: %s %s\n", - exec_file, target_pid_to_str (inferior_pid)); + exec_file, target_pid_to_str (inferior_ptid)); fflush (stdout); } if (args) signo = atoi (args); do_detach (signo); - inferior_pid = 0; + inferior_ptid = null_ptid; unpush_target (&procfs_ops); /* Pop out of handling an inferior */ } -static int -do_attach (int pid) +static ptid_t +do_attach (ptid_t ptid) { procinfo *pi; int fail; - if ((pi = create_procinfo (pid, 0)) == NULL) + if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL) perror ("procfs: out of memory in 'attach'"); if (!open_procinfo_files (pi, FD_CTL)) { fprintf_filtered (gdb_stderr, "procfs:%d -- ", __LINE__); sprintf (errmsg, "do_attach: couldn't open /proc file for process %d", - pid); + PIDGET (ptid)); dead_procinfo (pi, errmsg, NOKILL); } @@ -3698,7 +3699,7 @@ do_detach (int signo) procinfo *pi; /* Find procinfo for the main process */ - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); /* FIXME: threads */ + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); /* FIXME: threads */ if (signo) if (!proc_set_current_signal (pi, signo)) proc_warn (pi, "do_detach, set_current_signal", __LINE__); @@ -3754,14 +3755,14 @@ procfs_fetch_registers (int regno) int pid; int tid; - pid = PIDGET (inferior_pid); - tid = TIDGET (inferior_pid); + pid = PIDGET (inferior_ptid); + tid = TIDGET (inferior_ptid); /* First look up procinfo for the main process. */ pi = find_procinfo_or_die (pid, 0); /* If the event thread is not the same as GDB's requested thread - (ie. inferior_pid), then look up procinfo for the requested + (ie. inferior_ptid), then look up procinfo for the requested thread. */ if ((tid != 0) && (tid != proc_get_current_thread (pi))) @@ -3769,7 +3770,7 @@ procfs_fetch_registers (int regno) if (pi == NULL) error ("procfs: fetch_registers failed to find procinfo for %s", - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); if ((gregs = proc_get_gregs (pi)) == NULL) proc_error (pi, "fetch_registers, get_gregs", __LINE__); @@ -3826,14 +3827,14 @@ procfs_store_registers (int regno) int pid; int tid; - pid = PIDGET (inferior_pid); - tid = TIDGET (inferior_pid); + pid = PIDGET (inferior_ptid); + tid = TIDGET (inferior_ptid); /* First find procinfo for main process */ pi = find_procinfo_or_die (pid, 0); /* If current lwp for process is not the same as requested thread - (ie. inferior_pid), then find procinfo for the requested thread. */ + (ie. inferior_ptid), then find procinfo for the requested thread. */ if ((tid != 0) && (tid != proc_get_current_thread (pi))) @@ -3841,7 +3842,7 @@ procfs_store_registers (int regno) if (pi == NULL) error ("procfs: store_registers: failed to find procinfo for %s", - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); if ((gregs = proc_get_gregs (pi)) == NULL) proc_error (pi, "store_registers, get_gregs", __LINE__); @@ -3947,13 +3948,14 @@ syscall_is_lwp_create (procinfo *pi, int scall) * event codes are returned thru a pointer parameter. */ -static int -procfs_wait (int pid, struct target_waitstatus *status) +static ptid_t +procfs_wait (ptid_t ptid, struct target_waitstatus *status) { /* First cut: loosely based on original version 2.1 */ procinfo *pi; - int temp, wstat; - int retval; + int wstat; + int temp_tid; + ptid_t retval, temp_ptid; int why, what, flags; int retry = 0; @@ -3961,10 +3963,10 @@ wait_again: retry++; wstat = 0; - retval = -1; + retval = pid_to_ptid (-1); /* Find procinfo for main process */ - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); if (pi) { /* We must assume that the status is stale now... */ @@ -3985,14 +3987,17 @@ wait_again: /* wait_for_stop failed: has the child terminated? */ if (errno == ENOENT) { + int wait_retval; + /* /proc file not found; presumably child has terminated. */ - retval = wait (&wstat); /* "wait" for the child's exit */ + wait_retval = wait (&wstat); /* "wait" for the child's exit */ - if (retval != PIDGET (inferior_pid)) /* wrong child? */ + if (wait_retval != PIDGET (inferior_ptid)) /* wrong child? */ error ("procfs: couldn't stop process %d: wait returned %d\n", - inferior_pid, retval); + PIDGET (inferior_ptid), wait_retval); /* FIXME: might I not just use waitpid? Or try find_procinfo to see if I know about this child? */ + retval = pid_to_ptid (wait_retval); } else if (errno == EINTR) goto wait_again; @@ -4069,7 +4074,7 @@ wait_again: return a "success" exit code. Bogus: what if it returns something else? */ wstat = 0; - retval = inferior_pid; /* ? ? ? */ + retval = inferior_ptid; /* ? ? ? */ } else { @@ -4084,7 +4089,7 @@ wait_again: /* If wait returns -1, that's what we return to GDB. */ if (temp < 0) - retval = temp; + retval = pid_to_ptid (temp); } } else @@ -4111,12 +4116,12 @@ wait_again: { /* How to exit gracefully, returning "unknown event" */ status->kind = TARGET_WAITKIND_SPURIOUS; - return inferior_pid; + return inferior_ptid; } else { /* How to keep going without returning to wfi: */ - target_resume (pid, 0, TARGET_SIGNAL_0); + target_resume (ptid, 0, TARGET_SIGNAL_0); goto wait_again; } } @@ -4142,20 +4147,21 @@ wait_again: */ /* If not in procinfo list, add it. */ - temp = proc_get_current_thread (pi); - if (!find_procinfo (pi->pid, temp)) - create_procinfo (pi->pid, temp); + temp_tid = proc_get_current_thread (pi); + if (!find_procinfo (pi->pid, temp_tid)) + create_procinfo (pi->pid, temp_tid); - temp = MERGEPID (pi->pid, temp); + temp_ptid = MERGEPID (pi->pid, temp_tid); /* If not in GDB's thread list, add it. */ - if (!in_thread_list (temp)) + if (!in_thread_list (temp_ptid)) { - printf_filtered ("[New %s]\n", target_pid_to_str (temp)); - add_thread (temp); + printf_filtered ("[New %s]\n", + target_pid_to_str (temp_ptid)); + add_thread (temp_ptid); } /* Return to WFI, but tell it to immediately resume. */ status->kind = TARGET_WAITKIND_SPURIOUS; - return inferior_pid; + return inferior_ptid; } else if (syscall_is_lwp_exit (pi, what)) { @@ -4194,7 +4200,7 @@ wait_again: } #endif status->kind = TARGET_WAITKIND_SPURIOUS; - return inferior_pid; + return inferior_ptid; } break; case PR_REQUESTED: @@ -4211,17 +4217,17 @@ wait_again: else { /* If not in procinfo list, add it. */ - temp = proc_get_current_thread (pi); - if (!find_procinfo (pi->pid, temp)) - create_procinfo (pi->pid, temp); + temp_tid = proc_get_current_thread (pi); + if (!find_procinfo (pi->pid, temp_tid)) + create_procinfo (pi->pid, temp_tid); /* If not in GDB's thread list, add it. */ - temp = MERGEPID (pi->pid, temp); - if (!in_thread_list (temp)) + temp_ptid = MERGEPID (pi->pid, temp_tid); + if (!in_thread_list (temp_ptid)) { printf_filtered ("[New %s]\n", - target_pid_to_str (temp)); - add_thread (temp); + target_pid_to_str (temp_ptid)); + add_thread (temp_ptid); } status->kind = TARGET_WAITKIND_STOPPED; @@ -4273,7 +4279,7 @@ wait_again: break; case FLTPAGE: /* Recoverable page fault */ default: /* FIXME: use si_signo if possible for fault */ - retval = -1; + retval = pid_to_ptid (-1); printf_filtered ("procfs:%d -- ", __LINE__); printf_filtered ("child stopped for unknown reason:\n"); proc_prettyprint_why (why, what, 1); @@ -4292,8 +4298,8 @@ wait_again: * Got this far without error: * If retval isn't in the threads database, add it. */ - if (retval > 0 && - retval != inferior_pid && + if (PIDGET (retval) > 0 && + !ptid_equal (retval, inferior_ptid) && !in_thread_list (retval)) { /* @@ -4309,16 +4315,16 @@ wait_again: /* In addition, it's possible that this is the first * new thread we've seen, in which case we may not - * have created entries for inferior_pid yet. + * have created entries for inferior_ptid yet. */ - if (TIDGET (inferior_pid) != 0) + if (TIDGET (inferior_ptid) != 0) { - if (!in_thread_list (inferior_pid)) - add_thread (inferior_pid); - if (find_procinfo (PIDGET (inferior_pid), - TIDGET (inferior_pid)) == NULL) - create_procinfo (PIDGET (inferior_pid), - TIDGET (inferior_pid)); + if (!in_thread_list (inferior_ptid)) + add_thread (inferior_ptid); + if (find_procinfo (PIDGET (inferior_ptid), + TIDGET (inferior_ptid)) == NULL) + create_procinfo (PIDGET (inferior_ptid), + TIDGET (inferior_ptid)); } } } @@ -4357,7 +4363,7 @@ procfs_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite, int nbytes = 0; /* Find procinfo for main process */ - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); if (pi->as_fd == 0 && open_procinfo_files (pi, FD_AS) == 0) { @@ -4495,7 +4501,7 @@ make_signal_thread_runnable (procinfo *process, procinfo *pi, void *ptr) */ static void -procfs_resume (int pid, int step, enum target_signal signo) +procfs_resume (ptid_t ptid, int step, enum target_signal signo) { procinfo *pi, *thread; int native_signo; @@ -4517,7 +4523,7 @@ procfs_resume (int pid, int step, enum target_signal signo) to proc_run_process (for use in the prrun struct by ioctl). */ /* Find procinfo for main process */ - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); /* First cut: ignore pid argument */ errno = 0; @@ -4537,13 +4543,13 @@ procfs_resume (int pid, int step, enum target_signal signo) /* Void the process procinfo's caches. */ invalidate_cache (NULL, pi, NULL); - if (pid != -1) + if (PIDGET (ptid) != -1) { /* Resume a specific thread, presumably suppressing the others. */ - thread = find_procinfo (PIDGET (pid), TIDGET (pid)); + thread = find_procinfo (PIDGET (ptid), TIDGET (ptid)); if (thread == NULL) - warning ("procfs: resume can't find thread %d -- resuming all.", - TIDGET (pid)); + warning ("procfs: resume can't find thread %ld -- resuming all.", + TIDGET (ptid)); else { if (thread->tid != 0) @@ -4607,10 +4613,10 @@ register_gdb_signals (procinfo *pi, gdb_sigset_t *signals) */ static void -procfs_notice_signals (int pid) +procfs_notice_signals (ptid_t ptid) { gdb_sigset_t signals; - procinfo *pi = find_procinfo_or_die (PIDGET (pid), 0); + procinfo *pi = find_procinfo_or_die (PIDGET (ptid), 0); if (proc_get_traced_signals (pi, &signals) && register_gdb_signals (pi, &signals)) @@ -4630,7 +4636,7 @@ procfs_files_info (struct target_ops *ignore) { printf_filtered ("\tUsing the running image of %s %s via /proc.\n", attach_flag? "attached": "child", - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); } /* @@ -4762,10 +4768,10 @@ unconditionally_kill_inferior (procinfo *pi) static void procfs_kill_inferior (void) { - if (inferior_pid != 0) /* ? */ + if (!ptid_equal (inferior_ptid, null_ptid)) /* ? */ { /* Find procinfo for main process */ - procinfo *pi = find_procinfo (PIDGET (inferior_pid), 0); + procinfo *pi = find_procinfo (PIDGET (inferior_ptid), 0); if (pi) unconditionally_kill_inferior (pi); @@ -4784,10 +4790,10 @@ procfs_mourn_inferior (void) { procinfo *pi; - if (inferior_pid != 0) + if (!ptid_equal (inferior_ptid, null_ptid)) { /* Find procinfo for main process */ - pi = find_procinfo (PIDGET (inferior_pid), 0); + pi = find_procinfo (PIDGET (inferior_ptid), 0); if (pi) destroy_procinfo (pi); } @@ -4872,7 +4878,7 @@ procfs_init_inferior (int pid) /* The 'process ID' we return to GDB is composed of the actual process ID plus the lwp ID. */ - inferior_pid = MERGEPID (pi->pid, proc_get_current_thread (pi)); + inferior_ptid = MERGEPID (pi->pid, proc_get_current_thread (pi)); #ifdef START_INFERIOR_TRAPS_EXPECTED startup_inferior (START_INFERIOR_TRAPS_EXPECTED); @@ -5101,7 +5107,7 @@ procfs_create_inferior (char *exec_file, char *allargs, char **env) static int procfs_notice_thread (procinfo *pi, procinfo *thread, void *ptr) { - int gdb_threadid = MERGEPID (pi->pid, thread->tid); + ptid_t gdb_threadid = MERGEPID (pi->pid, thread->tid); if (!in_thread_list (gdb_threadid)) add_thread (gdb_threadid); @@ -5122,7 +5128,7 @@ procfs_find_new_threads (void) procinfo *pi; /* Find procinfo for main process */ - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); proc_update_threads (pi); proc_iterate_over_threads (pi, procfs_notice_thread, NULL); } @@ -5137,13 +5143,13 @@ procfs_find_new_threads (void) */ static int -procfs_thread_alive (int pid) +procfs_thread_alive (ptid_t ptid) { int proc, thread; procinfo *pi; - proc = PIDGET (pid); - thread = TIDGET (pid); + proc = PIDGET (ptid); + thread = TIDGET (ptid); /* If I don't know it, it ain't alive! */ if ((pi = find_procinfo (proc, thread)) == NULL) return 0; @@ -5167,14 +5173,14 @@ procfs_thread_alive (int pid) */ char * -procfs_pid_to_str (int pid) +procfs_pid_to_str (ptid_t ptid) { static char buf[80]; int proc, thread; procinfo *pi; - proc = PIDGET (pid); - thread = TIDGET (pid); + proc = PIDGET (ptid); + thread = TIDGET (ptid); pi = find_procinfo (proc, thread); if (thread == 0) @@ -5190,15 +5196,16 @@ procfs_pid_to_str (int pid) */ int -procfs_set_watchpoint (int pid, CORE_ADDR addr, int len, int rwflag, int after) +procfs_set_watchpoint (ptid_t ptid, CORE_ADDR addr, int len, int rwflag, + int after) { #ifndef UNIXWARE #ifndef AIX5 int pflags = 0; procinfo *pi; - pi = find_procinfo_or_die (pid == -1 ? - PIDGET (inferior_pid) : PIDGET (pid), 0); + pi = find_procinfo_or_die (PIDGET (ptid) == -1 ? + PIDGET (inferior_ptid) : PIDGET (ptid), 0); /* Translate from GDB's flags to /proc's */ if (len > 0) /* len == 0 means delete watchpoint */ @@ -5246,12 +5253,12 @@ procfs_set_watchpoint (int pid, CORE_ADDR addr, int len, int rwflag, int after) */ int -procfs_stopped_by_watchpoint (int pid) +procfs_stopped_by_watchpoint (ptid_t ptid) { procinfo *pi; - pi = find_procinfo (pid == -1 ? - PIDGET (inferior_pid) : PIDGET (pid), 0); + pi = find_procinfo_or_die (PIDGET (ptid) == -1 ? + PIDGET (inferior_ptid) : PIDGET (ptid), 0); if (!pi) /* If no process, then not stopped by watchpoint! */ return 0; @@ -5278,31 +5285,31 @@ procfs_stopped_by_watchpoint (int pid) * Function: procfs_find_LDT_entry * * Input: - * int pid; // The GDB-style pid-plus-LWP. + * ptid_t ptid; // The GDB-style pid-plus-LWP. * * Return: * pointer to the corresponding LDT entry. */ struct ssd * -procfs_find_LDT_entry (int pid) +procfs_find_LDT_entry (ptid_t ptid) { gdb_gregset_t *gregs; int key; procinfo *pi; /* Find procinfo for the lwp. */ - if ((pi = find_procinfo (PIDGET (pid), TIDGET (pid))) == NULL) + if ((pi = find_procinfo (PIDGET (ptid), TIDGET (ptid))) == NULL) { - warning ("procfs_find_LDT_entry: could not find procinfi for %d.", - pid); + warning ("procfs_find_LDT_entry: could not find procinfo for %d:%d.", + PIDGET (ptid), TIDGET (ptid)); return NULL; } /* get its general registers. */ if ((gregs = proc_get_gregs (pi)) == NULL) { - warning ("procfs_find_LDT_entry: could not read gregs for %d.", - pid); + warning ("procfs_find_LDT_entry: could not read gregs for %d:%d.", + PIDGET (ptid), TIDGET (ptid)); return NULL; } /* Now extract the GS register's lower 16 bits. */ @@ -5353,7 +5360,7 @@ info_proc_cmd (char *args, int from_tty) argv++; } if (pid == 0) - pid = PIDGET (inferior_pid); + pid = PIDGET (inferior_ptid); if (pid == 0) error ("No current process: you must name one."); else @@ -5402,13 +5409,13 @@ proc_trace_syscalls (char *args, int from_tty, int entry_or_exit, int mode) sysset_t *sysset; int syscallnum = 0; - if (inferior_pid <= 0) + if (PIDGET (inferior_ptid) <= 0) error ("you must be debugging a process to use this command."); if (args == NULL || args[0] == 0) error_no_arg ("system call to trace"); - pi = find_procinfo_or_die (PIDGET (inferior_pid), 0); + pi = find_procinfo_or_die (PIDGET (inferior_ptid), 0); if (isdigit (args[0])) { syscallnum = atoi (args); @@ -5495,11 +5502,8 @@ Default is the process being debugged."); * we will be able to find a 'live' procinfo. */ -int +ptid_t procfs_first_available (void) { - if (procinfo_list) - return procinfo_list->pid; - else - return -1; + return pid_to_ptid (procinfo_list ? procinfo_list->pid : -1); } diff --git a/gdb/ptx4-nat.c b/gdb/ptx4-nat.c index ee74227..65eef9d 100644 --- a/gdb/ptx4-nat.c +++ b/gdb/ptx4-nat.c @@ -153,7 +153,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR)) curseg = 0; while (1) { - rv = ptrace (PT_NEXT_VSEG, inferior_pid, &pv, curseg); + rv = ptrace (PT_NEXT_VSEG, PIDGET (inferior_ptid), &pv, curseg); #ifdef VERBOSE_DEBUG printf ("PT_NEXT_VSEG: rv %d errno %d\n", rv, errno); #endif @@ -187,7 +187,7 @@ proc_iterate_over_mappings (int (*func) (int, CORE_ADDR)) close (interp_fd); return 0; } - rv = ptrace (PT_RDATA_PAGE, inferior_pid, buf2, + rv = ptrace (PT_RDATA_PAGE, PIDGET (inferior_ptid), buf2, memptr); if (-1 == rv) { diff --git a/gdb/regcache.c b/gdb/regcache.c index b58ed29..bbc83e0 100644 --- a/gdb/regcache.c +++ b/gdb/regcache.c @@ -49,10 +49,9 @@ char *registers; signed char *register_valid; -/* The thread/process associated with the current set of registers. - For now, -1 is special, and means `no current process'. */ +/* The thread/process associated with the current set of registers. */ -static int registers_pid = -1; +static ptid_t registers_ptid; /* * FUNCTIONS: @@ -154,7 +153,7 @@ registers_changed (void) { int i; - registers_pid = -1; + registers_ptid = pid_to_ptid (-1); /* Force cleanup of any alloca areas if using C alloca instead of a builtin alloca. This particular call is used to clean up @@ -280,10 +279,10 @@ static void legacy_read_register_gen (int regnum, char *myaddr) { gdb_assert (regnum >= 0 && regnum < (NUM_REGS + NUM_PSEUDO_REGS)); - if (registers_pid != inferior_pid) + if (! ptid_equal (registers_ptid, inferior_ptid)) { registers_changed (); - registers_pid = inferior_pid; + registers_ptid = inferior_ptid; } if (!register_cached (regnum)) @@ -332,10 +331,10 @@ legacy_write_register_gen (int regnum, char *myaddr) if (CANNOT_STORE_REGISTER (regnum)) return; - if (registers_pid != inferior_pid) + if (! ptid_equal (registers_ptid, inferior_ptid)) { registers_changed (); - registers_pid = inferior_pid; + registers_ptid = inferior_ptid; } size = REGISTER_RAW_SIZE (regnum); @@ -440,21 +439,22 @@ read_register (int regnum) } ULONGEST -read_register_pid (int regnum, int pid) +read_register_pid (int regnum, ptid_t ptid) { + ptid_t save_ptid; int save_pid; CORE_ADDR retval; - if (pid == inferior_pid) + if (ptid_equal (ptid, inferior_ptid)) return read_register (regnum); - save_pid = inferior_pid; + save_ptid = inferior_ptid; - inferior_pid = pid; + inferior_ptid = ptid; retval = read_register (regnum); - inferior_pid = save_pid; + inferior_ptid = save_ptid; return retval; } @@ -470,21 +470,21 @@ read_signed_register (int regnum) } LONGEST -read_signed_register_pid (int regnum, int pid) +read_signed_register_pid (int regnum, ptid_t ptid) { - int save_pid; + ptid_t save_ptid; LONGEST retval; - if (pid == inferior_pid) + if (ptid_equal (ptid, inferior_ptid)) return read_signed_register (regnum); - save_pid = inferior_pid; + save_ptid = inferior_ptid; - inferior_pid = pid; + inferior_ptid = ptid; retval = read_signed_register (regnum); - inferior_pid = save_pid; + inferior_ptid = save_ptid; return retval; } @@ -503,23 +503,23 @@ write_register (int regnum, LONGEST val) } void -write_register_pid (int regnum, CORE_ADDR val, int pid) +write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid) { - int save_pid; + ptid_t save_ptid; - if (pid == inferior_pid) + if (ptid_equal (ptid, inferior_ptid)) { write_register (regnum, val); return; } - save_pid = inferior_pid; + save_ptid = inferior_ptid; - inferior_pid = pid; + inferior_ptid = ptid; write_register (regnum, val); - inferior_pid = save_pid; + inferior_ptid = save_ptid; } /* SUPPLY_REGISTER() @@ -536,10 +536,10 @@ void supply_register (int regnum, char *val) { #if 1 - if (registers_pid != inferior_pid) + if (! ptid_equal (registers_ptid, inferior_ptid)) { registers_changed (); - registers_pid = inferior_pid; + registers_ptid = inferior_ptid; } #endif @@ -590,12 +590,12 @@ supply_register (int regnum, char *val) TARGET_READ_PC directly. (cagney). */ CORE_ADDR -generic_target_read_pc (int pid) +generic_target_read_pc (ptid_t ptid) { #ifdef PC_REGNUM if (PC_REGNUM >= 0) { - CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, pid)); + CORE_ADDR pc_val = ADDR_BITS_REMOVE ((CORE_ADDR) read_register_pid (PC_REGNUM, ptid)); return pc_val; } #endif @@ -605,37 +605,37 @@ generic_target_read_pc (int pid) } CORE_ADDR -read_pc_pid (int pid) +read_pc_pid (ptid_t ptid) { - int saved_inferior_pid; + ptid_t saved_inferior_ptid; CORE_ADDR pc_val; - /* In case pid != inferior_pid. */ - saved_inferior_pid = inferior_pid; - inferior_pid = pid; + /* In case ptid != inferior_ptid. */ + saved_inferior_ptid = inferior_ptid; + inferior_ptid = ptid; - pc_val = TARGET_READ_PC (pid); + pc_val = TARGET_READ_PC (ptid); - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; return pc_val; } CORE_ADDR read_pc (void) { - return read_pc_pid (inferior_pid); + return read_pc_pid (inferior_ptid); } void -generic_target_write_pc (CORE_ADDR pc, int pid) +generic_target_write_pc (CORE_ADDR pc, ptid_t ptid) { #ifdef PC_REGNUM if (PC_REGNUM >= 0) - write_register_pid (PC_REGNUM, pc, pid); + write_register_pid (PC_REGNUM, pc, ptid); if (NPC_REGNUM >= 0) - write_register_pid (NPC_REGNUM, pc + 4, pid); + write_register_pid (NPC_REGNUM, pc + 4, ptid); if (NNPC_REGNUM >= 0) - write_register_pid (NNPC_REGNUM, pc + 8, pid); + write_register_pid (NNPC_REGNUM, pc + 8, ptid); #else internal_error (__FILE__, __LINE__, "generic_target_write_pc"); @@ -643,23 +643,23 @@ generic_target_write_pc (CORE_ADDR pc, int pid) } void -write_pc_pid (CORE_ADDR pc, int pid) +write_pc_pid (CORE_ADDR pc, ptid_t ptid) { - int saved_inferior_pid; + ptid_t saved_inferior_ptid; - /* In case pid != inferior_pid. */ - saved_inferior_pid = inferior_pid; - inferior_pid = pid; + /* In case ptid != inferior_ptid. */ + saved_inferior_ptid = inferior_ptid; + inferior_ptid = ptid; - TARGET_WRITE_PC (pc, pid); + TARGET_WRITE_PC (pc, ptid); - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; } void write_pc (CORE_ADDR pc) { - write_pc_pid (pc, inferior_pid); + write_pc_pid (pc, inferior_ptid); } /* Cope with strage ways of getting to the stack and frame pointers */ @@ -774,4 +774,8 @@ _initialize_regcache (void) add_com ("flushregs", class_maintenance, reg_flush_command, "Force gdb to flush its register cache (maintainer command)"); + + /* Initialize the thread/process associated with the current set of + registers. For now, -1 is special, and means `no current process'. */ + registers_ptid = pid_to_ptid (-1); } diff --git a/gdb/regcache.h b/gdb/regcache.h index dbffb57..93fbbc7 100644 --- a/gdb/regcache.h +++ b/gdb/regcache.h @@ -66,15 +66,15 @@ extern void write_register_bytes (int regbyte, char *myaddr, int len); extern ULONGEST read_register (int regnum); /* Rename to read_unsigned_register_pid()? */ -extern ULONGEST read_register_pid (int regnum, int pid); +extern ULONGEST read_register_pid (int regnum, ptid_t ptid); extern LONGEST read_signed_register (int regnum); -extern LONGEST read_signed_register_pid (int regnum, int pid); +extern LONGEST read_signed_register_pid (int regnum, ptid_t ptid); extern void write_register (int regnum, LONGEST val); -extern void write_register_pid (int regnum, CORE_ADDR val, int pid); +extern void write_register_pid (int regnum, CORE_ADDR val, ptid_t ptid); extern void supply_register (int regnum, char *val); diff --git a/gdb/remote-adapt.c b/gdb/remote-adapt.c index 10139b4..9d31d52 100644 --- a/gdb/remote-adapt.c +++ b/gdb/remote-adapt.c @@ -753,7 +753,7 @@ adapt_detach (char *args, int from_tty) /* Tell the remote machine to resume. */ void -adapt_resume (int pid, int step, enum target_signal sig) +adapt_resume (ptid_t ptid, int step, enum target_signal sig) { if (step) { @@ -781,8 +781,8 @@ adapt_resume (int pid, int step, enum target_signal sig) /* Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -int -adapt_wait (struct target_waitstatus *status) +ptid_t +adapt_wait (ptid_t ptid, struct target_waitstatus *status) { /* Strings to look for. '?' means match any single character. Note that with the algorithm we use, the initial character @@ -815,7 +815,7 @@ adapt_wait (struct target_waitstatus *status) status->kind = TARGET_WAITKIND_STOPPED; status->value.sig = TARGET_SIGNAL_TRAP; need_artificial_trap--; - return 0; + return inferior_ptid; } timeout = 0; /* Don't time out -- user program is running. */ @@ -871,7 +871,7 @@ adapt_wait (struct target_waitstatus *status) } timeout = old_timeout; immediate_quit = old_immediate_quit; - return 0; + return inferior_ptid; } /* Return the name of register number REGNO diff --git a/gdb/remote-array.c b/gdb/remote-array.c index 10f9c90..35d271d 100644 --- a/gdb/remote-array.c +++ b/gdb/remote-array.c @@ -67,7 +67,7 @@ static void array_open (); static void array_close (); static void array_detach (); static void array_attach (); -static void array_resume (); +static void array_resume (ptid_t ptid, int step, enum target_signal sig); static void array_fetch_register (); static void array_store_register (); static void array_fetch_registers (); @@ -79,7 +79,8 @@ static void array_create_inferior (); static void array_mourn_inferior (); static void make_gdb_packet (); static int array_xfer_memory (); -static int array_wait (); +static ptid_t array_wait (ptid_t ptid, + struct target_waitstatus *status); static int array_insert_breakpoint (); static int array_remove_breakpoint (); static int tohex (); @@ -697,7 +698,7 @@ array_attach (char *args, int from_tty) * array_resume -- Tell the remote machine to resume. */ static void -array_resume (int pid, int step, enum target_signal sig) +array_resume (ptid_t ptid, int step, enum target_signal sig) { debuglogs (1, "array_resume (step=%d, sig=%d)", step, sig); @@ -717,8 +718,8 @@ array_resume (int pid, int step, enum target_signal sig) * array_wait -- Wait until the remote machine stops, then return, * storing status in status just as `wait' would. */ -static int -array_wait (int pid, struct target_waitstatus *status) +static ptid_t +array_wait (ptid_t ptid, struct target_waitstatus *status) { int old_timeout = timeout; int result, i; @@ -784,7 +785,7 @@ array_wait (int pid, struct target_waitstatus *status) timeout = old_timeout; - return 0; + return inferior_ptid; } /* diff --git a/gdb/remote-bug.c b/gdb/remote-bug.c index 498edc6..3537957 100644 --- a/gdb/remote-bug.c +++ b/gdb/remote-bug.c @@ -115,7 +115,7 @@ bug_load (char *args, int fromtty) sr_check_open (); - inferior_pid = 0; + inferior_ptid = null_ptid; abfd = bfd_openr (args, 0); if (!abfd) { @@ -232,7 +232,7 @@ bug_open (char *args, int from_tty) /* Tell the remote machine to resume. */ void -bug_resume (int pid, int step, enum target_signal sig) +bug_resume (ptid_t ptid, int step, enum target_signal sig) { if (step) { @@ -261,8 +261,8 @@ static char *wait_strings[] = NULL, }; -int -bug_wait (int pid, struct target_waitstatus *status) +ptid_t +bug_wait (ptid_t ptid, struct target_waitstatus *status) { int old_timeout = sr_get_timeout (); int old_immediate_quit = immediate_quit; @@ -325,7 +325,7 @@ bug_wait (int pid, struct target_waitstatus *status) sr_set_timeout (old_timeout); immediate_quit = old_immediate_quit; - return 0; + return inferior_ptid; } /* Return the name of register number REGNO diff --git a/gdb/remote-e7000.c b/gdb/remote-e7000.c index 0f63703..4e7c97c 100644 --- a/gdb/remote-e7000.c +++ b/gdb/remote-e7000.c @@ -710,7 +710,7 @@ e7000_detach (char *arg, int from_tty) /* Tell the remote machine to resume. */ static void -e7000_resume (int pid, int step, enum target_signal sigal) +e7000_resume (ptid_t ptid, int step, enum target_signal sigal) { if (step) puts_e7000debug ("S\r"); @@ -1645,7 +1645,7 @@ e7000_load (char *args, 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 now that we have loaded @@ -1999,8 +1999,8 @@ static char *estrings[] = /* Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -static int -e7000_wait (int pid, struct target_waitstatus *status) +static ptid_t +e7000_wait (ptid_t ptid, struct target_waitstatus *status) { int stop_reason; int regno; @@ -2122,7 +2122,7 @@ e7000_wait (int pid, struct target_waitstatus *status) internal_error (__FILE__, __LINE__, "failed internal consistency check"); } - return 0; + return inferior_ptid; } /* Stop the running program. */ diff --git a/gdb/remote-eb.c b/gdb/remote-eb.c index aa7608c..fa003c6 100644 --- a/gdb/remote-eb.c +++ b/gdb/remote-eb.c @@ -520,7 +520,7 @@ eb_detach (int from_tty) /* Tell the remote machine to resume. */ void -eb_resume (int pid, int step, enum target_signal sig) +eb_resume (ptid_t ptid, int step, enum target_signal sig) { if (step) { @@ -559,8 +559,8 @@ eb_resume (int pid, int step, enum target_signal sig) /* Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -int -eb_wait (struct target_waitstatus *status) +ptid_t +eb_wait (ptid_t ptid, struct target_waitstatus *status) { /* Strings to look for. '?' means match any single character. Note that with the algorithm we use, the initial character diff --git a/gdb/remote-es.c b/gdb/remote-es.c index 11653e9..6423fe2 100644 --- a/gdb/remote-es.c +++ b/gdb/remote-es.c @@ -140,9 +140,9 @@ es1800_xfer_inferior_memory (CORE_ADDR, char *, int, int, static void es1800_prepare_to_store (void); -static int es1800_wait (int, struct target_waitstatus *); +static ptid_t es1800_wait (ptid_t, struct target_waitstatus *); -static void es1800_resume (int, int, enum target_signal); +static void es1800_resume (ptid_t, int, enum target_signal); static void es1800_detach (char *, int); @@ -500,7 +500,7 @@ es1800_detach (char *args, int from_tty) siggnal - the signal value to be given to the target (0 = no signal) */ static void -es1800_resume (int pid, int step, enum target_signal siggnal) +es1800_resume (ptid_t ptid, int step, enum target_signal siggnal) { char buf[PBUFSIZ]; @@ -523,8 +523,8 @@ es1800_resume (int pid, int step, enum target_signal siggnal) storing status in STATUS just as `wait' would. status - */ -static int -es1800_wait (int pid, struct target_waitstatus *status) +static ptid_t +es1800_wait (ptid_t ptid, struct target_waitstatus *status) { unsigned char buf[PBUFSIZ]; int old_timeout = timeout; @@ -589,7 +589,7 @@ es1800_wait (int pid, struct target_waitstatus *status) } signal (SIGINT, old_sigint); timeout = old_timeout; - return (0); + return inferior_ptid; } @@ -1206,9 +1206,9 @@ get_break_addr (int vec, CORE_ADDR *addrp) static void es1800_kill (void) { - if (inferior_pid != 0) + if (!ptid_equal (inferior_ptid, null_ptid)) { - inferior_pid = 0; + inferior_ptid = null_ptid; es1800_mourn_inferior (); } } @@ -1273,7 +1273,7 @@ es1800_load (char *filename, int from_tty) } breakpoint_init_inferior (); - inferior_pid = 0; + inferior_ptid = null_ptid; if (from_tty) { printf ("Downloading \"%s\" to the ES 1800\n", filename); @@ -1374,7 +1374,7 @@ bfd_copy (bfd *from_bfd, bfd *to_bfd) #endif -/* Start an process on the es1800 and set inferior_pid to the new +/* Start an process on the es1800 and set inferior_ptid to the new process' pid. execfile - the file to run args - arguments passed to the program @@ -1427,7 +1427,7 @@ es1800_create_inferior (char *execfile, char *args, char **env) /* The "process" (board) is already stopped awaiting our commands, and the program is already downloaded. We just set its PC and go. */ - inferior_pid = pid; /* Needed for wait_for_inferior below */ + inferior_ptid = pid_to_ptid (pid); /* Needed for wait_for_inferior below */ clear_proceed_status (); @@ -1961,7 +1961,7 @@ es1800_child_detach (char *args, int from_tty) pop_target (); if (from_tty) { - printf ("Ending debugging the process %d.\n", inferior_pid); + printf ("Ending debugging the process %d.\n", PIDGET (inferior_ptid)); } } diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c index dfde85b..882cbca 100644 --- a/gdb/remote-mips.c +++ b/gdb/remote-mips.c @@ -85,9 +85,11 @@ static void mips_close (int quitting); static void mips_detach (char *args, int from_tty); -static void mips_resume (int pid, int step, enum target_signal siggnal); +static void mips_resume (ptid_t ptid, int step, + enum target_signal siggnal); -static int mips_wait (int pid, struct target_waitstatus *status); +static ptid_t mips_wait (ptid_t ptid, + struct target_waitstatus *status); static int mips_map_regno (int regno); @@ -1704,7 +1706,7 @@ mips_detach (char *args, int from_tty) where PMON does return a reply. */ static void -mips_resume (int pid, int step, enum target_signal siggnal) +mips_resume (ptid_t ptid, int step, enum target_signal siggnal) { int err; @@ -1736,8 +1738,8 @@ mips_signal_from_protocol (int sig) /* Wait until the remote stops, and return a wait status. */ -static int -mips_wait (int pid, struct target_waitstatus *status) +static ptid_t +mips_wait (ptid_t ptid, struct target_waitstatus *status) { int rstatus; int err; @@ -1757,7 +1759,7 @@ mips_wait (int pid, struct target_waitstatus *status) { status->kind = TARGET_WAITKIND_STOPPED; status->value.sig = TARGET_SIGNAL_TRAP; - return 0; + return inferior_ptid; } /* No timeout; we sit here as long as the program continues to execute. */ @@ -1888,7 +1890,7 @@ mips_wait (int pid, struct target_waitstatus *status) status->value.sig = mips_signal_from_protocol (rstatus & 0x7f); } - return 0; + return inferior_ptid; } /* We have to map between the register numbers used by gdb and the @@ -2230,7 +2232,7 @@ Can't pass arguments to remote MIPS board; arguments ignored."); init_wait_for_inferior (); - /* FIXME: Should we set inferior_pid here? */ + /* FIXME: Should we set inferior_ptid here? */ proceed (entry_pt, TARGET_SIGNAL_DEFAULT, 0); } @@ -3439,7 +3441,7 @@ mips_load (char *file, 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 now that we have loaded diff --git a/gdb/remote-mm.c b/gdb/remote-mm.c index ccbacc5..67727e2 100644 --- a/gdb/remote-mm.c +++ b/gdb/remote-mm.c @@ -51,7 +51,7 @@ extern int stop_soon_quietly; /* for wait_for_inferior */ -static void mm_resume (); +static void mm_resume (ptid_t ptid, int step, enum target_signal sig) static void mm_fetch_registers (); static int fetch_register (); static void mm_store_registers (); @@ -523,7 +523,7 @@ mm_detach (char *args, int from_tty) ** Tell the remote machine to resume. */ static void -mm_resume (int pid, int step, enum target_signal sig) +mm_resume (ptid_t ptid, int step, enum target_signal sig) { if (sig != TARGET_SIGNAL_0) warning ("Can't send signals to a remote MiniMon system."); @@ -547,8 +547,8 @@ mm_resume (int pid, int step, enum target_signal sig) ** Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -static int -mm_wait (struct target_waitstatus *status) +static ptid_t +mm_wait (ptid_t ptid, struct target_waitstatus *status) { int i, result; int old_timeout = timeout; @@ -692,7 +692,7 @@ halted: timeout = old_timeout; /* Restore original timeout value */ immediate_quit = old_immediate_quit; - return 0; + return inferior_ptid; } /******************************************************* REMOTE_FETCH_REGISTERS diff --git a/gdb/remote-nindy.c b/gdb/remote-nindy.c index 419a1b1..9b8dfe8 100644 --- a/gdb/remote-nindy.c +++ b/gdb/remote-nindy.c @@ -255,7 +255,7 @@ non_dle (char *buf, int n) /* Tell the remote machine to resume. */ void -nindy_resume (int pid, int step, enum target_signal siggnal) +nindy_resume (ptid_t ptid, int step, enum target_signal siggnal) { if (siggnal != TARGET_SIGNAL_0 && siggnal != stop_signal) warning ("Can't send signals to remote NINDY targets."); @@ -316,8 +316,8 @@ clean_up_int (void) * Return to caller, storing status in 'status' just as `wait' would. */ -static int -nindy_wait (int pid, struct target_waitstatus *status) +static ptid_t +nindy_wait (ptid_t ptid, struct target_waitstatus *status) { fd_set fds; int c; @@ -409,7 +409,7 @@ nindy_wait (int pid, struct target_waitstatus *status) status->kind = TARGET_WAITKIND_STOPPED; status->value.sig = i960_fault_to_signal (stop_code); } - return inferior_pid; + return inferior_ptid; } /* Read the remote registers into the block REGS. */ @@ -513,7 +513,7 @@ nindy_create_inferior (char *execfile, char *args, char **env) /* The "process" (board) is already stopped awaiting our commands, and the program is already downloaded. We just set its PC and go. */ - inferior_pid = pid; /* Needed for wait_for_inferior below */ + inferior_ptid = pid_to_ptid (pid); /* Needed for wait_for_inferior below */ clear_proceed_status (); diff --git a/gdb/remote-os9k.c b/gdb/remote-os9k.c index 08b35fd..3302580 100644 --- a/gdb/remote-os9k.c +++ b/gdb/remote-os9k.c @@ -431,7 +431,7 @@ rombug_detach (int from_tty) * Tell the remote machine to resume. */ static void -rombug_resume (int pid, int step, enum target_signal sig) +rombug_resume (ptid_t ptid, int step, enum target_signal sig) { if (monitor_log) fprintf (log_file, "\nIn Resume (step=%d, sig=%d)\n", step, sig); @@ -460,8 +460,8 @@ rombug_resume (int pid, int step, enum target_signal sig) * storing status in status just as `wait' would. */ -static int -rombug_wait (int pid, struct target_waitstatus *status) +static ptid * +rombug_wait (ptid_t ptid, struct target_waitstatus *status) { int old_timeout = timeout; struct section_offsets *offs; @@ -499,7 +499,7 @@ rombug_wait (int pid, struct target_waitstatus *status) objfile_relocate (symfile_objfile, offs); } - return 0; + return inferior_ptid; } /* Return the name of register number regno in the form input and output by diff --git a/gdb/remote-rdi.c b/gdb/remote-rdi.c index fbd176f..9b7848c 100644 --- a/gdb/remote-rdi.c +++ b/gdb/remote-rdi.c @@ -60,7 +60,8 @@ static void arm_rdi_prepare_to_store (void); static void arm_rdi_fetch_registers (int regno); -static void arm_rdi_resume (int pid, int step, enum target_signal siggnal); +static void arm_rdi_resume (ptid_t pid, int step, + enum target_signal siggnal); static int arm_rdi_start_remote (char *dummy); @@ -76,7 +77,7 @@ static void arm_rdi_mourn (void); static void arm_rdi_send (char *buf); -static int arm_rdi_wait (int pid, struct target_waitstatus *status); +static int arm_rdi_wait (ptid_t ptid, struct target_waitstatus *status); static void arm_rdi_kill (void); @@ -339,10 +340,10 @@ device is attached to the remote system (e.g. /dev/ttya)."); printf_filtered ("Connected to ARM RDI target.\n"); closed_already = 0; - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); } -/* Start an inferior process and set inferior_pid to its pid. +/* Start an inferior process and set inferior_ptid to its pid. EXEC_FILE is the file to run. ARGS is a string containing the arguments to the program. ENV is the environment vector to pass. Errors reported with error(). @@ -374,7 +375,7 @@ arm_rdi_create_inferior (char *exec_file, char *args, char **env) strcat (arg_buf, " "); strcat (arg_buf, args); - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); insert_breakpoints (); /* Needed to get correct instruction in cache */ if (env != NULL) @@ -438,7 +439,7 @@ arm_rdi_close (int quitting) printf_filtered ("RDI_close: %s\n", rdi_error_message (rslt)); } closed_already = 1; - inferior_pid = 0; + inferior_ptid = null_ptid; Adp_CloseDevice (); generic_mourn_inferior (); } @@ -447,7 +448,7 @@ arm_rdi_close (int quitting) /* Tell the remote machine to resume. */ static void -arm_rdi_resume (int pid, int step, enum target_signal siggnal) +arm_rdi_resume (ptid_t ptid, int step, enum target_signal siggnal) { int rslt; PointHandle point; @@ -512,8 +513,8 @@ interrupt_query (void) STATUS just as `wait' would. Returns "pid" (though it's not clear what, if anything, that means in the case of this target). */ -static int -arm_rdi_wait (int pid, struct target_waitstatus *status) +static ptid_t +arm_rdi_wait (ptid_t ptid, struct target_waitstatus *status) { status->kind = (execute_status == RDIError_NoError ? TARGET_WAITKIND_EXITED : TARGET_WAITKIND_STOPPED); @@ -521,7 +522,7 @@ arm_rdi_wait (int pid, struct target_waitstatus *status) /* convert stopped code from target into right signal */ status->value.sig = rdi_error_signal (execute_status); - return inferior_pid; + return inferior_ptid; } /* Read the remote registers into the block REGS. */ diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c index f680960..673e423 100644 --- a/gdb/remote-rdp.c +++ b/gdb/remote-rdp.c @@ -1183,7 +1183,7 @@ remote_rdp_close (int quitting) to the target, or zero for no signal. */ static void -remote_rdp_resume (int pid, int step, enum target_signal siggnal) +remote_rdp_resume (ptid_t ptid, int step, enum target_signal siggnal) { if (step) rdp_step (); @@ -1195,8 +1195,8 @@ remote_rdp_resume (int pid, int step, enum target_signal siggnal) or -1 in case of error; store status through argument pointer STATUS, just as `wait' would. */ -static int -remote_rdp_wait (int pid, struct target_waitstatus *status) +static ptid_t +remote_rdp_wait (ptid_t ptid, struct target_waitstatus *status) { switch (ds.rdi_stopped_status) { @@ -1222,7 +1222,7 @@ remote_rdp_wait (int pid, struct target_waitstatus *status) #endif } - return inferior_pid; + return inferior_ptid; } /* Get ready to modify the registers array. On machines which store @@ -1348,7 +1348,7 @@ remote_rdp_create_inferior (char *exec_file, char *allargs, char **env) /* This gives us a chance to set up the command line */ rdp_set_command_line (exec_file, allargs); - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); insert_breakpoints (); /* Needed to get correct instruction in cache */ /* diff --git a/gdb/remote-sds.c b/gdb/remote-sds.c index b41ca35..27bc241 100644 --- a/gdb/remote-sds.c +++ b/gdb/remote-sds.c @@ -62,7 +62,7 @@ static void sds_prepare_to_store (void); static void sds_fetch_registers (int); -static void sds_resume (int, int, enum target_signal); +static void sds_resume (ptid_t, int, enum target_signal); static int sds_start_remote (PTR); @@ -86,7 +86,7 @@ static int sds_send (unsigned char *, int); static int readchar (int); -static int sds_wait (int, struct target_waitstatus *); +static ptid_t sds_wait (ptid_t, struct target_waitstatus *); static void sds_kill (void); @@ -347,7 +347,7 @@ static enum target_signal last_sent_signal = TARGET_SIGNAL_0; int last_sent_step; static void -sds_resume (int pid, int step, enum target_signal siggnal) +sds_resume (ptid_t ptid, int step, enum target_signal siggnal) { unsigned char buf[PBUFSIZ]; @@ -416,8 +416,8 @@ int kill_kludge; STATUS just as `wait' would. Returns "pid" (though it's not clear what, if anything, that means in the case of this target). */ -static int -sds_wait (int pid, struct target_waitstatus *status) +static ptid_t +sds_wait (ptid_t ptid, struct target_waitstatus *status) { unsigned char buf[PBUFSIZ]; int retlen; @@ -433,7 +433,7 @@ sds_wait (int pid, struct target_waitstatus *status) { just_started = 0; status->kind = TARGET_WAITKIND_STOPPED; - return inferior_pid; + return inferior_ptid; } while (1) @@ -457,7 +457,7 @@ sds_wait (int pid, struct target_waitstatus *status) } } got_status: - return inferior_pid; + return inferior_ptid; } static unsigned char sprs[16]; @@ -1001,7 +1001,7 @@ sds_mourn (void) static void sds_create_inferior (char *exec_file, char *args, char **env) { - inferior_pid = 42000; + inferior_ptid = pid_to_ptid (42000); /* Clean up from the last time we were running. */ clear_proceed_status (); @@ -1015,7 +1015,7 @@ sds_load (char *filename, int from_tty) { generic_load (filename, from_tty); - inferior_pid = 0; + inferior_ptid = null_ptid; } /* The SDS monitor has commands for breakpoint insertion, although it diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 890970f..71af074 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -86,9 +86,9 @@ static void gdbsim_close (int quitting); static void gdbsim_detach (char *args, int from_tty); -static void gdbsim_resume (int pid, int step, enum target_signal siggnal); +static void gdbsim_resume (ptid_t ptid, int step, enum target_signal siggnal); -static int gdbsim_wait (int pid, struct target_waitstatus *status); +static ptid_t gdbsim_wait (ptid_t ptid, struct target_waitstatus *status); static void gdbsim_prepare_to_store (void); @@ -359,7 +359,7 @@ gdbsim_kill (void) /* There is no need to `kill' running simulator - the simulator is not running */ - inferior_pid = 0; + inferior_ptid = null_ptid; } /* Load an executable file into the target process. This is expected to @@ -372,7 +372,7 @@ gdbsim_load (char *prog, int fromtty) if (sr_get_debug ()) printf_filtered ("gdbsim_load: prog \"%s\"\n", prog); - inferior_pid = 0; + inferior_ptid = null_ptid; /* FIXME: We will print two messages on error. Need error to either not print anything if passed NULL or need @@ -387,7 +387,7 @@ gdbsim_load (char *prog, int fromtty) } -/* Start an inferior process and set inferior_pid to its pid. +/* Start an inferior process and set inferior_ptid to its pid. EXEC_FILE is the file to run. ARGS is a string containing the arguments to the program. ENV is the environment vector to pass. Errors reported with error(). @@ -430,7 +430,7 @@ gdbsim_create_inferior (char *exec_file, char *args, char **env) argv = NULL; sim_create_inferior (gdbsim_desc, exec_bfd, argv, env); - inferior_pid = 42; + inferior_ptid = pid_to_ptid (42); insert_breakpoints (); /* Needed to get correct instruction in cache */ clear_proceed_status (); @@ -572,9 +572,9 @@ static enum target_signal resume_siggnal; static int resume_step; static void -gdbsim_resume (int pid, int step, enum target_signal siggnal) +gdbsim_resume (ptid_t ptid, int step, enum target_signal siggnal) { - if (inferior_pid != 42) + if (PIDGET (inferior_ptid) != 42) error ("The program is not being run."); if (sr_get_debug ()) @@ -634,8 +634,8 @@ gdbsim_cntrl_c (int signo) gdbsim_stop (); } -static int -gdbsim_wait (int pid, struct target_waitstatus *status) +static ptid_t +gdbsim_wait (ptid_t ptid, struct target_waitstatus *status) { static RETSIGTYPE (*prev_sigint) (); int sigrc = 0; @@ -697,7 +697,7 @@ gdbsim_wait (int pid, struct target_waitstatus *status) break; } - return inferior_pid; + return inferior_ptid; } /* Get ready to modify the registers array. On machines which store diff --git a/gdb/remote-st.c b/gdb/remote-st.c index b341aeb..868c08e 100644 --- a/gdb/remote-st.c +++ b/gdb/remote-st.c @@ -339,7 +339,7 @@ st2000_detach (int from_tty) /* Tell the remote machine to resume. */ static void -st2000_resume (int pid, int step, enum target_signal sig) +st2000_resume (ptid_t ptid, int step, enum target_signal sig) { if (step) { @@ -358,8 +358,8 @@ st2000_resume (int pid, int step, enum target_signal sig) /* Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -static int -st2000_wait (struct target_waitstatus *status) +static ptid_t +st2000_wait (ptid_t ptid, struct target_waitstatus *status) { int old_timeout = timeout; @@ -375,7 +375,7 @@ st2000_wait (struct target_waitstatus *status) timeout = old_timeout; - return 0; + return inferior_ptid; } /* Return the name of register number REGNO in the form input and output by diff --git a/gdb/remote-udi.c b/gdb/remote-udi.c index aa3b4ba..0015e99 100644 --- a/gdb/remote-udi.c +++ b/gdb/remote-udi.c @@ -54,7 +54,7 @@ extern int stop_soon_quietly; /* for wait_for_inferior */ extern struct value *call_function_by_hand (); -static void udi_resume (int pid, int step, enum target_signal sig); +static void udi_resume (ptid_t ptid, int step, enum target_signal sig); static void udi_fetch_registers (int regno); static void udi_load (char *args, int from_tty); static void fetch_register (int regno); @@ -148,7 +148,7 @@ udi_create_inferior (char *execfile, char *args, char **env) entry.Offset = 0; } - inferior_pid = 40000; + inferior_ptid = pid_to_ptid (40000); if (!entry.Offset) download (execfile, 0); @@ -318,7 +318,7 @@ udi_close ( /*FIXME: how is quitting used */ /* Do not try to close udi_session_id again, later in the program. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; printf_filtered (" Ending remote debugging\n"); } @@ -370,7 +370,7 @@ udi_detach (char *args, int from_tty) /* Don't try to UDIDisconnect it again in udi_close, which is called from pop_target. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; pop_target (); @@ -383,7 +383,7 @@ udi_detach (char *args, int from_tty) ** Tell the remote machine to resume. */ static void -udi_resume (int pid, int step, enum target_signal sig) +udi_resume (ptid_t ptid, int step, enum target_signal sig) { UDIError tip_error; UDIUInt32 Steps = 1; @@ -408,8 +408,8 @@ udi_resume (int pid, int step, enum target_signal sig) ** Wait until the remote machine stops, then return, storing status in STATUS just as `wait' would. */ -static int -udi_wait (int pid, struct target_waitstatus *status) +static ptid_t +udi_wait (int ptid_t, struct target_waitstatus *status) { UDIInt32 MaxTime; UDIPId PId; @@ -584,7 +584,7 @@ udi_wait (int pid, struct target_waitstatus *status) timeout = old_timeout; /* Restore original timeout value */ immediate_quit = old_immediate_quit; - return inferior_pid; + return inferior_ptid; } #if 0 @@ -1012,7 +1012,7 @@ udi_kill (void) UDIStop (); udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; if (from_tty) printf_unfiltered ("Target has been stopped."); @@ -1032,7 +1032,7 @@ udi_kill (void) /* Do not try to close udi_session_id again, later in the program. */ udi_session_id = -1; - inferior_pid = 0; + inferior_ptid = null_ptid; } /* diff --git a/gdb/remote-vx.c b/gdb/remote-vx.c index 1162b07..a441a93 100644 --- a/gdb/remote-vx.c +++ b/gdb/remote-vx.c @@ -163,7 +163,7 @@ net_break (int addr, u_long procnum) break_status = 0; ptrace_in.addr = addr; - ptrace_in.pid = inferior_pid; + ptrace_in.pid = PIDGET (inferior_ptid); status = net_clnt_call (procnum, xdr_rptrace, &ptrace_in, xdr_int, &break_status); @@ -192,7 +192,7 @@ vx_remove_breakpoint (int addr) return net_break (addr, VX_BREAK_DELETE); } -/* Start an inferior process and sets inferior_pid to its pid. +/* Start an inferior 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. @@ -227,7 +227,7 @@ vx_create_inferior (char *exec_file, char *args, char **env) strlen (passArgs.arg_array_val[0])); push_target (&vx_run_ops); - inferior_pid = taskStart.pid; + inferior_ptid = pid_to_ptid (taskStart.pid); /* We will get a trace trap after one instruction. Insert breakpoints and continue. */ @@ -338,7 +338,7 @@ net_wait (RDB_EVENT *pEvent) memset ((char *) pEvent, '\0', sizeof (RDB_EVENT)); - pid = inferior_pid; + pid = PIDGET inferior_ptid); status = net_clnt_call (PROCESS_WAIT, xdr_int, &pid, xdr_RDB_EVENT, pEvent); @@ -365,7 +365,7 @@ net_quit (void) /* don't let rdbTask suspend itself by passing a pid of 0 */ - if ((pid = inferior_pid) == 0) + if ((pid = PIDGET (inferior_ptid)) == 0) return -1; status = net_clnt_call (VX_TASK_SUSPEND, xdr_int, &pid, xdr_int, @@ -390,7 +390,7 @@ net_read_registers (char *reg_buf, int len, u_long procnum) /* Initialize RPC input argument structure. */ - ptrace_in.pid = inferior_pid; + ptrace_in.pid = PIDGET (inferior_ptid); ptrace_in.info.ttype = NOINFO; /* Initialize RPC return value structure. */ @@ -438,7 +438,7 @@ net_write_registers (char *reg_buf, int len, u_long procnum) in_data.bytes = reg_buf; in_data.len = len; - ptrace_in.pid = inferior_pid; + ptrace_in.pid = PIDGET (inferior_ptid); ptrace_in.info.ttype = DATA; ptrace_in.info.more_data = (caddr_t) & in_data; @@ -490,7 +490,7 @@ vx_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in)); memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out)); - ptrace_in.pid = inferior_pid; /* XXX pid unnecessary for READDATA */ + ptrace_in.pid = PIDGET (inferior_ptid); /* XXX pid unnecessary for READDATA */ ptrace_in.addr = (int) memaddr; /* Where from */ ptrace_in.data = len; /* How many bytes */ @@ -565,22 +565,22 @@ vx_run_files_info (void) { printf_unfiltered ("\tRunning %s VxWorks process %s", vx_running ? "child" : "attached", - local_hex_string (inferior_pid)); + local_hex_string (PIDGET (inferior_ptid))); if (vx_running) printf_unfiltered (", function `%s'", vx_running); printf_unfiltered (".\n"); } static void -vx_resume (int pid, int step, enum target_signal siggnal) +vx_resume (ptid_t ptid, int step, enum target_signal siggnal) { int status; Rptrace ptrace_in; Ptrace_return ptrace_out; CORE_ADDR cont_addr; - if (pid == -1) - pid = inferior_pid; + if (ptid_equal (ptid, minus_one_ptid)) + ptid = inferior_ptid; if (siggnal != 0 && siggnal != stop_signal) error ("Cannot send signals to VxWorks processes"); @@ -600,7 +600,7 @@ vx_resume (int pid, int step, enum target_signal siggnal) memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in)); memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out)); - ptrace_in.pid = pid; + ptrace_in.pid = PIDGET (ptid); ptrace_in.addr = cont_addr; /* Target side insists on this, or it panics. */ if (step) @@ -709,7 +709,7 @@ vx_load_command (char *arg_string, int from_tty) /* Refuse to load the module if a debugged task is running. Doing so can have a number of unpleasant consequences to the running task. */ - if (inferior_pid != 0 && target_has_execution) + if (PIDGET (inferior_ptid) != 0 && target_has_execution) { if (query ("You may not load a module while the target task is running.\n\ Kill the target task? ")) @@ -742,7 +742,7 @@ net_step (void) int step_status; SOURCE_STEP source_step; - source_step.taskId = inferior_pid; + source_step.taskId = PIDGET (inferior_ptid); if (step_range_end) { @@ -930,8 +930,8 @@ sleep_ms (long ms) perror_with_name ("select"); } -static int -vx_wait (int pid_to_wait_for, struct target_waitstatus *status) +static ptid_t +vx_wait (ptid_t ptid_to_wait_for, struct target_waitstatus *status) { register int pid; RDB_EVENT rdbEvent; @@ -977,7 +977,7 @@ vx_wait (int pid_to_wait_for, struct target_waitstatus *status) { sleep_ms (200); /* FIXME Don't kill the network too badly */ } - else if (pid != inferior_pid) + else if (pid != PIDGET (inferior_ptid)) internal_error (__FILE__, __LINE__, "Bad pid for debugged task: %s\n", local_hex_string ((unsigned long) pid)); @@ -1035,7 +1035,7 @@ vx_wait (int pid_to_wait_for, struct target_waitstatus *status) #endif break; } /* switch */ - return pid; + return pid_to_ptid (pid); } static int @@ -1208,7 +1208,7 @@ vx_attach (char *args, int from_tty) /* It worked... */ - inferior_pid = pid; + inferior_ptid = pid_to_ptid (pid); push_target (&vx_run_ops); if (vx_running) @@ -1238,14 +1238,15 @@ vx_detach (char *args, int from_tty) if (from_tty) printf_unfiltered ("Detaching pid %s.\n", - local_hex_string ((unsigned long) inferior_pid)); + local_hex_string ( + (unsigned long) PIDGET (inferior_ptid))); if (args) /* FIXME, should be possible to leave suspended */ signal = atoi (args); memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in)); memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out)); - ptrace_in.pid = inferior_pid; + ptrace_in.pid = PIDGET (inferior_ptid); status = net_ptrace_clnt_call (PTRACE_DETACH, &ptrace_in, &ptrace_out); if (status == -1) @@ -1256,7 +1257,7 @@ vx_detach (char *args, int from_tty) perror_with_name ("Detaching VxWorks process"); } - inferior_pid = 0; + inferior_ptid = null_ptid; pop_target (); /* go back to non-executing VxWorks connection */ } @@ -1269,11 +1270,11 @@ vx_kill (void) Ptrace_return ptrace_out; int status; - printf_unfiltered ("Killing pid %s.\n", local_hex_string ((unsigned long) inferior_pid)); + printf_unfiltered ("Killing pid %s.\n", local_hex_string ((unsigned long) PIDGET (inferior_ptid))); memset ((char *) &ptrace_in, '\0', sizeof (ptrace_in)); memset ((char *) &ptrace_out, '\0', sizeof (ptrace_out)); - ptrace_in.pid = inferior_pid; + ptrace_in.pid = PIDGET (inferior_ptid); status = net_ptrace_clnt_call (PTRACE_KILL, &ptrace_in, &ptrace_out); if (status == -1) @@ -1286,7 +1287,7 @@ vx_kill (void) /* If it gives good status, the process is *gone*, no events remain. If the kill failed, assume the process is gone anyhow. */ - inferior_pid = 0; + inferior_ptid = null_ptid; pop_target (); /* go back to non-executing VxWorks connection */ } @@ -1295,7 +1296,7 @@ vx_kill (void) static void vx_proc_close (int quitting) { - inferior_pid = 0; /* No longer have a process. */ + inferior_ptid = null_ptid; /* No longer have a process. */ if (vx_running) xfree (vx_running); vx_running = 0; diff --git a/gdb/remote.c b/gdb/remote.c index 18712c5..aeef7dd 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -79,8 +79,9 @@ static void remote_prepare_to_store (void); static void remote_fetch_registers (int regno); -static void remote_resume (int pid, int step, enum target_signal siggnal); -static void remote_async_resume (int pid, int step, +static void remote_resume (ptid_t ptid, int step, + enum target_signal siggnal); +static void remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal); static int remote_start_remote (PTR); @@ -114,8 +115,10 @@ static void remote_send (char *buf, long sizeof_buf); static int readchar (int timeout); -static int remote_wait (int pid, struct target_waitstatus *status); -static int remote_async_wait (int pid, struct target_waitstatus *status); +static ptid_t remote_wait (ptid_t ptid, + struct target_waitstatus *status); +static ptid_t remote_async_wait (ptid_t ptid, + struct target_waitstatus *status); static void remote_kill (void); static void remote_async_kill (void); @@ -133,7 +136,7 @@ static void interrupt_query (void); static void set_thread (int, int); -static int remote_thread_alive (int); +static int remote_thread_alive (ptid_t); static void get_offsets (void); @@ -177,7 +180,7 @@ static void packet_command (char *, int); static int stub_unpack_int (char *buff, int fieldlength); -static int remote_current_thread (int oldpid); +static ptid_t remote_current_thread (ptid_t oldptid); static void remote_find_new_threads (void); @@ -894,15 +897,16 @@ record_currthread (int currthread) /* If this is a new thread, add it to GDB's thread list. If we leave it up to WFI to do this, bad things will happen. */ - if (!in_thread_list (currthread)) + if (!in_thread_list (pid_to_ptid (currthread))) { - add_thread (currthread); + add_thread (pid_to_ptid (currthread)); #ifdef UI_OUT ui_out_text (uiout, "[New "); - ui_out_text (uiout, target_pid_to_str (currthread)); + ui_out_text (uiout, target_pid_to_str (pid_to_ptid (currthread))); ui_out_text (uiout, "]\n"); #else - printf_filtered ("[New %s]\n", target_pid_to_str (currthread)); + printf_filtered ("[New %s]\n", + target_pid_to_str (pid_to_ptid (currthread))); #endif } } @@ -940,8 +944,9 @@ set_thread (int th, int gen) /* Return nonzero if the thread TH is still alive on the remote system. */ static int -remote_thread_alive (int tid) +remote_thread_alive (ptid_t ptid) { + int tid = PIDGET (ptid); char buf[16]; if (tid < 0) @@ -1615,25 +1620,26 @@ remote_threadlist_iterator (rmt_thread_action stepfunction, void *context, static int remote_newthread_step (threadref *ref, void *context) { - int pid; + ptid_t ptid; - pid = threadref_to_int (ref); - if (!in_thread_list (pid)) - add_thread (pid); + ptid = pid_to_ptid (threadref_to_int (ref)); + + if (!in_thread_list (ptid)) + add_thread (ptid); return 1; /* continue iterator */ } #define CRAZY_MAX_THREADS 1000 -static int -remote_current_thread (int oldpid) +static ptid_t +remote_current_thread (ptid_t oldpid) { char *buf = alloca (PBUFSIZ); putpkt ("qC"); getpkt (buf, PBUFSIZ, 0); if (buf[0] == 'Q' && buf[1] == 'C') - return strtol (&buf[2], NULL, 16); + return pid_to_ptid (strtol (&buf[2], NULL, 16)); else return oldpid; } @@ -1647,8 +1653,8 @@ remote_find_new_threads (void) { remote_threadlist_iterator (remote_newthread_step, 0, CRAZY_MAX_THREADS); - if (inferior_pid == MAGIC_NULL_PID) /* ack ack ack */ - inferior_pid = remote_current_thread (inferior_pid); + if (PIDGET (inferior_ptid) == MAGIC_NULL_PID) /* ack ack ack */ + inferior_ptid = remote_current_thread (inferior_ptid); } /* @@ -1680,8 +1686,8 @@ remote_threads_info (void) do { tid = strtol (bufp, &bufp, 16); - if (tid != 0 && !in_thread_list (tid)) - add_thread (tid); + if (tid != 0 && !in_thread_list (pid_to_ptid (tid))) + add_thread (pid_to_ptid (tid)); } while (*bufp++ == ','); /* comma-separated list */ putpkt ("qsThreadInfo"); @@ -1724,7 +1730,7 @@ remote_threads_extra_info (struct thread_info *tp) if (use_threadextra_query) { - sprintf (bufp, "qThreadExtraInfo,%x", tp->pid); + sprintf (bufp, "qThreadExtraInfo,%x", PIDGET (tp->ptid)); putpkt (bufp); getpkt (bufp, PBUFSIZ, 0); if (bufp[0] != 0) @@ -1748,7 +1754,7 @@ remote_threads_extra_info (struct thread_info *tp) use_threadextra_query = 0; set = TAG_THREADID | TAG_EXISTS | TAG_THREADNAME | TAG_MOREDISPLAY | TAG_DISPLAY; - int_to_threadref (&id, tp->pid); + int_to_threadref (&id, PIDGET (tp->ptid)); if (remote_get_threadinfo (&id, set, &threadinfo)) if (threadinfo.active) { @@ -2019,7 +2025,7 @@ remote_start_remote (PTR dummy) /* Let the stub know that we want it to return the thread. */ set_thread (-1, 0); - inferior_pid = remote_current_thread (inferior_pid); + inferior_ptid = remote_current_thread (inferior_ptid); get_offsets (); /* Get text, data & bss offsets */ @@ -2136,7 +2142,7 @@ serial device is attached to the remote system\n\ be split out into seperate variables, especially since GDB will someday have a notion of debugging several processes. */ - inferior_pid = MAGIC_NULL_PID; + inferior_ptid = pid_to_ptid (MAGIC_NULL_PID); /* Start the remote connection; if error (0), discard this target. In particular, if the user quits, be sure to discard it (we'd be in an inconsistent state otherwise). */ @@ -2162,7 +2168,7 @@ serial device is attached to the remote system\n\ support svr4 shared libraries. */ #ifdef SOLIB_CREATE_INFERIOR_HOOK if (exec_bfd) /* No use without an exec file. */ - SOLIB_CREATE_INFERIOR_HOOK (inferior_pid); + SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); #endif } @@ -2223,7 +2229,7 @@ serial device is attached to the remote system\n\ flag indicating that a target is active. These functions should be split out into seperate variables, especially since GDB will someday have a notion of debugging several processes. */ - inferior_pid = MAGIC_NULL_PID; + inferior_ptid = pid_to_ptid (MAGIC_NULL_PID); /* With this target we start out by owning the terminal. */ remote_async_terminal_ours_p = 1; @@ -2265,7 +2271,7 @@ serial device is attached to the remote system\n\ support svr4 shared libraries. */ #ifdef SOLIB_CREATE_INFERIOR_HOOK if (exec_bfd) /* No use without an exec file. */ - SOLIB_CREATE_INFERIOR_HOOK (inferior_pid); + SOLIB_CREATE_INFERIOR_HOOK (PIDGET (inferior_ptid)); #endif } @@ -2347,9 +2353,10 @@ static enum target_signal last_sent_signal = TARGET_SIGNAL_0; static int last_sent_step; static void -remote_resume (int pid, int step, enum target_signal siggnal) +remote_resume (ptid_t ptid, int step, enum target_signal siggnal) { char *buf = alloca (PBUFSIZ); + int pid = PIDGET (ptid); char *p; if (pid == -1) @@ -2435,9 +2442,10 @@ remote_resume (int pid, int step, enum target_signal siggnal) /* Same as remote_resume, but with async support. */ static void -remote_async_resume (int pid, int step, enum target_signal siggnal) +remote_async_resume (ptid_t ptid, int step, enum target_signal siggnal) { char *buf = alloca (PBUFSIZ); + int pid = PIDGET (ptid); char *p; if (pid == -1) @@ -2744,8 +2752,8 @@ remote_console_output (char *msg) Returns "pid", which in the case of a multi-threaded remote OS, is the thread-id. */ -static int -remote_wait (int pid, struct target_waitstatus *status) +static ptid_t +remote_wait (ptid_t ptid, struct target_waitstatus *status) { unsigned char *buf = alloca (PBUFSIZ); int thread_num = -1; @@ -2953,14 +2961,14 @@ Packet Dropped"); got_status: if (thread_num != -1) { - return thread_num; + return pid_to_ptid (thread_num); } - return inferior_pid; + return inferior_ptid; } /* Async version of remote_wait. */ -static int -remote_async_wait (int pid, struct target_waitstatus *status) +static ptid_t +remote_async_wait (ptid_t ptid, struct target_waitstatus *status) { unsigned char *buf = alloca (PBUFSIZ); int thread_num = -1; @@ -3177,9 +3185,9 @@ Packet Dropped"); got_status: if (thread_num != -1) { - return thread_num; + return pid_to_ptid (thread_num); } - return inferior_pid; + return inferior_ptid; } /* Number of bytes of registers this stub implements. */ @@ -3198,7 +3206,7 @@ remote_fetch_registers (int regno) char *p; char *regs = alloca (REGISTER_BYTES); - set_thread (inferior_pid, 1); + set_thread (PIDGET (inferior_ptid), 1); sprintf (buf, "g"); remote_send (buf, PBUFSIZ); @@ -3322,7 +3330,7 @@ remote_store_registers (int regno) char *p; char *regs; - set_thread (inferior_pid, 1); + set_thread (PIDGET (inferior_ptid), 1); if (regno >= 0) { @@ -4996,7 +5004,7 @@ threadalive_test (char *cmd, int tty) { int sample_thread = SAMPLE_THREAD; - if (remote_thread_alive (sample_thread)) + if (remote_thread_alive (pid_to_ptid (sample_thread))) printf_filtered ("PASS: Thread alive test\n"); else printf_filtered ("FAIL: Thread alive test\n"); @@ -5107,11 +5115,11 @@ init_remote_threadtests (void) buffer. */ static char * -remote_pid_to_str (int pid) +remote_pid_to_str (ptid_t ptid) { static char buf[30]; - sprintf (buf, "Thread %d", pid); + sprintf (buf, "Thread %d", PIDGET (ptid)); return buf; } @@ -5282,7 +5290,7 @@ device is attached to the remote system (e.g. host:port)."); flag indicating that a target is active. These functions should be split out into seperate variables, especially since GDB will someday have a notion of debugging several processes. */ - inferior_pid = MAGIC_NULL_PID; + inferior_ptid = pid_to_ptid (MAGIC_NULL_PID); /* Start the remote connection; if error (0), discard this target. */ @@ -5514,15 +5522,15 @@ minitelnet (void) } } -static int -remote_cisco_wait (int pid, struct target_waitstatus *status) +static ptid_t +remote_cisco_wait (ptid_t ptid, struct target_waitstatus *status) { if (minitelnet () != ENTER_DEBUG) { error ("Debugging session terminated by protocol error"); } putpkt ("?"); - return remote_wait (pid, status); + return remote_wait (ptid, status); } static void diff --git a/gdb/rs6000-nat.c b/gdb/rs6000-nat.c index 7db0ba0..e6693cc 100644 --- a/gdb/rs6000-nat.c +++ b/gdb/rs6000-nat.c @@ -201,7 +201,7 @@ fetch_register (int regno) if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM) { nr = regno - FP0_REGNUM + FPR0; - ptrace32 (PT_READ_FPR, inferior_pid, addr, nr, 0); + ptrace32 (PT_READ_FPR, PIDGET (inferior_ptid), addr, nr, 0); } /* Bogus register number. */ @@ -219,13 +219,13 @@ fetch_register (int regno) nr = regno; if (!ARCH64 ()) - *addr = ptrace32 (PT_READ_GPR, inferior_pid, (int *)nr, 0, 0); + *addr = ptrace32 (PT_READ_GPR, PIDGET (inferior_ptid), (int *)nr, 0, 0); else { /* PT_READ_GPR requires the buffer parameter to point to long long, even if the register is really only 32 bits. */ long long buf; - ptrace64 (PT_READ_GPR, inferior_pid, nr, 0, (int *)&buf); + ptrace64 (PT_READ_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf); if (REGISTER_RAW_SIZE (regno) == 8) memcpy (addr, &buf, 8); else @@ -260,7 +260,7 @@ store_register (int regno) if (regno >= FP0_REGNUM && regno <= FPLAST_REGNUM) { nr = regno - FP0_REGNUM + FPR0; - ptrace32 (PT_WRITE_FPR, inferior_pid, addr, nr, 0); + ptrace32 (PT_WRITE_FPR, PIDGET (inferior_ptid), addr, nr, 0); } /* Bogus register number. */ @@ -289,7 +289,7 @@ store_register (int regno) nr = regno; if (!ARCH64 ()) - ptrace32 (PT_WRITE_GPR, inferior_pid, (int *)nr, *addr, 0); + ptrace32 (PT_WRITE_GPR, PIDGET (inferior_ptid), (int *)nr, *addr, 0); else { /* PT_WRITE_GPR requires the buffer parameter to point to an 8-byte @@ -299,7 +299,7 @@ store_register (int regno) memcpy (&buf, addr, 8); else buf = *addr; - ptrace64 (PT_WRITE_GPR, inferior_pid, nr, 0, (int *)&buf); + ptrace64 (PT_WRITE_GPR, PIDGET (inferior_ptid), nr, 0, (int *)&buf); } } @@ -373,9 +373,10 @@ read_word (CORE_ADDR from, int *to, int arch64) errno = 0; if (arch64) - *to = ptrace64 (PT_READ_I, inferior_pid, from, 0, NULL); + *to = ptrace64 (PT_READ_I, PIDGET (inferior_ptid), from, 0, NULL); else - *to = ptrace32 (PT_READ_I, inferior_pid, (int *)(long) from, 0, NULL); + *to = ptrace32 (PT_READ_I, PIDGET (inferior_ptid), (int *)(long) from, + 0, NULL); return !errno; } @@ -441,9 +442,9 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, for (i = 0, errno = 0; i < count; i++, addr += sizeof (int)) { if (arch64) - ptrace64 (PT_WRITE_D, inferior_pid, addr, buf[i], NULL); + ptrace64 (PT_WRITE_D, PIDGET (inferior_ptid), addr, buf[i], NULL); else - ptrace32 (PT_WRITE_D, inferior_pid, (int *)(long) addr, + ptrace32 (PT_WRITE_D, PIDGET (inferior_ptid), (int *)(long) addr, buf[i], NULL); if (errno) @@ -482,9 +483,9 @@ exec_one_dummy_insn (void) prev_pc = read_pc (); write_pc (DUMMY_INSN_ADDR); if (ARCH64 ()) - ret = ptrace64 (PT_CONTINUE, inferior_pid, 1, 0, NULL); + ret = ptrace64 (PT_CONTINUE, PIDGET (inferior_ptid), 1, 0, NULL); else - ret = ptrace32 (PT_CONTINUE, inferior_pid, (int *)1, 0, NULL); + ret = ptrace32 (PT_CONTINUE, PIDGET (inferior_ptid), (int *)1, 0, NULL); if (ret != 0) perror ("pt_continue"); @@ -493,7 +494,7 @@ exec_one_dummy_insn (void) { pid = wait (&status); } - while (pid != inferior_pid); + while (pid != PIDGET (inferior_ptid)); write_pc (prev_pc); target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents); diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index cc1e20c..97f3e24 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -73,7 +73,7 @@ struct target_ops sol_core_ops; extern int procfs_suppress_run; extern struct target_ops procfs_ops; /* target vector for procfs.c */ extern struct target_ops core_ops; /* target vector for corelow.c */ -extern char *procfs_pid_to_str (int pid); +extern char *procfs_pid_to_str (ptid_t ptid); /* Prototypes for supply_gregset etc. */ #include "gregset.h" @@ -84,7 +84,7 @@ extern char *procfs_pid_to_str (int pid); struct ps_prochandle { - pid_t pid; + ptid_t ptid; }; struct string_map @@ -97,14 +97,14 @@ static struct ps_prochandle main_ph; static td_thragent_t *main_ta; static int sol_thread_active = 0; -static struct cleanup *save_inferior_pid (void); -static void restore_inferior_pid (void *pid); +static struct cleanup *save_inferior_ptid (void); +static void restore_inferior_ptid (void *pid); static char *td_err_string (td_err_e errcode); static char *td_state_string (td_thr_state_e statecode); -static int thread_to_lwp (int thread_id, int default_lwp); -static void sol_thread_resume (int pid, int step, enum target_signal signo); -static int lwp_to_thread (int lwp); -static int sol_thread_alive (int pid); +static ptid_t thread_to_lwp (ptid_t thread_id, int default_lwp); +static void sol_thread_resume (ptid_t ptid, int step, enum target_signal signo); +static ptid_t lwp_to_thread (ptid_t lwp); +static int sol_thread_alive (ptid_t ptid); static void sol_core_close (int quitting); static void init_sol_thread_ops (void); @@ -288,7 +288,7 @@ td_state_string (td_thr_state_e statecode) SYNOPSIS - int thread_to_lwp (thread_id, default_lwp) + tpid_t thread_to_lwp (thread_id, default_lwp) DESCRIPTION @@ -302,8 +302,8 @@ td_state_string (td_thr_state_e statecode) */ -static int -thread_to_lwp (int thread_id, int default_lwp) +static ptid_t +thread_to_lwp (ptid_t thread_id, int default_lwp) { td_thrinfo_t ti; td_thrhandle_t th; @@ -316,20 +316,20 @@ thread_to_lwp (int thread_id, int default_lwp) val = p_td_ta_map_id2thr (main_ta, GET_THREAD (thread_id), &th); if (val == TD_NOTHR) - return -1; /* thread must have terminated */ + return pid_to_ptid (-1); /* thread must have terminated */ else if (val != TD_OK) error ("thread_to_lwp: td_ta_map_id2thr %s", td_err_string (val)); val = p_td_thr_get_info (&th, &ti); if (val == TD_NOTHR) - return -1; /* thread must have terminated */ + return pid_to_ptid (-1); /* thread must have terminated */ else if (val != TD_OK) error ("thread_to_lwp: td_thr_get_info: %s", td_err_string (val)); if (ti.ti_state != TD_THR_ACTIVE) { if (default_lwp != -1) - return default_lwp; + return pid_to_ptid (default_lwp); error ("thread_to_lwp: thread state not active: %s", td_state_string (ti.ti_state)); } @@ -358,8 +358,8 @@ thread_to_lwp (int thread_id, int default_lwp) */ -static int -lwp_to_thread (int lwp) +static ptid_t +lwp_to_thread (ptid_t lwp) { td_thrinfo_t ti; td_thrhandle_t th; @@ -371,11 +371,11 @@ lwp_to_thread (int lwp) /* It's an lwp. Convert it to a thread id. */ if (!sol_thread_alive (lwp)) - return -1; /* defunct lwp */ + return pid_to_ptid (-1); /* defunct lwp */ val = p_td_ta_map_lwp2thr (main_ta, GET_LWP (lwp), &th); if (val == TD_NOTHR) - return -1; /* thread must have terminated */ + return pid_to_ptid (-1); /* thread must have terminated */ else if (val != TD_OK) error ("lwp_to_thread: td_ta_map_lwp2thr: %s.", td_err_string (val)); @@ -388,7 +388,7 @@ lwp_to_thread (int lwp) val = p_td_thr_get_info (&th, &ti); if (val == TD_NOTHR) - return -1; /* thread must have terminated */ + return pid_to_ptid (-1); /* thread must have terminated */ else if (val != TD_OK) error ("lwp_to_thread: td_thr_get_info: %s.", td_err_string (val)); @@ -399,44 +399,44 @@ lwp_to_thread (int lwp) 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) { - int *saved_pid = xmalloc (sizeof (int)); - *saved_pid = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid); + ptid_t *saved_ptid = xmalloc (sizeof (ptid_t)); + *saved_ptid = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid); } static void -restore_inferior_pid (void *data) +restore_inferior_ptid (void *data) { - int *saved_pid = data; - inferior_pid = *saved_pid; - xfree (saved_pid); + ptid_t *saved_ptid = data; + inferior_ptid = *saved_ptid; + xfree (saved_ptid); } @@ -465,13 +465,13 @@ sol_thread_attach (char *args, int from_tty) if (sol_thread_active) { printf_filtered ("sol-thread active.\n"); - main_ph.pid = inferior_pid; /* Save for xfer_memory */ + main_ph.ptid = inferior_ptid; /* Save for xfer_memory */ push_target (&sol_thread_ops); - inferior_pid = lwp_to_thread (inferior_pid); - if (inferior_pid == -1) - inferior_pid = main_ph.pid; + inferior_ptid = lwp_to_thread (inferior_ptid); + if (PIDGET (inferior_ptid) == -1) + inferior_ptid = main_ph.ptid; else - add_thread (inferior_pid); + add_thread (inferior_ptid); } /* XXX - might want to iterate over all the threads and register them. */ } @@ -487,7 +487,7 @@ sol_thread_attach (char *args, int from_tty) static void sol_thread_detach (char *args, int from_tty) { - inferior_pid = PIDGET (main_ph.pid); + inferior_ptid = pid_to_ptid (PIDGET (main_ph.ptid)); unpush_target (&sol_thread_ops); procfs_ops.to_detach (args, from_tty); } @@ -498,29 +498,29 @@ sol_thread_detach (char *args, int from_tty) for procfs. */ static void -sol_thread_resume (int pid, int step, enum target_signal signo) +sol_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 (); - inferior_pid = thread_to_lwp (inferior_pid, main_ph.pid); - if (inferior_pid == -1) - inferior_pid = procfs_first_available (); + inferior_ptid = thread_to_lwp (inferior_ptid, PIDGET (main_ph.ptid)); + if (PIDGET (inferior_ptid) == -1) + inferior_ptid = procfs_first_available (); - if (pid != -1) + if (PIDGET (ptid) != -1) { - int save_pid = pid; + ptid_t save_ptid = ptid; - pid = thread_to_lwp (pid, -2); - if (pid == -2) /* Inactive thread */ + ptid = thread_to_lwp (ptid, -2); + if (PIDGET (ptid) == -2) /* Inactive thread */ error ("This version of Solaris can't start inactive threads."); - if (info_verbose && pid == -1) - warning ("Specified thread %d seems to have terminated", - GET_THREAD (save_pid)); + if (info_verbose && PIDGET (ptid) == -1) + warning ("Specified thread %ld seems to have terminated", + GET_THREAD (save_ptid)); } - procfs_ops.to_resume (pid, step, signo); + procfs_ops.to_resume (ptid, step, signo); do_cleanups (old_chain); } @@ -528,44 +528,44 @@ sol_thread_resume (int pid, int step, enum target_signal signo) /* 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 -sol_thread_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +sol_thread_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { - int rtnval; - int save_pid; + ptid_t rtnval; + ptid_t save_ptid; struct cleanup *old_chain; - save_pid = inferior_pid; - old_chain = save_inferior_pid (); + save_ptid = inferior_ptid; + old_chain = save_inferior_ptid (); - inferior_pid = thread_to_lwp (inferior_pid, main_ph.pid); - if (inferior_pid == -1) - inferior_pid = procfs_first_available (); + inferior_ptid = thread_to_lwp (inferior_ptid, PIDGET (main_ph.ptid)); + if (PIDGET (inferior_ptid) == -1) + inferior_ptid = procfs_first_available (); - if (pid != -1) + if (PIDGET (ptid) != -1) { - int save_pid = pid; + ptid_t save_ptid = ptid; - pid = thread_to_lwp (pid, -2); - if (pid == -2) /* Inactive thread */ + ptid = thread_to_lwp (ptid, -2); + if (PIDGET (ptid) == -2) /* Inactive thread */ error ("This version of Solaris can't start inactive threads."); - if (info_verbose && pid == -1) - warning ("Specified thread %d seems to have terminated", - GET_THREAD (save_pid)); + if (info_verbose && PIDGET (ptid) == -1) + warning ("Specified thread %ld seems to have terminated", + GET_THREAD (save_ptid)); } - rtnval = procfs_ops.to_wait (pid, ourstatus); + rtnval = procfs_ops.to_wait (ptid, ourstatus); if (ourstatus->kind != TARGET_WAITKIND_EXITED) { /* Map the LWP of interest back to the appropriate thread ID */ rtnval = lwp_to_thread (rtnval); - if (rtnval == -1) - rtnval = save_pid; + if (PIDGET (rtnval) == -1) + rtnval = save_ptid; /* See if we have a new thread */ if (is_thread (rtnval) - && rtnval != save_pid + && !ptid_equal (rtnval, save_ptid) && !in_thread_list (rtnval)) { printf_filtered ("[New %s]\n", target_pid_to_str (rtnval)); @@ -595,7 +595,7 @@ sol_thread_fetch_registers (int regno) caddr_t xregset; #endif - if (!is_thread (inferior_pid)) + if (!is_thread (inferior_ptid)) { /* LWP: pass the request on to procfs.c */ if (target_has_execution) procfs_ops.to_fetch_registers (regno); @@ -604,9 +604,9 @@ sol_thread_fetch_registers (int regno) return; } - /* Solaris thread: convert inferior_pid into a td_thrhandle_t */ + /* Solaris thread: convert inferior_ptid into a td_thrhandle_t */ - thread = GET_THREAD (inferior_pid); + thread = GET_THREAD (inferior_ptid); if (thread == 0) error ("sol_thread_fetch_registers: thread == 0"); @@ -673,15 +673,15 @@ sol_thread_store_registers (int regno) caddr_t xregset; #endif - if (!is_thread (inferior_pid)) + if (!is_thread (inferior_ptid)) { /* LWP: pass the request on to procfs.c */ procfs_ops.to_store_registers (regno); return; } - /* Solaris thread: convert inferior_pid into a td_thrhandle_t */ + /* Solaris thread: convert inferior_ptid into a td_thrhandle_t */ - thread = GET_THREAD (inferior_pid); + thread = GET_THREAD (inferior_ptid); val = p_td_ta_map_id2thr (main_ta, thread, &thandle); if (val != TD_OK) @@ -774,11 +774,11 @@ sol_thread_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int dowrite, int retval; struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - if (is_thread (inferior_pid) || /* A thread */ - !target_thread_alive (inferior_pid)) /* An lwp, but not alive */ - inferior_pid = procfs_first_available (); /* Find any live lwp. */ + if (is_thread (inferior_ptid) || /* A thread */ + !target_thread_alive (inferior_ptid)) /* An lwp, but not alive */ + inferior_ptid = procfs_first_available (); /* Find any live lwp. */ /* Note: don't need to call switch_to_thread; we're just reading memory. */ if (target_has_execution) @@ -808,9 +808,9 @@ sol_thread_kill_inferior (void) } static void -sol_thread_notice_signals (int pid) +sol_thread_notice_signals (ptid_t ptid) { - procfs_ops.to_notice_signals (PIDGET (pid)); + procfs_ops.to_notice_signals (pid_to_ptid (PIDGET (ptid))); } /* Fork an inferior process, and start debugging it with /proc. */ @@ -820,18 +820,18 @@ sol_thread_create_inferior (char *exec_file, char *allargs, char **env) { procfs_ops.to_create_inferior (exec_file, allargs, env); - if (sol_thread_active && inferior_pid != 0) + if (sol_thread_active && !ptid_equal (inferior_ptid, null_ptid)) { - main_ph.pid = inferior_pid; /* Save for xfer_memory */ + main_ph.ptid = inferior_ptid; /* Save for xfer_memory */ push_target (&sol_thread_ops); - inferior_pid = lwp_to_thread (inferior_pid); - if (inferior_pid == -1) - inferior_pid = main_ph.pid; + inferior_ptid = lwp_to_thread (inferior_ptid); + if (PIDGET (inferior_ptid) == -1) + inferior_ptid = main_ph.ptid; - if (!in_thread_list (inferior_pid)) - add_thread (inferior_pid); + if (!in_thread_list (inferior_ptid)) + add_thread (inferior_ptid); } } @@ -915,7 +915,7 @@ sol_thread_can_run (void) SYNOPSIS - static bool sol_thread_alive (int pid); + static bool sol_thread_alive (ptid_t ptid); DESCRIPTION @@ -924,14 +924,15 @@ sol_thread_can_run (void) */ static int -sol_thread_alive (int pid) +sol_thread_alive (ptid_t ptid) { - if (is_thread (pid)) /* non-kernel thread */ + if (is_thread (ptid)) /* non-kernel thread */ { td_err_e val; td_thrhandle_t th; + int pid; - pid = GET_THREAD (pid); + pid = GET_THREAD (ptid); if ((val = p_td_ta_map_id2thr (main_ta, pid, &th)) != TD_OK) return 0; /* thread not found */ if ((val = p_td_thr_validate (&th)) != TD_OK) @@ -942,9 +943,9 @@ sol_thread_alive (int pid) /* kernel thread (LWP): let procfs test it */ { if (target_has_execution) - return procfs_ops.to_thread_alive (pid); + return procfs_ops.to_thread_alive (ptid); else - return orig_core_ops.to_thread_alive (pid); + return orig_core_ops.to_thread_alive (ptid); } } @@ -1050,11 +1051,11 @@ rw_common (int dowrite, const struct ps_prochandle *ph, gdb_ps_addr_t addr, { struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - if (is_thread (inferior_pid) || /* A thread */ - !target_thread_alive (inferior_pid)) /* An lwp, but not alive */ - inferior_pid = procfs_first_available (); /* Find any live lwp. */ + if (is_thread (inferior_ptid) || /* A thread */ + !target_thread_alive (inferior_ptid)) /* An lwp, but not alive */ + inferior_ptid = procfs_first_available (); /* Find any live lwp. */ /* Note: don't need to call switch_to_thread; we're just reading memory. */ #if defined (__sparcv9) @@ -1154,9 +1155,9 @@ ps_lgetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, { struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid)); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); if (target_has_execution) procfs_ops.to_fetch_registers (-1); @@ -1177,9 +1178,9 @@ ps_lsetregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, { struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid)); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); supply_gregset ((gdb_gregset_t *) gregset); if (target_has_execution) @@ -1286,9 +1287,9 @@ ps_lgetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, { struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid)); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); if (target_has_execution) procfs_ops.to_fetch_registers (-1); @@ -1309,9 +1310,9 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, { struct cleanup *old_chain; - old_chain = save_inferior_pid (); + old_chain = save_inferior_ptid (); - inferior_pid = BUILD_LWP (lwpid, PIDGET (inferior_pid)); + inferior_ptid = BUILD_LWP (lwpid, PIDGET (inferior_ptid)); supply_fpregset ((gdb_fpregset_t *) fpregset); if (target_has_execution) @@ -1353,16 +1354,16 @@ ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, struct ssd *pldt) { /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */ - extern struct ssd *procfs_find_LDT_entry (int); + extern struct ssd *procfs_find_LDT_entry (ptid_t); struct ssd *ret; /* FIXME: can't I get the process ID from the prochandle or something? */ - if (inferior_pid <= 0 || lwpid <= 0) + if (PIDGET (inferior_ptid) <= 0 || lwpid <= 0) return PS_BADLID; - ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_pid))); + ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_ptid))); if (ret) { memcpy (pldt, ret, sizeof (struct ssd)); @@ -1376,31 +1377,31 @@ ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, /* Convert a pid to printable form. */ char * -solaris_pid_to_str (int pid) +solaris_pid_to_str (ptid_t ptid) { static char buf[100]; /* in case init failed to resolve the libthread_db library */ if (!procfs_suppress_run) - return procfs_pid_to_str (pid); + return procfs_pid_to_str (ptid); - if (is_thread (pid)) + if (is_thread (ptid)) { - int lwp; + ptid_t lwp; - lwp = thread_to_lwp (pid, -2); + lwp = thread_to_lwp (ptid, -2); - if (lwp == -1) - sprintf (buf, "Thread %d (defunct)", GET_THREAD (pid)); - else if (lwp != -2) - sprintf (buf, "Thread %d (LWP %d)", GET_THREAD (pid), GET_LWP (lwp)); + if (PIDGET (lwp) == -1) + sprintf (buf, "Thread %ld (defunct)", GET_THREAD (ptid)); + else if (PIDGET (lwp) != -2) + sprintf (buf, "Thread %ld (LWP %ld)", GET_THREAD (ptid), GET_LWP (lwp)); else - sprintf (buf, "Thread %d ", GET_THREAD (pid)); + sprintf (buf, "Thread %ld ", GET_THREAD (ptid)); } - else if (GET_LWP (pid) != 0) - sprintf (buf, "LWP %d ", GET_LWP (pid)); + else if (GET_LWP (ptid) != 0) + sprintf (buf, "LWP %ld ", GET_LWP (ptid)); else - sprintf (buf, "process %d ", PIDGET (pid)); + sprintf (buf, "process %d ", PIDGET (ptid)); return buf; } @@ -1415,15 +1416,15 @@ sol_find_new_threads_callback (const td_thrhandle_t *th, void *ignored) { td_err_e retval; td_thrinfo_t ti; - int pid; + ptid_t ptid; if ((retval = p_td_thr_get_info (th, &ti)) != TD_OK) { return -1; } - pid = BUILD_THREAD (ti.ti_tid, PIDGET (inferior_pid)); - if (!in_thread_list (pid)) - add_thread (pid); + ptid = BUILD_THREAD (ti.ti_tid, PIDGET (inferior_ptid)); + if (!in_thread_list (ptid)) + add_thread (ptid); return 0; } @@ -1435,12 +1436,12 @@ sol_find_new_threads (void) if (!procfs_suppress_run) return; - if (inferior_pid == -1) + if (PIDGET (inferior_ptid) == -1) { printf_filtered ("No process.\n"); return; } - procfs_find_new_threads (); /* first find new kernel threads. */ + procfs_ops.to_find_new_threads (); /* first find new kernel threads */ p_td_ta_thr_iter (main_ta, sol_find_new_threads_callback, (void *) 0, TD_THR_ANY_STATE, TD_THR_LOWEST_PRIORITY, TD_SIGNO_MASK, TD_THR_ANY_USER_FLAGS); diff --git a/gdb/solib-aix5.c b/gdb/solib-aix5.c index a48d4ae..54cb16f 100644 --- a/gdb/solib-aix5.c +++ b/gdb/solib-aix5.c @@ -329,7 +329,7 @@ open_symbol_file_object (void *from_ttyp) struct cleanup *old_chain = make_cleanup (null_cleanup, 0); struct so_list *sos; - sos = build_so_list_from_mapfile (PIDGET (inferior_pid), + sos = build_so_list_from_mapfile (PIDGET (inferior_ptid), MA_MAINEXEC, MA_MAINEXEC); @@ -374,7 +374,7 @@ aix5_current_sos (void) struct so_list *sos; /* Fetch the list of mappings, excluding the main executable. */ - sos = build_so_list_from_mapfile (PIDGET (inferior_pid), MA_MAINEXEC, 0); + sos = build_so_list_from_mapfile (PIDGET (inferior_ptid), MA_MAINEXEC, 0); /* Reverse the list; it looks nicer when we print it if the mappings are in the same order as in the map file. */ @@ -701,7 +701,7 @@ aix5_relocate_main_executable (void) struct cleanup *old_chain = make_cleanup (null_cleanup, 0); /* Fetch the mappings for the main executable from the map file. */ - so = build_so_list_from_mapfile (PIDGET (inferior_pid), + so = build_so_list_from_mapfile (PIDGET (inferior_ptid), MA_MAINEXEC, MA_MAINEXEC); /* Make sure we actually have some mappings to work with. */ @@ -858,7 +858,7 @@ aix5_find_global_pointer (CORE_ADDR addr) CORE_ADDR global_pointer = 0; struct cleanup *old_chain = make_cleanup (null_cleanup, 0); - sos = build_so_list_from_mapfile (PIDGET (inferior_pid), 0, 0); + sos = build_so_list_from_mapfile (PIDGET (inferior_ptid), 0, 0); for (so = sos; so != NULL; so = so->next) { @@ -902,7 +902,7 @@ aix5_find_gate_addresses (CORE_ADDR *start, CORE_ADDR *end) struct cleanup *old_chain = make_cleanup (null_cleanup, 0); /* Fetch the mappings for the main executable from the map file. */ - so = build_so_list_from_mapfile (PIDGET (inferior_pid), + so = build_so_list_from_mapfile (PIDGET (inferior_ptid), MA_KERNTEXT, MA_KERNTEXT); /* Make sure we actually have some mappings to work with. */ diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c index 79bbcdc..1112e29 100644 --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -744,7 +744,7 @@ locate_base (void) debug_base = elf_locate_base (); #ifdef HANDLE_SVR4_EXEC_EMULATORS /* Try it the hard way for emulated executables. */ - else if (inferior_pid != 0 && target_has_execution) + else if (!ptid_equal (inferior_ptid, null_ptid) && target_has_execution) proc_iterate_over_mappings (look_for_base); #endif } @@ -1571,7 +1571,7 @@ svr4_solib_create_inferior_hook (void) stop_signal = TARGET_SIGNAL_0; do { - target_resume (-1, 0, stop_signal); + target_resume (pid_to_ptid (-1), 0, stop_signal); wait_for_inferior (); } while (stop_signal != TARGET_SIGNAL_TRAP); diff --git a/gdb/somsolib.c b/gdb/somsolib.c index cabb3a1..6838fdd 100644 --- a/gdb/somsolib.c +++ b/gdb/somsolib.c @@ -878,7 +878,7 @@ som_solib_create_inferior_hook (void) } anaddr = SYMBOL_VALUE_ADDRESS (msymbol); - store_unsigned_integer (buf, 4, inferior_pid); + store_unsigned_integer (buf, 4, PIDGET (inferior_ptid)); status = target_write_memory (anaddr, buf, 4); if (status != 0) { @@ -1033,9 +1033,9 @@ keep_going: static void -reset_inferior_pid (int saved_inferior_pid) +reset_inferior_ptid (int saved_inferior_ptid) { - inferior_pid = saved_inferior_pid; + inferior_ptid = saved_inferior_ptid; } @@ -1057,11 +1057,11 @@ som_solib_remove_inferior_hook (int pid) int status; char dld_flags_buffer[TARGET_INT_BIT / TARGET_CHAR_BIT]; unsigned int dld_flags_value; - int saved_inferior_pid = inferior_pid; - struct cleanup *old_cleanups = make_cleanup (reset_inferior_pid, saved_inferior_pid); + int saved_inferior_ptid = inferior_ptid; + struct cleanup *old_cleanups = make_cleanup (reset_inferior_ptid, saved_inferior_ptid); /* Ensure that we're really operating on the specified process. */ - inferior_pid = pid; + inferior_ptid = pid_to_ptid (pid); /* We won't bother to remove the solib breakpoints from this process. diff --git a/gdb/sparc-nat.c b/gdb/sparc-nat.c index ec3f91f..feee2cc 100644 --- a/gdb/sparc-nat.c +++ b/gdb/sparc-nat.c @@ -74,7 +74,7 @@ fetch_inferior_registers (int regno) || regno >= Y_REGNUM || (!register_valid[SP_REGNUM] && regno < I7_REGNUM)) { - if (0 != ptrace (PTRACE_GETREGS, inferior_pid, + if (0 != ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0)) perror ("ptrace_getregs"); @@ -104,7 +104,7 @@ fetch_inferior_registers (int regno) regno == FPS_REGNUM || (regno >= FP0_REGNUM && regno <= FP0_REGNUM + 31)) { - if (0 != ptrace (PTRACE_GETFPREGS, inferior_pid, + if (0 != ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0)) perror ("ptrace_getfpregs"); @@ -230,7 +230,7 @@ store_inferior_registers (int regno) inferior_registers.r_y = *(int *) ®isters[REGISTER_BYTE (Y_REGNUM)]; - if (0 != ptrace (PTRACE_SETREGS, inferior_pid, + if (0 != ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers, 0)) perror ("ptrace_setregs"); } @@ -244,7 +244,7 @@ store_inferior_registers (int regno) memcpy (&inferior_fp_registers.Fpu_fsr, ®isters[REGISTER_BYTE (FPS_REGNUM)], sizeof (FPU_FSR_TYPE)); if (0 != - ptrace (PTRACE_SETFPREGS, inferior_pid, + ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers, 0)) perror ("ptrace_setfpregs"); } diff --git a/gdb/standalone.c b/gdb/standalone.c index 2395189..6ae8f53 100644 --- a/gdb/standalone.c +++ b/gdb/standalone.c @@ -336,7 +336,7 @@ have_core_file_p (void) kill_command (void) { - inferior_pid = 0; + inferior_ptid = null_ptid; } terminal_inferior (void) @@ -531,7 +531,7 @@ int wait (WAITTYPE *w) { WSETSTOP (*w, fault_table[fault_code / FAULT_CODE_UNITS]); - return inferior_pid; + return PIDGET (inferior_ptid); } /* Allocate a big space in which files for kdb to read will be stored. diff --git a/gdb/sun3-nat.c b/gdb/sun3-nat.c index 1110547..988ed37 100644 --- a/gdb/sun3-nat.c +++ b/gdb/sun3-nat.c @@ -38,11 +38,11 @@ fetch_inferior_registers (int regno) registers_fetched (); - ptrace (PTRACE_GETREGS, inferior_pid, + ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers); if (FP0_REGNUM >= 0) - ptrace (PTRACE_GETFPREGS, inferior_pid, + ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers); memcpy (registers, &inferior_registers, 16 * 4); @@ -83,10 +83,10 @@ store_inferior_registers (int regno) sizeof inferior_fp_registers - sizeof inferior_fp_registers.fps_regs); - ptrace (PTRACE_SETREGS, inferior_pid, + ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_registers); if (FP0_REGNUM >= 0) - ptrace (PTRACE_SETFPREGS, inferior_pid, + ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & inferior_fp_registers); } diff --git a/gdb/sun386-nat.c b/gdb/sun386-nat.c index b0909f5..eef89fc 100644 --- a/gdb/sun386-nat.c +++ b/gdb/sun386-nat.c @@ -187,9 +187,9 @@ /* OBSOLETE */ /* OBSOLETE registers_fetched (); */ /* OBSOLETE */ -/* OBSOLETE ptrace (PTRACE_GETREGS, inferior_pid, */ +/* OBSOLETE ptrace (PTRACE_GETREGS, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */ -/* OBSOLETE ptrace (PTRACE_GETFPREGS, inferior_pid, */ +/* OBSOLETE ptrace (PTRACE_GETFPREGS, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_fp_registers); */ /* OBSOLETE */ /* OBSOLETE memcpy (registers, &inferior_registers, sizeof inferior_registers); */ @@ -226,25 +226,25 @@ /* OBSOLETE instruction that moves eax into ebp gets single-stepped. */ */ /* OBSOLETE { */ /* OBSOLETE int stack = inferior_registers.r_reg[SP_REGNUM]; */ -/* OBSOLETE int stuff = ptrace (PTRACE_PEEKDATA, inferior_pid, */ +/* OBSOLETE int stuff = ptrace (PTRACE_PEEKDATA, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) stack); */ /* OBSOLETE int reg = inferior_registers.r_reg[EAX]; */ /* OBSOLETE inferior_registers.r_reg[EAX] = */ /* OBSOLETE inferior_registers.r_reg[FP_REGNUM]; */ -/* OBSOLETE ptrace (PTRACE_SETREGS, inferior_pid, */ +/* OBSOLETE ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */ -/* OBSOLETE ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, */ +/* OBSOLETE ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) stack, */ /* OBSOLETE 0xc589); */ -/* OBSOLETE ptrace (PTRACE_SINGLESTEP, inferior_pid, (PTRACE_ARG3_TYPE) stack, */ +/* OBSOLETE ptrace (PTRACE_SINGLESTEP, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) stack, */ /* OBSOLETE 0); */ /* OBSOLETE wait (0); */ -/* OBSOLETE ptrace (PTRACE_POKEDATA, inferior_pid, (PTRACE_ARG3_TYPE) stack, */ +/* OBSOLETE ptrace (PTRACE_POKEDATA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) stack, */ /* OBSOLETE stuff); */ /* OBSOLETE inferior_registers.r_reg[EAX] = reg; */ /* OBSOLETE } */ /* OBSOLETE #endif */ -/* OBSOLETE ptrace (PTRACE_SETREGS, inferior_pid, */ +/* OBSOLETE ptrace (PTRACE_SETREGS, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_registers); */ -/* OBSOLETE ptrace (PTRACE_SETFPREGS, inferior_pid, */ +/* OBSOLETE ptrace (PTRACE_SETFPREGS, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) & inferior_fp_registers); */ /* OBSOLETE } */ diff --git a/gdb/symm-nat.c b/gdb/symm-nat.c index f5e01a0..844e915 100644 --- a/gdb/symm-nat.c +++ b/gdb/symm-nat.c @@ -66,7 +66,7 @@ store_inferior_registers (int regno) might cause problems when calling functions in the inferior. At least fpu_control and fpa_pcr (probably more) should be added to the registers array to solve this properly. */ - mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0); + mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0); regs.pr_eax = *(int *) ®isters[REGISTER_BYTE (0)]; regs.pr_ebx = *(int *) ®isters[REGISTER_BYTE (5)]; @@ -91,7 +91,7 @@ store_inferior_registers (int regno) memcpy (regs.pr_fpu.fpu_stack[5], ®isters[REGISTER_BYTE (ST5_REGNUM)], 10); memcpy (regs.pr_fpu.fpu_stack[6], ®isters[REGISTER_BYTE (ST6_REGNUM)], 10); memcpy (regs.pr_fpu.fpu_stack[7], ®isters[REGISTER_BYTE (ST7_REGNUM)], 10); - mptrace (XPT_WREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0); + mptrace (XPT_WREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0); } void @@ -102,7 +102,7 @@ fetch_inferior_registers (int regno) registers_fetched (); - mptrace (XPT_RREGS, inferior_pid, (PTRACE_ARG3_TYPE) & regs, 0); + mptrace (XPT_RREGS, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regs, 0); *(int *) ®isters[REGISTER_BYTE (EAX_REGNUM)] = regs.pr_eax; *(int *) ®isters[REGISTER_BYTE (EBX_REGNUM)] = regs.pr_ebx; *(int *) ®isters[REGISTER_BYTE (ECX_REGNUM)] = regs.pr_ecx; @@ -375,7 +375,7 @@ i386_float_info (void) if (have_inferior_p ()) { - PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) & regset); + PTRACE_READ_REGS (PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regset); } else { @@ -424,8 +424,8 @@ sigchld_handler (int signo) /* * Thanks to XPT_MPDEBUGGER, we have to mange child_wait(). */ -int -child_wait (int pid, struct target_waitstatus *status) +ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *status) { int save_errno, rv, xvaloff, saoff, sa_hand; struct pt_stop pt; @@ -437,6 +437,7 @@ child_wait (int pid, struct target_waitstatus *status) #ifdef SVR4_SHARED_LIBS /* use this to distinguish ptx 2 vs ptx 4 */ prstatus_t pstatus; #endif + int pid = PIDGET (ptid); do { @@ -464,7 +465,7 @@ child_wait (int pid, struct target_waitstatus *status) pid = pt.ps_pid; - if (pid != inferior_pid) + if (pid != PIDGET (inferior_ptid)) { /* NOTE: the mystery fork in csh/tcsh needs to be ignored. * We should not return new children for the initial run @@ -577,9 +578,9 @@ child_wait (int pid, struct target_waitstatus *status) } } - while (pid != inferior_pid); /* Some other child died or stopped */ + while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */ - return pid; + return pid_to_ptid (pid); } #else /* !ATTACH_DETACH */ /* @@ -587,10 +588,12 @@ child_wait (int pid, struct target_waitstatus *status) * the MPDEBUGGER child_wait() works properly. This will go away when * that is fixed. */ -child_wait (int pid, struct target_waitstatus *ourstatus) +ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { int save_errno; int status; + int pid = PIDGET (ptid); do { @@ -605,12 +608,12 @@ child_wait (int pid, struct target_waitstatus *ourstatus) safe_strerror (save_errno)); ourstatus->kind = TARGET_WAITKIND_SIGNALLED; ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN; - return -1; + return pid_to_ptid (-1); } } - while (pid != inferior_pid); /* Some other child died or stopped */ + while (pid != PIDGET (inferior_ptid)); /* Some other child died or stopped */ store_waitstatus (ourstatus, status); - return pid; + return pid_to_ptid (pid); } #endif /* ATTACH_DETACH */ @@ -641,18 +644,18 @@ call_mptrace (int request, int pid, PTRACE_ARG3_TYPE addr, int data) void kill_inferior (void) { - if (inferior_pid == 0) + if (ptid_equal (inferior_ptid, null_ptid)) return; /* For MPDEBUGGER, don't use PT_KILL, since the child will stop again with a PTS_EXIT. Just hit him with SIGKILL (so he stops) and detach. */ - kill (inferior_pid, SIGKILL); + kill (PIDGET (inferior_ptid), SIGKILL); #ifdef ATTACH_DETACH detach (SIGKILL); #else /* ATTACH_DETACH */ - ptrace (PT_KILL, inferior_pid, 0, 0); + ptrace (PT_KILL, PIDGET (inferior_ptid), 0, 0); wait ((int *) NULL); #endif /* ATTACH_DETACH */ target_mourn_inferior (); @@ -663,12 +666,14 @@ kill_inferior (void) If SIGNAL is nonzero, give it that signal. */ void -child_resume (int pid, int step, enum target_signal signal) +child_resume (ptid_t ptid, int step, enum target_signal signal) { + int pid = PIDGET (ptid); + errno = 0; if (pid == -1) - pid = inferior_pid; + pid = PIDGET (inferior_ptid); /* An address of (PTRACE_ARG3_TYPE)1 tells ptrace to continue from where it was. (If GDB wanted it to start some other way, we have already @@ -715,7 +720,7 @@ detach (int signo) { int rv; - rv = mptrace (XPT_UNDEBUG, inferior_pid, 1, signo); + rv = mptrace (XPT_UNDEBUG, PIDGET (inferior_ptid), 1, signo); if (-1 == rv) { error ("mptrace(XPT_UNDEBUG): %s", safe_strerror (errno)); @@ -769,14 +774,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, if (addr != memaddr || len < (int) sizeof (PTRACE_XFER_TYPE)) { /* Need part of initial word -- fetch it. */ - buffer[0] = ptrace (PT_RTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, + buffer[0] = ptrace (PT_RTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, 0); } if (count > 1) /* FIXME, avoid if even boundary */ { buffer[count - 1] - = ptrace (PT_RTEXT, inferior_pid, + = ptrace (PT_RTEXT, PIDGET (inferior_ptid), ((PTRACE_ARG3_TYPE) (addr + (count - 1) * sizeof (PTRACE_XFER_TYPE))), 0); @@ -793,14 +798,14 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - ptrace (PT_WDATA, inferior_pid, (PTRACE_ARG3_TYPE) addr, + ptrace (PT_WDATA, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, buffer[i]); if (errno) { /* Using the appropriate one (I or D) is necessary for Gould NP1, at least. */ errno = 0; - ptrace (PT_WTEXT, inferior_pid, (PTRACE_ARG3_TYPE) addr, + ptrace (PT_WTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, buffer[i]); } if (errno) @@ -813,7 +818,7 @@ child_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, for (i = 0; i < count; i++, addr += sizeof (PTRACE_XFER_TYPE)) { errno = 0; - buffer[i] = ptrace (PT_RTEXT, inferior_pid, + buffer[i] = ptrace (PT_RTEXT, PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) addr, 0); if (errno) return 0; diff --git a/gdb/target.c b/gdb/target.c index 7151542..cdccd7f 100644 --- a/gdb/target.c +++ b/gdb/target.c @@ -71,7 +71,7 @@ static void update_current_target (void); static void nosupport_runtime (void); -static void normal_target_post_startup_inferior (int pid); +static void normal_target_post_startup_inferior (ptid_t ptid); /* Transfer LEN bytes between target address MEMADDR and GDB address MYADDR. Returns 0 for success, errno code for failure (which @@ -92,9 +92,9 @@ static void debug_to_attach (char *, int); static void debug_to_detach (char *, int); -static void debug_to_resume (int, int, enum target_signal); +static void debug_to_resume (ptid_t, int, enum target_signal); -static int debug_to_wait (int, struct target_waitstatus *); +static ptid_t debug_to_wait (ptid_t, struct target_waitstatus *); static void debug_to_fetch_registers (int); @@ -134,9 +134,9 @@ static void debug_to_mourn_inferior (void); static int debug_to_can_run (void); -static void debug_to_notice_signals (int); +static void debug_to_notice_signals (ptid_t); -static int debug_to_thread_alive (int); +static int debug_to_thread_alive (ptid_t); static void debug_to_stop (void); @@ -271,7 +271,7 @@ nosymbol (char *name, CORE_ADDR *addrp) static void nosupport_runtime (void) { - if (!inferior_pid) + if (ptid_equal (inferior_ptid, null_ptid)) noprocess (); else error ("No run-time support for this"); @@ -363,13 +363,13 @@ cleanup_target (struct target_ops *t) (void (*) (int, char *, int)) target_ignore); de_fault (to_resume, - (void (*) (int, int, enum target_signal)) + (void (*) (ptid_t, int, enum target_signal)) noprocess); de_fault (to_wait, - (int (*) (int, struct target_waitstatus *)) + (ptid_t (*) (ptid_t, struct target_waitstatus *)) noprocess); de_fault (to_post_wait, - (void (*) (int, int)) + (void (*) (ptid_t, int)) target_ignore); de_fault (to_fetch_registers, (void (*) (int)) @@ -416,7 +416,7 @@ cleanup_target (struct target_ops *t) de_fault (to_create_inferior, maybe_kill_then_create_inferior); de_fault (to_post_startup_inferior, - (void (*) (int)) + (void (*) (ptid_t)) target_ignore); de_fault (to_acknowledge_created_inferior, (void (*) (int)) @@ -474,10 +474,10 @@ cleanup_target (struct target_ops *t) de_fault (to_can_run, return_zero); de_fault (to_notice_signals, - (void (*) (int)) + (void (*) (ptid_t)) target_ignore); de_fault (to_thread_alive, - (int (*) (int)) + (int (*) (ptid_t)) return_zero); de_fault (to_find_new_threads, (void (*) (void)) @@ -1376,7 +1376,7 @@ generic_mourn_inferior (void) { extern int show_breakpoint_hit_counts; - inferior_pid = 0; + inferior_ptid = null_ptid; attach_flag = 0; breakpoint_init_inferior (inf_exited); registers_changed (); @@ -2162,11 +2162,11 @@ int target_activity_fd; buffer. */ char * -normal_pid_to_str (int pid) +normal_pid_to_str (ptid_t ptid) { static char buf[30]; - sprintf (buf, "process %d", pid); + sprintf (buf, "process %d", PIDGET (ptid)); return buf; } @@ -2183,7 +2183,7 @@ normal_pid_to_str (int pid) target_acknowledge_forked_child. */ static void -normal_target_post_startup_inferior (int pid) +normal_target_post_startup_inferior (ptid_t ptid) { /* This space intentionally left blank. */ } @@ -2270,24 +2270,25 @@ debug_to_require_detach (int pid, char *args, int from_tty) } static void -debug_to_resume (int pid, int step, enum target_signal siggnal) +debug_to_resume (ptid_t ptid, int step, enum target_signal siggnal) { - debug_target.to_resume (pid, step, siggnal); + debug_target.to_resume (ptid, step, siggnal); - fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", pid, + fprintf_unfiltered (gdb_stdlog, "target_resume (%d, %s, %s)\n", PIDGET (ptid), step ? "step" : "continue", target_signal_to_name (siggnal)); } -static int -debug_to_wait (int pid, struct target_waitstatus *status) +static ptid_t +debug_to_wait (ptid_t ptid, struct target_waitstatus *status) { - int retval; + ptid_t retval; - retval = debug_target.to_wait (pid, status); + retval = debug_target.to_wait (ptid, status); fprintf_unfiltered (gdb_stdlog, - "target_wait (%d, status) = %d, ", pid, retval); + "target_wait (%d, status) = %d, ", PIDGET (ptid), + PIDGET (retval)); fprintf_unfiltered (gdb_stdlog, "status->kind = "); switch (status->kind) { @@ -2327,12 +2328,12 @@ debug_to_wait (int pid, struct target_waitstatus *status) } static void -debug_to_post_wait (int pid, int status) +debug_to_post_wait (ptid_t ptid, int status) { - debug_target.to_post_wait (pid, status); + debug_target.to_post_wait (ptid, status); fprintf_unfiltered (gdb_stdlog, "target_post_wait (%d, %d)\n", - pid, status); + PIDGET (ptid), status); } static void @@ -2521,12 +2522,12 @@ debug_to_create_inferior (char *exec_file, char *args, char **env) } static void -debug_to_post_startup_inferior (int pid) +debug_to_post_startup_inferior (ptid_t ptid) { - debug_target.to_post_startup_inferior (pid); + debug_target.to_post_startup_inferior (ptid); fprintf_unfiltered (gdb_stdlog, "target_post_startup_inferior (%d)\n", - pid); + PIDGET (ptid)); } static void @@ -2776,22 +2777,23 @@ debug_to_can_run (void) } static void -debug_to_notice_signals (int pid) +debug_to_notice_signals (ptid_t ptid) { - debug_target.to_notice_signals (pid); + debug_target.to_notice_signals (ptid); - fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", pid); + fprintf_unfiltered (gdb_stdlog, "target_notice_signals (%d)\n", + PIDGET (ptid)); } static int -debug_to_thread_alive (int pid) +debug_to_thread_alive (ptid_t ptid) { int retval; - retval = debug_target.to_thread_alive (pid); + retval = debug_target.to_thread_alive (ptid); fprintf_unfiltered (gdb_stdlog, "target_thread_alive (%d) = %d\n", - pid, retval); + PIDGET (ptid), retval); return retval; } diff --git a/gdb/target.h b/gdb/target.h index 6d41029..457308c 100644 --- a/gdb/target.h +++ b/gdb/target.h @@ -196,9 +196,9 @@ struct target_ops void (*to_require_attach) (char *, int); void (*to_detach) (char *, int); void (*to_require_detach) (int, char *, int); - void (*to_resume) (int, int, enum target_signal); - int (*to_wait) (int, struct target_waitstatus *); - void (*to_post_wait) (int, int); + void (*to_resume) (ptid_t, int, enum target_signal); + ptid_t (*to_wait) (ptid_t, struct target_waitstatus *); + void (*to_post_wait) (ptid_t, int); void (*to_fetch_registers) (int); void (*to_store_registers) (int); void (*to_prepare_to_store) (void); @@ -261,7 +261,7 @@ struct target_ops void (*to_load) (char *, int); int (*to_lookup_symbol) (char *, CORE_ADDR *); void (*to_create_inferior) (char *, char *, char **); - void (*to_post_startup_inferior) (int); + void (*to_post_startup_inferior) (ptid_t); void (*to_acknowledge_created_inferior) (int); void (*to_clone_and_follow_inferior) (int, int *); void (*to_post_follow_inferior_by_clone) (void); @@ -281,10 +281,10 @@ struct target_ops int (*to_has_exited) (int, int, int *); void (*to_mourn_inferior) (void); int (*to_can_run) (void); - void (*to_notice_signals) (int pid); - int (*to_thread_alive) (int pid); + void (*to_notice_signals) (ptid_t ptid); + int (*to_thread_alive) (ptid_t ptid); void (*to_find_new_threads) (void); - char *(*to_pid_to_str) (int); + char *(*to_pid_to_str) (ptid_t); char *(*to_extra_thread_info) (struct thread_info *); void (*to_stop) (void); int (*to_query) (int /*char */ , char *, char *, int *); @@ -421,18 +421,18 @@ extern void target_detach (char *, int); #define target_require_detach(pid, args, from_tty) \ (*current_target.to_require_detach) (pid, args, from_tty) -/* Resume execution of the target process PID. STEP says whether to +/* Resume execution of the target process PTID. STEP says whether to single-step or to run free; SIGGNAL is the signal to be given to the target, or TARGET_SIGNAL_0 for no signal. The caller may not pass TARGET_SIGNAL_DEFAULT. */ -#define target_resume(pid, step, siggnal) \ +#define target_resume(ptid, step, siggnal) \ do { \ dcache_invalidate(target_dcache); \ - (*current_target.to_resume) (pid, step, siggnal); \ + (*current_target.to_resume) (ptid, step, siggnal); \ } while (0) -/* Wait for process pid to do something. Pid = -1 to wait for any pid +/* Wait for process pid to do something. PTID = -1 to wait for any pid to do something. Return pid of child, or -1 in case of error; store status through argument pointer STATUS. Note that it is *not* OK to return_to_top_level out of target_wait without popping @@ -440,8 +440,8 @@ extern void target_detach (char *, int); to the prompt with a debugging target but without the frame cache, stop_pc, etc., set up. */ -#define target_wait(pid, status) \ - (*current_target.to_wait) (pid, status) +#define target_wait(ptid, status) \ + (*current_target.to_wait) (ptid, status) /* The target_wait operation waits for a process event to occur, and thereby stop the process. @@ -453,8 +453,8 @@ extern void target_detach (char *, int); This operation provides a target-specific hook that allows the necessary bookkeeping to be performed to track such sequences. */ -#define target_post_wait(pid, status) \ - (*current_target.to_post_wait) (pid, status) +#define target_post_wait(ptid, status) \ + (*current_target.to_post_wait) (ptid, status) /* Fetch at least register REGNO, or all regs if regno == -1. No result. */ @@ -514,9 +514,9 @@ extern char *child_core_file_to_sym_file (char *); extern void child_post_attach (int); #endif -extern void child_post_wait (int, int); +extern void child_post_wait (ptid_t, int); -extern void child_post_startup_inferior (int); +extern void child_post_startup_inferior (ptid_t); extern void child_acknowledge_created_inferior (int); @@ -554,7 +554,7 @@ extern int child_has_syscall_event (int, enum target_waitkind *, int *); extern int child_has_exited (int, int, int *); -extern int child_thread_alive (int); +extern int child_thread_alive (ptid_t); /* From exec.c */ @@ -640,7 +640,7 @@ extern void target_load (char *arg, int from_tty); #define target_lookup_symbol(name, addrp) \ (*current_target.to_lookup_symbol) (name, addrp) -/* Start an inferior process and set inferior_pid to its pid. +/* Start an inferior process and set 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. Errors reported with error(). @@ -660,8 +660,8 @@ extern void target_load (char *arg, int from_tty); Such targets will supply an appropriate definition for this function. */ -#define target_post_startup_inferior(pid) \ - (*current_target.to_post_startup_inferior) (pid) +#define target_post_startup_inferior(ptid) \ + (*current_target.to_post_startup_inferior) (ptid) /* On some targets, the sequence of starting up an inferior requires some synchronization between gdb and the new inferior process, PID. */ @@ -803,13 +803,13 @@ extern void target_load (char *arg, int from_tty); /* post process changes to signal handling in the inferior. */ -#define target_notice_signals(pid) \ - (*current_target.to_notice_signals) (pid) +#define target_notice_signals(ptid) \ + (*current_target.to_notice_signals) (ptid) /* Check to see if a thread is still alive. */ -#define target_thread_alive(pid) \ - (*current_target.to_thread_alive) (pid) +#define target_thread_alive(ptid) \ + (*current_target.to_thread_alive) (ptid) /* Query for new threads and add them to the thread list. */ @@ -944,7 +944,7 @@ extern void target_link (char *, CORE_ADDR *); #ifndef target_tid_to_str #define target_tid_to_str(PID) \ target_pid_to_str (PID) -extern char *normal_pid_to_str (int pid); +extern char *normal_pid_to_str (ptid_t ptid); #endif /* Return a short string describing extra information about PID, diff --git a/gdb/thread-db.c b/gdb/thread-db.c index e357751..8c1bdba 100644 --- a/gdb/thread-db.c +++ b/gdb/thread-db.c @@ -124,7 +124,8 @@ static void thread_db_find_new_threads (void); #ifndef TIDGET #define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET(PID) (((PID) & 0xffff)) +#define PIDGET0(PID) (((PID) & 0xffff)) +#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) #define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) #endif @@ -151,21 +152,21 @@ struct private_thread_info /* Helper functions. */ static void -restore_inferior_pid (void *arg) +restore_inferior_ptid (void *arg) { - int *saved_pid_ptr = arg; - inferior_pid = *saved_pid_ptr; + ptid_t *saved_ptid_ptr = arg; + inferior_ptid = *saved_ptid_ptr; xfree (arg); } static struct cleanup * -save_inferior_pid (void) +save_inferior_ptid (void) { - int *saved_pid_ptr; + ptid_t *saved_ptid_ptr; - saved_pid_ptr = xmalloc (sizeof (int)); - *saved_pid_ptr = inferior_pid; - return make_cleanup (restore_inferior_pid, saved_pid_ptr); + saved_ptid_ptr = xmalloc (sizeof (ptid_t)); + *saved_ptid_ptr = inferior_ptid; + return make_cleanup (restore_inferior_ptid, saved_ptid_ptr); } @@ -252,50 +253,50 @@ thread_db_state_str (td_thr_state_e state) /* Convert between user-level thread ids and LWP ids. */ -static int -thread_from_lwp (int pid) +static ptid_t +thread_from_lwp (ptid_t ptid) { td_thrinfo_t ti; td_thrhandle_t th; td_err_e err; - if (GET_LWP (pid) == 0) - pid = BUILD_LWP (pid, pid); + if (GET_LWP (ptid) == 0) + ptid = BUILD_LWP (GET_PID (ptid), GET_PID (ptid)); - gdb_assert (is_lwp (pid)); + gdb_assert (is_lwp (ptid)); - err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (pid), &th); + err = td_ta_map_lwp2thr_p (thread_agent, GET_LWP (ptid), &th); if (err != TD_OK) error ("Cannot find user-level thread for LWP %d: %s", - GET_LWP (pid), thread_db_err_str (err)); + GET_LWP (ptid), thread_db_err_str (err)); err = td_thr_get_info_p (&th, &ti); if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); - return BUILD_THREAD (ti.ti_tid, GET_PID (pid)); + return BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); } -static int -lwp_from_thread (int pid) +static ptid_t +lwp_from_thread (ptid_t ptid) { td_thrinfo_t ti; td_thrhandle_t th; td_err_e err; - if (! is_thread (pid)) - return pid; + if (! is_thread (ptid)) + return ptid; - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (pid), &th); + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); if (err != TD_OK) error ("Cannot find thread %ld: %s", - (long) GET_THREAD (pid), thread_db_err_str (err)); + (long) GET_THREAD (ptid), thread_db_err_str (err)); err = td_thr_get_info_p (&th, &ti); if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); - return BUILD_LWP (ti.ti_lid, GET_PID (pid)); + return BUILD_LWP (ti.ti_lid, GET_PID (ptid)); } @@ -544,7 +545,7 @@ thread_db_new_objfile (struct objfile *objfile) /* Initialize the structure that identifies the child process. Note that at this point there is no guarantee that we actually have a child process. */ - proc_handle.pid = GET_PID (inferior_pid); + proc_handle.pid = GET_PID (inferior_ptid); /* Now attempt to open a connection to the thread library. */ err = td_ta_new_p (&proc_handle, &thread_agent); @@ -593,7 +594,7 @@ thread_db_new_objfile (struct objfile *objfile) } static void -attach_thread (int pid, const td_thrhandle_t *th_p, +attach_thread (ptid_t ptid, const td_thrhandle_t *th_p, const td_thrinfo_t *ti_p, int verbose) { struct thread_info *tp; @@ -602,31 +603,31 @@ attach_thread (int pid, const td_thrhandle_t *th_p, check_thread_signals (); if (verbose) - printf_unfiltered ("[New %s]\n", target_pid_to_str (pid)); + printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid)); /* Add the thread to GDB's thread list. */ - tp = add_thread (pid); + tp = add_thread (ptid); tp->private = xmalloc (sizeof (struct private_thread_info)); tp->private->lwpid = ti_p->ti_lid; /* Under Linux, we have to attach to each and every thread. */ #ifdef ATTACH_LWP - if (ti_p->ti_lid != GET_PID (pid)) - ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (pid)), 0); + if (ti_p->ti_lid != GET_PID (ptid)) + ATTACH_LWP (BUILD_LWP (ti_p->ti_lid, GET_PID (ptid)), 0); #endif /* Enable thread event reporting for this thread. */ err = td_thr_event_enable_p (th_p, 1); if (err != TD_OK) error ("Cannot enable thread event reporting for %s: %s", - target_pid_to_str (pid), thread_db_err_str (err)); + target_pid_to_str (ptid), thread_db_err_str (err)); } static void -detach_thread (int pid, int verbose) +detach_thread (ptid_t ptid, int verbose) { if (verbose) - printf_unfiltered ("[%s exited]\n", target_pid_to_str (pid)); + printf_unfiltered ("[%s exited]\n", target_pid_to_str (ptid)); } static void @@ -639,16 +640,16 @@ thread_db_detach (char *args, int from_tty) } static void -thread_db_resume (int pid, int step, enum target_signal signo) +thread_db_resume (ptid_t ptid, int step, enum target_signal signo) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); - if (pid == -1) - inferior_pid = lwp_from_thread (inferior_pid); - else if (is_thread (pid)) - pid = lwp_from_thread (pid); + if (GET_PID (ptid) == -1) + inferior_ptid = lwp_from_thread (inferior_ptid); + else if (is_thread (ptid)) + ptid = lwp_from_thread (ptid); - target_beneath->to_resume (pid, step, signo); + target_beneath->to_resume (ptid, step, signo); do_cleanups (old_chain); } @@ -658,7 +659,7 @@ thread_db_resume (int pid, int step, enum target_signal signo) the event. */ static void -check_event (int pid) +check_event (ptid_t ptid) { td_event_msg_t msg; td_thrinfo_t ti; @@ -666,7 +667,7 @@ check_event (int pid) CORE_ADDR stop_pc; /* Bail out early if we're not at a thread event breakpoint. */ - stop_pc = read_pc_pid (pid) - DECR_PC_AFTER_BREAK; + stop_pc = read_pc_pid (ptid) - DECR_PC_AFTER_BREAK; if (stop_pc != td_create_bp_addr && stop_pc != td_death_bp_addr) return; @@ -683,7 +684,7 @@ check_event (int pid) if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); - pid = BUILD_THREAD (ti.ti_tid, GET_PID (pid)); + ptid = BUILD_THREAD (ti.ti_tid, GET_PID (ptid)); switch (msg.event) { @@ -700,8 +701,8 @@ check_event (int pid) /* We may already know about this thread, for instance when the user has issued the `info threads' command before the SIGTRAP for hitting the thread creation breakpoint was reported. */ - if (! in_thread_list (pid)) - attach_thread (pid, msg.th_p, &ti, 1); + if (! in_thread_list (ptid)) + attach_thread (ptid, msg.th_p, &ti, 1); return; case TD_DEATH: @@ -712,10 +713,10 @@ check_event (int pid) error ("Thread death event doesn't match breakpoint."); #endif - if (! in_thread_list (pid)) + if (! in_thread_list (ptid)) error ("Spurious thread death event."); - detach_thread (pid, 1); + detach_thread (ptid, 1); return; default: @@ -723,34 +724,34 @@ check_event (int pid) } } -static int -thread_db_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +thread_db_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { - extern int trap_pid; + extern ptid_t trap_ptid; - if (pid != -1 && is_thread (pid)) - pid = lwp_from_thread (pid); + if (GET_PID (ptid) != -1 && is_thread (ptid)) + ptid = lwp_from_thread (ptid); - pid = target_beneath->to_wait (pid, ourstatus); + ptid = target_beneath->to_wait (ptid, ourstatus); if (proc_handle.pid == 0) /* The current child process isn't the actual multi-threaded program yet, so don't try to do any special thread-specific post-processing and bail out early. */ - return pid; + return ptid; if (ourstatus->kind == TARGET_WAITKIND_EXITED) - return -1; + return pid_to_ptid (-1); if (ourstatus->kind == TARGET_WAITKIND_STOPPED && ourstatus->value.sig == TARGET_SIGNAL_TRAP) /* Check for a thread event. */ - check_event (pid); + check_event (ptid); - if (trap_pid) - trap_pid = thread_from_lwp (trap_pid); + if (!ptid_equal (trap_ptid, null_ptid)) + trap_ptid = thread_from_lwp (trap_ptid); - return thread_from_lwp (pid); + return thread_from_lwp (ptid); } static int @@ -758,17 +759,17 @@ thread_db_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target) { - struct cleanup *old_chain = save_inferior_pid (); + struct cleanup *old_chain = save_inferior_ptid (); int xfer; - if (is_thread (inferior_pid)) + if (is_thread (inferior_ptid)) { /* FIXME: This seems to be necessary to make sure breakpoints are removed. */ - if (! target_thread_alive (inferior_pid)) - inferior_pid = GET_PID (inferior_pid); + if (! target_thread_alive (inferior_ptid)) + inferior_ptid = pid_to_ptid (GET_PID (inferior_ptid)); else - inferior_pid = lwp_from_thread (inferior_pid); + inferior_ptid = lwp_from_thread (inferior_ptid); } xfer = target_beneath->to_xfer_memory (memaddr, myaddr, len, write, attrib, target); @@ -785,27 +786,27 @@ thread_db_fetch_registers (int regno) gdb_prfpregset_t fpregset; td_err_e err; - if (! is_thread (inferior_pid)) + if (! is_thread (inferior_ptid)) { /* Pass the request to the target beneath us. */ target_beneath->to_fetch_registers (regno); return; } - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_pid), &th); + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); if (err != TD_OK) error ("Cannot find thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); err = td_thr_getgregs_p (&th, gregset); if (err != TD_OK) error ("Cannot fetch general-purpose registers for thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); err = td_thr_getfpregs_p (&th, &fpregset); if (err != TD_OK) error ("Cannot get floating-point registers for thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); /* Note that we must call supply_gregset after calling the thread_db routines because the thread_db routines call ps_lgetgregs and @@ -822,17 +823,17 @@ thread_db_store_registers (int regno) gdb_prfpregset_t fpregset; td_err_e err; - if (! is_thread (inferior_pid)) + if (! is_thread (inferior_ptid)) { /* Pass the request to the target beneath us. */ target_beneath->to_store_registers (regno); return; } - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_pid), &th); + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (inferior_ptid), &th); if (err != TD_OK) error ("Cannot find thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); if (regno != -1) { @@ -849,11 +850,11 @@ thread_db_store_registers (int regno) err = td_thr_setgregs_p (&th, gregset); if (err != TD_OK) error ("Cannot store general-purpose registers for thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); err = td_thr_setfpregs_p (&th, &fpregset); if (err != TD_OK) error ("Cannot store floating-point registers for thread %ld: %s", - (long) GET_THREAD (inferior_pid), thread_db_err_str (err)); + (long) GET_THREAD (inferior_ptid), thread_db_err_str (err)); } static void @@ -869,13 +870,13 @@ thread_db_create_inferior (char *exec_file, char *allargs, char **env) } static void -thread_db_post_startup_inferior (int pid) +thread_db_post_startup_inferior (ptid_t ptid) { if (proc_handle.pid == 0) { /* The child process is now the actual multi-threaded program. Snatch its process ID... */ - proc_handle.pid = GET_PID (pid); + proc_handle.pid = GET_PID (ptid); /* ...and perform the remaining initialization steps. */ enable_thread_event_reporting (); @@ -893,14 +894,14 @@ thread_db_mourn_inferior (void) } static int -thread_db_thread_alive (int pid) +thread_db_thread_alive (ptid_t ptid) { - if (is_thread (pid)) + if (is_thread (ptid)) { td_thrhandle_t th; td_err_e err; - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (pid), &th); + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); if (err != TD_OK) return 0; @@ -912,7 +913,7 @@ thread_db_thread_alive (int pid) } if (target_beneath->to_thread_alive) - return target_beneath->to_thread_alive (pid); + return target_beneath->to_thread_alive (ptid); return 0; } @@ -922,16 +923,16 @@ find_new_threads_callback (const td_thrhandle_t *th_p, void *data) { td_thrinfo_t ti; td_err_e err; - int pid; + ptid_t ptid; err = td_thr_get_info_p (th_p, &ti); if (err != TD_OK) error ("Cannot get thread info: %s", thread_db_err_str (err)); - pid = BUILD_THREAD (ti.ti_tid, GET_PID (inferior_pid)); + ptid = BUILD_THREAD (ti.ti_tid, GET_PID (inferior_ptid)); - if (! in_thread_list (pid)) - attach_thread (pid, th_p, &ti, 1); + if (! in_thread_list (ptid)) + attach_thread (ptid, th_p, &ti, 1); return 0; } @@ -950,24 +951,24 @@ thread_db_find_new_threads (void) } static char * -thread_db_pid_to_str (int pid) +thread_db_pid_to_str (ptid_t ptid) { - if (is_thread (pid)) + if (is_thread (ptid)) { static char buf[64]; td_thrhandle_t th; td_thrinfo_t ti; td_err_e err; - err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (pid), &th); + err = td_ta_map_id2thr_p (thread_agent, GET_THREAD (ptid), &th); if (err != TD_OK) error ("Cannot find thread %ld: %s", - (long) GET_THREAD (pid), thread_db_err_str (err)); + (long) GET_THREAD (ptid), thread_db_err_str (err)); err = td_thr_get_info_p (&th, &ti); if (err != TD_OK) error ("Cannot get thread info for thread %ld: %s", - (long) GET_THREAD (pid), thread_db_err_str (err)); + (long) GET_THREAD (ptid), thread_db_err_str (err)); if (ti.ti_state == TD_THR_ACTIVE && ti.ti_lid != 0) { @@ -983,10 +984,10 @@ thread_db_pid_to_str (int pid) return buf; } - if (target_beneath->to_pid_to_str (pid)) - return target_beneath->to_pid_to_str (pid); + if (target_beneath->to_pid_to_str (ptid)) + return target_beneath->to_pid_to_str (ptid); - return normal_pid_to_str (pid); + return normal_pid_to_str (ptid); } static void diff --git a/gdb/thread.c b/gdb/thread.c index 22c35fa..e781682 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -61,8 +61,8 @@ static void thread_apply_all_command (char *, int); static int thread_alive (struct thread_info *); static void info_threads_command (char *, int); static void thread_apply_command (char *, int); -static void restore_current_thread (int); -static void switch_to_thread (int pid); +static void restore_current_thread (ptid_t); +static void switch_to_thread (ptid_t ptid); static void prune_threads (void); static void @@ -103,13 +103,13 @@ init_thread_list (void) so that back_ends can initialize their private data. */ struct thread_info * -add_thread (int pid) +add_thread (ptid_t ptid) { struct thread_info *tp; tp = (struct thread_info *) xmalloc (sizeof (struct thread_info)); - tp->pid = pid; + tp->ptid = ptid; tp->num = ++highest_thread_num; tp->prev_pc = 0; tp->prev_func_start = 0; @@ -132,14 +132,14 @@ add_thread (int pid) } void -delete_thread (int pid) +delete_thread (ptid_t ptid) { struct thread_info *tp, *tpprev; tpprev = NULL; for (tp = thread_list; tp; tpprev = tp, tp = tp->next) - if (tp->pid == pid) + if (ptid_equal (tp->ptid, ptid)) break; if (!tp) @@ -165,14 +165,14 @@ find_thread_id (int num) return NULL; } -/* Find a thread_info by matching 'pid'. */ +/* Find a thread_info by matching PTID. */ struct thread_info * -find_thread_pid (int pid) +find_thread_pid (ptid_t ptid) { struct thread_info *tp; for (tp = thread_list; tp; tp = tp->next) - if (tp->pid == pid) + if (ptid_equal (tp->ptid, ptid)) return tp; return NULL; @@ -218,34 +218,34 @@ valid_thread_id (int num) } int -pid_to_thread_id (int pid) +pid_to_thread_id (ptid_t ptid) { struct thread_info *tp; for (tp = thread_list; tp; tp = tp->next) - if (tp->pid == pid) + if (ptid_equal (tp->ptid, ptid)) return tp->num; return 0; } -int +ptid_t thread_id_to_pid (int num) { struct thread_info *thread = find_thread_id (num); if (thread) - return thread->pid; + return thread->ptid; else - return -1; + return pid_to_ptid (-1); } int -in_thread_list (int pid) +in_thread_list (ptid_t ptid) { struct thread_info *tp; for (tp = thread_list; tp; tp = tp->next) - if (tp->pid == pid) + if (ptid_equal (tp->ptid, ptid)) return 1; return 0; /* Never heard of 'im */ @@ -285,7 +285,7 @@ gdb_list_thread_ids (/* output object */) /* Load infrun state for the thread PID. */ void -load_infrun_state (int pid, CORE_ADDR *prev_pc, CORE_ADDR *prev_func_start, +load_infrun_state (ptid_t ptid, CORE_ADDR *prev_pc, CORE_ADDR *prev_func_start, char **prev_func_name, int *trap_expected, struct breakpoint **step_resume_breakpoint, struct breakpoint **through_sigtramp_breakpoint, @@ -299,7 +299,7 @@ load_infrun_state (int pid, CORE_ADDR *prev_pc, CORE_ADDR *prev_func_start, /* If we can't find the thread, then we're debugging a single threaded process. No need to do anything in that case. */ - tp = find_thread_id (pid_to_thread_id (pid)); + tp = find_thread_id (pid_to_thread_id (ptid)); if (tp == NULL) return; @@ -322,7 +322,7 @@ load_infrun_state (int pid, CORE_ADDR *prev_pc, CORE_ADDR *prev_func_start, /* Save infrun state for the thread PID. */ void -save_infrun_state (int pid, CORE_ADDR prev_pc, CORE_ADDR prev_func_start, +save_infrun_state (ptid_t ptid, CORE_ADDR prev_pc, CORE_ADDR prev_func_start, char *prev_func_name, int trap_expected, struct breakpoint *step_resume_breakpoint, struct breakpoint *through_sigtramp_breakpoint, @@ -336,7 +336,7 @@ save_infrun_state (int pid, CORE_ADDR prev_pc, CORE_ADDR prev_func_start, /* If we can't find the thread, then we're debugging a single-threaded process. Nothing to do in that case. */ - tp = find_thread_id (pid_to_thread_id (pid)); + tp = find_thread_id (pid_to_thread_id (ptid)); if (tp == NULL) return; @@ -360,11 +360,11 @@ save_infrun_state (int pid, CORE_ADDR prev_pc, CORE_ADDR prev_func_start, static int thread_alive (struct thread_info *tp) { - if (tp->pid == -1) + if (PIDGET (tp->ptid) == -1) return 0; - if (!target_thread_alive (tp->pid)) + if (!target_thread_alive (tp->ptid)) { - tp->pid = -1; /* Mark it as dead */ + tp->ptid = pid_to_ptid (-1); /* Mark it as dead */ return 0; } return 1; @@ -379,7 +379,7 @@ prune_threads (void) { next = tp->next; if (!thread_alive (tp)) - delete_thread (tp->pid); + delete_thread (tp->ptid); } } @@ -394,7 +394,7 @@ static void info_threads_command (char *arg, int from_tty) { struct thread_info *tp; - int current_pid; + ptid_t current_ptid; struct frame_info *cur_frame; int saved_frame_level = selected_frame_level; int counter; @@ -407,18 +407,18 @@ info_threads_command (char *arg, int from_tty) prune_threads (); target_find_new_threads (); - current_pid = inferior_pid; + current_ptid = inferior_ptid; for (tp = thread_list; tp; tp = tp->next) { - if (tp->pid == current_pid) + if (ptid_equal (tp->ptid, current_ptid)) printf_filtered ("* "); else printf_filtered (" "); #ifdef HPUXHPPA - printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->pid)); + printf_filtered ("%d %s", tp->num, target_tid_to_str (tp->ptid)); #else - printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->pid)); + printf_filtered ("%d %s", tp->num, target_pid_to_str (tp->ptid)); #endif extra_info = target_extra_thread_info (tp); @@ -426,14 +426,14 @@ info_threads_command (char *arg, int from_tty) printf_filtered (" (%s)", extra_info); puts_filtered (" "); - switch_to_thread (tp->pid); + switch_to_thread (tp->ptid); if (selected_frame) print_only_stack_frame (selected_frame, -1, 0); else printf_filtered ("[No stack.]\n"); } - switch_to_thread (current_pid); + switch_to_thread (current_ptid); /* Code below copied from "up_silently_base" in "stack.c". * It restores the frame set by the user before the "info threads" @@ -461,12 +461,12 @@ info_threads_command (char *arg, int from_tty) /* Switch from one thread to another. */ static void -switch_to_thread (int pid) +switch_to_thread (ptid_t ptid) { - if (pid == inferior_pid) + if (ptid_equal (ptid, inferior_ptid)) return; - inferior_pid = pid; + inferior_ptid = ptid; flush_cached_frames (); registers_changed (); stop_pc = read_pc (); @@ -474,34 +474,34 @@ switch_to_thread (int pid) } static void -restore_current_thread (int pid) +restore_current_thread (ptid_t ptid) { - if (pid != inferior_pid) + if (! ptid_equal (ptid, inferior_ptid)) { - switch_to_thread (pid); + switch_to_thread (ptid); print_stack_frame (get_current_frame (), 0, -1); } } struct current_thread_cleanup { - int inferior_pid; + ptid_t inferior_ptid; }; static void do_restore_current_thread_cleanup (void *arg) { struct current_thread_cleanup *old = arg; - restore_current_thread (old->inferior_pid); + restore_current_thread (old->inferior_ptid); xfree (old); } static struct cleanup * -make_cleanup_restore_current_thread (int inferior_pid) +make_cleanup_restore_current_thread (ptid_t inferior_ptid) { struct current_thread_cleanup *old = xmalloc (sizeof (struct current_thread_cleanup)); - old->inferior_pid = inferior_pid; + old->inferior_ptid = inferior_ptid; return make_cleanup (do_restore_current_thread_cleanup, old); } @@ -525,7 +525,7 @@ thread_apply_all_command (char *cmd, int from_tty) if (cmd == NULL || *cmd == '\000') error ("Please specify a command following the thread ID list"); - old_chain = make_cleanup_restore_current_thread (inferior_pid); + old_chain = make_cleanup_restore_current_thread (inferior_ptid); /* It is safe to update the thread list now, before traversing it for "thread apply all". MVS */ @@ -538,14 +538,14 @@ thread_apply_all_command (char *cmd, int from_tty) for (tp = thread_list; tp; tp = tp->next) if (thread_alive (tp)) { - switch_to_thread (tp->pid); + switch_to_thread (tp->ptid); #ifdef HPUXHPPA printf_filtered ("\nThread %d (%s):\n", tp->num, - target_tid_to_str (inferior_pid)); + target_tid_to_str (inferior_ptid)); #else printf_filtered ("\nThread %d (%s):\n", tp->num, - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); #endif execute_command (cmd, from_tty); strcpy (cmd, saved_cmd); /* Restore exact command used previously */ @@ -572,7 +572,7 @@ thread_apply_command (char *tidlist, int from_tty) if (*cmd == '\000') error ("Please specify a command following the thread ID list"); - old_chain = make_cleanup_restore_current_thread (inferior_pid); + old_chain = make_cleanup_restore_current_thread (inferior_ptid); /* Save a copy of the command in case it is clobbered by execute_command */ @@ -615,13 +615,13 @@ thread_apply_command (char *tidlist, int from_tty) warning ("Thread %d has terminated.", start); else { - switch_to_thread (tp->pid); + switch_to_thread (tp->ptid); #ifdef HPUXHPPA printf_filtered ("\nThread %d (%s):\n", tp->num, - target_tid_to_str (inferior_pid)); + target_tid_to_str (inferior_ptid)); #else printf_filtered ("\nThread %d (%s):\n", tp->num, - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); #endif execute_command (cmd, from_tty); strcpy (cmd, saved_cmd); /* Restore exact command used previously */ @@ -644,11 +644,11 @@ thread_command (char *tidstr, int from_tty) /* Don't generate an error, just say which thread is current. */ if (target_has_stack) printf_filtered ("[Current thread is %d (%s)]\n", - pid_to_thread_id (inferior_pid), + pid_to_thread_id (inferior_ptid), #if defined(HPUXHPPA) - target_tid_to_str (inferior_pid) + target_tid_to_str (inferior_ptid) #else - target_pid_to_str (inferior_pid) + target_pid_to_str (inferior_ptid) #endif ); else @@ -681,25 +681,25 @@ see the IDs of currently known threads.", num); if (!thread_alive (tp)) error ("Thread ID %d has terminated.\n", num); - switch_to_thread (tp->pid); + switch_to_thread (tp->ptid); #ifdef UI_OUT ui_out_text (uiout, "[Switching to thread "); - ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_pid)); + ui_out_field_int (uiout, "new-thread-id", pid_to_thread_id (inferior_ptid)); ui_out_text (uiout, " ("); #if defined(HPUXHPPA) - ui_out_text (uiout, target_tid_to_str (inferior_pid)); + ui_out_text (uiout, target_tid_to_str (inferior_ptid)); #else - ui_out_text (uiout, target_pid_to_str (inferior_pid)); + ui_out_text (uiout, target_pid_to_str (inferior_ptid)); #endif ui_out_text (uiout, ")]"); #else /* UI_OUT */ printf_filtered ("[Switching to thread %d (%s)]\n", - pid_to_thread_id (inferior_pid), + pid_to_thread_id (inferior_ptid), #if defined(HPUXHPPA) - target_tid_to_str (inferior_pid) + target_tid_to_str (inferior_ptid) #else - target_pid_to_str (inferior_pid) + target_pid_to_str (inferior_ptid) #endif ); #endif /* UI_OUT */ diff --git a/gdb/top.c b/gdb/top.c index 77d6c6a..be4504d 100644 --- a/gdb/top.c +++ b/gdb/top.c @@ -341,7 +341,8 @@ void (*memory_changed_hook) (CORE_ADDR addr, int len); /* Called when going to wait for the target. Usually allows the GUI to run while waiting for target events. */ -int (*target_wait_hook) (int pid, struct target_waitstatus * status); +ptid_t (*target_wait_hook) (ptid_t ptid, + struct target_waitstatus * status); /* Used by UI as a wrapper around command execution. May do various things like enabling/disabling buttons, etc... */ @@ -1709,7 +1710,7 @@ set_prompt (char *s) int quit_confirm (void) { - if (inferior_pid != 0 && target_has_execution) + if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { char *s; @@ -1746,7 +1747,7 @@ quit_force (char *args, int from_tty) exit_code = (int) value_as_long (val); } - if (inferior_pid != 0 && target_has_execution) + if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution) { if (attach_flag) target_detach (args, from_tty); diff --git a/gdb/ultra3-nat.c b/gdb/ultra3-nat.c index 7c6c133..3b73680 100644 --- a/gdb/ultra3-nat.c +++ b/gdb/ultra3-nat.c @@ -80,7 +80,7 @@ /* OBSOLETE /* Global Registers */ */ /* OBSOLETE #ifdef ULTRA3 */ /* OBSOLETE errno = 0; */ -/* OBSOLETE ptrace (PT_READ_STRUCT, inferior_pid, */ +/* OBSOLETE ptrace (PT_READ_STRUCT, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) register_addr (GR96_REGNUM, 0), */ /* OBSOLETE (int) &pt_struct.pt_gr[0], 32 * 4); */ /* OBSOLETE if (errno != 0) */ @@ -101,7 +101,7 @@ /* OBSOLETE /* Local Registers */ */ /* OBSOLETE #ifdef ULTRA3 */ /* OBSOLETE errno = 0; */ -/* OBSOLETE ptrace (PT_READ_STRUCT, inferior_pid, */ +/* OBSOLETE ptrace (PT_READ_STRUCT, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) register_addr (LR0_REGNUM, 0), */ /* OBSOLETE (int) &pt_struct.pt_lr[0], 128 * 4); */ /* OBSOLETE if (errno != 0) */ @@ -154,7 +154,7 @@ /* OBSOLETE return; */ /* OBSOLETE regaddr = register_addr (regno, 0); */ /* OBSOLETE errno = 0; */ -/* OBSOLETE ptrace (PT_WRITE_U, inferior_pid, */ +/* OBSOLETE ptrace (PT_WRITE_U, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) regaddr, read_register (regno)); */ /* OBSOLETE if (errno != 0) */ /* OBSOLETE { */ @@ -171,7 +171,7 @@ /* OBSOLETE for (regno = LR0_REGNUM; regno < LR0_REGNUM + 128; regno++) */ /* OBSOLETE pt_struct.pt_gr[regno] = read_register (regno); */ /* OBSOLETE errno = 0; */ -/* OBSOLETE ptrace (PT_WRITE_STRUCT, inferior_pid, */ +/* OBSOLETE ptrace (PT_WRITE_STRUCT, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) register_addr (GR1_REGNUM, 0), */ /* OBSOLETE (int) &pt_struct.pt_gr1, (1 * 32 * 128) * 4); */ /* OBSOLETE if (errno != 0) */ @@ -190,7 +190,7 @@ /* OBSOLETE pt_struct.pt_bp = read_register (BP_REGNUM); */ /* OBSOLETE pt_struct.pt_fc = read_register (FC_REGNUM); */ /* OBSOLETE errno = 0; */ -/* OBSOLETE ptrace (PT_WRITE_STRUCT, inferior_pid, */ +/* OBSOLETE ptrace (PT_WRITE_STRUCT, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) register_addr (CPS_REGNUM, 0), */ /* OBSOLETE (int) &pt_struct.pt_psr, (10) * 4); */ /* OBSOLETE if (errno != 0) */ @@ -238,7 +238,7 @@ /* OBSOLETE else */ /* OBSOLETE { */ /* OBSOLETE errno = 0; */ -/* OBSOLETE val = ptrace (PT_READ_U, inferior_pid, */ +/* OBSOLETE val = ptrace (PT_READ_U, PIDGET (inferior_ptid), */ /* OBSOLETE (PTRACE_ARG3_TYPE) register_addr (regno, 0), 0); */ /* OBSOLETE if (errno != 0) */ /* OBSOLETE { */ diff --git a/gdb/uw-thread.c b/gdb/uw-thread.c index 8f1d1c6..617cfbd 100644 --- a/gdb/uw-thread.c +++ b/gdb/uw-thread.c @@ -135,7 +135,7 @@ #endif /* Back end to CALL_BASE() and TRY_BASE(): evaluate CALL, then convert - inferior_pid to a composite thread/process id. */ + inferior_ptid to a composite thread/process id. */ #define CALL_BASE_1(call) \ do { \ @@ -144,8 +144,8 @@ do { \ do_cleanups (infpid_cleanup); \ } while (0) -/* If inferior_pid can be converted to a composite lwp/process id, do so, - evaluate base_ops function CALL, and then convert inferior_pid back to a +/* If inferior_ptid can be converted to a composite lwp/process id, do so, + evaluate base_ops function CALL, and then convert inferior_ptid back to a composite thread/process id. Otherwise, issue an error message and return nonlocally. */ @@ -158,7 +158,7 @@ do { \ } while (0) /* Like CALL_BASE(), but instead of returning nonlocally on error, set - *CALLED to whether the inferior_pid conversion was successful. */ + *CALLED to whether the inferior_ptid conversion was successful. */ #define TRY_BASE(call, called) \ do { \ @@ -220,7 +220,7 @@ static CORE_ADDR thr_map_main; libthread.so passes null map when calling stub with tc_*_complete. */ static struct thread_info *switchto_thread; -/* Cleanup chain for safely restoring inferior_pid after CALL_BASE. */ +/* Cleanup chain for safely restoring inferior_ptid after CALL_BASE. */ static struct cleanup *infpid_cleanup; @@ -261,7 +261,7 @@ dbg (char *fmt, ...) /* Return a string representing composite PID's components. */ static char * -dbgpid (int pid) +dbgpid (ptid_t ptid) { static char *buf, buf1[80], buf2[80]; if (!buf || buf == buf2) @@ -269,10 +269,10 @@ dbgpid (int pid) else buf = buf2; - if (pid <= 0) - sprintf (buf, "%d", pid); + if (PIDGET (ptid) <= 0) + sprintf (buf, "%d", PIDGET (ptid)); else - sprintf (buf, "%s %d/%d", ISTID (pid) ? "thr" : "lwp", + sprintf (buf, "%s %ld/%d", ISTID (pid) ? "thr" : "lwp", TIDGET (pid), PIDGET (pid)); return buf; @@ -404,20 +404,20 @@ deactivate_uw_thread (void) /* Return the composite lwp/process id corresponding to composite id PID. If PID is a thread with no lwp, return 0. */ -static int -thr_to_lwp (int pid) +static ptid_t +thr_to_lwp (ptid_t ptid) { struct thread_info *info; - int lid; + ptid_t lid; - if (!ISTID (pid)) - lid = pid; - else if (!(info = find_thread_pid (pid))) - lid = 0; + if (!ISTID (ptid)) + lid = ptid; + else if (!(info = find_thread_pid (ptid))) + lid = null_ptid; else if (!info->private->lwpid) - lid = 0; + lid = null_ptid; else - lid = MKLID (pid, info->private->lwpid); + lid = MKLID (PIDGET (ptid), info->private->lwpid); DBG2((" thr_to_lwp(%s) = %s", dbgpid (pid), dbgpid (lid))); return lid; @@ -431,7 +431,7 @@ find_thread_lwp_callback (struct thread_info *tp, void *data) { int lwpid = (int)data; - if (!ISTID (tp->pid)) + if (!ISTID (tp->ptid)) return 0; if (!tp->private->stable) return 0; @@ -454,51 +454,52 @@ find_thread_lwp (int lwpid) /* Return the composite thread/process id corresponding to composite id PID. If PID is an lwp with no thread, return PID. */ -static int -lwp_to_thr (int pid) +static ptid_t +lwp_to_thr (ptid_t ptid) { struct thread_info *info; - int tid = pid, lwpid; + int lwpid; + ptid_t tid = ptid; - if (ISTID (pid)) + if (ISTID (ptid)) goto done; - if (!(lwpid = LIDGET (pid))) + if (!(lwpid = LIDGET (ptid))) goto done; if (!(info = find_thread_lwp (lwpid))) goto done; - tid = MKTID (pid, info->private->thrid); + tid = MKTID (PIDGET (ptid), info->private->thrid); done: - DBG2((ISTID (tid) ? NULL : "lwp_to_thr: no thr for %s", dbgpid (pid))); + DBG2((ISTID (tid) ? NULL : "lwp_to_thr: no thr for %s", dbgpid (ptid))); return tid; } -/* do_cleanups() callback: convert inferior_pid to a composite +/* do_cleanups() callback: convert inferior_ptid to a composite thread/process id after having made a procfs call. */ static void thr_infpid (void *unused) { - int pid = lwp_to_thr (inferior_pid); - DBG2((" inferior_pid from procfs: %s => %s", - dbgpid (inferior_pid), dbgpid (pid))); - inferior_pid = pid; + ptid_t ptid = lwp_to_thr (inferior_ptid); + DBG2((" inferior_ptid from procfs: %s => %s", + dbgpid (inferior_ptid), dbgpid (ptid))); + inferior_ptid = ptid; } -/* If possible, convert inferior_pid to a composite lwp/process id in +/* If possible, convert inferior_ptid to a composite lwp/process id in preparation for making a procfs call. Return success. */ static int lwp_infpid (void) { - int pid = thr_to_lwp (inferior_pid); - DBG2((" inferior_pid to procfs: %s => %s", - dbgpid (inferior_pid), dbgpid (pid))); + ptid_t ptid = thr_to_lwp (inferior_ptid); + DBG2((" inferior_ptid to procfs: %s => %s", + dbgpid (inferior_ptid), dbgpid (ptid))); - if (!pid) + if (ptid_equal (ptid, null_ptid)) return 0; - inferior_pid = pid; + inferior_ptid = ptid; infpid_cleanup = make_cleanup (thr_infpid, NULL); return 1; } @@ -507,11 +508,11 @@ lwp_infpid (void) lwp id LWPID, map address MAPP, and composite thread/process PID. */ static void -add_thread_uw (int thrid, int lwpid, CORE_ADDR mapp, int pid) +add_thread_uw (int thrid, int lwpid, CORE_ADDR mapp, ptid_t ptid) { struct thread_info *newthread; - if ((newthread = add_thread (pid)) == NULL) + if ((newthread = add_thread (ptid)) == NULL) error ("failed to create new thread structure"); newthread->private = xmalloc (sizeof (struct private_thread_info)); @@ -521,7 +522,7 @@ add_thread_uw (int thrid, int lwpid, CORE_ADDR mapp, int pid) newthread->private->mapp = mapp; if (target_has_execution) - printf_unfiltered ("[New %s]\n", target_pid_to_str (pid)); + printf_unfiltered ("[New %s]\n", target_pid_to_str (ptid)); } /* notice_threads() and find_main() callback: if the thread list doesn't @@ -533,10 +534,10 @@ notice_thread (iter_t *iter, void *data) { int thrid = iter->map.thr_tid; int lwpid = !iter->map.thr_lwpp ? 0 : iter->lwp.lwp_id; - int pid = MKTID (inferior_pid, thrid); + ptid_t ptid = MKTID (PIDGET (inferior_ptid), thrid); - if (!find_thread_pid (pid) && (!data || thrid == 1)) - add_thread_uw (thrid, lwpid, iter->mapp, pid); + if (!find_thread_pid (ptid) && (!data || thrid == 1)) + add_thread_uw (thrid, lwpid, iter->mapp, ptid); return 0; } @@ -558,7 +559,7 @@ find_main (void) { struct thread_info *info; thread_iter (notice_thread, (void *)1); - if ((info = find_thread_pid (MKTID (inferior_pid, 1)))) + if ((info = find_thread_pid (MKTID (PIDGET (inferior_ptid), 1)))) thr_map_main = info->private->mapp; } return thr_map_main; @@ -590,12 +591,16 @@ uw_thread_detach (char *args, int from_tty) and all threads otherwise. */ static void -uw_thread_resume (int pid, int step, enum target_signal signo) +uw_thread_resume (ptid_t ptid, int step, enum target_signal signo) { - if (pid > 0 && !(pid = thr_to_lwp (pid))) - pid = -1; + if (PIDGET (ptid) > 0) + { + ptid = thr_to_lwp (ptid); + if (ptid_equal (ptid, null_ptid)) + ptid = pid_to_ptid (-1); + } - CALL_BASE (base_ops.to_resume (pid, step, signo)); + CALL_BASE (base_ops.to_resume (ptid, step, signo)); } /* If the trap we just received from lwp PID was due to a breakpoint @@ -603,21 +608,22 @@ uw_thread_resume (int pid, int step, enum target_signal signo) accordingly. */ static void -libthread_stub (int pid) +libthread_stub (ptid_t ptid) { CORE_ADDR sp, mapp, mapp_main; enum thread_change change; struct thread_map map; __lwp_desc_t lwp; - int tid = 0, lwpid; + int lwpid; + ptid_t tid = null_ptid; struct thread_info *info; /* Check for stub breakpoint. */ - if (read_pc_pid (pid) - DECR_PC_AFTER_BREAK != thr_brk_addr) + if (read_pc_pid (ptid) - DECR_PC_AFTER_BREAK != thr_brk_addr) return; /* Retrieve stub args. */ - sp = read_register_pid (SP_REGNUM, pid); + sp = read_register_pid (SP_REGNUM, ptid); if (!base_ops.to_xfer_memory (sp + SP_ARG0, (char *)&mapp, sizeof (mapp), 0, NULL, &base_ops)) goto err; @@ -642,7 +648,7 @@ libthread_stub (int pid) break; if (!read_map (mapp, &map)) goto err; - tid = MKTID (pid, map.thr_tid); + tid = MKTID (PIDGET (ptid), map.thr_tid); switch (change) { case tc_thread_create: /* new thread */ @@ -658,8 +664,8 @@ libthread_stub (int pid) case tc_thread_exit: /* thread has exited */ printf_unfiltered ("[Exited %s]\n", target_pid_to_str (tid)); delete_thread (tid); - if (tid == inferior_pid) - inferior_pid = pid; + if (ptid_equal (tid, inferior_ptid)) + inferior_ptid = ptid; break; case tc_switch_begin: /* lwp is switching threads */ @@ -720,22 +726,25 @@ libthread_stub (int pid) /* Wait for thread/lwp/process ID if >= 0 or for any thread otherwise. */ -static int -uw_thread_wait (int pid, struct target_waitstatus *status) +static ptid_t +uw_thread_wait (ptid_t ptid, struct target_waitstatus *status) { - if (pid > 0) - pid = thr_to_lwp (pid); - CALL_BASE (pid = base_ops.to_wait (pid > 0 ? pid : -1, status)); + if (PIDGET (ptid) > 0) + ptid = thr_to_lwp (ptid); + if (PIDGET (ptid) <= 0) + ptid = pid_to_ptid (-1); + + CALL_BASE (ptid = base_ops.to_wait (ptid, status)); if (status->kind == TARGET_WAITKIND_STOPPED && status->value.sig == TARGET_SIGNAL_TRAP) - libthread_stub (pid); + libthread_stub (ptid); - return lwp_to_thr (pid); + return lwp_to_thr (ptid); } /* Tell gdb about the registers in the thread/lwp/process specified by - inferior_pid. */ + inferior_ptid. */ static void uw_thread_fetch_registers (int regno) @@ -748,7 +757,7 @@ uw_thread_fetch_registers (int regno) if (called) return; - if (!(info = find_thread_pid (inferior_pid))) + if (!(info = find_thread_pid (inferior_ptid))) return; if (!read_map (info->private->mapp, &map)) return; @@ -758,7 +767,7 @@ uw_thread_fetch_registers (int regno) } /* Store gdb's current view of the register set into the thread/lwp/process - specified by inferior_pid. */ + specified by inferior_ptid. */ static void uw_thread_store_registers (int regno) @@ -822,14 +831,14 @@ uw_thread_can_run (void) /* Return whether thread PID is still valid. */ static int -uw_thread_alive (int pid) +uw_thread_alive (ptid_t ptid) { - if (!ISTID (pid)) - return base_ops.to_thread_alive (pid); + if (!ISTID (ptid)) + return base_ops.to_thread_alive (ptid); /* If it's in the thread list, it's valid, because otherwise libthread_stub() would have deleted it. */ - return in_thread_list (pid); + return in_thread_list (ptid); } /* Add to the thread list any threads and lwps it doesn't already contain. */ @@ -846,16 +855,16 @@ uw_thread_find_new_threads (void) This may be called by either procfs.c or by generic gdb. */ static char * -uw_thread_pid_to_str (int pid) +uw_thread_pid_to_str (ptid_t ptid) { -#define FMT "Thread %d" - static char buf[sizeof (FMT) + 3 * sizeof (pid)]; +#define FMT "Thread %ld" + static char buf[sizeof (FMT) + 3 * sizeof (long)]; - if (!ISTID (pid)) + if (!ISTID (ptid)) /* core_ops says "process foo", so call procfs_ops explicitly. */ - return procfs_ops.to_pid_to_str (pid); + return procfs_ops.to_pid_to_str (ptid); - sprintf (buf, FMT, TIDGET (pid)); + sprintf (buf, FMT, TIDGET (ptid)); #undef FMT return buf; } @@ -872,7 +881,7 @@ uw_extra_thread_info (struct thread_info *info) int lwpid; char *name; - if (!ISTID (info->pid)) + if (!ISTID (info->ptid)) return NULL; if (!info->private->stable) diff --git a/gdb/v850ice.c b/gdb/v850ice.c index 704d2a2..1aec483 100644 --- a/gdb/v850ice.c +++ b/gdb/v850ice.c @@ -73,7 +73,8 @@ static void v850ice_prepare_to_store (void); static void v850ice_fetch_registers (int regno); -static void v850ice_resume (int pid, int step, enum target_signal siggnal); +static void v850ice_resume (ptid_t ptid, int step, + enum target_signal siggnal); static void v850ice_open (char *name, int from_tty); @@ -85,7 +86,8 @@ static void v850ice_store_registers (int regno); static void v850ice_mourn (void); -static int v850ice_wait (int pid, struct target_waitstatus *status); +static ptid_t v850ice_wait (ptid_t ptid, + struct target_waitstatus *status); static void v850ice_kill (void); @@ -367,7 +369,7 @@ v850ice_open (char *name, int from_tty) target is active. These functions should be split out into seperate variables, especially since GDB will someday have a notion of debugging several processes. */ - inferior_pid = 42000; + inferior_ptid = pid_to_ptid (42000); start_remote (); return; @@ -383,7 +385,7 @@ v850ice_close (int quitting) { UnregisterClient (); ice_open = 0; - inferior_pid = 0; + inferior_ptid = null_ptid; } } @@ -409,7 +411,7 @@ v850ice_detach (char *args, int from_tty) /* Tell the remote machine to resume. */ static void -v850ice_resume (int pid, int step, enum target_signal siggnal) +v850ice_resume (ptid_t ptid, int step, enum target_signal siggnal) { long retval; char buf[256]; @@ -432,8 +434,8 @@ v850ice_resume (int pid, int step, enum target_signal siggnal) Returns "pid" (though it's not clear what, if anything, that means in the case of this target). */ -static int -v850ice_wait (int pid, struct target_waitstatus *status) +static ptid_t +v850ice_wait (ptid_t ptid, struct target_waitstatus *status) { long v850_status; char buf[256]; @@ -485,7 +487,7 @@ v850ice_wait (int pid, struct target_waitstatus *status) } while (!done); - return inferior_pid; + return inferior_ptid; } static int @@ -752,7 +754,7 @@ static void v850ice_kill (void) { target_mourn_inferior (); - inferior_pid = 0; + inferior_ptid = null_ptid; } static void diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index 277b473..4113f2c 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -79,7 +79,7 @@ enum extern struct target_ops child_ops; static void child_stop (void); -static int win32_child_thread_alive (int); +static int win32_child_thread_alive (ptid_t); void child_kill_inferior (void); static int last_sig = 0; /* Set if a signal was received from the @@ -233,7 +233,7 @@ child_add_thread (DWORD id, HANDLE h) th->h = h; th->next = thread_head.next; thread_head.next = th; - add_thread (id); + add_thread (pid_to_ptid (id)); return th; } @@ -262,8 +262,8 @@ child_delete_thread (DWORD id) thread_info *th; if (info_verbose) - printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (id)); - delete_thread (id); + printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (pid_to_ptid (id))); + delete_thread (pid_to_ptid (id)); for (th = &thread_head; th->next != NULL && th->next->id != id; @@ -313,7 +313,7 @@ do_child_fetch_inferior_registers (int r) static void child_fetch_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_fetch_inferior_registers (r); } @@ -333,7 +333,7 @@ do_child_store_inferior_registers (int r) static void child_store_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_store_inferior_registers (r); } @@ -849,7 +849,8 @@ get_child_debug_event (int pid ATTRIBUTE_UNUSED, struct target_waitstatus *ourst current_event.u.CreateThread.hThread); if (info_verbose) printf_unfiltered ("[New %s]\n", - target_pid_to_str (current_event.dwThreadId)); + target_pid_to_str ( + pid_to_ptid (current_event.dwThreadId))); retval = current_event.dwThreadId; break; @@ -942,7 +943,7 @@ get_child_debug_event (int pid ATTRIBUTE_UNUSED, struct target_waitstatus *ourst else { current_thread = th ? : thread_rec (current_event.dwThreadId, TRUE); - inferior_pid = retval; + inferior_ptid = pid_to_ptid (retval); } out: @@ -950,9 +951,11 @@ out: } /* Wait for interesting events to occur in the target process. */ -static int -child_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { + int pid = PIDGET (ptid); + /* We loop when we get a non-standard exception rather than return with a SPURIOUS because resume can try and step or modify things, which needs a current_thread->h. But some of these exceptions mark @@ -963,7 +966,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) { int retval = get_child_debug_event (pid, ourstatus); if (retval) - return retval; + return pid_to_ptid (retval); else { int detach = 0; @@ -1032,10 +1035,10 @@ child_attach (char *args, int from_tty) if (exec_file) printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else printf_unfiltered ("Attaching to %s\n", - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } @@ -1053,10 +1056,10 @@ child_detach (char *args ATTRIBUTE_UNUSED, int from_tty) if (exec_file == 0) exec_file = ""; printf_unfiltered ("Detaching from program: %s %s\n", exec_file, - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); gdb_flush (gdb_stdout); } - inferior_pid = 0; + inferior_ptid = null_ptid; unpush_target (&child_ops); } @@ -1066,7 +1069,7 @@ static void child_files_info (struct target_ops *ignore ATTRIBUTE_UNUSED) { printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid)); + attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } /* ARGSUSED */ @@ -1076,7 +1079,7 @@ child_open (char *arg ATTRIBUTE_UNUSED, int from_tty ATTRIBUTE_UNUSED) error ("Use the \"run\" command to start a Unix child process."); } -/* Start an inferior win32 child process and sets inferior_pid to its pid. +/* Start an inferior win32 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. Errors reported with error(). */ @@ -1276,11 +1279,12 @@ child_kill_inferior (void) } void -child_resume (int pid, int step, enum target_signal sig) +child_resume (ptid_t ptid, int step, enum target_signal sig) { thread_info *th; DWORD continue_status = last_sig > 0 && last_sig < NSIG ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE; + int pid = PIDGET (ptid); last_sig = 0; @@ -1326,7 +1330,8 @@ child_can_run (void) static void child_close (int x ATTRIBUTE_UNUSED) { - DEBUG_EVENTS (("gdb: child_close, inferior_pid=%d\n", inferior_pid)); + DEBUG_EVENTS (("gdb: child_close, inferior_ptid=%d\n", + PIDGET (inferior_ptid))); } struct target_ops child_ops; @@ -1437,17 +1442,21 @@ _initialize_inftarg (void) by "polling" it. If WaitForSingleObject returns WAIT_OBJECT_0 it means that the pid has died. Otherwise it is assumed to be alive. */ static int -win32_child_thread_alive (int pid) +win32_child_thread_alive (ptid_t ptid) { + int pid = PIDGET (ptid); + return WaitForSingleObject (thread_rec (pid, FALSE)->h, 0) == WAIT_OBJECT_0 ? FALSE : TRUE; } /* Convert pid to printable format. */ char * -cygwin_pid_to_str (int pid) +cygwin_pid_to_str (ptid_t ptid) { static char buf[80]; + int pid = PIDGET (ptid); + if ((DWORD) pid == current_event.dwProcessId) sprintf (buf, "process %d", pid); else diff --git a/gdb/wince.c b/gdb/wince.c index 83112d9..d931ddc 100644 --- a/gdb/wince.c +++ b/gdb/wince.c @@ -129,7 +129,7 @@ static int remote_add_host = 0; /* Forward declaration */ extern struct target_ops child_ops; -static int win32_child_thread_alive (int); +static int win32_child_thread_alive (ptid_t); void child_kill_inferior (void); static int last_sig = 0; /* Set if a signal was received from the @@ -1131,7 +1131,7 @@ do_child_fetch_inferior_registers (int r) static void child_fetch_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_fetch_inferior_registers (r); } @@ -1151,7 +1151,7 @@ do_child_store_inferior_registers (int r) static void child_store_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_store_inferior_registers (r); } @@ -1412,9 +1412,10 @@ get_child_debug_event (int pid, struct target_waitstatus *ourstatus, "CREATE_PROCESS_DEBUG_EVENT")); current_process_handle = current_event.u.CreateProcessInfo.hProcess; - main_thread_id = inferior_pid = current_event.dwThreadId; + main_thread_id = current_event.dwThreadId; + inferior_ptid = pid_to_ptid (main_thread_id); /* Add the main thread */ - th = child_add_thread (inferior_pid, + th = child_add_thread (PIDGET (inferior_ptid), current_event.u.CreateProcessInfo.hThread); break; @@ -1486,11 +1487,12 @@ out: } /* Wait for interesting events to occur in the target process. */ -static int -child_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { DWORD event_code; int retval; + int pid = PIDGET (ptid); /* We loop when we get a non-standard exception rather than return with a SPURIOUS because resume can try and step or modify things, @@ -1500,7 +1502,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) while (1) if (get_child_debug_event (pid, ourstatus, EXCEPTION_DEBUG_EVENT, &retval)) - return retval; + return pid_to_ptid (retval); else { int detach = 0; @@ -1519,7 +1521,7 @@ static void child_files_info (struct target_ops *ignore) { printf_unfiltered ("\tUsing the running image of child %s.\n", - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); } /* ARGSUSED */ @@ -1711,7 +1713,7 @@ wince_initialize (void) close (s0); } -/* Start an inferior win32 child process and sets inferior_pid to its pid. +/* Start an inferior win32 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. Errors reported with error(). */ @@ -1759,7 +1761,8 @@ child_create_inferior (char *exec_file, char *args, char **env) current_process_handle = pi.hProcess; current_event.dwProcessId = pi.dwProcessId; memset (¤t_event, 0, sizeof (current_event)); - inferior_pid = current_event.dwThreadId = pi.dwThreadId; + current_event.dwThreadId = pi.dwThreadId; + inferior_ptid = pid_to_ptid (current_event.dwThreadId); push_target (&child_ops); child_init_thread_list (); child_add_thread (pi.dwThreadId, pi.hThread); @@ -1769,7 +1772,7 @@ child_create_inferior (char *exec_file, char *args, char **env) target_terminal_inferior (); /* Run until process and threads are loaded */ - while (!get_child_debug_event (inferior_pid, &dummy, + while (!get_child_debug_event (PIDGET (inferior_ptid), &dummy, CREATE_PROCESS_DEBUG_EVENT, &ret)) continue; @@ -1828,11 +1831,12 @@ child_kill_inferior (void) /* Resume the child after an exception. */ void -child_resume (int pid, int step, enum target_signal sig) +child_resume (ptid_t ptid, int step, enum target_signal sig) { thread_info *th; DWORD continue_status = last_sig > 0 && last_sig < NSIG ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE; + int pid = PIDGET (ptid); DEBUG_EXEC (("gdb: child_resume (pid=%d, step=%d, sig=%d);\n", pid, step, sig)); @@ -1870,7 +1874,8 @@ child_can_run (void) static void child_close (void) { - DEBUG_EVENTS (("gdb: child_close, inferior_pid=%d\n", inferior_pid)); + DEBUG_EVENTS (("gdb: child_close, inferior_ptid=%d\n", + PIDGET (inferior_ptid))); } /* Explicitly upload file to remotedir */ @@ -2023,8 +2028,9 @@ debugging over a network.", &setlist), by "polling" it. If WaitForSingleObject returns WAIT_OBJECT_0 it means that the pid has died. Otherwise it is assumed to be alive. */ static int -win32_child_thread_alive (int pid) +win32_child_thread_alive (ptid_t ptid) { + int pid = PIDGET (ptid); return thread_alive (thread_rec (pid, FALSE)->h); } diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index 277b473..4113f2c 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -79,7 +79,7 @@ enum extern struct target_ops child_ops; static void child_stop (void); -static int win32_child_thread_alive (int); +static int win32_child_thread_alive (ptid_t); void child_kill_inferior (void); static int last_sig = 0; /* Set if a signal was received from the @@ -233,7 +233,7 @@ child_add_thread (DWORD id, HANDLE h) th->h = h; th->next = thread_head.next; thread_head.next = th; - add_thread (id); + add_thread (pid_to_ptid (id)); return th; } @@ -262,8 +262,8 @@ child_delete_thread (DWORD id) thread_info *th; if (info_verbose) - printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (id)); - delete_thread (id); + printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (pid_to_ptid (id))); + delete_thread (pid_to_ptid (id)); for (th = &thread_head; th->next != NULL && th->next->id != id; @@ -313,7 +313,7 @@ do_child_fetch_inferior_registers (int r) static void child_fetch_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_fetch_inferior_registers (r); } @@ -333,7 +333,7 @@ do_child_store_inferior_registers (int r) static void child_store_inferior_registers (int r) { - current_thread = thread_rec (inferior_pid, TRUE); + current_thread = thread_rec (PIDGET (inferior_ptid), TRUE); do_child_store_inferior_registers (r); } @@ -849,7 +849,8 @@ get_child_debug_event (int pid ATTRIBUTE_UNUSED, struct target_waitstatus *ourst current_event.u.CreateThread.hThread); if (info_verbose) printf_unfiltered ("[New %s]\n", - target_pid_to_str (current_event.dwThreadId)); + target_pid_to_str ( + pid_to_ptid (current_event.dwThreadId))); retval = current_event.dwThreadId; break; @@ -942,7 +943,7 @@ get_child_debug_event (int pid ATTRIBUTE_UNUSED, struct target_waitstatus *ourst else { current_thread = th ? : thread_rec (current_event.dwThreadId, TRUE); - inferior_pid = retval; + inferior_ptid = pid_to_ptid (retval); } out: @@ -950,9 +951,11 @@ out: } /* Wait for interesting events to occur in the target process. */ -static int -child_wait (int pid, struct target_waitstatus *ourstatus) +static ptid_t +child_wait (ptid_t ptid, struct target_waitstatus *ourstatus) { + int pid = PIDGET (ptid); + /* We loop when we get a non-standard exception rather than return with a SPURIOUS because resume can try and step or modify things, which needs a current_thread->h. But some of these exceptions mark @@ -963,7 +966,7 @@ child_wait (int pid, struct target_waitstatus *ourstatus) { int retval = get_child_debug_event (pid, ourstatus); if (retval) - return retval; + return pid_to_ptid (retval); else { int detach = 0; @@ -1032,10 +1035,10 @@ child_attach (char *args, int from_tty) if (exec_file) printf_unfiltered ("Attaching to program `%s', %s\n", exec_file, - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); else printf_unfiltered ("Attaching to %s\n", - target_pid_to_str (pid)); + target_pid_to_str (pid_to_ptid (pid))); gdb_flush (gdb_stdout); } @@ -1053,10 +1056,10 @@ child_detach (char *args ATTRIBUTE_UNUSED, int from_tty) if (exec_file == 0) exec_file = ""; printf_unfiltered ("Detaching from program: %s %s\n", exec_file, - target_pid_to_str (inferior_pid)); + target_pid_to_str (inferior_ptid)); gdb_flush (gdb_stdout); } - inferior_pid = 0; + inferior_ptid = null_ptid; unpush_target (&child_ops); } @@ -1066,7 +1069,7 @@ static void child_files_info (struct target_ops *ignore ATTRIBUTE_UNUSED) { printf_unfiltered ("\tUsing the running image of %s %s.\n", - attach_flag ? "attached" : "child", target_pid_to_str (inferior_pid)); + attach_flag ? "attached" : "child", target_pid_to_str (inferior_ptid)); } /* ARGSUSED */ @@ -1076,7 +1079,7 @@ child_open (char *arg ATTRIBUTE_UNUSED, int from_tty ATTRIBUTE_UNUSED) error ("Use the \"run\" command to start a Unix child process."); } -/* Start an inferior win32 child process and sets inferior_pid to its pid. +/* Start an inferior win32 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. Errors reported with error(). */ @@ -1276,11 +1279,12 @@ child_kill_inferior (void) } void -child_resume (int pid, int step, enum target_signal sig) +child_resume (ptid_t ptid, int step, enum target_signal sig) { thread_info *th; DWORD continue_status = last_sig > 0 && last_sig < NSIG ? DBG_EXCEPTION_NOT_HANDLED : DBG_CONTINUE; + int pid = PIDGET (ptid); last_sig = 0; @@ -1326,7 +1330,8 @@ child_can_run (void) static void child_close (int x ATTRIBUTE_UNUSED) { - DEBUG_EVENTS (("gdb: child_close, inferior_pid=%d\n", inferior_pid)); + DEBUG_EVENTS (("gdb: child_close, inferior_ptid=%d\n", + PIDGET (inferior_ptid))); } struct target_ops child_ops; @@ -1437,17 +1442,21 @@ _initialize_inftarg (void) by "polling" it. If WaitForSingleObject returns WAIT_OBJECT_0 it means that the pid has died. Otherwise it is assumed to be alive. */ static int -win32_child_thread_alive (int pid) +win32_child_thread_alive (ptid_t ptid) { + int pid = PIDGET (ptid); + return WaitForSingleObject (thread_rec (pid, FALSE)->h, 0) == WAIT_OBJECT_0 ? FALSE : TRUE; } /* Convert pid to printable format. */ char * -cygwin_pid_to_str (int pid) +cygwin_pid_to_str (ptid_t ptid) { static char buf[80]; + int pid = PIDGET (ptid); + if ((DWORD) pid == current_event.dwProcessId) sprintf (buf, "process %d", pid); else diff --git a/gdb/xcoffsolib.c b/gdb/xcoffsolib.c index dd3c1d8..867f102 100644 --- a/gdb/xcoffsolib.c +++ b/gdb/xcoffsolib.c @@ -67,8 +67,8 @@ solib_info (char *args, int from_tty) struct vmap *vp = vmap; /* Check for new shared libraries loaded with load (). */ - if (inferior_pid) - xcoff_relocate_symtab (inferior_pid); + if (! ptid_equal (inferior_ptid, null_ptid)) + xcoff_relocate_symtab (PIDGET (inferior_ptid)); if (vp == NULL || vp->nxt == NULL) { @@ -101,8 +101,8 @@ sharedlibrary_command (char *pattern, int from_tty) dont_repeat (); /* Check for new shared libraries loaded with load (). */ - if (inferior_pid) - xcoff_relocate_symtab (inferior_pid); + if (! ptid_equal (inferior_ptid, null_ptid)) + xcoff_relocate_symtab (PIDGET (inferior_ptid)); if (pattern) { -- cgit v1.1