+
+ * 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.
+
* rdi-share/devsw.c: Include <time.h> for struct tm
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,
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,
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,
{
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);
{
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");
{
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");
}
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
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. */
{
/* 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). */
/* 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. */
#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)
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);
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);
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);
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);
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)
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)
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);
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);
{
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);
}
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__);
{
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)
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;
}
{
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)
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;
}
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__);
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
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
)
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) &&
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
/* 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;
}
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.
/* 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);
}
/* 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 */
/* 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);
}
}
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);
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);
#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 <signal.h>
#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 <signal.h>
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)
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 */
#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 <signal.h>
#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
#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
#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);
#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 */
/* 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))
#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)
#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
#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 <signal.h>
/* 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
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
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
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)
/* 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))
#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. */
/* 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 */
/* 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
*/
#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
#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
#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 <signal.h>
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);
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 */
#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))
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);
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. */
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. */
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.
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);
behaviour.
*/
static int
-core_file_thread_alive (int tid)
+core_file_thread_alive (ptid_t tid)
{
return 1;
}
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); */
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);
{
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);
}
{
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)
{
}
}
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)
{
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");
/* 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)
{
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)
{
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);
}
}
}
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;
}
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
/* 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))
+
\f
/* Optional host machine definition. Pure autoconf targets will not
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);
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 */
}
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
}
-/* 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,
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. */
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.
*/
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 ();
#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 ()
#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,
}
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
}
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
/* 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
#
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
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) */
/* 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. */
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,
/* 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,
(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. */
}
}
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
{
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)
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. */
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"
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);
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);
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);
}
/* 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);
}
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);
inf_detach (current_inferior);
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
unpush_target (&gnu_ops); /* Pop out of handling an inferior */
}
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));
}
\f
}
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)
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;
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);
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;
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;
{
normal_stop ();
cleanup_client ();
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
prog_has_started = 0;
}
save_npx ();
#endif
- inferior_pid = SOME_PID;
+ inferior_ptid = pid_to_ptid (SOME_PID);
push_target (&go32_ops);
clear_proceed_status ();
insert_breakpoints ();
}
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);
}
#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
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);
}
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);
}
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. */
}
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);
}
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)
{
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)
{
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;
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))
{
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
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. */
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
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)
{
}
}
- /* 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;
}
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");
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;
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
/* 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 */
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 */
}
/* 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
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)
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)
{
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)
{
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);
}
/* 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. */
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)
{
/* 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)
{
{
/* 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);
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]);
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]);
{
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);
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);
}
/* 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);
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);
}
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);
}
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
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
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++)
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;
}
return "TRUE". */
int
-child_thread_alive (int pid)
+child_thread_alive (ptid_t ptid)
{
return 1;
}
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);
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;
}
\f
static int 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);
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)
}
#endif
- child_ops.to_resume (pid, step, signo);
+ child_ops.to_resume (ptid, step, signo);
cached_thread = 0;
cached_active_thread = 0;
/* 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 ();
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)
{
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)
{
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);
}
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. */
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);
}
}
}
static int
-hpux_thread_alive (int pid)
+hpux_thread_alive (ptid_t ptid)
{
return 1;
}
/* 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);
/* 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. */
}
/* 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;
}
/* 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;
}
/* 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
}
/* 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
/* 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
/* 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,
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;
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)
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;
}
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));
}
{
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);
}
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)
{
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 ();
}
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
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;
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);
}
}
{
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);
{
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");
{
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");
}
{
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
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");
}
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
/* 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)
{
/* 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)
{
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);
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);
}
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);
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);
}
\f
#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);
}
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
}
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;
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 */
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;
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;
}
}
}
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);
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;
}
}
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)
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). */
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\
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
/* Take any necessary post-attaching actions for this platform.
*/
- target_post_attach (inferior_pid);
+ target_post_attach (PIDGET (inferior_ptid));
normal_stop ();
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
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).
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);
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. */
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 */
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 */
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;
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 */
}
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.");
pass_signal (int signo)
{
#ifndef _WIN32
- kill (PIDGET (inferior_pid), SIGINT);
+ kill (PIDGET (inferior_ptid), SIGINT);
#endif
}
{
#ifndef _WIN32
if ((*target_activity_function) ())
- kill (inferior_pid, SIGINT);
+ kill (PIDGET (inferior_ptid), SIGINT);
#endif
}
}
add_com ("kill", class_run, kill_command,
"Kill execution of program being debugged.");
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
terminal_is_ours = 1;
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;
}
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
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 ();
}
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
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;
/* 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
}
/* 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;
}
/* 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;
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);
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)
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;
}
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);
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. */
(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. */
/* 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
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.) */
}
/* 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. */
/* 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. */
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 ();
/* 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));
}
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);
}
}
(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;
}
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. */
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
{
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):
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;
if (should_resume)
{
- int resume_pid;
+ ptid_t resume_ptid;
if (use_thread_step_needed && thread_step_needed)
{
{
/* Breakpoint deleted: ok to do regular resume
where all the threads either step or continue. */
- resume_pid = -1;
+ resume_ptid = RESUME_ALL;
}
else
{
trap_expected = 1;
step = 1;
}
- resume_pid = inferior_pid;
+ resume_ptid = inferior_ptid;
}
}
else
/* 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);
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;
int new_thread_event;
struct target_waitstatus tmpstatus;
enum infwait_states infwait_state;
- int waiton_pid;
+ ptid_t waiton_ptid;
int wait_some_more;
};
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;
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);
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;
}
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);
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);
}
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;
}
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. */
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;
* 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;
/* 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
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
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;
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
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;
}
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;
}
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;
}
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
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;
/* 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
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);
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)
{
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,
{
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
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);
* 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;
}
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;
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;
}
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,
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,
&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 ();
}
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;
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);
{
#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);
{
/* 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
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
(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
#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:
argv++;
}
- target_notice_signals (inferior_pid);
+ target_notice_signals (inferior_ptid);
if (from_tty)
{
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);
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);
/* 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;
int related_pid;
int syscall_id;
enum target_waitkind kind;
+ int pid;
do
{
attached process. */
set_sigio_trap ();
- pid = ptrace_wait (inferior_pid, &status);
+ pid = ptrace_wait (inferior_ptid, &status);
save_errno = errno;
/* 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?
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))
{
ourstatus->kind = TARGET_WAITKIND_EXECD;
ourstatus->value.execd_pathname = execd_pathname;
- return pid;
+ return pid_to_ptid (pid);
}
}
{
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.
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);
}
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);
}
else
REQUIRE_ATTACH (pid);
- inferior_pid = pid;
+ inferior_ptid = pid_to_ptid (pid);
push_target (&child_ops);
}
#endif /* ATTACH_DETACH */
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)
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);
}
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 */
/* 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(). */
#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.
#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
static thread_info_header deleted_threads =
{0, NULL, NULL};
-static saved_real_pid = 0;
+static ptid_t saved_real_ptid;
\f
/*************************************************
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
{
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
* 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;
}
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
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)
*
* 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;
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;
#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);
* 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);
}
/* 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));
warning ("Internal error: process-wait failed.");
}
- return return_pid;
+ return pid_to_ptid (return_pid);
}
\f
* 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.
* 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.
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
}
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.
xfree (paranoia);
call_ttrace (TT_PROC_STOP,
- inferior_pid,
+ PIDGET (inferior_ptid),
TT_NIL,
TT_NIL,
TT_NIL);
* -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
* | 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) ||
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);
/*
* 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?
*
*/
*
* 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!).
{
errno = 0;
call_ttrace (TT_PROC_DETACH,
- inferior_pid,
+ PIDGET (inferior_ptid),
TT_NIL,
(TTRACE_ARG_TYPE) signal,
TT_NIL);
{
/* 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);
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,
{
errno = 0;
call_ttrace (TT_LWP_WRDATA,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
(TTRACE_ARG_TYPE) buffer[i],
TT_NIL);
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);
{
errno = 0;
buffer[i] = call_ttrace (TT_LWP_RDTEXT,
- inferior_pid,
+ PIDGET (inferior_ptid),
(TTRACE_ARG_TYPE) addr,
TT_NIL,
TT_NIL);
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);
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.
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++)
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;
}
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;
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);
{
/* 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). */
#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
/* 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;
\f
/* This module's target-specific operations. */
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;
/* 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)
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;
/* 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);
}
\f
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 ();
/* 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 ();
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;
}
{
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;
/* 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);
}
#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;
}
}
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;
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;
if (resume_all)
iterate_over_lwps (resume_callback, NULL);
- child_resume (pid, step, signo);
+ child_resume (ptid, step, signo);
}
\f
{
int ret;
- ret = kill (GET_LWP (lp->pid), SIGSTOP);
+ ret = kill (GET_LWP (lp->ptid), SIGSTOP);
gdb_assert (ret == 0);
lp->signalled = 1;
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;
}
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
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
{
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))
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;
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;
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)
/* 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. */
{
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));
}
}
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));
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. */
&& 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;
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;
}
/* 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;
init_lwp_list ();
- trap_pid = 0;
+ trap_ptid = null_ptid;
/* Restore the original signal mask. */
sigprocmask (SIG_SETMASK, &normal_mask, NULL);
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);
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);
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);
}
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;
}
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
#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)
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);
* 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,
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)
{
}
/* 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;
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;
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);
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);
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);
}
}
/* 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 */
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.
{
/* 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
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. */
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,
*/
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)
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) */
}
*/
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));
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;
}
}
/*
- * 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.
*/
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,
}
/*
- * 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.
*/
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)
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.
*/
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)
}
- 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)
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)
{
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;
/*
* 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.
*/
/* 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;
}
{
/* 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;
}
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
{
/* 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);
}
}
}
{
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)
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 */
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
{
wstatus [signo] = 1;
}
- child_resume (retpid, 0, TARGET_SIGNAL_0);
+ child_resume (pid_to_ptid (retpid), 0, TARGET_SIGNAL_0);
continue;
}
* 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;
/* 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
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.
/* 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;
/* 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,
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,
*/
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;
/* 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);
}
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);
}
#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
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.
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
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)
{
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);
}
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);
}
}
}
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);
}
}
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,
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.
{
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. */
{
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));
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)
{
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
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 */
{
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;
}
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;
/* 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)"
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);
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
{
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);
}
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);
/* [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);
}
}
}
/* 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));
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)
if (WIFEXITED(linuxthreads_exit_status))
{
store_waitstatus (ourstatus, linuxthreads_exit_status);
- return inferior_pid;
+ return inferior_ptid;
}
else
{
/* Claim it exited with unknown signal. */
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
ourstatus->value.sig = TARGET_SIGNAL_UNKNOWN;
- return -1;
+ return pid_to_ptid (-1);
}
}
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
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)
{
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;
{
/* 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);
{
/* 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;
}
update_stop_threads (rpid);
}
- else if (rpid != inferior_pid)
+ else if (rpid != PIDGET (inferior_ptid))
continue;
store_waitstatus (ourstatus, status);
else if (linuxthreads_breakpoint_pid)
linuxthreads_breakpoint_pid = 0;
- return rpid;
+ return pid_to_ptid (rpid);
}
}
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
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
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)");
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)");
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)");
}
/* 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)");
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)");
}
else
reglo = reghi = regno;
- ecp = registers_addr (inferior_pid);
+ ecp = registers_addr (PIDGET (inferior_ptid));
for (regno = reglo; regno <= reghi; 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)");
else
reglo = reghi = regno;
- ecp = registers_addr (inferior_pid);
+ ecp = registers_addr (PIDGET (inferior_ptid));
for (regno = reglo; regno <= reghi; 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)");
/* 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)
{
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 */
/* 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)
{
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");
/* 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;
}
}
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.
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;
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
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;
}
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;
}
}
store_waitstatus (ourstatus, w);
- return inferior_pid;
+ return inferior_ptid;
}
}
mach3_exception_actions (&w, FALSE, "Task");
store_waitstatus (ourstatus, w);
- return inferior_pid;
+ return inferior_ptid;
}
}
}
{
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);
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;
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)
{
{
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);
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
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);
}
\f
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);
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 */
{
/* 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
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;
static void
m32r_load (char *filename, int from_tty)
{
- extern int inferior_pid;
bfd *abfd;
asection *s;
unsigned int i, data_count = 0;
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
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;
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
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));
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);
}
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); */
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);
}
{
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)
{
}
}
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");
/* 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)
{
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));
}
}
}
}
-static int
-child_wait (int pid, struct target_waitstatus *ourstatus)
+static ptid_t
+child_wait (ptid_t ptid, struct target_waitstatus *ourstatus)
{
}
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);
}
}
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);
}
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 */
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(). */
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);
}
void
-child_resume (int pid, int step, enum target_signal signal)
+child_resume (ptid_t ptid, int step, enum target_signal signal)
{
}
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);
}
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)
{
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
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
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);
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 */
/* 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");
/* 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];
in_monitor_wait = 0;
- return inferior_pid;
+ return inferior_ptid;
}
/* Fetch register REGNO, or all registers if REGNO is -1. Returns
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
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);
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);
}
\f
/* 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;
}
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). */
/* 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;
{
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
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);
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);
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);
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);
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;
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 */
}
#endif
- return inferior_pid;
+ return inferior_ptid;
}
\f
static int bdm_regmap[] =
#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]);
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]);
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
}
/* 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
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);
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);
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);
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);
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);
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 */
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. */
* 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 *);
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);
}
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);
}
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__);
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)))
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__);
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)))
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__);
* 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;
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... */
/* 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;
return a "success" exit code. Bogus: what if
it returns something else? */
wstat = 0;
- retval = inferior_pid; /* ? ? ? */
+ retval = inferior_ptid; /* ? ? ? */
}
else
{
/* If wait returns -1, that's what we return to GDB. */
if (temp < 0)
- retval = temp;
+ retval = pid_to_ptid (temp);
}
}
else
{
/* 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;
}
}
*/
/* 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))
{
}
#endif
status->kind = TARGET_WAITKIND_SPURIOUS;
- return inferior_pid;
+ return inferior_ptid;
}
break;
case PR_REQUESTED:
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;
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);
* 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))
{
/*
/* 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));
}
}
}
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)
{
*/
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;
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;
/* 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)
*/
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))
{
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));
}
/*
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);
{
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);
}
/* 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);
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);
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);
}
*/
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;
*/
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)
*/
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 */
*/
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;
* 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. */
argv++;
}
if (pid == 0)
- pid = PIDGET (inferior_pid);
+ pid = PIDGET (inferior_ptid);
if (pid == 0)
error ("No current process: you must name one.");
else
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);
* 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);
}
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
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)
{
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:
{
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
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))
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);
}
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;
}
}
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;
}
}
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()
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
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
}
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");
}
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 */
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);
}
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);
/* 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)
{
/* 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
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. */
}
timeout = old_timeout;
immediate_quit = old_immediate_quit;
- return 0;
+ return inferior_ptid;
}
/* Return the name of register number REGNO
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 ();
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 ();
* 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);
* 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;
timeout = old_timeout;
- return 0;
+ return inferior_ptid;
}
/*
sr_check_open ();
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
abfd = bfd_openr (args, 0);
if (!abfd)
{
/* 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)
{
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;
sr_set_timeout (old_timeout);
immediate_quit = old_immediate_quit;
- return 0;
+ return inferior_ptid;
}
/* Return the name of register number REGNO
/* 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");
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
/* 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;
internal_error (__FILE__, __LINE__, "failed internal consistency check");
}
- return 0;
+ return inferior_ptid;
}
/* Stop the running program. */
/* 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)
{
/* 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
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);
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];
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;
}
signal (SIGINT, old_sigint);
timeout = old_timeout;
- return (0);
+ return inferior_ptid;
}
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 ();
}
}
}
breakpoint_init_inferior ();
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
if (from_tty)
{
printf ("Downloading \"%s\" to the ES 1800\n", filename);
#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
/* 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 ();
pop_target ();
if (from_tty)
{
- printf ("Ending debugging the process %d.\n", inferior_pid);
+ printf ("Ending debugging the process %d.\n", PIDGET (inferior_ptid));
}
}
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);
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;
/* 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;
{
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. */
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
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);
}
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
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 ();
** 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.");
** 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;
timeout = old_timeout; /* Restore original timeout value */
immediate_quit = old_immediate_quit;
- return 0;
+ return inferior_ptid;
}
/******************************************************* REMOTE_FETCH_REGISTERS
/* 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.");
* 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;
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. */
/* 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 ();
* 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);
* 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;
objfile_relocate (symfile_objfile, offs);
}
- return 0;
+ return inferior_ptid;
}
/* Return the name of register number regno in the form input and output by
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);
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);
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().
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)
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 ();
}
/* 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;
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);
/* 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. */
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 ();
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)
{
#endif
}
- return inferior_pid;
+ return inferior_ptid;
}
/* Get ready to modify the registers array. On machines which store
/* 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 */
/*
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);
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);
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];
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;
{
just_started = 0;
status->kind = TARGET_WAITKIND_STOPPED;
- return inferior_pid;
+ return inferior_ptid;
}
while (1)
}
}
got_status:
- return inferior_pid;
+ return inferior_ptid;
}
static unsigned char sprs[16];
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 ();
{
generic_load (filename, from_tty);
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
\f
/* The SDS monitor has commands for breakpoint insertion, although it
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);
/* 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
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
}
-/* 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().
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 ();
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 ())
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;
break;
}
- return inferior_pid;
+ return inferior_ptid;
}
/* Get ready to modify the registers array. On machines which store
/* 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)
{
/* 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;
timeout = old_timeout;
- return 0;
+ return inferior_ptid;
}
/* Return the name of register number REGNO in the form input and output by
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);
entry.Offset = 0;
}
- inferior_pid = 40000;
+ inferior_ptid = pid_to_ptid (40000);
if (!entry.Offset)
download (execfile, 0);
/* 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");
}
/* 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 ();
** 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;
** 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;
timeout = old_timeout; /* Restore original timeout value */
immediate_quit = old_immediate_quit;
- return inferior_pid;
+ return inferior_ptid;
}
#if 0
UDIStop ();
udi_session_id = -1;
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
if (from_tty)
printf_unfiltered ("Target has been stopped.");
/* Do not try to close udi_session_id again, later in the program. */
udi_session_id = -1;
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
/*
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);
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.
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. */
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);
/* 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,
/* 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. */
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;
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 */
{
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");
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)
/* 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? "))
int step_status;
SOURCE_STEP source_step;
- source_step.taskId = inferior_pid;
+ source_step.taskId = PIDGET (inferior_ptid);
if (step_range_end)
{
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;
{
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));
#endif
break;
} /* switch */
- return pid;
+ return pid_to_ptid (pid);
}
\f
static int
/* It worked... */
- inferior_pid = pid;
+ inferior_ptid = pid_to_ptid (pid);
push_target (&vx_run_ops);
if (vx_running)
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)
perror_with_name ("Detaching VxWorks process");
}
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
pop_target (); /* go back to non-executing VxWorks connection */
}
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)
/* 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 */
}
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;
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);
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);
static void set_thread (int, int);
-static int remote_thread_alive (int);
+static int remote_thread_alive (ptid_t);
static void get_offsets (void);
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);
/* 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
}
}
/* 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)
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;
}
{
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);
}
/*
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");
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)
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)
{
/* 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 */
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). */
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
}
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;
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
}
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)
/* 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)
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;
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;
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. */
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);
char *p;
char *regs;
- set_thread (inferior_pid, 1);
+ set_thread (PIDGET (inferior_ptid), 1);
if (regno >= 0)
{
{
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");
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;
}
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. */
}
}
-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
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. */
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
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. */
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
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);
}
}
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;
}
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)
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");
{
pid = wait (&status);
}
- while (pid != inferior_pid);
+ while (pid != PIDGET (inferior_ptid));
write_pc (prev_pc);
target_remove_breakpoint (DUMMY_INSN_ADDR, shadow_contents);
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"
struct ps_prochandle
{
- pid_t pid;
+ ptid_t ptid;
};
struct string_map
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);
SYNOPSIS
- int thread_to_lwp (thread_id, default_lwp)
+ tpid_t thread_to_lwp (thread_id, default_lwp)
DESCRIPTION
*/
-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;
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));
}
*/
-static int
-lwp_to_thread (int lwp)
+static ptid_t
+lwp_to_thread (ptid_t lwp)
{
td_thrinfo_t ti;
td_thrhandle_t th;
/* 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));
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));
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);
}
\f
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. */
}
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);
}
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);
}
/* 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));
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);
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");
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)
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)
}
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. */
{
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);
}
}
SYNOPSIS
- static bool sol_thread_alive (int pid);
+ static bool sol_thread_alive (ptid_t ptid);
DESCRIPTION
*/
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)
/* 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);
}
}
{
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)
{
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);
{
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)
{
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);
{
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)
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));
/* 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;
}
{
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;
}
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);
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);
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. */
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. */
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)
{
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. */
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
}
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);
}
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)
{
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;
}
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.
|| 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");
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");
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");
}
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");
}
kill_command (void)
{
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
terminal_inferior (void)
wait (WAITTYPE *w)
{
WSETSTOP (*w, fault_table[fault_code / FAULT_CODE_UNITS]);
- return inferior_pid;
+ return PIDGET (inferior_ptid);
}
\f
/* Allocate a big space in which files for kdb to read will be stored.
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);
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);
}
/* 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); */
/* 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 } */
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)];
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
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;
if (have_inferior_p ())
{
- PTRACE_READ_REGS (inferior_pid, (PTRACE_ARG3_TYPE) & regset);
+ PTRACE_READ_REGS (PIDGET (inferior_ptid), (PTRACE_ARG3_TYPE) & regset);
}
else
{
/*
* 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;
#ifdef SVR4_SHARED_LIBS /* use this to distinguish ptx 2 vs ptx 4 */
prstatus_t pstatus;
#endif
+ int pid = PIDGET (ptid);
do
{
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
}
}
- 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 */
/*
* 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
{
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 */
\f
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 ();
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
{
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));
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);
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)
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;
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
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);
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);
static void
nosupport_runtime (void)
{
- if (!inferior_pid)
+ if (ptid_equal (inferior_ptid, null_ptid))
noprocess ();
else
error ("No run-time support for this");
(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))
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))
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))
{
extern int show_breakpoint_hit_counts;
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
attach_flag = 0;
breakpoint_init_inferior (inf_exited);
registers_changed ();
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;
}
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. */
}
}
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)
{
}
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
}
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
}
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;
}
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);
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);
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 *);
#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
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.
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. */
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);
extern int child_has_exited (int, int, int *);
-extern int child_thread_alive (int);
+extern int child_thread_alive (ptid_t);
/* From exec.c */
#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().
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. */
/* 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. */
#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,
#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
/* 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);
}
\f
/* 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));
}
\f
/* 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);
}
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;
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
}
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);
}
the event. */
static void
-check_event (int pid)
+check_event (ptid_t ptid)
{
td_event_msg_t msg;
td_thrinfo_t ti;
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;
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)
{
/* 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:
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:
}
}
-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
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);
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
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)
{
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
}
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 ();
}
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;
}
if (target_beneath->to_thread_alive)
- return target_beneath->to_thread_alive (pid);
+ return target_beneath->to_thread_alive (ptid);
return 0;
}
{
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;
}
}
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)
{
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
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
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;
}
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)
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;
}
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 */
/* 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,
/* 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;
/* 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,
/* 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;
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;
{
next = tp->next;
if (!thread_alive (tp))
- delete_thread (tp->pid);
+ delete_thread (tp->ptid);
}
}
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;
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);
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"
/* 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 ();
}
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);
}
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 */
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 */
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 */
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 */
/* 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
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 */
/* 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... */
int
quit_confirm (void)
{
- if (inferior_pid != 0 && target_has_execution)
+ if (! ptid_equal (inferior_ptid, null_ptid) && target_has_execution)
{
char *s;
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);
/* 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) */
/* 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) */
/* 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 { */
/* 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) */
/* 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) */
/* 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 { */
#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 { \
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. */
} 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 { \
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;
/* 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)
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;
/* 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;
{
int lwpid = (int)data;
- if (!ISTID (tp->pid))
+ if (!ISTID (tp->ptid))
return 0;
if (!tp->private->stable)
return 0;
/* 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;
}
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));
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
{
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;
}
{
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;
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
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;
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 */
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 */
/* 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)
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;
}
/* 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)
/* 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. */
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;
}
int lwpid;
char *name;
- if (!ISTID (info->pid))
+ if (!ISTID (info->ptid))
return NULL;
if (!info->private->stable)
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);
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);
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;
{
UnregisterClient ();
ice_open = 0;
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
}
/* 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];
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];
}
while (!done);
- return inferior_pid;
+ return inferior_ptid;
}
static int
v850ice_kill (void)
{
target_mourn_inferior ();
- inferior_pid = 0;
+ inferior_ptid = null_ptid;
}
static void
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
th->h = h;
th->next = thread_head.next;
thread_head.next = th;
- add_thread (id);
+ add_thread (pid_to_ptid (id));
return th;
}
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;
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);
}
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);
}
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;
else
{
current_thread = th ? : thread_rec (current_event.dwThreadId, TRUE);
- inferior_pid = retval;
+ inferior_ptid = pid_to_ptid (retval);
}
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
{
int retval = get_child_debug_event (pid, ourstatus);
if (retval)
- return retval;
+ return pid_to_ptid (retval);
else
{
int detach = 0;
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);
}
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);
}
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 */
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(). */
}
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;
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;
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
/* 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
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);
}
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);
}
"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;
}
/* 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,
while (1)
if (get_child_debug_event (pid, ourstatus, EXCEPTION_DEBUG_EVENT, &retval))
- return retval;
+ return pid_to_ptid (retval);
else
{
int detach = 0;
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 */
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(). */
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);
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;
/* 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));
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 */
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);
}
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
th->h = h;
th->next = thread_head.next;
thread_head.next = th;
- add_thread (id);
+ add_thread (pid_to_ptid (id));
return th;
}
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;
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);
}
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);
}
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;
else
{
current_thread = th ? : thread_rec (current_event.dwThreadId, TRUE);
- inferior_pid = retval;
+ inferior_ptid = pid_to_ptid (retval);
}
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
{
int retval = get_child_debug_event (pid, ourstatus);
if (retval)
- return retval;
+ return pid_to_ptid (retval);
else
{
int detach = 0;
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);
}
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);
}
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 */
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(). */
}
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;
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;
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
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)
{
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)
{